OPULS: UGrid Subsetting: Difference between revisions

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽
Line 3: Line 3:


== Background information on UGrid 0.9 ==
== Background information on UGrid 0.9 ==
The [https://github.com/ugrid-conventions UGrid specification] moved to GitHub in 2013. The 0.9 version of the specification was last edited on 29 Oct 2013. Our function conforms to that specification and to an older version (0.6?), where the major difference is the organization of the mesh array data. For a triangular array, the 0.9 version specifies the array be a Nx3 while the older specification specified a 3xN. Our code supports both.


== The ugr5 Function ==
== The ugr5 Function ==

Revision as of 23:29, 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 UGrid specification moved to GitHub in 2013. The 0.9 version of the specification was last edited on 29 Oct 2013. Our function conforms to that specification and to an older version (0.6?), where the major difference is the organization of the mesh array data. For a triangular array, the 0.9 version specifies the array be a Nx3 while the older specification specified a 3xN. Our code supports both.

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 (that returns the DDS for the subset data):
http://54.172.39.65:8080/opendap/hyrax/ugrids/Ike/2D_varied_manning_windstress/test_dir-norename.ncml.dds?ugr5(0,depth,"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 an 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

A server with unstructured grid data and subsetting function on board is here: http://54.172.39.65:8080/opendap/

In the directory ugrids You can find a number of test datasets.

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.