Hi, There are a couple of little-known functions in Ferret that will help read data like this; EXPNDI_BY_Z or EXPNDI_BY_T. http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/appendix-a-external-functions/expndi_by_z http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/appendix-a-external-functions/expndi_by_t these let you read data which represents a set of time series OR a set of depth profiles, and organize them in a 2D grid, which is X-by-Z or X-by-T. Here X would be station number. For this data, at each station you have a set of depths; 1, 5, 10 then 1,5,10,15,20,25,30, then ... so this data is suited for EXPNDI_BY_Z. Use the example from the documentation to define an X-T variable. The result of the function is on an abstract grid, i=1:nstation and k=1,2,.... You will need to use the "COLUMNS" command to read and handle the date variables in your file. I'll show the use of the EXPNDI_BY_Z function to handle the numeric variables, using the example data from the documentation. The next step would be to define a Z depth axis using the data in the variable depth. One could read the variable and use Ferret commands to find the longest profile, but here I'll just look at the ascii file and define the axis. If the maximum depth is 600 then this - otherwise we'd use the deepest profile in the data. Continuing with the example in the Users Guide, ... yes? let sal_xz = expndi_by_z(salt, mask, n_profiles, max_profile_len) yes? define axis/depth/units=meters/z zdepth = {0,5,10,20,50,75,200,300,400,600} yes? let sal_z = sal_xz[gz=zdepth@asn]Now, put the longitude and latitude data on the same XZ grid, yes? let lon_xz = expndi_by_z(lon, mask, n_profiles, max_profile_len) yes? let lon_z = lon_xz[gz=zdepth@asn] yes? let lat_xz = expndi_by_z(lat, mask, n_profiles, max_profile_len) yes? let lat_z = lat_xz[gz=zdepth@asn] Now we have variables which could be used to define a grid in longitude and latitude, using one of the scat2grid functions. You'll get the best result if there are a lot of stations, of course. The scat2grid functions allow for the variable being gridded to vary in z (look at the output of the command "show details scat2gridgauss_xy"). Continuing with our example: yes? ! Define an output grid. yes? define axis/x=10:20:1/units=degrees_east xlon yes? define axis/y=40:55:1/units=degrees_north ylat yes? let xpts = x[gx=xlon] yes? let ypts = y[gy=ylat] yes? let salinity_xyz = scat2gridgauss_xy(lon_z[k=1], lat_z[k=1], sal_z, xpts,ypts, 10,10,10, 0) Finally the function RHO_UN may be used to compute density from temperature and salinity fields; and you can use the SAVE command to store any of the variables in netCDF files. On 11/9/2012 3:48 AM, Akshay Hegde
wrote:
|