Is it possible to return date of maximum from yearmax or similar?
Added by Ed Maurer over 7 years ago
yearmax does exactly what I need, but it would be helpful to have, for each year, the date on which the maximum occurs. I haven't seen this issue raised elsewhere. I could see by selecting year-by-year through the output file from yearmax and then selecting the value from the original file that matches, but that seems very inefficient. Any suggestions would be appreciated.
Replies (10)
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller over 7 years ago
hi Ed!
To my knowledge there is no such operator. the problem is, that the resulting horizontal field would be of some kind of data/time-type. AFAIK there is no such thing defined in the CF-Convention. Esp the possibility of having multiple occurrences of an extreme value make things worse. In that case, each grid point should have a list of values (dates or times) attached to it.
I'm not sure, but it might be worth checking, if the operator consects could be helpful. It needs a 0-1-mask to operate, which can be generates by cutting whatever is below the yearmax:
cdo -eq,0 -sub yearData.nc yearMaxData.nc maxMask.nc
consects should create a file with the layout of the original data, but with a 1 where and when the maxumim value occurred.
hth
ralf
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Viktoria mohr about 7 years ago
Hello Ed and Ralf,
I am writing here as I hope you have probably solved your problem
I am looking for consecutive days of daily temperature of >=6°C and
cdo consects -gtc,6 daily_temperature_1970_12km_germany.nc outfile.nc
is what I need.
But now I am trying to find the timestep where 8 consecutive days of 6°C appeared. Is there a possibility to get this information out of the file into a new outfile?.
From Ralfs answer I understand that there is no such operator, is that (still) true!?
thanks a lot
Viktoria
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller about 7 years ago
Hi!
this is just an idea - I didn't do any tests: Have a look at https://code.mpimet.mpg.de/issues/14#note-5. consecsum
sums things up step by step, hence your timesteps should have the value of 8
. I think you could chain the above call using consecsum
instead of consects
with operator eq,8
:
cdo -eq,8 -consecsum -gtc,6 <ifile> <ofile>
Give it a shot! - I'am curious if it works out.
hth
ralf
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller about 7 years ago
Did some testing now - eq
does not really do it, you better use setvrange
like this
-setvrange,7.5,8.5Then all remaining timesteps with non-missing values are the right ones.
cheers
ralf
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Viktoria mohr about 7 years ago
Hi Ralf,
thanks a lot for your quick answer and suggestion
I tried
cdo setvrange,0.75,0.85 -consecsum -gtc,6 <infile> <outfile>
(because the -gtc,6 gives me the values 0 and 0.1 ) I am using CDO version 1.6.7
but unfortunately the output is 0-0
cheers
Viktoria
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller about 7 years ago
hi Victoria!
gtc
should return 0-1-fields, pls check with
cdo -infov -gtc,6 <infile>
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Viktoria mohr about 7 years ago
Hi Ralf,
thankyou very much for your help, you are right it is 0 and 1. Before I just checked with ncview where it was 0 and 0.1.
Now I tried
cdo setvrange,7.5,8.5 -consecsum -gtc,6 infile.nc outfile.nc
but still I get an empty file
I uploaded one month of my file (as the whole year is too big)... I tried with setvrange,0.5,1.5 for that file which still didn't work, but maybe I did it wrong?
cheers
Viktoria
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller about 7 years ago
First: please update your CDO binary - 1.6.7 is at least 2 years old.
Here is what I get
% cdo infov tas_hyras_12.5_1971_v1.01_06.nc [Fri 2017-12-15|13:36:07] -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1971-06-01 12:00:00 0 174688 171548 : -19.685 156.39 208.26 : tas 2 : 1971-06-02 12:00:00 0 174688 171548 : -10.790 170.20 230.92 : tas 3 : 1971-06-03 12:00:00 0 174688 171548 : 9.9979 170.95 221.72 : tas 4 : 1971-06-04 12:00:00 0 174688 171548 : 14.919 169.06 216.64 : tas 5 : 1971-06-05 12:00:00 0 174688 171548 : 13.386 162.06 223.68 : tas 6 : 1971-06-06 12:00:00 0 174688 171548 : 1.8746 147.90 216.34 : tas 7 : 1971-06-07 12:00:00 0 174688 171548 : -9.7610 144.18 197.00 : tas 8 : 1971-06-08 12:00:00 0 174688 171548 : -6.1492 136.26 188.39 : tas 9 : 1971-06-09 12:00:00 0 174688 171548 : -20.238 139.13 187.01 : tas 10 : 1971-06-10 12:00:00 0 174688 171548 : -18.441 132.49 200.74 : tas 11 : 1971-06-11 12:00:00 0 174688 171548 : -31.801 119.86 164.83 : tas 12 : 1971-06-12 12:00:00 0 174688 171548 : -64.895 101.70 140.18 : tas 13 : 1971-06-13 12:00:00 0 174688 171548 : -38.889 112.83 156.36 : tas 14 : 1971-06-14 12:00:00 0 174688 171548 : -31.979 135.19 184.18 : tas 15 : 1971-06-15 12:00:00 0 174688 171548 : -35.944 115.88 191.34 : tas 16 : 1971-06-16 12:00:00 0 174688 171548 : -47.346 94.618 132.94 : tas 17 : 1971-06-17 12:00:00 0 174688 171548 : -43.687 101.72 146.62 : tas 18 : 1971-06-18 12:00:00 0 174688 171548 : -62.734 94.437 136.18 : tas 19 : 1971-06-19 12:00:00 0 174688 171548 : -36.627 98.818 145.15 : tas 20 : 1971-06-20 12:00:00 0 174688 171548 : 14.514 127.15 182.15 : tas 21 : 1971-06-21 12:00:00 0 174688 171548 : 20.961 126.44 180.49 : tas 22 : 1971-06-22 12:00:00 0 174688 171548 : 24.493 132.31 185.82 : tas 23 : 1971-06-23 12:00:00 0 174688 171548 : 30.919 131.20 196.77 : tas 24 : 1971-06-24 12:00:00 0 174688 171548 : 20.444 143.81 190.35 : tas 25 : 1971-06-25 12:00:00 0 174688 171548 : 17.745 166.30 207.74 : tas 26 : 1971-06-26 12:00:00 0 174688 171548 : 24.169 175.41 219.11 : tas 27 : 1971-06-27 12:00:00 0 174688 171548 : 8.4061 134.31 195.32 : tas 28 : 1971-06-28 12:00:00 0 174688 171548 : 9.4804 125.66 192.36 : tas 29 : 1971-06-29 12:00:00 0 174688 171548 : -36.861 112.94 162.64 : tas 30 : 1971-06-30 12:00:00 0 174688 171548 : -54.000 104.56 146.68 : tas
looks ok. pretty much everything is missing values and you could boil some eggs in this air, but hey ....
% cdo infov -gtc,6 tas_hyras_12.5_1971_v1.01_06.nc [Fri 2017-12-15|13:37:30] cdo infon: Started child process "gtc,6 tas_hyras_12.5_1971_v1.01_06.nc (pipe1.1)". -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1971-06-01 12:00:00 0 174688 171548 : 0.0000 0.99841 1.0000 : tas 2 : 1971-06-02 12:00:00 0 174688 171548 : 0.0000 0.99873 1.0000 : tas 3 : 1971-06-03 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 4 : 1971-06-04 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 5 : 1971-06-05 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 6 : 1971-06-06 12:00:00 0 174688 171548 : 0.0000 0.99968 1.0000 : tas 7 : 1971-06-07 12:00:00 0 174688 171548 : 0.0000 0.99745 1.0000 : tas 8 : 1971-06-08 12:00:00 0 174688 171548 : 0.0000 0.99841 1.0000 : tas 9 : 1971-06-09 12:00:00 0 174688 171548 : 0.0000 0.99873 1.0000 : tas 10 : 1971-06-10 12:00:00 0 174688 171548 : 0.0000 0.99522 1.0000 : tas 11 : 1971-06-11 12:00:00 0 174688 171548 : 0.0000 0.98726 1.0000 : tas 12 : 1971-06-12 12:00:00 0 174688 171548 : 0.0000 0.97038 1.0000 : tas 13 : 1971-06-13 12:00:00 0 174688 171548 : 0.0000 0.99076 1.0000 : tas 14 : 1971-06-14 12:00:00 0 174688 171548 : 0.0000 0.99777 1.0000 : tas 15 : 1971-06-15 12:00:00 0 174688 171548 : 0.0000 0.99331 1.0000 : tas 16 : 1971-06-16 12:00:00 0 174688 171548 : 0.0000 0.97707 1.0000 : tas 17 : 1971-06-17 12:00:00 0 174688 171548 : 0.0000 0.98471 1.0000 : tas 18 : 1971-06-18 12:00:00 0 174688 171548 : 0.0000 0.97102 1.0000 : tas 19 : 1971-06-19 12:00:00 0 174688 171548 : 0.0000 0.98854 1.0000 : tas 20 : 1971-06-20 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 21 : 1971-06-21 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 22 : 1971-06-22 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 23 : 1971-06-23 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 24 : 1971-06-24 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 25 : 1971-06-25 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 26 : 1971-06-26 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 27 : 1971-06-27 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 28 : 1971-06-28 12:00:00 0 174688 171548 : 1.0000 1.0000 1.0000 : tas 29 : 1971-06-29 12:00:00 0 174688 171548 : 0.0000 0.99268 1.0000 : tas 30 : 1971-06-30 12:00:00 0 174688 171548 : 0.0000 0.97420 1.0000 : tas cdo(2) gtc: Processed 5240640 values from 1 variable over 30 timesteps ( 0.04s ) cdo infon: Processed 5240640 values from 1 variable over 30 timesteps ( 0.04s 46MB )each timestep has something above 6 degrees - fine
% cdo infov -consecsum -gtc,6 tas_hyras_12.5_1971_v1.01_06.nc [Fri 2017-12-15|13:37:37] cdo infon: Started child process "consecsum -gtc,6 tas_hyras_12.5_1971_v1.01_06.nc (pipe1.1)". cdo(2) consecsum: Started child process "gtc,6 tas_hyras_12.5_1971_v1.01_06.nc (pipe2.1)". -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1971-06-01 12:00:00 0 174688 0 : 0.0000 0.017946 1.0000 : tas 2 : 1971-06-02 12:00:00 0 174688 0 : 0.0000 0.035898 2.0000 : tas 3 : 1971-06-03 12:00:00 0 174688 0 : 0.0000 0.053873 3.0000 : tas 4 : 1971-06-04 12:00:00 0 174688 0 : 0.0000 0.071848 4.0000 : tas 5 : 1971-06-05 12:00:00 0 174688 0 : 0.0000 0.089823 5.0000 : tas 6 : 1971-06-06 12:00:00 0 174688 0 : 0.0000 0.10776 6.0000 : tas 7 : 1971-06-07 12:00:00 0 174688 0 : 0.0000 0.12550 7.0000 : tas 8 : 1971-06-08 12:00:00 0 174688 0 : 0.0000 0.14344 8.0000 : tas 9 : 1971-06-09 12:00:00 0 174688 0 : 0.0000 0.16140 9.0000 : tas 10 : 1971-06-10 12:00:00 0 174688 0 : 0.0000 0.17888 10.000 : tas 11 : 1971-06-11 12:00:00 0 174688 0 : 0.0000 0.19520 11.000 : tas 12 : 1971-06-12 12:00:00 0 174688 0 : 0.0000 0.20931 12.000 : tas 13 : 1971-06-13 12:00:00 0 174688 0 : 0.0000 0.22712 13.000 : tas 14 : 1971-06-14 12:00:00 0 174688 0 : 0.0000 0.24505 14.000 : tas 15 : 1971-06-15 12:00:00 0 174688 0 : 0.0000 0.26279 15.000 : tas 16 : 1971-06-16 12:00:00 0 174688 0 : 0.0000 0.27956 16.000 : tas 17 : 1971-06-17 12:00:00 0 174688 0 : 0.0000 0.29722 17.000 : tas 18 : 1971-06-18 12:00:00 0 174688 0 : 0.0000 0.31381 18.000 : tas 19 : 1971-06-19 12:00:00 0 174688 0 : 0.0000 0.33157 19.000 : tas 20 : 1971-06-20 12:00:00 0 174688 0 : 0.0000 0.34955 20.000 : tas 21 : 1971-06-21 12:00:00 0 174688 0 : 0.0000 0.36752 21.000 : tas 22 : 1971-06-22 12:00:00 0 174688 0 : 0.0000 0.38550 22.000 : tas 23 : 1971-06-23 12:00:00 0 174688 0 : 0.0000 0.40347 23.000 : tas 24 : 1971-06-24 12:00:00 0 174688 0 : 0.0000 0.42145 24.000 : tas 25 : 1971-06-25 12:00:00 0 174688 0 : 0.0000 0.43942 25.000 : tas 26 : 1971-06-26 12:00:00 0 174688 0 : 0.0000 0.45740 26.000 : tas 27 : 1971-06-27 12:00:00 0 174688 0 : 0.0000 0.47537 27.000 : tas 28 : 1971-06-28 12:00:00 0 174688 0 : 0.0000 0.49335 28.000 : tas 29 : 1971-06-29 12:00:00 0 174688 0 : 0.0000 0.50999 29.000 : tas 30 : 1971-06-30 12:00:00 0 174688 0 : 0.0000 0.52394 30.000 : tas cdo(3) gtc: Processed 5240640 values from 1 variable over 30 timesteps ( 0.08s ) cdo(2) consecsum: Processed 5240640 values from 1 variable over 30 timesteps ( 0.09s ) cdo infon: Processed 5240640 values from 1 variable over 30 timesteps ( 0.09s 50MB )since it's above 6 degrees somewhere somewhen, the natural max is 30, i.e. the number of timesteps
now the final step with excluding everything which is not 8.0
<ram@melian:~/Downloads> % cdo -s infov -setvrange,7.5,8.5 -consecsum -gtc,6 tas_hyras_12.5_1971_v1.01_06.nc [Fri 2017-12-15|13:45:56] -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1971-06-01 12:00:00 0 174688 174688 : nan : tas 2 : 1971-06-02 12:00:00 0 174688 174688 : nan : tas 3 : 1971-06-03 12:00:00 0 174688 174688 : nan : tas 4 : 1971-06-04 12:00:00 0 174688 174688 : nan : tas 5 : 1971-06-05 12:00:00 0 174688 174688 : nan : tas 6 : 1971-06-06 12:00:00 0 174688 174688 : nan : tas 7 : 1971-06-07 12:00:00 0 174688 174688 : nan : tas 8 : 1971-06-08 12:00:00 0 174688 171557 : 8.0000 8.0000 8.0000 : tas 9 : 1971-06-09 12:00:00 0 174688 174687 : 8.0000 : tas 10 : 1971-06-10 12:00:00 0 174688 174688 : nan : tas 11 : 1971-06-11 12:00:00 0 174688 174688 : nan : tas 12 : 1971-06-12 12:00:00 0 174688 174688 : nan : tas 13 : 1971-06-13 12:00:00 0 174688 174688 : nan : tas 14 : 1971-06-14 12:00:00 0 174688 174688 : nan : tas 15 : 1971-06-15 12:00:00 0 174688 174688 : nan : tas 16 : 1971-06-16 12:00:00 0 174688 174688 : nan : tas 17 : 1971-06-17 12:00:00 0 174688 174688 : nan : tas 18 : 1971-06-18 12:00:00 0 174688 174688 : nan : tas 19 : 1971-06-19 12:00:00 0 174688 174688 : nan : tas 20 : 1971-06-20 12:00:00 0 174688 174684 : 8.0000 8.0000 8.0000 : tas 21 : 1971-06-21 12:00:00 0 174688 174688 : nan : tas 22 : 1971-06-22 12:00:00 0 174688 174688 : nan : tas 23 : 1971-06-23 12:00:00 0 174688 174688 : nan : tas 24 : 1971-06-24 12:00:00 0 174688 174687 : 8.0000 : tas 25 : 1971-06-25 12:00:00 0 174688 174688 : nan : tas 26 : 1971-06-26 12:00:00 0 174688 174633 : 8.0000 8.0000 8.0000 : tas 27 : 1971-06-27 12:00:00 0 174688 174652 : 8.0000 8.0000 8.0000 : tas 28 : 1971-06-28 12:00:00 0 174688 174688 : nan : tas 29 : 1971-06-29 12:00:00 0 174688 174688 : nan : tas 30 : 1971-06-30 12:00:00 0 174688 174688 : nan : tas <ram@melian:~/Downloads>
here are your dates - problem is that its different for different locations. but at least any location with a non-missing values belongs to a valid timestep
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Viktoria mohr about 7 years ago
hi Ralf,
thanks again for testing, I get the same using infov and I see that I get that time information. But I was just wondering as with ncview and ncdump I don't see anything.
What I actually would like to have as output is a 2D field lat/lon of one timestep with day of year, using "time" as variable when the condition of 8 consecutive days of >=6 °C is achieved...
sorry, I know it is not yet christmas and I don't know if my wish is realisable
cheers
Viktoria
RE: Is it possible to return date of maximum from yearmax or similar? - Added by Ralf Mueller about 7 years ago
When I select the 8th timestep, I get something non-missing (uploaded t8.nc)
the problem is, that "time" is a coordinate - CDO will never turn it into a data variable, because it's not CF-conform. you will have to program that yourself, sorry ;-(