Re: How do I change time on a dataset [message #77126] |
Fri, 05 August 2011 03:08 |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Thu, 4 Aug 2011 10:33:00 -0700 (PDT), Ahmed Salahuddin
<salahuddin0812@gmail.com> wrote:
> Here is what I have from the file of
> hadam3p_pnw_zezs_1999_1_006983552_0_1 Folder
> zezsga.pdj9dec.pnw.nc
> zezsga.pdk0jan.pnw.nc
> zezsga.pdk0feb.pnw.nc
> zezsga.pdk0mar.pnw.nc
> zezsga.pdk0apr.pnw.nc
> zezsga.pdk0may.pnw.nc
> zezsga.pdk0jun.pnw.nc
> zezsga.pdk0jul.pnw.nc
> zezsga.pdk0aug.pnw.nc
> zezsga.pdk0sep.pnw.nc
> zezsga.pdk0oct.pnw.nc
> zezsga.pdk0nov.pnw.nc
> for i=12,334 do begin ; I have 27 years starting from 1980
> if imo gt 11 then begin
> imo=0
> endif
> vararr=tavg(*,*,i) ; I calculated temp avg
> for iarea=0,nareas-1 do begin ; I have 8 areas
> domain=c_area(iarea)
> inarr=vararr(*,*)
> regcpdn_area_avg,domain,WOCmask,WOMmask,WOEmask,WOImask,CAma sk,CVmask,WUSma
> sk,WVmask,lon,lat,inarr,outval
> obsarr(iyear,imo,iarea)=outval
> if finite(outval) eq 0 then stop
> endfor
> print,1979+iyear,imo
> if imo eq 0 then iyear=iyear+1
> imo=imo+1
> endfor
>
>
> Regards,
> salahud
As for the IDL code, I understand
1. imo: month counter [0,11] = [jan,dec]
2. iyear: year counter (iyear=0 => 1979)
3. i: loop counter = months starting from jan 1980 (i=0 => jan 1980)
4. Since i starts from 12 I suppose, from the logic of the loop that
iyear=1 and imo=12
5. If you loop over 27 years (=324 months) shouldn't you do:
for i=12,335 do begin ...
Then the loop logic is beyond me. From the comment "I have 27 years
starting from 1980" I would expect this to be printed:
1980 0 (jan 1980)
1980 1
1980 2
...
2006 9
2006 10
2006 11 (dec 2006)
What we get however is this (which explains the 1 year shift)
1980 0 (jan 1980)
1981 1 (feb 1981)
1981 2
...
2007 8
2007 9
2007 10 (oct 2007)
Unless 0=dec, 1=jan, ... but that doesn't make sense for
obsarr(iyear,imo,iarea). So instead of this:
iyear=1
imo=12
for i=12,334 do begin
if imo gt 11 then begin
imo=0
endif
...
print,1979+iyear,imo
if imo eq 0 then iyear=iyear+1
imo=imo+1
endfor
You could do this:
for i=12,335 do begin
imo=i mod 12
iyear=i/12
...
print,1979+iyear,imo
endfor
Also make sure that obsarr(iyear,imo,iarea) is correct. Since you
start from jan 1980, obsarr(iyear,*,*) will be empty (whole of 1979).
Then back to your files:
zezsga.pdj9dec.pnw.nc
zezsga.pdk0jan.pnw.nc
zezsga.pdk0feb.pnw.nc
As for the filename-date correlation, don't you have scanning
description files like zezsga.pdj9dec.ctl? 0 jan doesn't make sense...
Now intead of starting from jan 1980 and spanning 27 years, these
files start from dec 1999 and end at nov 2000 (by your understanding).
Then you would need to do
for i=251,262 do begin
imo=i mod 12
iyear=i/12
...
print,1979+iyear,imo
if i eq 30 then break
endfor
However I suspect tavg(*,*,i) doesn't reach back to jan 1979, so my
assumptions might be wrong. What is the relation between tavg and the
data files? Anyway, you probably get the idea by now.
|
|
|
Re: How do I change time on a dataset [message #77131 is a reply to message #77126] |
Thu, 04 August 2011 13:50  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On 8/4/11 3:12 PM, Ahmed Salahuddin wrote:
> Hi IDL Group,
>
> It would be greatly appreciated if someone out there can help me on
> how to shift 1 year forward in time. Here is the details.
> Here is what I have from the file of
> hadam3p_pnw_zezs_1999_1_006983552_0_1 Folder
> zezsga.pdj9dec.pnw.nc
> zezsga.pdk0jan.pnw.nc
> zezsga.pdk0feb.pnw.nc
> zezsga.pdk0mar.pnw.nc
> zezsga.pdk0apr.pnw.nc
> zezsga.pdk0may.pnw.nc
> zezsga.pdk0jun.pnw.nc
> zezsga.pdk0jul.pnw.nc
> zezsga.pdk0aug.pnw.nc
> zezsga.pdk0sep.pnw.nc
> zezsga.pdk0oct.pnw.nc
> zezsga.pdk0nov.pnw.nc
>
> From the above file structure it means only the first file
> (zezsga.pdj9dec.pnw.nc) for dec of 1999 and the remaining files for
> 2000.
>
> Originally, our understanding of the file structure is as follows
> dec1998
> jan1999
> feb1999
> mar1999
> apr1999
> may1999
> jun1999
> jul1999
> aug1999
> sep1999
> oct1999
> nov1999
>
> Thus, the dates are shifted by a full year in the original IDL program
> and I need to have it be consistent. Where can I change this in the
> idl program?
>
> for i=12,334 do begin ; I have 27 years starting from 1980
> if imo gt 11 then begin
> imo=0
> endif
> vararr=tavg(*,*,i) ; I calculated temp avg
> for iarea=0,nareas-1 do begin ; I have 8 areas
> domain=c_area(iarea)
> inarr=vararr(*,*)
>
> regcpdn_area_avg,domain,WOCmask,WOMmask,WOEmask,WOImask,CAma sk,CVmask,WUSmask,WVmask,lon,lat,inarr,outval
> obsarr(iyear,imo,iarea)=outval
> if finite(outval) eq 0 then stop
> endfor
> print,1979+iyear,imo
> if imo eq 0 then iyear=iyear+1
> imo=imo+1
> endfor
>
> Regards,
> salahud
It's hard to tell how this code relates to the lists of years and months
you have above. Maybe it has to do with the original definition of iyear
(which must be above the code you quote) - should be 0 instead of 1,
perhaps?
-Jeremy.
|
|
|