Project

General

Profile

select minimum value per year from NetCDF file with timeseries

Added by Mara Antonella almost 3 years ago

I have a .nc file with the following form (!Screenshot_5.jpg!). I want to select for the year 1986 the minimum value of tas, for 1987 the minimum value (from the 9 different model values) and so on until 2005 minimum value of tas and write them in a file like:

1986 284.02
1987 283.87
....
2005 286.01

Do you have any idea? Can I do this with CDO? Thank you!


Replies (5)

RE: select minimum value per year from NetCDF file with timeseries - Added by Karin Meier-Fleischer almost 3 years ago

Hi Mara,

this is a problem because there are 9 equal time steps for one and the same variable. It would be better to name each of these 9 model variables differently (var1, var2,...var9). Can you upload the data?

-Karin

RE: select minimum value per year from NetCDF file with timeseries - Added by Mara Antonella almost 3 years ago

Also, I have the 9 separate files with dates from 1986 to 2005, before I merged them. I am uploading one of them.

RE: select minimum value per year from NetCDF file with timeseries - Added by Karin Meier-Fleischer almost 3 years ago

There are two ways to get the result you want:

Either using the currently merged file out_stdv.nc and set a new zaxis. This means that each level represent a model value. Then get the vertical minimun values for a year.

Here, I use a ksh-script to create a zaxis description file and do the calculation:

#!/use/bin/env ksh

cat << EOF > new_zaxis.txt
zaxistype = surface
size = 9
levels = 1 2 3 4 5 6 7 8 9
EOF

cdo -vertmin -setzaxis,new_zaxis.txt out_stdv.nc out_stdv_yearmin.nc

or when merging the 9 netCDF files do a different time shift for each file, e.g. shift plus 1hr, 2hr, ..., 9hr.

cdo -merge /mnt/data/europe_historical/tas/merged/tasmpic_sd_field.nc \
    -shifttime,1hr /mnt/data/europe_historical/tas/merged/tasir_sd_field.nc \
    -shifttime,2hr /mnt/data/europe_historical/tas/merged/tasmpirca_sd_field.nc \
    -shifttime,3hr /mnt/data/europe_historical/tas/merged/tasmremo_sd_field.nc \
    -shifttime,4hr /mnt/data/europe_historical/tas/merged/tas1irc_sd_field.nc \
    -shifttime,5hr /mnt/data/europe_historical/tas/merged/tasmc_sd_field.nc \
    -shifttime,6hr /mnt/data/europe_historical/tas/merged/tasmrac_sd_field.nc \
    -shifttime,7hr /mnt/data/europe_historical/tas/merged/tasnh_sd_field.nc \
    -shifttime,8hr /mnt/data/europe_historical/tas/merged/tasmrca_sd_field.nc \
    /mnt/data/erope_historical/tas/merged/out_stdv.nc

cdo -yearmin /mnt/data/erope_historical/tas/merged/out_stdv.nc out_stdv_yearmin.nc

The last one should work too, but its just a guess.

RE: select minimum value per year from NetCDF file with timeseries - Added by Mara Antonella almost 3 years ago

I didn't try the second one, but the first one works fine! Thanks a lot

    (1-5/5)