MATLAB Model Interoperability Demo
The Matlab Model Interoperability Demo shows how to efficiently access and visualize multidimensional data (e.g. elevation, salinity, water velocity, wave heights) from a number of different Gulf of Maine ocean models using tools from a new CF Toolbox. The CF toolbox uses high-level NetCDF-Java routines that return lon,lat,depth and time in a standard form regardless of the type of model, allowing data from FVCOM, POM, ECOM, ROMS, WAVEWATCH3 to be accessed using the exact same matlab function.
Setting up Matlab to work with NetCDF-Java and the CF Toolbox:
Step 1: Fix Matlab's java classpath: - In Matlab, type "edit classpath.txt" and comment the line that contains mwucarunits.jar so it looks like this:
#$matlabroot/java/jarext/mwucarunits.jar
and save your changes. For Linux users: If you can't edit the system classpath.txt file, then copy it to your home directory and make the edit there. Matlab looks first for classpath.txt in your home directory, so it will use your edited version.
- Exit and restart MATLAB.
- (Worried that you just commented out some java methods used by the system? Don't be. The mwucarunits.jar file is only used by the Mathworks "Model-Based Calibration Toolbox" and contains an old implementation of the Unidata UDUNITS package that conflicts with the more recent version that NetCDF-Java uses.)
- Get our version of Unidata's NetCDF-Java library: toolsUI-2.2.22-skb0.4.jar (~15 MB) and save it on your computer. If your browser saves it with a .zip extension, just rename it back to .jar after you have downloaded it.
- Get our CSTM Java library: cstmTools-1.0.02.jar (~5 MB) and save it to your computer.
For Matlab 7+: In Matlab, type "edit startup.m" and add the following lines (modified for the actual location of your jar files):
javaaddpath('c:\your_path_here\toolsUI-2.2.22-skb0.4.jar','-end');
javaaddpath('c:\your_path_here\cstmTools-1.0.02.jar','-end');- For Matlab 6 or 6.5: Type "edit classpath.txt" in Matlab, add the jar files to the list
- Restart Matlab. If you type "javaclasspath" you should see the two jar files you added (along with all the Java stuff that comes with Matlab)
- Get our Matlab CF Toolbox: matlab_cf_2.6.zip
- This toolbox has four directories: ./cf, ./cf/demos, ./seawater and ./RPSstuff. If you already have the seawater and RPSstuff directories you can use your existing ones.
- Add "cf", "seawater" and "RPSstuff" directories to your Matlab path
- Go to the CF Toolbox demos subdirectory ( ./cf/demos), and try the following:
- do_interop.m Demonstrates reading several different structured (POM, ECOM, and ROMS) and unstructured grid (FVCOM) model results with the exact same routine. Doesn't make any fancy plots, but delivers 3D data fields with corrresponding lon,lat, z and time.
- do_interop_plot3d.m Makes a 3D plot of the bottom temperature for structured grid models.
- test_plot3D_fvcom.m Makes a 3D plot of bottom layer temperature for unstructured grid FVCOM model.
- do_interop_data.m Compares an observed vertical profile of temperature to two different models.
- gomoos_latest.m Plots a daily-averaged section of alongshore velocity from the latest GoMOOS forecast.
- do_interop_bot_temp.m Plots observed bottom temperatures within the last day on top of the predicted bottom temperature from the GoMOOS forecast model.
- bathy_comp.m Compare bathymetry from two different bathymetric grids (global or regional).
- Type "help cf" to see a brief description of the CF tools. http://w3.ualg.pt/~jluis/mirone/
- The tools with "cf" are meant to be used with CF compliant data, while the tool "nj_varget" works with non-CF compliant data as well. All the data on the Gulf of Maine Interoperability Experiment THREDDS Catalog at http://coast-enviro.er.usgs.gov/thredds/gom_interop_catalog.html is CF-compliant. Browse the catalog and then cut-n-paste the OpenDAP URL into your matlab workspace to access that dataset.
- Explore bathymetry! A collection of regional and global bathymetry (including the NOAA Coastal Relief Model) is available through this THREDDS Catalog:
http://coast-enviro.er.usgs.gov/thredds/bathy_catalog.html
If you are on a PC, there is an extremely useful toolkit for bathymetry called Mirone, by Joachim Luis. You can use the "cf_subsetGrid.m" routine to clip just the region you want from a bathymetry data set. For example:
>> uri='http://coast-enviro.er.usgs.gov/thredds/dodsC/bathy/crm_vol1.nc';
>> [data,geo]=cf_subsetGrid(uri,'topo',[-70.9 -70.1 41.15 41.65]);
will clip the bathy data from the Martha's Vineyard region out of the Coastal Relief Model Vol. 1 (Northeast) into your Matlab work space. To make a simple plot, you can use "pcolor" or
>> imagesc(geo.lon,geo.lat,data); axis xy
To get the data into Mirone, do:
>> grid2mirone(data,geo)
See the Mirone help for more information -- it's a very powerful tool with many capabilities, including profiles, color-shaded relief images, output to Google Earth, the free Fledermaus IVIEW3D viewer, and more. - The CF toolbox routines can access data from THREDDS catalogs and OpenDAP servers (as well as local and remote NetCDF files). More sources of data can be found by searching for "thredds" or "opendap" at NASA's Global Change Master Directory (http://gcmd.nasa.gov)






















