Project

General

Profile

Remapping unstructured ascii data to a regular grid

Added by Tony Leboissetier over 4 years ago

Hello,
I have an unstructured ASCII file and I want to convert it to a regular grid netcdf file.
For example this:

121.86    38.94    16.00
121.63 38.90 16.00
121.40 38.85 24.00
121.17 38.81 16.00
120.93 38.76 32.00
122.70 38.72 104.00

Should I use:

cdo -f nc input,mygrid ofile.nc < data.txt

If so what should be the mygrid file since the lon/lat coordinates don't increase monotously? (using gridtype = cell?)
Also, is the data.txt supposed to be the third column of the array above?

Cordially,
Tony


Replies (1)

RE: Remapping unstructured ascii data to a regular grid - Added by Karin Meier-Fleischer over 4 years ago

Hi Tony,

if you ASCII file is data/lat/lon then you have create a gridfile (mygrid), extract the data values from your input file and last but not least convert it to netcdf.

Extract the data values from input file:

cat input.asc | awk '{print $1}' > data.asc

Create the gridfile mygrid:

cat << EOF > mygrid
gridtype = cell
gridsize = 6
xvals = 38.94 38.90 38.85 38.81 38.76 38.72
yvals = 16.00 16.00 24.00 16.00 32.00 104.00
EOF

Convert the ASCII data to netCDF - don't forget to set the time:

cdo -f nc -setreftime,2019-01-01,00:00:00,1day -settaxis,2019-11-26,12:00:00,1day -setcalendar,standard -input,mygrid ofile.nc < data.asc

You have to modidy the settaxis and setreftime settings to your needs.

-Karin

    (1-1/1)