Project

General

Profile

How can I change the missing values?

Added by Beata Szabo-Takacs over 9 years ago

I used a netcdf file in Matlab where I changed the missing values from -999 to 0. After some calculation the missing values changed to NaN value for distinguish the zero values from the missing value. I wrote the results in netcdf file where the missing values are marked NaN. According to

cdo infon file.nc

the missing values are 0. I tried changed these values to -999 by the following way:

cdo setmisstoc,0 -setmissval,-999 file.nc file2.nc

but unfortunately the missing values did not change. How can I change the missing values in this case? I add a sample file.

Thank you for your help in advance!
Beata

sample.nc (2.85 MB) sample.nc

Replies (3)

RE: How can I change the missing values? - Added by Uwe Schulzweida over 9 years ago

To make it short, the name of the attribute to identify the missing values is not correct. An underscore is missing:

pr:_FillValue = NaN;

RE: How can I change the missing values? - Added by Beata Szabo-Takacs over 9 years ago

Thank you Uwe for your help! I rewrited the netcdf files and corrected them with _FillValue=NaN. After that I changed the missing value with

cdo setmissval,-999 CNRM_pr_power1961.nc CNRM_pr_power1961_n.nc.

I enclosed the a sample3_sm.nc file about the resulted netcdf file. I copyed it to grb2 by

cdo -b F32 -f grb2 copy CNRM_pr_power1961_n.nc CNRM_pr_power1961.grb2

And converted the grb2 to csv with wgrib2 by

wgrib2 CNRM_pr_power1961.grb2 -csv CNRM_pr_power1961

I looked into the csv and it seems that the missing values remain zero.

I tried also the operator:

cdo setmisstoc,-999 sample2.nc sample2_sm.nc

It changes the missing values but it also changes the non missing values too. I enclosed the sample2_sm.nc file too. Could you please write me, which method is real? How can I distinguish the missing values from the non missing zero values without changing the non missing values?

RE: How can I change the missing values? - Added by Beata Szabo-Takacs over 9 years ago

Meantime I asked the staff of Climate Prediction Center about wgrib2 –csv and they informed me that the produced csv does not contain the missing values.
I could also control the resulted netcdf file after

 cdo setmissval,-999 CNRM_pr_power1961.nc CNRM_pr_power1961_n.nc

and the missing values are changed correctly. Sorry for my previous question.

    (1-3/3)