Project

General

Profile

delete specific dates

Added by ch ch01 over 11 years ago

I have a problem to delete specific range of dates in my data (daily 1958-2000),

cdo delete,seldate=1959-01-01/1959-04-15 base.nc test.nc

got this error:

Parameter >seldate=1959-01-01< has not a valid keyword!

did i make mistake with this command,
thank you


Replies (9)

RE: delete specific dates - Added by Ralf Mueller over 11 years ago

seldate is an operator. the keys for deletion/selection are listen in the docu, try

cdo -h delete
Dates cannot be deleted directly, you might use the timestep for this.

RE: delete specific dates - Added by ch ch01 over 11 years ago

Thanks Ralf,

How can I apply the timestep operator for my case? to delete 1959-01-01 to 1959-04-15 within the daily data
extending from 1958-2000 ?

I am looking forward to your suggestion.
Thanks.

RE: delete specific dates - Added by Ralf Mueller over 11 years ago

the operators select and delete read key-value pairs as input parameters to determine what to select/delete:

cdo delete,day=1,2,3,mon=4 ifile ofile
will delete the first 3 days of april in each year of you input file. You can also use the level, level index (levidx) or the variable name:
 cdo select,name=tsurf,level=500,timestep=200,1000

The timestep not an operator but an integer number. you can create a list of timestep by selecting a single variable,level,value of your input data:
cdo outputkey,date,time -fldmax -select,name=T,level=500 ifile

This creates writes a list of timestamps to stdout - you should use the line number of the dates you want to exclude (lets say 123,134,145,146) and rerun you delete operation
cdo delete,timestep=123,134,145,146 ifile ofile

shell is not optimal for this, so might check the bindings to python/ruby (cdo.{rb,py}, Tutorial).

RE: delete specific dates - Added by Jaison-Thomas Ambadan over 11 years ago

Hi,

I guess there is no "date" option for "delete" operator. The other option is to simply select the date-range that you want (excluding the dates you want to delete) and merge, like:

cdo -mergetime -seldate,${START_DATE}/1958-12-31T00:00:00 ifile -seldate,1959-04-16T00:00:00/${END_DATE} ifile ofile

Cheers,
J

RE: delete specific dates - Added by ch ch01 over 11 years ago

For instance.,

I have a shell scrip something like this:

for i in 1959,1962,1964,1967,1974,1975,1976,1982,1983

do
echo $i
cdo -selyear,$(($i-1))/${i} ifile year_${i}.nc
done

cdo mergetime year_*.nc final.nc

it's intended to choose a year before in our interest year-i.However I got and error due to
repeating year values. for instance: 1974 (1973-1974) and 1975 (1974-1975) once you merge the whole file, you will have two times 1974.
How can I handle this issue, so that in the end of my merging time i will not have some repeating years.

Thank you

RE: delete specific dates - Added by ch ch01 over 11 years ago

For instance.,

I have a shell scrip something like this:

for i in 1959,1962,1964,1967,1974,1975,1976,1982,1983

do
echo $i
cdo -selyear,$(($i-1))/${i} ifile year_${i}.nc
done

cdo mergetime year_*.nc final.nc

it's intended to also include "a year before" in our interest year-i.However I got and error due to
repeating year values. for instance: 1974 (1973-1974) and 1975 (1974-1975) once you merge the whole file, you will have two times 1974.
How can I handle this issue, so that in the end of my merging time i will not have some repeating years.

Thank you

RE: delete specific dates - Added by Jaison-Thomas Ambadan over 11 years ago

You can try setting the environment variable SKIP_SAME_TIME=1 Please have a look at the following thread (last reply by Uwe Schulzweida):

https://code.zmaw.de/boards/1/topics/1134#message-1136

First set the environment variable, then merge all your data, and then select the required date-range and use "mergetime" again.

Cheers,
J

RE: delete specific dates - Added by ch ch01 over 11 years ago

Thanks a lot J,

because my system is

echo $SHELL
/bin/tcsh

once I set the environment as you pointed out, I got this error:

setenv SKIP_SAME_TIME=1
*setenv: Syntax Error.*

I have no clue why, any suggestion?
Thank you

RE: delete specific dates - Added by ch ch01 over 11 years ago

sorry,, it works perfect!!..
I figured it out by using bash option.

Thank you!!

    (1-9/9)