Hi,
I've been using the DAYS1900TOYMDHMS function for this type of subsetting.
Below is the code that mimics what you achieved with TAX_DATESTRING and STRINDEX, but using TAX_JDAY1900 and DAYS1900TOYMDHMS.
Please share your comment on the relative pros and cons of the two approaches.
Cheers,
Paulo
!--------------------------------------------
use monthly_navy_winds
let tv = t[g=uwnd]
let kymd = DAYS1900TOYMDHMS( TAX_JDAY1900(tv,uwnd) )
list/l=1:10 tv, TAX_JDAY1900(tv,uwnd), kymd[k=1], kymd[k=2], kymd[k=3]
let var=UWND[i=@ave,j=@ave]
let var_MAR = if kymd[k=2] eq 3 then var
let var_SEP = if kymd[k=2] eq 9 then var
ppl color 6, 70,70,70
plot/grat=(dash,color=6) var
plot/over/symbol=22/color=blue/title="March" var_MAR
plot/over/symbol=22/color=red/title="September" var_SEP
quit
---------------------------
On Mon, 2017-01-30 at 15:45 +0100, Patrick Brockmann wrote:
Hi ferreters,
I have found very convenient to use the function TAX_DATESTRING to get the date
as a string and then test with STRINDEX the presence of a specific month
to select specific month in a time serie.
I am sure you can perform this selection by playing with indices but I didn't want
any assumption on the starting month (l=1 in not always january).
In addition, this is very short to write without any additionnal variable declaration.
So just to keep a trace. Let me know if this can be achieve with another simpler way.
Happy ferreting.
Regards
Patrick
!=====================================
use monthly_navy_winds
let var=UWND[i=@ave,j=@ave]
let var_MAR = if STRINDEX(TAX_DATESTRING(t[gt=var], var[i=1,j=1], "month"), "MAR") then var
let var_SEP = if STRINDEX(TAX_DATESTRING(t[gt=var], var[i=1,j=1], "month"), "SEP") then var
! I have specified var[i=1,j=1] to limit memory usage
ppl color 6, 70,70,70
plot/grat=(dash,color=6) var
plot/over/symbol=22/color=blue/title="March" var_MAR
plot/over/symbol=22/color=red/title="September" var_SEP
--
Data Analysis and Visualization Engineer
LSCE/IPSL, CEA-CNRS-UVSQ laboratory
LSCE - Climate and Environment Sciences Laboratory
IPSL - Institut Pierre Simon Laplace
--
|