Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47175
| References | <f39648d9-3d21-4186-8e79-c7aba935beb2@googlegroups.com> <CAEk9e3qhVhY2nt=2QdNot3dWdfs8BCLcdoXyXObws0DjW6u3Yg@mail.gmail.com> |
|---|---|
| Date | 2013-06-06 07:22 +0530 |
| Subject | Re: python netcdf |
| From | Sudheer Joseph <sjo.india@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2781.1370483543.3114.python-list@python.org> (permalink) |
[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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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