Project

General

Profile

help to get daily accumulated precipitation with CDO

Added by Noelia Otero almost 8 years ago

Hi!

I'm trying to use CDO to get daily rainfall from 3hourly accumulated data (although I am not sure if it will be possible by using CDO or not..just I jus wanted to post here the question).
If I want to substract the second day from the first one, is it possible? Because I was using

cdo timselsum,8 precip_1990.nc file1.nc #to get accumulated rain every day from 8 timesteps
cdo shifttime,+1day file1.nc file2.nc #to get a file with the day+1
cdo sub file2.nc file1.nc out.nc #substract day+1 to day

I think I'm doing wrong using shiftime..since the values of both files (file1 and file2) are exactly the same...

Any suggestion would be very welcome!

Thanks!

Cheers


Replies (14)

RE: help to get daily accumulated precipitation with CDO - Added by Paolo Davini almost 8 years ago

Hi,

I think you should use the ydaysub operator otherwise as far as I know the subtraction is carried out independently of time.
Perhaps there is an even simpler way, but I would extract the right timesteps... For a 30 day file file it can be something like:

cdo sub -seltimestep,2/30 file1.nc -seltimestep,1/29 file1.nc out.nc

hope it works for you!
Cheers
Paolo

RE: help to get daily accumulated precipitation with CDO - Added by Ehsan Taghizadeh almost 6 years ago

Dears,
I have similar problem and I'll be thankful if I could have your help.
I want to obtain 24 hour precipitation by adding 12 hour precipitation (for example: 00Z1jan2015 + 12z1jan2015) from attached file.
I used following command, however it seems doesn't work correctly.

cdo -b F32 -f nc4c -z zip timselsum,2 2_2_ERAI_Prec_2015_Jan_00_12_12.nc 2_2_ERAI_Prec_2015_Jan_24_cdo.nc4

Could anybody help me about it, please?

Sincerely
Ehsan

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller almost 6 years ago

% cdo infov 2_2_ERAI_Prec_2015_Jan_00_12_12.nc                                                                                                                                            [Fri 2018-06-01|12:13:03]
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2015-01-01 12:00:00       0   115680       0 : -5.4306e-11   0.0011458     0.36080 : tp            
     2 : 2015-01-02 00:00:00       0   115680       0 : -5.4306e-11   0.0011920     0.14570 : tp            
     3 : 2015-01-02 12:00:00       0   115680       0 : -5.4306e-11   0.0011475     0.11263 : tp            
     4 : 2015-01-03 00:00:00       0   115680       0 : -5.4306e-11   0.0011626     0.11249 : tp            

the only suspicious thing is, that you have only a single timestep for the first day. you can ignore the first timestep with

cdo -b F32 -f nc4c -z zip timselsum,2 -delete,timestep=1,-1 2_2_ERAI_Prec_2015_Jan_00_12_12.nc delFirst_2_2_ERAI_Prec_2015_Jan_24_cdo.nc4
same is true for the last day.

hth
ralf

RE: help to get daily accumulated precipitation with CDO - Added by Ehsan Taghizadeh almost 6 years ago

Dear Ralf,
Thank you so much for you nice reply.
As you know I want to add tp from "12:00:00" of one day with "00:00:00" of next day.
So, for example, I think sum of maximum "2015-01-03 12:00:00" (which is 0.18553) + "2015-01-04 00:00:00" (which is 0.18883) (which equals 0.18553+0.18883=0.37436) of "2_2_ERAI_Prec_2015_Jan_00_12_12.nc" must equals maximum "2015-01-04 18:00:00" (which is 0.22077!) of "2_2_ERAI_Prec_2015_Jan_24_cdo.nc4" or must equals maximum "2015-01-04 06:00:00" of "delFirst_2_2_ERAI_Prec_2015_Jan_24_cdo.nc4" (which is 0.22692!).
I think this is the simplest way to query the result. However plotting of these files show same images from 12Z of "2_2_ERAI_Prec_2015_Jan_00_12_12.nc" with image from "2_2_ERAI_Prec_2015_Jan_24_cdo.nc4", which shouldn't be same!
I hope I could say my opinion correctly.

Sincerely
Ehsan

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller almost 6 years ago

Ehsan Taghizadeh wrote:

Dear Ralf,
Thank you so much for you nice reply.
As you know I want to add tp from "12:00:00" of one day with "00:00:00" of next day.

in that case, your initial command is correct IMO

So, for example, I think sum of maximum "2015-01-03 12:00:00" (which is 0.18553) + "2015-01-04 00:00:00" (which is 0.18883) (which equals 0.18553+0.18883=0.37436) of "2_2_ERAI_Prec_2015_Jan_00_12_12.nc" must equals maximum "2015-01-04 18:00:00" (which is 0.22077!) of "2_2_ERAI_Prec_2015_Jan_24_cdo.nc4" or must equals maximum "2015-01-04 06:00:00" of "delFirst_2_2_ERAI_Prec_2015_Jan_24_cdo.nc4" (which is 0.22692!).

eh, these maxima can be at different locations, so you cdo timselsum,2 does *not necessarily * compute their sum

I X-checked with

cdo -infov -select,timestep=1/3 -timselsum,2 -fldmean 2_2_ERAI_Prec_2015_Jan_00_12_12.nc
where sum up over single values (here it is the fldmean) with this output
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2015-01-01 18:00:00       0        1       0 :               0.0029235             : tp            
     2 : 2015-01-02 18:00:00       0        1       0 :               0.0029179             : tp            
     3 : 2015-01-03 18:00:00       0        1       0 :               0.0031082             : tp            

Compare this to the original input

