On 2/25/2016 8:43 PM, Venu wrote:
Hi Venu, You bring up a topic that is coming up a lot recently. This will be a long answer, and the start of more discussion on these general ideas. Collections of profiles, ship track data, time series (such as surface mooring data), and other discrete data are a topic of development in our group and in the CF standards. Look for more Ferret commands and scripts for handling non-gridded data in future releases. Having made a profile collections dataset, tools for visualizing it and working with the data are being developed for LAS, and will be made available to general Ferret users as well. The CF standard has defined a style of NetCDF files for this kind of data, "discrete sampling geometries": http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch09.html. It looks as if what you have is a collection of profiles, with "instance variables" that include location, time and perhaps more variables that might include a profile ID and other identifying information for each profile. These could be stored as an Orthogonal Multidimensional Array representation, http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch09s03.html#idp7637760 To use Ferret and make an individual profile file, you would save single-valued variables for those instance variables, perhaps in the L direction or the E direction (E for ensemble, a collected set of something). You'll need to customize things for your data, but it might look something like this. [I'm just typing commands here, and they are of course not tested, so beware of typo's.] This assumes one ascii file per profile. Open the ascii file, listing the variable names from the different columns. yes? file/var="lon,lat,year,month,day,depth,tmp,sal" ascii_file.datDefining a Z axis from depth yes? define axis/z/DEPTH/units=meters zdepth = depthDefine a single-point axis in any direction, say the X axis, for the instance variables yes? define axis/x=1:1:1 xaxDefine variables to write out : temperature and salinity on the depth axis yes? let/units="deg c"/title="temperature" temp = reshape(tmp, zz)and the instance variables. The standard says to put "coordinates" attributes on these, as they are used for geolocation. http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch09s05.html yes? let/units="degrees_east"/title="Longitude" longitude = reshape(lon[i=1], xx)for time, here is how to define a time variable from year, month, day variables. http://ferret.pmel.noaa.gov/Ferret/faq/creating-a-time-axis-from-time-variables. We're not going to define a time axis, just a single time for the profile. yes? let data_time_1900 = DAYS1900(year,month,day)It may be convenient to define time in other units and a different time origin, more on this below yes? let days_since_1970 = DAYS1900(1970,1,1)Make an ID from the dataset name. This could be defined in some other way from metadata about the profile, and other relevant variables defined similarly, but only one variable has the cf_role attribute. yes? define symbol idname = `temp,return=dset`Write the profile to a netCDF file. The depth coordinate will be written as the coordinate variable for salinity and time. yes? save/file=($idname).nc longitude, latitude, time, id, salt, tempThe final thing that a Discrete Sampling Geometries file needs is the global featureType attribute. Ferret currently doesn't have a direct command-line method to write a custom global attribute to a file but we can call the NCO_ATTR function to write one. All of that to make each single profile dataset. So, how to collect these into a single collection? You could define a long axis in the "num_profiles" dimension (here perhaps the E direction) and use Ferret's SAVE/APPEND, with the logic to append slabs in the profiles dimension as is done here in example 4yes? let status = NCO_ATTR("($idname).nc", "global", "featureType", "c", "o", "profile") yes? load status http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/converting-to-netcdf/SIMPLE-CONVERSIONS-USING-FERRET#_VPINDEXENTRY_1071 The thing to be careful of is to get assign each profile its own E index of the grid. Define an axis as long or longer than the number of profiles. The first command saves empty space for the entire axis in the M direction. yes? define axis/e=1:2000:1 profile_axisLikewise for all of the instance variables. For any variables that are strings, use a RESHAPE function to define the variable on the correct index in the E direction.
yes? cancel data profile1 Another option for creating a collection is to install ERDDAP. http://coastwatch.pfeg.noaa.gov/erddap/index.html. This is a tool that works beautifully for this purpose. It points to collections of data, leaving them in their underlying individual files, and then treats them as a single dataset. The advantage of this is that to add new data, or make a correction (say you found that some of the files were duplicates of others, and should be removed), you just make the change to the collection of profiles, refresh the ERDDAP, and the new set is available. ERDDAP allows for subset requests, say a subset in space and/or time, a subset of depths, one or multiple variables, and there are various file output types. ERDDAP is the reason I defined time as seconds-since-1970 above. That is required for ERDDAP time information. Ansley
|