[Thread Prev][Thread Next][Index]

Re: [ferret_users] Re: depth coordinate (inverted vertical axis)



Hi Ryo,
Thank you for following up. It helps the Users List to have the final answer posted.  I'll agree with you that the error message here could be more helpful.  The message "syntax error" here does indeed mean that /ORDER= does not apply to the FILE/FORMAT=STREAM command.  It might more properly be an "invalid qualifier" error (though we don't have that category of error message).

Ansley

Ryo Furue wrote:
Hi Ferret users,

I asked this question a while ago:

  
I'm wondering how to associate depth coordinate values
with a binary datafile which has this structure:

  k = 1    --- 1000m depth
  k = 2    ---  990m depth
  . . . .
  k = 101  ---    0m
    

to which Steve Guimond suggested a solution.  With his
permission, I quote part of his message.

|   Just a thought, but maybe you could try flipping the z axis using
| the /order qualifier such as :
| 
| use/order=y-z my_file.nc
| 
| You could make your grid with the depth axis as is, then save to a 
| netcdf file, and reopen with the line above. [...]

In fact, his solution works excellently.

  1) Open the original stream binary file;
  2) Save it as a netCDF file without changing axes or anything;
  3) Open the netCDF file, flipping the z-axis with the ORDER keyword;
  4) Regrid the variable (blindly, using @ASN) to depth coordinates.

I'm attaching a sample script to do this.

Before reaching this solution, I tried to invert the z-axis
when opening the original stream binary (step 1 above), which fails:

  yes? file/format=stream/var=v/grid=grid_abst/swap/order=y-z  mybin.dat
   **ERROR: command syntax: ORDER=Y-Z

This seems to mean that axis reversal isn't allowed for stream
datafiles.  (If so, the "command syntax" bit in the error message
is a little misleading because it suggests that "ORDER=Y-Z" is
syntactically incorrect.)

This was the reason why steps 2 & 3 were necessary.

Thanks, Steve.

Ryo

================================================================
!--- abstract grid ------------------------------------------
define axis/y=1:22:1  j_abst
define axis/z=1:101:1 k_abst
define grid/y=j_abst/z=k_abst grid_abst
!--- read the orginal stream binary and save to a netCDF ----
file/format=stream/var=v/grid=grid_abst/swap  mybin.dat
list/format=cdf/clobber/file=mybin-abst.nc v
cancel data/all

!--- real grid ----------------------------------------------
define axis/y=23.25S:12.75S:0.5             y_real
define axis/z=0:1000:10/units=meters/depth  z_real
define grid/y=y_real/z=z_real               grid_real
!--- read the netCDF file, inverting the z axis -------------
set data/order=y-z mybin-abst.nc
!--- regrid -------------------------------------------------
let new_v = v[g=grid_real@ASN]
  

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement