OPULS: UGrid Subsetting: Difference between revisions

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽
Line 16: Line 16:
:: ugr5(0, depth, "28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")
:: ugr5(0, depth, "28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")
: Used in a url:
: Used in a url:
:: [http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir.ncml.dds?ugr5(0,depth,%2228.0%3Clat&lat%3C29.0&-89.0%3Clon&lon%3C-88.0%22) http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir.ncml.dds?ugr5(0,depth,"28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")]
:: [http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir.ncml.dds?ugr5(0,h,%2228.0%3Clat&lat%3C29.0&-89.0%3Clon&lon%3C-88.0%22) http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir.ncml.dds?ugr5(0,h,"28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")]


; Subsetting the range variables
; Subsetting the range variables

Revision as of 23:01, 15 May 2015

Overview

We have written a server function that uses Bill Howe's Gridfields library to subset unstructured grids (aka irregular meshes) that conform to the UGrid 0.9 specification that is part of the CF-1.6 specification. Our function has a little latitude in its requirements because it also supports features found in earlier versions of the UGrid specification (e.g., the 'mesh array' can be either the 3xN or Nx3). However, our function only supports triangular meshes, not the other mesh schemes outlined in the specification. The function will subset one or more range variables based on the values of the domain variables as expressed in a simple relational expression. The result of the function is an unstructured grid - that is, the subsetting operation will return a a set of variables that could be written to a netcdf file and the result would conform to the UGrid 0.9 specification. Because the specification has evolved over time and older data are still perfectly valid, we often 'tweak' those older datasets using NcML so that the contain the variables and attributes required by the newer versions of the UGrid specification.

Background information on UGrid 0.9

The ugr5 Function

Name
ugr5 - Restrict the domain of an unstructured 2D Mesh Topology grid
Syntax
ugr5(0, rangeVariable:string, [rangeVariable:string, ... ] condition:string)
  • The first parameter indicates that the supplied relational constraint condition is to be applied to coordinate values at the nodes (0) or the faces (2) of the mesh.
  • The second, third, ..., parameter is a list of (range) data variables that you wish to subset, they may be associated with nodes or faces of the mesh.
  • The last parameter is an expression that defines conditions that the domain variables must meet in order to be included in the result.
Here is an example:
ugr5(0, depth, "28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")
Used in a url:
http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir.ncml.dds?ugr5(0,h,"28.0<lat & lat<29.0 & -89.0<lon & lon<-88.0")
Subsetting the range variables
In the example dataset NECOFS_GOM3_FORECAST.nc (DDS DAS) we can see that there are range variables associated with the nodes of the mesh that have a 'time' dimension and a 'siglay' dimension. Since the 'time' dimension has 145 values, and 'siglay' dimension has 40 values it may be that you wish to only retrieve a single time slice and/or siglay slice. This can accomplished by using a dap4 array constraint on the variable as it is passed to the ugrid function. For example, to retrieve the 12th siglay slice of the 5th time slice of the variable salinity you would constrain it like salinity[4][11][*] (note that the indices begin at zero). In the request URL this would look like
http://54.172.39.65:8080/opendap/hyrax/ugrids/NECOFS_GOM3_FORECAST.nc.dds?ugr5(0,salinity[4][11][*],"38.0<lat & lat<42.0 & -64.0<lon & lon<-60.0")
It is also possible to request, say, every 5th time slice salinity[0:5:*][*][*] or every 3rd siglay slice from 3 to 30 salinity[4][3:3:30][*] In a request URL this would look like
http://54.172.39.65:8080/opendap/hyrax/ugrids/NECOFS_GOM3_FORECAST.nc.dds?ugr5(0,salinity[4][3:3:30][*],"38.0<lat & lat<42.0 & -64.0<lon & lon<-60.0")

The Data

I have a new server up with the ugrid data and subsetting function on board here: http://54.172.39.65:8080/opendap/

In this dir: http://54.172.39.65:8080/opendap/ugrids/ You can find the datasets (hex.nc, test4.nc) that were used by Bill & Scott at UW to develop the first ugrid restrict using the gridfields library. However their code was based on an older version of the ugrid spec, and it seems the specification shifted out from under their code. I worked on the code to get it to respond to datasets organized as described here: https://publicwiki.deltares.nl/display/NETCDF/Deltares+CF+proposal+for+Unstructured+Grid+data+model

I adapted their original test data using ncml files. I wrote an ncml file for test4.nc ( called test4-ugrid.ncml in the same directory) that makes it compliant with the Deltares specification and it can be subset with the ugrid restrict function. http://54.172.39.65:8080/opendap/ugrids/test4-ugrid.ncml Also in that directory is the dataset (NECOFS_GOM3_FORECAST.nc) that Rich Signell provided http://54.172.39.65:8080/opendap/hyrax/ugrids/NECOFS_GOM3_FORECAST.nc Which can be subset using the ugrid restrict function.

Also, a while back I tracked down and downloaded on of the larger, multi-time-step fvcom ugrid data files, it's now set up here: http://54.172.39.65:8080/opendap/ugrids/Ike/ Inside you'll find that the 2D models have useful stuff. In http://54.172.39.65:8080/opendap/ugrids/Ike/2D_varied_manning_windstress/ You should see the original nmcl files from the source server. These weren't compatible with Hyrax - mostly the result of Hyrax not being as "elastic" as the TDS with its inputs.

The file test_dir-norename.ncml can be subset using the ugrid restrict function: http://54.172.39.65:8080/opendap/ugrids/Ike/2D_varied_manning_windstress/test_dir-norename.ncml The file test_dir.ncml is closer to the original ncml file 00_dir.ncml, unfortunately it only works superficially. You can get the metadata responses for this dataset, but there is a bug in the ncml code that prevents ugrid restrict function from returning data values for renamed variables. The test_dir-norename.ncml is simply test_dir.ncml without the renamed variables.