Project

General

Profile

redcuing netCDF to only non-zero values.

Added by Sondre Bekken over 4 years ago

Dear,

I am wondering if it is possible to reduce the gridsize of a netCDF to only exist of the values with non-zero numbers and cut out the values that are zero?
If so how is it done?

Kind regards
Sondre


Replies (6)

RE: redcuing netCDF to only non-zero values. - Added by Sondre Bekken over 4 years ago

I manage to figure it out. Used cdo ifthen infile infile outfile.

RE: redcuing netCDF to only non-zero values. - Added by Ralf Mueller over 4 years ago

Sondre,
could you prove some sample data and one or two CDO calls? this would be very helpful to understand your solution.

thx in advance
ralf

RE: redcuing netCDF to only non-zero values. - Added by Sondre Bekken over 4 years ago

I was not able to reduce the gridsize, but only adding more missing data.
I did this:

cdo ifthen northsea.nc northsea.nc nonzeronorthsea.nc

This made all the 0 values to NaN and where not added when I plotted the file in panoply(which is a mapping program).

Hope this is helpful!

Kind regards,
Sondre

RE: redcuing netCDF to only non-zero values. - Added by Ralf Mueller over 4 years ago

didn't look into your data, yet. But I think the operators reducegrid might be what your are looking for. There is a special post about it: https://code.mpimet.mpg.de/boards/53/topics/3895

hth
ralf

RE: redcuing netCDF to only non-zero values. - Added by Karin Meier-Fleischer over 4 years ago

Hi Sondre, hi Ralf,

just to mention that you can use

cdo -f nc -setctomiss,0 northsea.nc nonzeronorthsea_miss.nc

The output of reducegrid is an unstructured grid which can't be diplayed by Panoply.

-Karin

RE: redcuing netCDF to only non-zero values. - Added by Ralf Mueller over 4 years ago

A more general remark: If you want to reduce the gridsize, you should be aware of the fact, that the grid is constant for all timesteps. In case of a time-varying number of missing values (or zeros) this will not be possible. And CDO does not support time dependent grids - nor do I know any other tool, that does.

So it depends what your plan was: reducing file size? avoid handling of missing values in your program?

    (1-6/6)