[Thread Prev][Thread Next][Index]

[ferret_users] Re: Pls help...



Hi,
Here are some general suggestions for asking questions on this list, and for debugging Ferret scripts. Then I do have a couple of suggestions for your script. It's often quite complex to read ascii data. This is a really useful technique that I don't think we've really developed before.  We'll gather this into an FAQ to add to the documentation.


 - First, when asking a question, make the subject line something that relates to the question. For instance, "reading station data from an ascii file" is more likely to get answers than "ferret question" or "please help".
 
 - If you see error messages, tell us what those messages say.  In general people don't want to start by downloading your data and your script and run it, but they will look at an error message and tell you what it's about.  It's not a bad idea to include your data and script, but your description of what's happening and why the results don't seem right, is where the list members start when answering questions.

- We're already doing some of this but when working on a script, at various stages along the way, use Ferret to check what the variables look like. I think you've done the first steps correctly, but any time I read a new data source, particularly ascii data, I plot some of it to make sure the read I've got the right fields:
yes? plot/vs lon, lat  ! shows the locations of the  stations
yes? plot depth  ! shows all the depth profiles
yes? plot salt      ! check that they look like salinity values
Or use the STAT command to see what the range of data for variables looks like.

After defining sal_xz, you could visualize it:
yes? shade sal_xz
Using Ferret to list or plot your variables will often suggest to you the changes you need.

As you said, and as you see from the SHADE command above, the max_profile_len is larger than it needed to be.  Now that the profiles have been split up, Ferret can tell you what the longest profile was.  The @NGD transformation tells you how many valid data there are for a variable on an axis. Try this:
yes? list sal_xz[k=@ngd]
That's the number of valid data in each profile. So,  in the script, define sal_xz and so forth as you're doing, then redefine max_profile_len.
let max_profile_len = 9999
let sal_xz = expndi_by_z(salt, mask, n_profiles, max_profile_len)

let proflen = sal_xz[k=@ngd]
let max_profile_len = `proflen [i=@max]`
Now you do not need to re-define sal_xz and temp_xz - they are defined in terms of the variable max_profile_len, so changing max_profile_len is all that's needed.  Have a look at this again:

   yes? shade sal_xz

To define the depth axis, you could define a variable "depth_xz" with expndi_by, and then find the longest profile, and use the depths listed there to define the z axis.
let depth_xz = expndi_by_z(salt, mask, n_profiles, max_profile_len

! at which X is the variable proflen largest?  
let deepest_p_loc = proflen[i=1:`n_profiles`@LOC:`max_profile_len`]

! define the z axis from that set of depth?
define axis/depth/units=meters/z  zdepth = depth_z[i=`deepest_p_loc`]

The definition of the X and Y axes in longitude look fine to me, but you might try different values for the delta-x and delta y, perhaps making a coarser grid.  The range should cover the range of the longitudes and latitudes in your data and ideally the grid cells would contain multiple stations.

In the documentation of SCAT2GRIDGAUSS_XY, there is a discussion of the scale and cutoff parameters for the scat2gridgauss functions.  If you make these numbers larger, or define a coarser grid, the interpolation to the grid will cover more area because you are bringing in more data to fill each grid cell.

Ansley

On 11/15/2012 4:53 AM, Akshay Hegde wrote:
Kindly help...not able to get right output


columns/skip=1/delim="\t,\b,-"/type="numeric,numeric,numeric,numeric,numeric,text,numeric,time,text,latitude,longitude,text,numeric,numeric,numeric" 748phy.csv
list v13
show d
! consisting 14801 lines
define axis/x=1:14801:1 xin
define grid/x=xin input_grid
columns/skip=1/delim="\t,\b,-"/type="numeric,numeric,numeric,numeric,numeric,text,numeric,time,text,latitude,longitude,text,numeric,numeric,numeric"/grid=input_grid 748phy.csv

let stn = v2
let depth = v13
let temp = v14
let salt = v15
let lon = v11
let lat = v10

list depth, temp, salt
let mask = if depth[i=@ddb] LT 1 then 1
list depth, mask, stn
let n_profiles = `1 + mask[i=@ngd]`

! Have confusion here...how to find max profile length ?
let max_profile_len = 9999
let sal_xz = expndi_by_z(salt, mask, n_profiles, max_profile_len)
let temp_xz = expndi_by_z(temp, mask, n_profiles, max_profile_len)
list sal_xz
list temp_xz

let sal_xz = expndi_by_z(salt, mask, n_profiles, max_profile_len)

! Is there any other way to define depth ? it takes time to define manually, my max depth is more than 4000 meter

define axis/depth/units=meters/z  zdepth ={0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200}
let sal_z = sal_xz[gz=zdepth@asn]
let temp_z = temp_xz[gz=zdepth@asn]
let lon_xz = expndi_by_z(lon, mask, n_profiles, max_profile_len)
let lon_z = lon_xz[gz=zdepth@asn]
let lat_xz = expndi_by_z(lat, mask, n_profiles, max_profile_len)
let lat_z = lat_xz[gz=zdepth@asn]

! I have confusion here in defining latitude and longitude

define axis/x=10:20:1/units=degrees_east xlon
define axis/y=40:75:1/units=degrees_north ylat
let xpts = x[gx=xlon]
let ypts = y[gy=ylat]

! why 10,10,10,0 at the end of function declaration ?
let salinity_xyz = scat2gridgauss_xy(lon_z[k=1], lat_z[k=1], sal_z, xpts,ypts, 10,10,10, 0)
let temp_xyz = scat2gridgauss_xy(lon_z[k=1], lat_z[k=1], temp_z, xpts,ypts, 10,10,10, 0)

! sometimes error comes here

list/file=phy.nc/format=cdf/clobber temp_xyz,salinity_xyz


-Akshay Hegde


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement