[Thread Prev][Thread Next][Index]

Re: [ferret_users] 3 column ascii to netcdf

Hi Nitin,

To use shade you need to create a 2D variable. There are several ways to
In the attached (modified) script I've used RESHAPE to do that because
your data is on a regular (easy to define) grid. 


On Wed, 2014-09-17 at 10:52 +0530, Nitin Patil wrote:
> Dear ferret users,
> I am having a ascii file which includes 3 column (lat, lon, values of
> CO), Now I am trying to convert this into a netcdf to see a spatial
> variability.
> I am able to read the ascii but while saving it is not saving in the
> I(lat) J(lon) format so that I can command in ferret shade
> CO[x=65:95,y=5:40];go land to get spatial plot.
> Please find the attached script and supporting file. Kindly let me
> know if anyone knows.
> --
> Regards,
> Nitin Patil

cancel data/all
FILE/VAR="lat,lon,co"/COLUMNS=3 ascii_to_nc.txt

!------------------------------------  Guess axis ranges --------------
let lon_min      = lon[i=@min]
let lon_max      = lon[i=@max]
let lon_stepi    = lon[i=@shf:1] - lon
let lon_step     = lon_stepi[i=1]      !--- OK only because it's constant

let lon_min_msk    = if lon eq `lon[i=1]` then 1
let lat_at_lon_min = compressi(lat*lon_min_msk)

let lat_min      = lat[i=@min]
let lat_max      = lat[i=@max]
let lat_stepi    = lat_at_lon_min[i=@shf:1] - lat_at_lon_min
let lat_step     = lat_stepi[i=@ave]  

def ax/x=`lon_min`:`lon_max`:`lon_step`/units=LONGITUDE xlo
def ax/y=`lat_min`:`lat_max`:`lat_step`/units=LATITUDE  yla
def gr/x=xlo/y=yla grd

let co2d = reshape(co, x[g=grd]+y[g=grd])

shade co2d
go land_detail

save/clob/file=temp.nc co2d

Attachment: co2d.gif
Description: GIF image

Attachment: temp.nc
Description: Cdf file

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

Privacy Policy | Disclaimer | Accessibility Statement