Using Matlab to query the database

94 views
Skip to first unread message

Zinalabedini, Amir H CIV USN NSWC CRD BDA MD (USA)

unread,
Mar 2, 2022, 1:25:55 PM3/2/22
to Attn: Michael McDonald

Michael,

 

I have been successful at query the database and downloading files (“expt_19_2012.nc4” ) by using the following webpage.

NetCDF Subset Service for Grids (hycom.org)

I use matlab to read the downloaded files and plot the results.

 

I am hoping to use matlab to query the database directly without downloading files by giving the url address and giving the variable names that I am interested in. I do not know what file name to use when I tell matlab to go to the above webpage so that the results can be directly loaded to matlab. Maybe you can direct me in the right direction.

 

Amir

 

 

 

 

Michael McDonald

unread,
Mar 16, 2022, 5:48:30 PM3/16/22
to Zinalabedini, Amir H CIV USN NSWC CRD BDA MD (USA), Attn: Michael McDonald
With most modern versions of Matlab you can directly open NetCDF files, both locally, as you have already shown works, and remotely via OPENDAP URLs. It is safest to open/interact with *individual* remote Netcdf objects exposed via OPENDAP rather than the virtual aggregations (as you referenced the GOFS 3.0 reanalysis), as virtual aggregations essentially present to Matlab "ONE HUGE NETCDF FILE", which if not subsetted properly will often break/hang your Matlab session. Individual files will also be faster and less prone to other server-side issues (e.g., catalog aggregation updates). 

Please start at the top level the tds.hycom.org THREDDS catalog here, http://tds.hycom.org/thredds/catalog.html

then choose the  * Unaggregated * -> "All Data/" at the top of the page.
(browse the filesystem tree until you arrive at a listing of individual NetCDF files you are interested in. 

e.g., 


Clicking on any one of these files should bring up another page with several "Access:" methods listed, OPENDAP typically being the one at the top of the list.

e.g., in the "OPeNDAP Dataset Access Form" you'll see a "Data URL" with the proper URL/string to use in MATLAB as your remote NetCDF object to open/load. Keep this URL clean of any subsetting as clicking on various parts of this Dataset Access Form will append to this URL, which can present problems in certain apps, like matlab. 

e.g., *this* is an OPENDAP URL



Reply all
Reply to author
Forward
0 new messages