source: trunk/src/timeserie.pro @ 11

Last change on this file since 11 was 11, checked in by pinsard, 15 years ago

smal typo for doc

  • Property svn:keywords set to Id
File size: 8.5 KB
Line 
1; docformat = 'rst'
2;+
3;
4; plot time series
5;
6; :Categories: PNG Climatology AMSU OLR2
7;
8; :Params:
9;   dataset : in, required, type='string: AMSU OLR'
10;    dataset to plot
11;   canal : in, optional, type='string: ax bx'
12;    canal of AMSU
13;
14;    only used if AMSU dataset
15;
16; :Keywords:
17;  UBOX : type='1D array of 4 items'
18;   latitudes and longitudes of the box in this order : ulon1 ulon2 ulat1 ulat2
19;
20; :Restrictions:
21;  - Requires SAXO
22;
23; :Returns:
24;
25; :Uses:
26;  pltt_
27;
28;  .. _pltt: http://forge.ipsl.jussieu.fr/saxo/download/idldoc_html_output/ToBeReviewed/PLOTS/DESSINE/pltt.html
29;
30;  cm_4cal_
31;
32;  .. _cm\_4cal: http://forge.ipsl.jussieu.fr/saxo/download/idldoc_html_output/Commons/cm_4cal.html
33;
34; :Pre:
35;  varamma_profile.sh_
36;
37;  .. _varamma_profile.sh: varamma_profile.sh.html
38;
39;  for AMSU dataset be sure to have ``cx.an*yyyy*.climato.nc`` ++
40;  in the directory defined in ${VARAMMA_ID}/
41;
42;  for OLR dataset be sure to have ``olr.day.mean_climato_ng.nc``
43;  in the directory defined in ${VARAMMA_ID}/
44;
45; :Post:
46;  varamma_profile.sh_
47;
48;  PNG file is now present in ${VARAMMA_OD}
49;
50; :Todo:
51;
52;  ++ check ubox (lat and lon) validity
53;
54;  ++ exploitation du champ info des fichiers OLR
55;
56;  ++ split read and plot
57;
58;  ++ saveimage or openps (for image to provide to publisher)
59;
60;  ++ add _EXTRA keyword
61;
62; :Examples:
63;
64; To plot AMSU a4 climatology
65; ::
66;
67;   IDL> timeserie, 'AMSU', 'a4', ubox=[-10.,+5.,-30.,45.]
68;
69; To plot OLR climatology
70; ::
71;
72;   IDL> timeserie, 'OLR', 'n.a.', ubox=[-10.,+5.,-30.,45.]
73;
74; :History:
75;
76;  - fplod 2009-01-05T09:10:12Z aedon.locean-ipsl.upmc.fr (Darwin)
77;
78;    * add latitude and longitude boundaries in keywords (UBOX)
79;
80;  - fplod 2008-08-05T14:03:03Z zeus.locean-ipsl.upmc.fr (Linux)
81;
82;    * creation from hovmuller_latitude.pro
83;    * extract from ananewvaramma3.pro 20080718 :
84;      ::
85;
86;      ; series temporelles
87;      mois=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
88;      mo_lon=[31,28,31,30,31,30,31,31,30,31,30,31]
89;      canal='a5'
90;      file='stagiaire/'+canal+'.climato.nc'
91;      initncdf, file, xaxisname = 'xlon', yaxisname = 'ylat'
92;
93;      domdef,-10,5,15,25
94;      imo=4   ; no du mois
95;      im1=9
96;      j1=total(mo_lon(0:imo-2)) & J2=total(mo_lon(0:im1-2))+mo_lon(im1-1)-1
97;      ;imo=1   ; no du mois
98;      ;im1=12
99;      ;j1=0 & j2=364 ;J2=total(mo_lon(0:im1-2))+mo_lon(im1-1)-1
100;      print,j1,j2
101;      data=read_ncdf('moyenne_tb', j1,j2,/timestep,timevar = 'jours', file = file)
102;      time=julday(imo,1,2000)+lindgen(jpt)
103;      seriea5=(data.arr-min(data.arr))/(max(data.arr)-min(data.arr))
104;      pltt,window=1,seriea5, 't',title='climatology time series',min=0.1,max=0.9
105;      xyouts,max(time)+20,0.1,'a5',color=0,charsize=2
106;
107;
108; :Version:
109;  $Id$
110;
111;-
112pro timeserie, dataset, canal $
113             , UBOX=ubox
114;
115 compile_opt idl2, strictarrsubs
116;
117@cm_4cal
118;
119; ++ check required and optional parameters
120;
121CASE dataset OF
122 'AMSU' : BEGIN
123          END
124 'OLR' : BEGIN
125          END
126 ELSE  : BEGIN
127  msg = 'eee : invalid dataset parameter = ' + dataset
128  ras = report(msg)
129  msg = 'eee : dataset must be AMSU or OLR'
130  ras = report(msg)
131  RETURN
132         END
133 ENDCASE
134
135; check input parameters
136 IF (dataset EQ 'AMSU') THEN BEGIN
137  CASE strmid(canal,0,1) OF
138  'a' : BEGIN
139   CASE strmid(canal,1) OF
140   '1' :
141   '2' :
142   '3' :
143   '4' :
144   '5' :
145   '6' :
146   '7' :
147   '8' :
148   '9' :
149   '15' : BEGIN
150    msg = 'iii : valid canal parameter = ' + canal
151    ras = report(msg)
152        END
153   ELSE : BEGIN
154    msg = 'eee : invalid canal parameter = ' + canal
155    ras = report(msg)
156    msg = 'eee : canal must be a1, a2, a3, a4, a5, a6, a7, a8, a9 or a15'
157    ras = report(msg)
158    RETURN
159          END
160   ENDCASE
161        END
162  'b' : BEGIN
163   CASE strmid(canal,1) OF
164   '1' :
165   '2' :
166   '3' :
167   '4' :
168   '5' : BEGIN
169    msg = 'iii : valid canal parameter = ' + canal
170    ras = report(msg)
171        END
172   ELSE : BEGIN
173    msg = 'eee : invalid canal parameter = ' + canal
174    ras = report(msg)
175    msg = 'eee : canal must be b1, b2, b3, b4 or b15'
176    ras = report(msg)
177    RETURN
178          END
179   ENDCASE
180        END
181  ELSE  : BEGIN
182   msg = 'eee : invalid canal parameter = ' + canal
183   ras = report(msg)
184   msg = 'eee : canal must be start with a or b'
185   ras = report(msg)
186   RETURN
187          END
188  ENDCASE
189 ENDIF
190;
191IF (keyword_set(UBOX)) THEN BEGIN
192 IF (N_ELEMENTS(ubox) NE 4) THEN BEGIN
193  msg = 'eee : axe must be latitude or longitude'
194  ras = report(msg)
195  RETURN
196 ENDIF ELSE BEGIN
197  ulon1 = ubox[0]
198  ulon2 = ubox[1]
199  ulat1 = ubox[2]
200  ulat2 = ubox[3]
201 ; ++ check lat and lon validity
202 ENDELSE
203ENDIF ELSE BEGIN
204 msg = 'eee : no box user defined'
205 ras = report(msg)
206 RETURN
207ENDELSE
208;
209; ++ parametrisation date début date fin
210mois=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
211 mo_lon=[31,28,31,30,31,30,31,31,30,31,30,31]
212
213 imo=4
214 im1=10
215;
216; check for input file
217;
218; test if ${VARAMMA_ID} defined
219 varamma_id_env=GETENV('VARAMMA_ID')
220 CASE varamma_id_env OF
221  ''  :  BEGIN
222   msg = 'eee : ${VARAMMA_ID} is not defined'
223   ras = report(msg)
224   RETURN
225         END
226  ELSE: BEGIN
227   msg = 'iii : ${VARAMMA_ID} is ' + varamma_id_env
228   ras = report(msg)
229        END
230 ENDCASE
231;
232 iodirin = isadirectory(varamma_id_env)
233;
234; existence and protection of ${VARAMMA_ID}
235 IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
236  msg = 'eee : the directory' + iodirin  + ' is not accessible.'
237  ras = report(msg)
238  RETURN
239 ENDIF
240;
241; build input and output filenames
242; define field to be plot (field)
243; define the title of the plot (title)
244; define the interval of each color level (int)
245; for hovmuller latitude
246; ++for hovmuller longitude
247CASE dataset OF
248 'AMSU' : BEGIN
249   filename_in=canal+'.climato.nc'
250   field='moyenne_tb'
251   title='climatology time series '+ dataset + ' ' + canal
252   int = .5
253   filename_out=canal+ $
254   string(imo,format='(I2.2)')+ $
255   string(im1,format='(I2.2)')+ $
256   '-climato-'+ $
257   string(abs(ulon1),format='(I3.3)')+ $
258   '-'+ $
259   string(abs(ulon2),format='(I3.3)')+ $
260  '.png'
261          END
262 'OLR' : BEGIN
263   filename_in='olr.day.mean_climato_ng.nc'
264   field='olr'
265   title='climatology time series '+ dataset
266   int = 8
267   filename_out='olr.day.mean_'+ $
268   string(imo,format='(I2.2)')+ $
269   string(im1,format='(I2.2)')+ $
270   '-climato-'+ $
271   string(abs(ulon1),format='(I3.3)')+ $
272   '-'+ $
273   string(abs(lon2),format='(I3.3)')+ $
274  '.png'
275          END
276 ELSE  : BEGIN
277  msg = 'eee : invalid dataset parameter = ' + dataset
278  ras = report(msg)
279  msg = 'eee : dataset must be AMSU or OLR'
280  ras = report(msg)
281  RETURN
282         END
283 ENDCASE
284;
285; check if this file exists
286 fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST)
287 IF fullfilename_in[0] EQ '' THEN BEGIN
288  msg = 'eee : the file ' + fullfilename_in + ' was not found.'
289  ras = report(msg)
290  RETURN
291 ENDIF
292;
293; test if ${VARAMMA_OD} defined
294 varamma_od_env=GETENV('VARAMMA_OD')
295 CASE varamma_od_env OF
296  '' : BEGIN
297   msg = 'eee : ${VARAMMA_OD} is not defined'
298   ras = report(msg)
299   RETURN
300       END
301  ELSE: BEGIN
302   msg = 'iii : ${VARAMMA_OD} is ' + varamma_od_env
303   ras = report(msg)
304        END
305 ENDCASE
306;
307; check if output data will be possible
308 iodirout = isadirectory(varamma_od_env)
309;
310; existence and protection
311 IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
312  msg = 'eee : the directory' + iodirout  + ' was not found.'
313  ras = report(msg)
314  RETURN
315 ENDIF
316;
317 fullfilename_out = iodirout + filename_out
318;
319; in order to avoid unexpected overwritten
320 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
321  msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
322  ras = report(msg)
323  RETURN
324 ENDIF
325;
326 initncdf, fullfilename_in[0], xaxisname = 'xlon', yaxisname = 'ylat'
327;
328; reduce geographic domain
329 domdef,ulon1,ulon2,ulat1,ulat2
330;
331; reduce temporal domain
332 date1=20000401L
333 date2=20001101L
334;
335; read data to be plot
336 data=read_ncdf(field, date1,date2,timevar = 'jours', file = fullfilename_in[0])
337;
338; redefinition axe temps
339 ;++time=julday(imo,1,2000)+lindgen(jpt)
340;
341; define font
342!P.FONT = 0
343DEVICE, SET_FONT = "-adobe-helvetica-medium-r-normal--17-120-100-100-p-88-iso8859-1"
344;
345; plot timeserie diagram
346; with no contour (/nocontour)
347; using color palette 64 (lct=64)
348; maximizing the size of the plot in the window (/rempli)
349; window keyword is uses to create a new window each time this procedure
350; is used
351; ++ DIGITSYEAR=0 is a attempt to suppress year in x label
352 pltt, data, 't', $
353 title=title,/nocontour, int = int, format='(f5.1)', $
354 lct = 64, /rempli, $
355 window=0
356 pltt, data, $
357 title=title,/nocontour, int = int, format='(f5.1)', $
358 lct = 64, /rempli, $
359 window=1, DIGITSYEAR=0
360;
361; save an image file
362 saveimage, fullfilename_out,/png
363
364END
Note: See TracBrowser for help on using the repository browser.