Problem with cdd and cwd
Added by Patricia Tarin-Carrasco over 2 years ago
Hello everyone,
I have a file with 30 years data of daily precipitation. I am having problems with the comand eca_cwd and eca_cdd.
I am doing:
cdo eca_cdd,5,5 ifile.nc outfile.nc
cdo eca_cwd,5,5 ifile.nc outfile.nc
and I obtain results as 400 days for cdd and 16 for cwd by period.
But I tried to do:
cdo eca_cdd,5,5,freq=year ifile.nc outfile.nc
cdo eca_cwd,5,5,freq=year ifile.nc outfile.nc
and I obtain different results as 270 days for cdd (as maximum value for one year) and 12 days for cwd (as maximum value for one year).
This is the info of my precipitation variable:
float pr(time, lat, lon) ;
pr:standard_name = "precipitation_flux" ;
pr:long_name = "Precipitation" ;
pr:units = "kg m-2 s-1" ;
pr:_FillValue = 1.e+20f ;
pr:missing_value = 1.e+20f ;
pr:comment = "includes both liquid and solid phases" ;
pr:cell_methods = "area: time: mean" ;
pr:cell_measures = "area: areacella" ;
pr:history = "2019-11-09T02:13:28Z altered by CMOR: replaced missing value flag (-1.07374e+09) with standard missing value (1e+20)." ;
I convert the data to day multiplying by 86400.
How is possible that for cdd give me 400 days of consecutive dry days as maximum value per period (30 years)? And how is possible that if I did it separately by year I obtain differnt results?
Can someone help me with this?
Thank you!
Replies (3)
RE: Problem with cdd and cwd - Added by Karin Meier-Fleischer over 2 years ago
Hi Patricia,
is it possible to upload the data?
RE: Problem with cdd and cwd - Added by Patricia Tarin-Carrasco over 2 years ago
This file is an example of one of them
RE: Problem with cdd and cwd - Added by Karin Meier-Fleischer over 2 years ago
If you want to compute the consecutive dry and wet days for each single year you have to
- split the input file into years
- compute the consecutive dry days for each single year
- merge yearly consecutive dry days files
- compute the consecutive wet days for each single year
- merge yearly consecutive dry days files
You can write a script to do the steps (see below example Python script).
The min/max values for dry and wet days results are:
Consecutice dry days: 1970-12-31T12:00:00.000000000 - min: 31.0 max: 179.0 Consecutice dry days: 1971-12-31T12:00:00.000000000 - min: 36.0 max: 208.0 Consecutice dry days: 1972-12-31T12:00:00.000000000 - min: 35.0 max: 165.0 Consecutice dry days: 1973-12-31T12:00:00.000000000 - min: 26.0 max: 135.0 Consecutice dry days: 1974-12-31T12:00:00.000000000 - min: 62.0 max: 158.0 Consecutice dry days: 1975-12-31T12:00:00.000000000 - min: 60.0 max: 293.0 Consecutice dry days: 1976-12-31T12:00:00.000000000 - min: 37.0 max: 170.0 Consecutice dry days: 1977-12-31T12:00:00.000000000 - min: 55.0 max: 141.0 Consecutice dry days: 1978-12-31T12:00:00.000000000 - min: 41.0 max: 179.0 Consecutice dry days: 1979-12-31T12:00:00.000000000 - min: 35.0 max: 212.0 Consecutice dry days: 1980-12-31T12:00:00.000000000 - min: 40.0 max: 181.0 Consecutice dry days: 1981-12-31T12:00:00.000000000 - min: 43.0 max: 248.0 Consecutice dry days: 1982-12-31T12:00:00.000000000 - min: 39.0 max: 141.0 Consecutice dry days: 1983-12-31T12:00:00.000000000 - min: 32.0 max: 139.0 Consecutice dry days: 1984-12-31T12:00:00.000000000 - min: 32.0 max: 202.0 Consecutice dry days: 1985-12-31T12:00:00.000000000 - min: 34.0 max: 175.0 Consecutice dry days: 1986-12-31T12:00:00.000000000 - min: 33.0 max: 205.0 Consecutice dry days: 1987-12-31T12:00:00.000000000 - min: 41.0 max: 170.0 Consecutice dry days: 1988-12-31T12:00:00.000000000 - min: 44.0 max: 235.0 Consecutice dry days: 1989-12-31T12:00:00.000000000 - min: 42.0 max: 135.0 Consecutice dry days: 1990-12-31T12:00:00.000000000 - min: 41.0 max: 170.0 Consecutice dry days: 1991-12-31T12:00:00.000000000 - min: 41.0 max: 140.0 Consecutice dry days: 1992-12-31T12:00:00.000000000 - min: 43.0 max: 177.0 Consecutice dry days: 1993-12-31T12:00:00.000000000 - min: 34.0 max: 211.0 Consecutice dry days: 1994-12-31T12:00:00.000000000 - min: 26.0 max: 193.0 Consecutice dry days: 1995-12-31T12:00:00.000000000 - min: 41.0 max: 173.0 Consecutice dry days: 1996-12-31T12:00:00.000000000 - min: 62.0 max: 181.0 Consecutice dry days: 1997-12-31T12:00:00.000000000 - min: 31.0 max: 211.0 Consecutice dry days: 1998-12-31T12:00:00.000000000 - min: 47.0 max: 273.0 Consecutice dry days: 1999-12-31T12:00:00.000000000 - min: 45.0 max: 168.0 ------------------------------------------------------------------------ Consecutice wet days: 1970-12-31T12:00:00.000000000 - min: 1.0 max: 7.0 Consecutice wet days: 1971-12-31T12:00:00.000000000 - min: 2.0 max: 7.0 Consecutice wet days: 1972-12-31T12:00:00.000000000 - min: 2.0 max: 11.0 Consecutice wet days: 1973-12-31T12:00:00.000000000 - min: 1.0 max: 4.0 Consecutice wet days: 1974-12-31T12:00:00.000000000 - min: 1.0 max: 12.0 Consecutice wet days: 1975-12-31T12:00:00.000000000 - min: 1.0 max: 5.0 Consecutice wet days: 1976-12-31T12:00:00.000000000 - min: 1.0 max: 8.0 Consecutice wet days: 1977-12-31T12:00:00.000000000 - min: 1.0 max: 13.0 Consecutice wet days: 1978-12-31T12:00:00.000000000 - min: 2.0 max: 8.0 Consecutice wet days: 1979-12-31T12:00:00.000000000 - min: 1.0 max: 8.0 Consecutice wet days: 1980-12-31T12:00:00.000000000 - min: 2.0 max: 8.0 Consecutice wet days: 1981-12-31T12:00:00.000000000 - min: 1.0 max: 4.0 Consecutice wet days: 1982-12-31T12:00:00.000000000 - min: 1.0 max: 5.0 Consecutice wet days: 1983-12-31T12:00:00.000000000 - min: 2.0 max: 7.0 Consecutice wet days: 1984-12-31T12:00:00.000000000 - min: 1.0 max: 7.0 Consecutice wet days: 1985-12-31T12:00:00.000000000 - min: 1.0 max: 5.0 Consecutice wet days: 1986-12-31T12:00:00.000000000 - min: 2.0 max: 5.0 Consecutice wet days: 1987-12-31T12:00:00.000000000 - min: 1.0 max: 6.0 Consecutice wet days: 1988-12-31T12:00:00.000000000 - min: 1.0 max: 8.0 Consecutice wet days: 1989-12-31T12:00:00.000000000 - min: 1.0 max: 10.0 Consecutice wet days: 1990-12-31T12:00:00.000000000 - min: 2.0 max: 6.0 Consecutice wet days: 1991-12-31T12:00:00.000000000 - min: 2.0 max: 6.0 Consecutice wet days: 1992-12-31T12:00:00.000000000 - min: 2.0 max: 7.0 Consecutice wet days: 1993-12-31T12:00:00.000000000 - min: 2.0 max: 6.0 Consecutice wet days: 1994-12-31T12:00:00.000000000 - min: 1.0 max: 6.0 Consecutice wet days: 1995-12-31T12:00:00.000000000 - min: 1.0 max: 7.0 Consecutice wet days: 1996-12-31T12:00:00.000000000 - min: 1.0 max: 9.0 Consecutice wet days: 1997-12-31T12:00:00.000000000 - min: 1.0 max: 4.0 Consecutice wet days: 1998-12-31T12:00:00.000000000 - min: 1.0 max: 4.0 Consecutice wet days: 1999-12-31T12:00:00.000000000 - min: 1.0 max: 10.0
Example Python script:
#!/usr/bin/env python # coding: utf-8 import os, glob import xarray as xr from cdo import * cdo = Cdo() #-- input file infile = os.environ['HOME']+'/Downloads/ACCESS-CM2_day_hist_19701999_AUS_mmday.nc' #-- basename of yearly files yfiles = os.environ['HOME']+'/Downloads/ACCESS-CM2_year' #-- delete previous generated cdd and cwd files ret = os.system('rm -f '+yfiles+'*.nc ACCESS-CM2_c*d_1970-1999.nc') #-- split input file into single years cdo.splityear(input=infile, output=yfiles) #-- get list of generated yearly files files = glob.glob(os.environ['HOME']+'/Downloads/ACCESS-CM2_year*.nc') #-- compute consecutive dry days for each year for f in files: name = os.path.splitext(f)[0] cdo.eca_cdd('5,5', input=f, output=name+'_cdd.nc') cdo.mergetime(input=os.environ['HOME']+'/Downloads/ACCESS-CM2_year*_cdd.nc', output=os.environ['HOME']+'/Downloads/ACCESS-CM2_cdd_1970-1999.nc', ) #-- compute consecutive wet days for each year for f in files: name = os.path.splitext(f)[0] cdo.eca_cwd('5,5', input=f, output=name+'_cwd.nc') cdo.mergetime(input=os.environ['HOME']+'/Downloads/ACCESS-CM2_year*_cwd.nc', output=os.environ['HOME']+'/Downloads/ACCESS-CM2_cwd_1970-1999.nc', ) #-- check CDO results: consecutive wet days for each year ds_cdd = xr.open_dataset(os.environ['HOME']+'/Downloads/ACCESS-CM2_cdd_1970-1999.nc') cdd = ds_cdd.consecutive_dry_days_index_per_time_period for i in range(0,len(cdd.time)): print('Consecutice dry days: '+str(cdd.time[i].values)+\ ' - min: '+str(cdd[i,:,:].min().values)+\ ' max: '+str(cdd[i,:,:].max().values)) #-- check CDO results: consecutive wet days for each year ds_cwd = xr.open_dataset(os.environ['HOME']+'/Downloads/ACCESS-CM2_cwd_1970-1999.nc') cwd = ds_cwd.consecutive_wet_days_index_per_time_period print('------------------------------------------------------------------------') for i in range(0,len(cwd.time)): print('Consecutice wet days: '+str(cwd.time[i].values)+\ ' - min: '+str(cwd[i,:,:].min().values)+\ ' max: '+str(cwd[i,:,:].max().values))