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


Groups > comp.lang.python > #47166 > unrolled thread

python netcdf

Started bySudheer Joseph <sjo.india@gmail.com>
First post2013-06-05 18:07 -0700
Last post2013-06-06 07:22 +0530
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#47166 — python netcdf

FromSudheer Joseph <sjo.india@gmail.com>
Date2013-06-05 18:07 -0700
Subjectpython netcdf
Message-ID<f39648d9-3d21-4186-8e79-c7aba935beb2@googlegroups.com>
Dear Members,
                  Is there a way to get the time:origin attribute from a netcdf file as string using the Python netcdf?
with best regards,
Sudheer

[toc] | [next] | [standalone]


#47167

FromJason Swails <jason.swails@gmail.com>
Date2013-06-05 21:33 -0400
Message-ID<mailman.2776.1370482419.3114.python-list@python.org>
In reply to#47166

[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

[toc] | [prev] | [next] | [standalone]


#47175

FromSudheer Joseph <sjo.india@gmail.com>
Date2013-06-06 07:22 +0530
Message-ID<mailman.2781.1370483543.3114.python-list@python.org>
In reply to#47166

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

Thank you very much Jason
With best regards
Sudheer

On Thursday, June 6, 2013, Jason Swails wrote:

>
>
>
> On Wed, Jun 5, 2013 at 9:07 PM, Sudheer Joseph <sjo.india@gmail.com<javascript:_e({}, 'cvml', '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
>


-- 
Sent from my iPad Mini

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web