Project

General

Profile

grid issue, remapping with remapnn

Added by andrea hurtado about 10 years ago

Hello

This is my second post regarding the same issue, but this time I have going a little bit forward but now I get another error and I would like you to help me with it if it is possible, many thanks in advance!

I have two files with the following characteristics:

$ cdo sinfo testlatlon.nc
File format: netCDF
-1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter ID
1 : unknown unknown constant 1 1 67420 1 F32 : -1
2 : unknown unknown constant 1 1 67420 1 F32 : -2
Grid coordinates :
1 : generic > size : dim = 67420 nx = 67420 ny = 0
Vertical coordinates :
1 : surface : 0

and

$ cdo sinfo test.nc
File format: netCDF
-1 : Institut Source Ttype Levels Num Gridsize Num Dtype : Parameter ID
1 : unknown unknown constant 1 1 67209 1 F32 : -1
2 : unknown unknown constant 1 1 67209 1 F32 : -2
3 : unknown unknown constant 1 1 67209 1 F32 : -3
4 : unknown unknown constant 1 1 67209 1 F32 : -4
5 : unknown unknown constant 1 1 67209 1 F32 : -5
6 : unknown unknown constant 1 1 67209 1 F32 : -6
7 : unknown unknown constant 1 1 67209 1 F32 : -7
8 : unknown unknown constant 1 1 67209 1 F32 : -8
9 : unknown unknown constant 1 1 67209 1 F32 : -9
10 : unknown unknown constant 1 1 67209 1 F32 : -10
11 : unknown unknown constant 1 1 67209 1 F32 : -11
12 : unknown unknown constant 1 1 67209 1 F32 : -12
13 : unknown unknown constant 1 1 67209 1 F32 : -13
14 : unknown unknown constant 1 1 67209 1 F32 : -14
15 : unknown unknown constant 1 1 67209 1 F32 : -15
Grid coordinates :
1 : generic > size : dim = 67209 nx = 67209 ny = 0
Vertical coordinates :
1 : surface : 0

I would like to use the command remapnn to remap the second file into the first one, as you can see the second one is shorter by ~200 points, when I perform remapnn I get the following error:

$ cdo remapnn,testlatlon.nc test.nc final.nc

cdo remapnn (Abort): Unsupported grid type: generic

Basically the "grid" is defined by the pair of coordiantes in file #1 (Parameters -1 and -2 are LONGITUDE and LATITUDE respectively) and not by a grid description of the file; for each pair of coordinates in file #1 there is a value from file #2 that corresponds to this pair, then the "extra" coordinate pairs that do not hold a value (~200 points) will obtain one calculated by a nearest neighbour approach, how can I perform this operation obtaining a file with the size as the first one but also the variables from the second one remapped? hope you can help me with this issue, I look forward to hearing from you soon.

Best Wishes

Andrea Hurtado


Replies (6)

RE: grid issue, remapping with remapnn - Added by Jaison-Thomas Ambadan about 10 years ago

1 : generic > size : dim = 67209 nx = 67209 ny = 0

I think cdo cannot remap because ny=0. You mentioned that the file contains LONGITUDE and LATITUDE as data variables, so you could use NCO tools to properly define the LONGITUDE and LATITUDE as the co-ordinates to the data variable that you want to interpolate and then CDO remapnn should work.

RE: grid issue, remapping with remapnn - Added by andrea hurtado about 10 years ago

Dear Jaison

Thank you very much for your prompt answer, the problem is also that I do not know how to proceed in order to achieve that, should I write a grid description file? What type of grid description will be adequate for this example, eg. latlon, cell? How do I extract the values of Longitude and Latitude from file #1 to make a grid description? Or if it is not the case what command should I performed to set these variables as coordinates? I am sorry if I sound very basic, but I am new to CDO and I have gone through the documentation and do not seem to have found so far a soulution to this, maybe an exmple will be of great help, thank you very much in advace, I look forward to hearing from you soon.

All the Best

Andrea Hurtado

RE: grid issue, remapping with remapnn - Added by Jaison-Thomas Ambadan about 10 years ago

Could you please upload your input file(s) testlatlon.nc or both if that is not too big (< 50MB)

RE: grid issue, remapping with remapnn - Added by andrea hurtado about 10 years ago

Dear Jaison

Yes sure, thanks again for all your help

Best Wishes

Andrea Hurtado

RE: grid issue, remapping with remapnn - Added by Jaison-Thomas Ambadan about 10 years ago

Your data is a bit complicated (at least to me). The dimension "67209" is not even (it looks like some unstructured grid or some station data)

One way to make it regular is by using GMT (Generic Mapping Tool): http://gmt.soest.hawaii.edu/

for example for the variable field342:

1. cdo -outputf,%13.6f,1 -selvar,field342 test.nc > field342.dat
2. cdo -outputf,%13.6f,1 -selvar,longitude test.nc > lon.dat
3. cdo -outputf,%13.6f,1 -selvar,latitude test.nc > lat.dat
4. paste -d"\t" lon.dat lat.dat field342.dat >> input.dat
5. xyz2grd input.dat -R-179.75/179.75/-55.75/83.25 -I0.75/0.75 -Dlon/lat/field342 -Gnew_file.nc

This will generate a regular gridded file new_file.nc (basically assign nearest neighbor grid to the corresponding values). Visualization with ncview looks okay to me.

*xyz2grd* is a GMT command. The -R-179.75/179.75/-55.75/83.25 are the min-max of longitude/latitude your data with roughly 0.75 degree increment (from your input data but you may change if you wish.)

xyz2grd: https://www.soest.hawaii.edu/gmt/gmt/html/man/xyz2grd.html

If you don't have GMT, I recommend you to install (it is relatively easy).

The default short-name of your variable in the new_file.nc is probably "z" but you can rename using CDO setname or chname operators

Once you have all the fields, then use the merge operator to merge all fields.
--------------

The other option is use tools like Matlab or Python CDO ... to read your files and modify accordingly. Unfortunately I do not have any other ideas at the moment.

Hope this helps,

RE: grid issue, remapping with remapnn - Added by andrea hurtado about 10 years ago

Dear Jaison

Thank you very much! I will try it now and let you know, again many thanks!

All the Best

Andrea Hurtado

    (1-6/6)