Project

General

Profile

Convert no regular grid ascii files to netcdf

Added by Juanma Sancho about 13 years ago

Hello,

I would need to convert ascii data files from stations distributed in a non regular grid to netcdf files to be operated using cdo.
The ascii files are in the form:

lat, lon, value
35, 4, 225
33, 5, 300
34, 3, 250
.....

Is there any cdo operator to get netcdf format from ascii files like this?
Thank you in advance.
Juanma


Replies (32)

RE: Convert no regular grid ascii files to netcdf - Added by joao ferreira about 11 years ago

It seems very fine now!!

ncview reads it and the missing values are almost everywhere they should! (maybe a little too much missing values this time... :-))

The only problem is that Panoply does not make a plot...

But what did you do?! Please explain... Thanks a lot!!

RE: Convert no regular grid ascii files to netcdf - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

As far as I know it is not possible with CDO alone(?). I use both CDO and GMT http://gmt.soest.hawaii.edu/ tool called "xyz2grd" http://gmt.soest.hawaii.edu/gmt/html/man/xyz2grd.html

step 1: cdo -outputkey,lon,lat,value ofile.nc > data.dat

step 2: xyz2grd data.dat -R-40/5/35.025/44.975 -I0.05/0.05 -Gregular.nc

DONE! that's it

One could use original data instead of ofile.nc

You can include additional info in "regular.nc" using other options in "xyz2grd"

If you don't have GMT, I recommend you to install (it is relatively easy). It is one of THE BEST tool(s) to plot unstructured grids.

Cheers,
J

RE: Convert no regular grid ascii files to netcdf - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

I forgot to mention - I think it not exactly "nearest neighbor remapping" - as far as I know CDO doesn't have a feature like this (?) - if not it is really worth to implement the same in CDO.

Cheers,
J

RE: Convert no regular grid ascii files to netcdf - Added by joao ferreira about 11 years ago

Yes... I think so too... I wanted to rely only on cdo and ncview...I already have ncl and surfer that can paint the pixel.
The advantage of gmt is that xyz2grd is only a simple command, but if you have gmt installed you can paint the pixel without the need of ncview...

Nevertheless it's one more way to skin a cat...

But I insist... Can someone else listen to me? Implement the possibility of a radius of influence in remapnn and all this is solved without the need of extra software!!

RE: Convert no regular grid ascii files to netcdf - Added by joao ferreira about 11 years ago

Anyone who finds essential that remapnn cdo can receive a radius of influence in order to put missing value in the interpolated grid point if the distance to the nearest observed unstructured value is behind that radius, please ask the developers to implement this facility in the next version of cdo.

I think it's a simple and essential thing to implement

RE: Convert no regular grid ascii files to netcdf - Added by joao ferreira about 9 years ago

Hi,

Glad to know my request was attended...
Now I want the opposite... :-)

Given a file with lots of missing data over sea, remapnn should give me the nearest point with valid data.

Doing:

cdo -R -outputtab,year,month,day,lon,lat,value -remapnn,lon=-9.497536_lat=38.781711 reduced.grib

is giving me:

1981 1 18 -9.49754 38.7817 -9e+33

where -9e+33 is the missing value because the nearest point is indeed missing value.

But very near I have a landpoint with good data, that I would like to use.

If I use -remapnn it gets good values, but it uses 4 points and I want to use just one...

RE: Convert no regular grid ascii files to netcdf - Added by joao ferreira about 9 years ago

sorry...

If I use -remapdis it gets good values, but it uses 4 points and I want to use just one...

(26-32/32)