Ticket #31 (defect)
Opened 12 years ago
Last modified 12 years ago
change dim names to match var name in netCDF (ntime to time)
Status: assigned
Reported by: | haines | Assigned to: | haines (accepted) |
---|---|---|---|
Priority: | major | Milestone: | raw2proc-1.0 |
Component: | raw2proc | Version: | |
Keywords: | netcdf | Cc: | |
In each proc_*.py creator module, change dimension names to match corresponding variable name. It might not make reading the file by humans easy, but it will allow pydap to work correctly to grab data dependency.
For example, pydap cannot load d2.wtemp[:] because ntime dimension does not match time var. pydap is looking for the dependency based on dimension values.
>>> d2= pydap.open_url('http://whewell.marine.unc.edu/dods/nccoos/level1/b2/ctd1/b2_ctd1_2011_11.nc') >>> d2.wtemp {'wtemp': <pydap.model.BaseType object at 0xb792fb8c>, 'ntime': <pydap.model.BaseType object at 0xb792fc2c>}
>>> d2.wtemp[:] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/env/haines/dataproc/lib/python2.6/site-packages/pydap/model.py", line 662, in __getitem__ var.data = var.data[slice_] File "/opt/env/haines/dataproc/lib/python2.6/site-packages/pydap/proxy.py", line 115, in __getitem__ resp, data = request(url) File "/opt/env/haines/dataproc/lib/python2.6/site-packages/pydap/util/http.py", line 50, in request raise ServerError(msg) pydap.exceptions.ServerError: 'Server error 42: "\'ntime\'"'
However, we can still read the data via pydap, but have to know to get time separately, e.g.
>>> d2.wtemp.array[:] array([ 23.10750008, 23.14500046, 23.38870049, ..., 22.0807991 , 22.06220055, 22.07489967], dtype=float32) >>> d2.time.array[:] array([1320121566, 1320132726, 1320137406, ..., 1322696548, 1322696908, 1322697268])
So change the following in creator():
# dimension names use tuple so order of initialization is maintained dim_inits = ( ('ntime', NC.UNLIMITED), ('nlat', 1), ('nlon', 1), ('nz', 1), )
to
# dimension names use tuple so order of initialization is maintained dim_inits = ( ('time', NC.UNLIMITED), ('lat', 1), ('lon', 1), ('z', 1), )
and any ntime to time (or nlat to lat or nlon to lon or nz to z, etc)
# (varName, varType, (dimName1, [dimName2], var_inits = ( # coordinate variables ('time', NC.INT, ('time',)), ('lat', NC.FLOAT, ('lat',)), ('lon', NC.FLOAT, ('lon',)), ('z', NC.FLOAT, ('z',)), # data variables ('wtemp', NC.FLOAT, ('time',)), ('cond', NC.FLOAT, ('time',)), ('press', NC.FLOAT, ('time',)), # derived variables ('depth', NC.FLOAT, ('time',)), ('salin', NC.FLOAT, ('time',)), ('density', NC.FLOAT, ('time',)), )
Change History
06/26/12 11:24:45: Modified by haines
- status changed from new to assigned.
06/26/12 11:29:42: Modified by haines
- component changed from adcp to raw2proc.