export date from a file with 99 percentile values
Added by Mara Antonella over 2 years ago
Hello everyone,
I have a NetCDF file with daily precipitation data for 20 years. I used the command line "cdo yearpctl,90 infile -yearmin infile -yearmax infile outfile" in order to calculate the 99 percentile of my data.
Now I want to extract for each gridpoint and year the exact date of the threshold of 99 percentile. For example for xx grid point the 99 percentile for the year 2001 is 40.123mm. I want to know which date this value (40.123mm) occurs, and save this info in a new file. Is that possible or with the command yearpctl I lost this kind of info?
Thank you,
Mara
Replies (5)
RE: export date from a file with 99 percentile values - Added by Karin Meier-Fleischer over 2 years ago
Hi Mara,
something like that
cdo -s -outputtab,year,lon,lat,value -expr,'prc=((prc >= 40.123)) ? prc : 0.0' \ outfile.nc | awk '$4!=0.0' > outfile_gt_40.123.txt
RE: export date from a file with 99 percentile values - Added by Mara Antonella over 2 years ago
Thank you Karin. That was close, however, the 40.123 was just an example. I want this value to be the different 99 percentile values per year and grid point.
With "cdo yearpctl,90 infile -yearmin infile -yearmax infile outfile", I calculated the 99 percentile per year, so the threshold that I want in each grid point, but I lost the information about the exact day, when this threshold occurs. I know it is complicated, tell me if you want more information about my request..
Thank you in advance,
Mara
RE: export date from a file with 99 percentile values - Added by Karin Meier-Fleischer over 2 years ago
If I understand you right then you need to write a script that loops through your pctl file to get the thresholds and to the step from above for each threshold.
RE: export date from a file with 99 percentile values - Added by Mara Antonella over 2 years ago
Yes, I think this is the way I have to do it. Could you help me with the loop for this purpose? I have never used loops with cdo.
Thank you in advance, Mara
RE: export date from a file with 99 percentile values - Added by Mara Antonella over 2 years ago
I can imagine something like this but the command inside the do doesn't work... Thanks
for i in yearly_percentile_99.nc
do
cdo -s -outputtab,date,value -expr,'prc=((prc == i)) ? prc : 0.0' \
yearly_percentile_99.nc | awk '$4!=0.0' > outfile_date_of_percentile.nc
done