Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47167

Re: python netcdf

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jason.swails@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'attribute': 0.07; 'conventions': 0.07; 'suppose': 0.07; 'variables': 0.07; 'string': 0.09; 'attributes': 0.09; 'bindings': 0.09; 'variable,': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'python': 0.11; 'stored': 0.12; 'attribute,': 0.16; 'cc:name:python list': 0.16; 'newer,': 0.16; 'numpy': 0.16; 'slicing:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'appears': 0.22; 'example': 0.22; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'package.': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'options': 0.25; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'dimensions': 0.31; 'origin': 0.31; 'file': 0.32; 'class': 0.32; 'option': 0.32; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'accessible': 0.36; 'similar': 0.36; 'skip:& 10': 0.38; 'jason': 0.38; 'pm,': 0.38; 'use.': 0.39; 'skip:n 30': 0.60; 'course': 0.61; "you're": 0.61; 'skip:n 10': 0.64; 'more': 0.64; 'dear': 0.65; 'to:addr:gmail.com': 0.65; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vm6mPfzJdN6TJmJT9cw7i1ty1SiLN/+heNcSv0lRLLA=; b=X59du4qzz43nfiHw/hVwOhusJ3zyDdUgrTmQ7fvgukLiRGoeDpopieRZEYmymOAJrR mzHYR76lqd0cvTWK+oJUrr7aYfUM5IaaVV4oEKMja6omDLnqY9WfkZANnVZWf3Y9jppk GTmsTyK1CwalN21+ayh/k81xAjvTT/OHBOdE7YxrzliBPerK4qQYrA+Ow5z0nRqYbT8f Qr/ZxA5GeMgquSUsO+6Tnk/YhcyigI9t62d/pWx5HnYgZ45cAXt7LFPG+mcuha3PM0v4 h5g4YT5UehKsWTNRjRgTPfeYKERlBQbu1LwzGygUg/af2wjJdMkTHTpQaw3mg6PlAJob KdHw==
MIME-Version 1.0
X-Received by 10.42.250.202 with SMTP id mp10mr16008881icb.21.1370482416568; Wed, 05 Jun 2013 18:33:36 -0700 (PDT)
In-Reply-To <f39648d9-3d21-4186-8e79-c7aba935beb2@googlegroups.com>
References <f39648d9-3d21-4186-8e79-c7aba935beb2@googlegroups.com>
Date Wed, 5 Jun 2013 21:33:36 -0400
Subject Re: python netcdf
From Jason Swails <jason.swails@gmail.com>
To Sudheer Joseph <sjo.india@gmail.com>
Content-Type multipart/alternative; boundary=20cf3010e6c99c508604de724da4
Cc python list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2776.1370482419.3114.python-list@python.org> (permalink)
Lines 114
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370482419 news.xs4all.nl 15926 [2001:888:2000:d::a6]:42507
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47167

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Jun 5, 2013 at 9:07 PM, Sudheer Joseph <sjo.india@gmail.com> wrote:

> Dear Members,
>                   Is there a way to get the time:origin attribute from a
> netcdf file as string using the Python netcdf?
>

Attributes of the NetCDF file and attributes of each of the variables can
be accessed via the dot-operator, as per standard Python.

For instance, suppose that your NetCDF file has a Conventions attribute,
you can access it via:

ncfile.Conventions

Suppose that your variable, time, has an attribute "origin", you can get it
via:

ncfile.variables['time'].origin

Of course there's the question of what NetCDF bindings you're going to use.
 The options that I'm familiar with are the ScientificPython's NetCDFFile
class (Scientific.IO.NetCDF.NetCDFFile), pynetcdf (which is just the
ScientificPython's class in a standalone format), and the netCDF4 package.
 Each option has a similar API with attributes accessed the same way.

An example with netCDF4 (which is newer, has NetCDF 4 capabilities, and
appears to be more supported):

from netCDF4 import Dataset

ncfile = Dataset('my_netcdf_file.nc', 'r')

origin = ncfile.variables['time'].origin

etc. etc.

The variables and dimensions of a NetCDF file are stored in dictionaries,
and the data from variables are accessible via slicing:

time_data = ncfile.variables['time'][:]

The slice returns a numpy ndarray.

HTH,
Jason

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

python netcdf Sudheer Joseph <sjo.india@gmail.com> - 2013-06-05 18:07 -0700
  Re: python netcdf Jason Swails <jason.swails@gmail.com> - 2013-06-05 21:33 -0400
  Re: python netcdf Sudheer Joseph <sjo.india@gmail.com> - 2013-06-06 07:22 +0530

csiph-web