function jdmat=cf_time(uri,var,timeIndex) % CF_TIME Get entire time vector for variable 'var' from any CF-compliant file % Usage: jdmat=cf_time(uri,var,timeIndex); % Inputs: uri = Local or remote NetCDF and NCML files, or OPeNDAP % var = variable name % timeindex = time step % Output: jdmat = vector of times in DATENUM format % Example: % Gridded dataset: % uri='http://stellwagen.er.usgs.gov/cgi-bin/nph-dods/models/test/bora_feb.nc'; % var='temp'; % Non-Gridded dataset: (But has CF-compliant time coordinate variable) % uri='http://www.gri.msstate.edu/rsearch_data/nopp/non-gridded/adcirc/adc.050913.fort.64.nc'; % var='ubar'; % % jdmat=cf_time(uri,var,timeIndex); % Rich Signell (rsignell@usgs.gov) % skbhate@ngi.msstate.edu import msstate.cstm.data.JDataset import msstate.cstm.data.grid.JGeoGridDataset import msstate.cstm.data.JNetcdfDataset if nargin < 2 help cf_time return end %get the 'msstate.cstm.data.JDataset' object jd = JDataset(uri); %get the geogrid associated with the dataset GeoGridData = JGeoGridDataset(jd.getGridDataset(),var); if ( isa(GeoGridData.getGeoGrid(), 'ucar.nc2.dt.grid.GeoGrid') ) % make sure it's gridded data netcdfDatasetObj = GeoGridData; else netcdfDatasetObj = jd.getNetcdfDataset(); % handle as plain netcdf dataset end switch nargin case 2 jdmat = nj_time(netcdfDatasetObj); case 3 jdmat= nj_time(netcdfDatasetObj,timeIndex); otherwise, error('MATLAB:cf_time:Nargin',... 'Incorrect number of arguments'); end %cleanup jd.close(); end