% cdo -infov -select,timestep=1/3  -fldmean 2_2_ERAI_Prec_2015_Jan_00_12_12.nc 
cdo(2) select: Process started
cdo(3) fldmean: Process started
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2015-01-01 12:00:00       0        1       0 :               0.0014288             : tp            
     2 : 2015-01-02 00:00:00       0        1       0 :               0.0014947             : tp            
     3 : 2015-01-02 12:00:00       0        1       0 :               0.0014350             : tp            
cdo(3) fldmean: Processed 7172160 values from 1 variable over 62 timesteps
cdo(2) select: Processed 3 values from 1 variable over 4 timesteps
cdo infon: Processed 3 values from 1 variable over 3 timesteps [0.10s 56MB]

then cdo should compute >> 0.0014947 + 0.0014288 = 0.0029235 which is the value of the first timestep in the command above. So IMO everything is ok wrt. what you wanted to obtain.

I think this is the simplest way to query the result. However plotting of these files show same images from 12Z of "2_2_ERAI_Prec_2015_Jan_00_12_12.nc" with image from "2_2_ERAI_Prec_2015_Jan_24_cdo.nc4", which shouldn't be same!
I hope I could say my opinion correctly.

here are my plots

original timestep 1
original timestep 2
sum of both

If you have a closer look into south east asia you will see the differences. It should be more visible with log-scale images

original timestep 1
original timestep 2
sum of both

hth
ralf

RE: help to get daily accumulated precipitation with CDO - Added by Ehsan Taghizadeh almost 6 years ago

Dear Ralf,
So do you think I could use "cdo -b F32 -f nc4c -z zip timselsum,2 2_2_ERAI_Prec_2015_Jan_00_12_12.nc 2_2_ERAI_Prec_2015_Jan_24_cdo.nc4" or I should delete first day and last day as you mentioned? I mean could you please suggest final command(s)?
Beside that could I change time 18:00:00 in output file to 00:00:00? Because this is precipitation from 00:00:00 to 00:00:00.

Sincerely
Ehsan

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller almost 6 years ago

First of all your initial command is correct if you just want to sum up each 2 consecutive time stamps.

if your are sure, that the field at 0 o'clock should be counted for the day before, you dont have to remove it or shift the time. This depends on what your variable tp is about. E.g. if its accumulated rain, that the 0 o'clock field has a meaning for the preceding day, if its an instantaneous field, it has a meaning only for the date/time it is labeled with. you see, it depends... From what I can tell, total precipitation is of the first kind.

Regarding the time (not the date) of the records: Since it's a daily value, the time has no meaning IMO. Everything you do with it, is for beautification, only ;-). The date must be the one of the first timestep (of the two), but CDO already handles this correctly.

hth
ralf

RE: help to get daily accumulated precipitation with CDO - Added by Ehsan Taghizadeh almost 6 years ago

Dear Ralf,
Pardon me for late reply.
First I really appreciate your helpful comments.
Also about Maximum value, you are right; I couldn't sum Maximum. However summation Mean(12:00:00) of one day with Mean(00:00:00) of next day, give correct result for daily precipitation. For example Mean(2015-01-01 12:00:00) + Mean(2015-01-02 00:00:00) (ie. 0.0011458+0.0011920) equals Mean(2015-01-01 18:00:00) (ie. 0.0023378).
But just for my curious, it is possible which 2_2_ERAI_Prec_2015_Jan_24_cdo.nc4 have 00:00:00 instead of 18:00:00?

Sincerely
Ehsan

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller almost 6 years ago

there are environment variables for that purpose. its in the docs.

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller almost 6 years ago

in the pdf docu appendix a, page 205.

RE: help to get daily accumulated precipitation with CDO - Added by Ehsan Taghizadeh almost 6 years ago

Hi,
I've read pdf docu, page 16, and I found sum of a value with a missing must be miss.
However in my case, as I used "cdo -b F32 -f nc4c -z zip timselsum,2 2_2_ERAI_Prec_2015_Jan_00_12_12.nc 2_2_ERAI_Prec_2015_Jan_24_cdo.nc4",
"_FillValue" for input is "-3.2288e-11" and "_FillValue" for output is "-6.4576e-11".
However it seems cdo considers "-3.2288e-11" as Minimum. Because if I open output via Panoply (for example), "_FillValue" is "-3.2288e-11" for both input and output files.
However I tried option (-m <missval>;) as follows, but it doesn't change anything:
cdo -m -3.2288e-11 -b F32 -f nc4c -z zip timselsum,2 2_ERAI_Prec_2015_Jan_00_12_12.nc 3_ERAI_Prec_2015_Jan_24_cdo.nc4

What should I do to prevent sum 2 miss values?

Sincerely
Ehsan

RE: help to get daily accumulated precipitation with CDO - Added by Sukanya Mukherjee about 2 years ago

Noelia Otero wrote:

Hi!

I'm trying to use CDO to get daily rainfall from 3hourly accumulated data (although I am not sure if it will be possible by using CDO or not..just I jus wanted to post here the question).
If I want to substract the second day from the first one, is it possible? Because I was using

cdo timselsum,8 precip_1990.nc file1.nc #to get accumulated rain every day from 8 timesteps
cdo shifttime,+1day file1.nc file2.nc #to get a file with the day+1
cdo sub file2.nc file1.nc out.nc #substract day+1 to day

I think I'm doing wrong using shiftime..since the values of both files (file1 and file2) are exactly the same...

Any suggestion would be very welcome!

Thanks!

Cheers

hello everyone!
I am having 6 hourly accumulated rainfall, from that nc file I want to extract daily rainfall of each day.
can I perform this in CDO?
thanks!

RE: help to get daily accumulated precipitation with CDO - Added by Ralf Mueller about 2 years ago

hi!
you want to compute the sum of 6-hourly data PER day. think simple. the operator is called daysum ;-)

hth
ralf

    (1-14/14)