How to replace values of variables in a nc file for specific points?
Added by Natalia L over 3 years ago
Hi,
I have a netcdf file with multiple 2D variables for multiple points (lat/lon).
I want to change the values of all the 2D variables for specific points (lat,lon). i.e. For 5 points of lat/lon I want to set all the 2D variables to zero. Could I do that with cdo?
The 2D variables are 37 with specific names.
Replies (4)
RE: How to replace values of variables in a nc file for specific points? - Added by Uwe Schulzweida over 3 years ago
Hi Natalia,
This will be possible in the next CDO version 2.0.0 with the new operator setgridcell.
The new version will be ready in about 4 weeks. Here is an example:
cdo setgridcell,value=0.0,cell=1,2,3,4,5 infile outfilecell=1,2,3,4,5 selects the cells with index 1,2,3,4,5. You have to replace this with the cell index of your cells.
Cheers,
Uwe
RE: How to replace values of variables in a nc file for specific points? - Added by Natalia L over 3 years ago
Thank you Uwe.
However, can I multiply the values of the variables for all the points with a constant? i.e. for the whole grid.
I have a file with several variables e.g. val1, val2, val3 etc. and I want to create a new file including all the variables but multiply them with a different constant
i.e. val1*c1, val2*c2 etc.
RE: How to replace values of variables in a nc file for specific points? - Added by Uwe Schulzweida over 3 years ago
Try the operator expr, here is an example:
cdo expr,"val1=val1*c1;val2=val2*c2;val3=val3*c3;" infile outfile
RE: How to replace values of variables in a nc file for specific points? - Added by Bikem Ekberzade 18 days ago
I would like to ask two additional questions under this thread:
I have a netcdf file of a single coordinate but multiple years. I would like to add a second variable (single coordinate, same amount of time span) so I have a 2 two variable file. My 2nd variable is in a vector format. Can I do that?
Or can I change a certain time segment (1 year) from the existing netcdf variable and replace it with another vector (i.e. can I update the values of a variable between 2013-2014 let's say, with a new vector)?