[Thread Prev][Thread Next][Index]

Re: [ferret_users] ASCII to netCDF issue



Hi Daniel,
Reading ASCII data is always tricky isn't it.  The input files are all a bit different. The problem here is in trying to skip over the first column using "dummy1".  The data starts out like this with longitude across the top, and each row being a latitude. The fact that it starts at 90N and goes downward is also a bit of an issue, I'll talk about that at the end.

Effective Dose (uSv/hour) at 11 km, Oct-27-2003 UT00:00
 glon     0     5    10    15    20    25    30    35    40    45    50    55 ... 355
 90.0   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9
...
 85.0   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9 ...
 80.0   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9   5.9 ...
 75.0   5.8   5.8   5.8   5.8   5.8   5.8   5.8   5.8   5.8   5.8   5.8   5.8 ...


You want to skip those two header lines and the first column, reading the remaining data into the variable. Running your script, if you look at the data after the "file" command,

yes? def axis/y=90.0:-90.0/npoints=37/units="degrees_north" yax

yes? def axis/x=0:355/npoints=72/units="degrees_east" xax

 

yes? define axis/t="23-oct-2003":"23-oct-2003":1/units=hours tax1

yes? def grid/x=xax/y=yax/t=tax1 my_grid

 

yes? file/skip=2/columns=73/order=yx/var="dummy1,effective_dose"/grid=my_grid "/home/doostra/NAIRAS/EV000-87.dat"

yes? show data
     currently SET data sets:
    1> ./EV000-87.dat  (default)
 name     title                             I         J         K         L
 DUMMY1   DUMMY1                           1:72      1:36      ...       1:1
 EFFECTIVE_DOSE
          Effective Dose (NAIRAS)          1:72      1:36      ...       1:1
you'll see both dummy1 and effective_dose as variables on the 2D grid. Ferret couldn't tell that you wanted to read "dummy1" as a single column, and "effective_dose" on the 37x72 grid.

I think the best way to do that is with a formatted read, where /FORMAT=(5x, 72f6.1) will skip the first number in each record, and then read just the one variable in each of 72 columns.
yes? file/skip=2/columns=72/format=(5x,72f6.1)/var="effective_dose"/grid=my_grid"/home/doostra/NAIRAS/EV000-87.dat"
This file is ordered with X varying fastest, along the records, so you do not want the /order=yx, but instead the default which is /order=xy. 

One last thing. We can define a backwards axis only for a depth/altitude axis in Ferret. When you define the latitude axis,
def axis/y=90.0:-90.0/npoints=37/units="degrees_north" yax
Ferret re-orders that. (If you had said def axis/y=90.0:-90.0:-5  you would have seen an error message. This is an unfortunate feature of DEFINE AXIS which I'll look into). The axis will be defined as if you said,
def axis/y=-90.0:90.0/npoints=37/units="degrees_north" yax
Check by looking at "list/y=90 effective_dose " and "list/y=-90 effective_dose". There's an easy fix for that however. Once your data is in the netCDF file, then we can use features of the netCDF library to easily reverse that axis. So,

   ...

   set variable/title="Effective Dose (NAIRAS)" effective_dose

   set variable/units="uSv/hr"/bad=-999.0 effective_dose

   save/file=n1.nc/clobber effective_dose


  cancel variable/all; cancel data/all
  use/order=x-y n1
.nc
  save/file=
nairas_hal-87.nc/clobber effective_dose
 

Ansley

On 10/11/2011 10:28 AM, Oostra, Daniel H. (LARC-E302)[SCIENCE SYSTEMS AND APPLICATIONS, INC] wrote:

Hi Ferret Users,


I’m working on converting an ASCII file to netCDF for use in the LAS.  I’ve included the file in this message (EV000-87.dat), and the netCDF file this script creates.

 

Here is the script:

def axis/y=90.0:-90.0/npoints=37/units="degrees_north" yax

def axis/x=0:355/npoints=72/units="degrees_east" xax

 

define axis/t="23-oct-2003":"23-oct-2003":1/units=hours tax1

def grid/x=xax/y=yax/t=tax1 my_grid

 

file/skip=2/columns=73/order=yx/var="dummy1,effective_dose"/grid=my_grid "/home/doostra/NAIRAS/EV000-87.dat"

set variable/title="Effective Dose (NAIRAS)" effective_dose

set variable/units="uSv/hr"/bad=-999.0 effective_dose

save/file=nairas_hal-87.nc/clobber effective_dose

 

The issue is that the netcdf file only has 18 of the 37 latitude points, so in the LAS it only plots half of the grid.  I’ve tried defining y with modulo and this gets me all the lat points, but the data is missing for half again.  I’ve also tried defining y with modulo and x=180:-180, as well as some other things—basically grasping at straws.

 

Does anyone see anything I’m doing wrong? Or, have a better way to do this?  I’m open to any and all feedback.

 

Thank you!

 

Dan

 

Daniel Oostra (SSAI)

NASA/LaRC Atmospheric Sciences Data Center

2 South Wright Street

Hampton, VA 23681-2199

Ph: 757.864.6157

daniel.h.oostra@xxxxxxxx

 

 


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

Privacy Policy | Disclaimer | Accessibility Statement