About accessing sequential data in nctoolbox through OPeNDAP Dapper

26 views
Skip to first unread message

alex...@gmail.com

unread,
May 24, 2013, 5:27:57 PM5/24/13
to ncto...@googlegroups.com
I tried to read sequence data in this way:
ds = ncdataset('http://apdrc.soest.hawaii.edu/dapper/insitu/ladcp.cdp');
location = ds.netcdf.findVariable('location');
profile = location.findVariable('profile');
temperature = profile.findVariable('ctd_t');

Can I select select a region and print first 5 locations with temperature data like Pydap (Python library)?

Example in Pyday: print the data with a small region
>>> from dap.client import open
>>> dataset = open_url('http://apdrc.soest.hawaii.edu/dapper/insitu/ladcp.cdp')
>>> print type(dataset.location)
<class 'pydap.model.SequenceType'>
>>> print dataset.location.keys()
['time', 'lat', 'lon', '_id', 'profile', 'attributes', 'variable_attributes']

>>> my_location = dataset.location[
...         (dataset.location.lat < 0)]

>>> my_location = my_location[:5]
>>> print len(my_location['_id'])
5

>>> my_location.keys()
['time', 'lat', 'lon', '_id', 'profile', 'attributes', 'variable_attributes']
>>> my_location.profile.keys()
['ctd_ss', 'u_do', 'ts', 'range', 'v_shear_method', 'v_do', 'u_up', 'range_up', 'v_up', 'ensemble_vel_err', 'ctd_t', 'ts_out', 'w_shear_method', 'range_do', 'ctd_s', 'v', 'u', 'nvel', 'uerr', 'u_shear_method', 'p', 'z']

>>> for value in my_location.profile.ctd_t:
...     print value[:10]
...
[9.8829107, 9.761694, 9.5405989, 9.5265846, 9.5052958, 9.4946136, 9.3353405, 9.2345428, 8.8949976, 8.6744404]
[10.550227, 10.532578, 10.505015, 10.31136, 10.286689, 10.145658, 9.6334896, 9.2090206, 8.9810734, 8.8150978]
[10.647948, 10.556409, 10.12057, 9.7420454, 9.5320473, 9.1422911, 8.9969978, 8.9284277, 8.8854694, 8.8590002]
[9.8911743, 9.8749323, 9.8544912, 9.4953737, 9.4862947, 9.4749165, 9.4250631, 9.0358047, 8.866889, 8.7565432]
[10.543967, 10.211137, 9.9243612, 9.8211136, 9.6091099, 9.1954517, 8.8879824, 8.7605925, 8.592474, 8.5208397]

Reference: http://www.pydap.org/client.html#accessing-sequential-data

Thanks,
  Alex

Brian Schlining

unread,
May 28, 2013, 8:33:43 PM5/28/13
to ncto...@googlegroups.com
Hi Alex, 
I tried to read sequence data in this way:
ds = ncdataset('http://apdrc.soest.hawaii.edu/dapper/insitu/ladcp.cdp');
location = ds.netcdf.findVariable('location');
profile = location.findVariable('profile');
temperature = profile.findVariable('ctd_t');

Can I select select a region and print first 5 locations with temperature data like Pydap (Python library)?

The short answer is 'No'.

The longer answer is that, as mentioned in previous threads, nctoolbox doesn't really have support for sequence/structure data built in. I have never had to deal with them as part of my job, and I suspect the other authors on nctoolbox don't use them much either. If one of us needs it in the future, we'll likely add it. That's not meant to be a snarky answer, it's just that implementation of features takes time and our employers won't pay us to work on features that they don't need. With that said, it is an open source project, so we welcome contributions from developers. 

Cheers

-- 
Brian Schlining 

Reply all
Reply to author
Forward
0 new messages