source: trunk/src/tropflux.pro @ 175

Last change on this file since 175 was 175, checked in by pinsard, 12 years ago

an other bunch of new functions

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 20.9 KB
Line 
1;+
2;
3; ============
4; tropflux.pro
5; ============
6;
7; .. function:: tropflux(yyyymmddb,yyyymmdde)
8;
9; DESCRITION
10; ==========
11;
12; This program computes net heat flux components on the 1° oaflux grid.
13;
14; all input variables are corrected for mean bias and variability.
15;
16; gustiness correction is applied for wind speed based on cronin's climatological
17; gustiness values.
18;
19; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc`
20; containing
21; OAFLUX grid
22; has been produced by
23; :func:`oaflux_mask_30n30s`.
24;
25; :file:`${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc`
26; containing
27; sst corrected on OAFLUX grid
28; has been produced by
29; :func:`sst_correction_ncdf`.
30;
31; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc`
32; containing
33; ws corrected on OAFLUX grid
34; has been produced by
35; :func:`ws_correction_ncdf`.
36;
37; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc`
38; containing
39; ++
40; has been produced by
41; :func:`cronin_gustiness_ncdf`.
42;
43; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc`
44; containing
45; ws corrected on OAFLUX grid
46; has been produced by
47; :func:`tropflux_swr_blnd`.
48;
49; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc`
50; containing
51; lwr corrected on OAFLUX grid
52; has been produced by
53; :func:`lwr_correction_ncdf`.
54;
55; containing
56; t2m corrected on OAFLUX grid
57; has been produced by
58; :func:`t2m_correction_ncdf`.
59;
60; :file:`${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc`
61; containing
62; q2m corrected on OAFLUX grid
63; has been produced by
64; :func:`d2m_to_q2m_erai`.
65;
66; net heat flux components are written
67; in :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc`
68; if this file not already exists.
69;
70; This output file
71; :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc`
72; will be used by
73; :ref:`TropFlux_NRT_ncdf.pro`.
74;
75;     .. graphviz::
76;
77;        digraph tropflux {
78;
79;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
80;           file_sst [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc"];
81;           file_ws [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc"];
82;           file_wg [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"];
83;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc"];
84;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc"];
85;           file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc"];
86;           file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc"];
87;
88;           file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc"];
89;
90;           tropflux [shape=box,
91;           fontname=Courier,
92;           color=blue,
93;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux.pro",
94;           label="${PROJECT}/src/tropflux.pro"];
95;
96;           {mask file_sst file_ws file_wg file_swr file_lwr file_t2m file_q2m} -> {tropflux} -> {file_out}
97;
98;        }
99;
100; SEE ALSO
101; ========
102;
103; :ref:`project_profile.sh`
104;
105; Used by :ref:`tropflux.sh`
106;
107; :func:`report <saxo:report>`
108; :func:`isadirectory <saxo:isadirectory>`
109; :func:`isafile <saxo:isafile>`
110; :func:`initncdf <saxo:initncdf>`
111; :func:`ncdf_lec <saxo:ncdf_lec>`
112; :func:`read_ncdf <saxo:read_ncdf>`
113; :func:`caldat <saxo:caldat>`
114; :func:`julday <saxo:julday>`
115; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
116;
117; :func:`qsee`
118; :func:`lwnet_clark`
119; :func:`calc_claud_vlat`
120; :func:`cor30a`
121;
122; .. note::
123;
124;    :func:`lwdown_clark` is not used here but available.
125;
126; EXAMPLES
127; ========
128;
129; ::
130;
131;  IDL> yyyymmddb = 20000101L
132;  IDL> yyyymmdde = 20001231L
133;  IDL> result = tropflux(yyyymmddb, yyyymmdde)
134;  IDL> print, result
135
136; TODO
137; ====
138;
139; describe usage of tau
140;
141; compare time between all inputs after reading
142;
143; make it work ::
144;
145;     % Compiled module: EXTRAPOLATE.
146;     % Attempt to subscript LAND with OK is out of range.
147;     % Execution halted at: EXTRAPOLATE       176
148;       /usr/home/fplod/SAXO_DIR/SRC/Interpolation/extrapolate.pro
149;     %                      TROPFLUX_19890101_20091231  450
150;       /usr/home/fplod/incas/tropflux/tropflux_ws/src/TropFlux_19890101_20091231.p
151;       ro
152;     %                      $MAIN$
153;     % Program caused arithmetic error: Floating overflow
154;     % Program caused arithmetic error: Floating illegal operand
155;
156; the incriminated line is ::
157;
158;     tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,1)) & tab(ocean)=x & m=fi    nite(tab) & tab=extrapolate(tab,m) & lwr(*,*,jt)=tab*msk+valmask*(1-msk)
159;
160; to make progress I DO NOT extrapolate anymore lwr, sen and lat
161; !!!!! must be reactivated
162;
163; when I DO NOT extrapolate lwr, sen and lat , program end with ::
164;
165;     Written to
166;     !/usr/work/incas/fplod/tropflux_d/TropFlux_19890101_20091231_coarev3.nc
167;     -------------------------
168;     % Program caused arithmetic error: Floating divide by 0
169;     % Program caused arithmetic error: Floating underflow
170;     % Program caused arithmetic error: Floating overflow
171;     % Program caused arithmetic error: Floating illegal operand
172;
173; explain why :func:`lwdown_clark` is not used
174;
175; check if K or °C in input
176;
177; get rid of::
178;
179;   % date 1: 19880101 is not found in the time axis.
180;
181; why ::
182;
183;   da1=19880101
184;
185; 1st date 19890101 no ?
186;
187; why da1-1 (with da1=19880101) when reading gustiness file ::
188;
189;   wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr)
190;
191; coding rules
192;
193; KNOWN ISSUES
194; ============
195;
196; test of existence of fullfilename_msk not very efficient because
197; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
198;
199; EVOLUTIONS
200; ==========
201;
202; $Id
203;
204; $URL$
205;
206; - fplod 20120322
207;
208;   * pro -> func
209;   * rename with lower case TropFlux_19890101_20091231 become tropflux
210;   * taking project_overwite into account
211;   * try to add compile_opt
212;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters
213;   * get rid of timegen
214;
215; - fplod 20110830T135832Z cratos (Linux)
216;
217;   * replace tt by time
218;
219; - fplod 20110830T084129Z aedon.locean-ipsl.upmc.fr (Darwin)
220;
221;   * add tau in ouptut file
222;
223; - fplod 20110822T090838Z aedon.locean-ipsl.upmc.fr (Darwin)
224;
225;    * split some multiple lines statement to investigate
226;      pb of extropalation for lwr
227;
228; - fplod 20110819T144332Z aedon.locean-ipsl.upmc.fr (Darwin)
229;
230;   * add _coarev3 to filename output
231;   * check if filename output exists
232;
233; - fplod 20110809T110911Z aedon.locean-ipsl.upmc.fr (Darwin)
234;
235;   * complete descritption
236;   * remove v* from filenames (in and out)
237;   * usage of ${PROJECT_OD}
238;   * remove return statement
239;   * add test on IO files
240;
241; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
242;
243;   * remove hard coded directory for mask_oaflux_30N30S.nc
244;
245; - fplod 20101214T112131Z aedon.locean-ipsl.upmc.fr (Darwin)
246;
247;   * add graph
248;
249; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
250;
251;   * minimal header
252;
253; - pbk 2008
254;
255;   * creation
256;
257;-
258;
259function tropflux $
260         , yyyymmddb $
261         , yyyymmdde
262;
263compile_opt idl2, strictarrsubs, logical_predicate
264;
265@cm_4cal
266@cm_4data
267@cm_4mesh
268@cm_4data
269@cm_project
270;
271; Return to caller if errors
272ON_ERROR, 2
273;
274result = -1
275;
276usage = 'result = tropflux_swr_nrt(yyyymmddb, yyyymmdde)'
277nparam = N_PARAMS()
278IF (nparam NE 2) THEN BEGIN
279    ras = report(['Incorrect number of arguments.' $
280          + '!C' $
281          + 'Usage : ' + usage])
282    return, result
283ENDIF
284;
285; check for input directory
286;
287; test if ${PROJECT_ID} defined
288CASE project_id_env OF
289    ''  :  BEGIN
290     msg = 'eee : ${PROJECT_ID} is not defined'
291     ras = report(msg)
292     return, result
293           END
294 ELSE: BEGIN
295     msg = 'iii : ${PROJECT_ID} is ' + project_id_env
296     ras = report(msg)
297       END
298ENDCASE
299;
300iodirin = isadirectory(project_id_env)
301;
302; existence and protection of ${PROJECT_ID}
303IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
304   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
305   ras = report(msg)
306   return, result
307ENDIF
308;
309; build mask filename
310filename_msk='mask_oaflux_30N30S.nc'
311;
312; check if this file exists
313msg='iii : looking for ' + filename_msk
314ras = report(msg)
315fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
316IF fullfilename_msk[0] EQ '' THEN BEGIN
317   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
318   ras = report(msg)
319   return, result
320ENDIF
321;
322; test if ${PROJECT_OD} defined
323CASE project_od_env OF
324  '' : BEGIN
325         msg = 'eee : ${PROJECT_OD} is not defined'
326         ras = report(msg)
327       return, result
328       END
329  ELSE: BEGIN
330          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
331          ras = report(msg)
332        END
333 ENDCASE
334;
335; check if output data will be possible
336iodirout = isadirectory(project_od_env)
337;
338; existence and protection for reading
339IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
340   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
341   ras = report(msg)
342   return, result
343ENDIF
344;
345; existence and protection for writing
346IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
347    msg = 'eee : the directory' + iodirout  + ' was not found.'
348    ras = report(msg)
349    return, result
350ENDIF
351;
352; build sst data filename
353filename_sst='TropFlux_sst_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
354;
355; check if this file exists
356msg='iii : looking for ' + filename_sst
357ras = report(msg)
358fullfilename_sst = isafile(iodirout + filename_sst, NEW=0, /MUST_EXIST)
359IF fullfilename_sst[0] EQ '' THEN BEGIN
360   msg = 'eee : the file ' + fullfilename_sst + ' was not found.'
361   ras = report(msg)
362   return, result
363ENDIF
364;
365; build ws data filename
366filename_ws='TropFlux_ws_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
367;
368; check if this file exists
369msg='iii : looking for ' + filename_ws
370ras = report(msg)
371fullfilename_ws = isafile(iodirout + filename_ws, NEW=0, /MUST_EXIST)
372IF fullfilename_ws[0] EQ '' THEN BEGIN
373   msg = 'eee : the file ' + fullfilename_ws + ' was not found.'
374   ras = report(msg)
375   return, result
376ENDIF
377;
378; build swr data filename
379filename_swr='TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_BLND.nc'
380;
381; check if this file exists
382msg='iii : looking for ' + filename_swr
383ras = report(msg)
384fullfilename_swr = isafile(iodirout + filename_swr, NEW=0, /MUST_EXIST)
385IF fullfilename_swr[0] EQ '' THEN BEGIN
386   msg = 'eee : the file ' + fullfilename_swr + ' was not found.'
387   ras = report(msg)
388   return, result
389ENDIF
390;
391; build lwr data filename
392filename_lwr='TropFlux_lwr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
393;
394; check if this file exists
395msg='iii : looking for ' + filename_lwr
396ras = report(msg)
397fullfilename_lwr = isafile(iodirout + filename_lwr, NEW=0, /MUST_EXIST)
398IF fullfilename_lwr[0] EQ '' THEN BEGIN
399   msg = 'eee : the file ' + fullfilename_lwr + ' was not found.'
400   ras = report(msg)
401   return, result
402ENDIF
403;
404; build t2m data filename
405filename_t2m='TropFlux_t2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
406;
407; check if this file exists
408msg='iii : looking for ' + filename_t2m
409ras = report(msg)
410fullfilename_t2m = isafile(iodirout + filename_t2m, NEW=0, /MUST_EXIST)
411IF fullfilename_t2m[0] EQ '' THEN BEGIN
412   msg = 'eee : the file ' + fullfilename_t2m + ' was not found.'
413   ras = report(msg)
414   return, result
415ENDIF
416;
417; build q2m data filename
418filename_q2m='TropFlux_q2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
419;
420; check if this file exists
421msg='iii : looking for ' + filename_q2m
422ras = report(msg)
423fullfilename_q2m = isafile(iodirout + filename_q2m, NEW=0, /MUST_EXIST)
424IF fullfilename_q2m[0] EQ '' THEN BEGIN
425   msg = 'eee : the file ' + fullfilename_q2m + ' was not found.'
426   ras = report(msg)
427   return, result
428ENDIF
429;
430; build wg data filename
431filename_wg='TropFlux_gustiness_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc'
432;
433; check if this file exists
434msg='iii : looking for ' + filename_wg
435ras = report(msg)
436fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST)
437IF fullfilename_wg[0] EQ '' THEN BEGIN
438   msg = 'eee : the file ' + fullfilename_wg + ' was not found.'
439   ras = report(msg)
440   return, result
441ENDIF
442;
443; build output filename
444filename_out = 'TropFlux_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_coarev3.nc'
445fullfilename_out = iodirout + filename_out
446; in order to avoid unexpected overwritten
447IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
448   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
449   ras = report(msg)
450   return, result
451ENDIF
452;
453initncdf, fullfilename_msk
454msk=ncdf_lec(fullfilename_msk,var='msk')
455;
456initncdf, fullfilename_sst
457;
458ws=read_ncdf('ws',yyyymmddb-.5d,yyyymmdde,file=fullfilename_ws,/nostr)
459timein=24.d*(time-julday(1,1,1957,0,0,0))
460jpt=n_elements(timein)
461da=jul2date(time[0])
462cda0=string(da,format='(i8.8)')
463da=jul2date(time[jpt-1])
464cda1=string(da,format='(i8.8)')
465print, 'ws in tropflux first date ', cda0
466print, 'ws in ws_correction_ncdf last date ' , cda1
467;
468wg=read_ncdf('wg',yyyymmddb-.5d-1,yyyymmdde,file=fullfilename_wg,/nostr)
469timein=24.d*(time-julday(1,1,1957,0,0,0))
470jpt=n_elements(timein)
471da=jul2date(time[0])
472cda0=string(da,format='(i8.8)')
473da=jul2date(time[jpt-1])
474cda1=string(da,format='(i8.8)')
475print, 'wg in tropflux first date ', cda0
476print, 'wg in ws_correction_ncdf last date ' , cda1
477tt=time
478jpt=n_elements(time)
479sst=read_ncdf('sst',yyyymmddb-.5d,yyyymmdde,file=fullfilename_sst,/nostr)
480timein=24.d*(time-julday(1,1,1957,0,0,0))
481jpt=n_elements(timein)
482da=jul2date(time[0])
483cda0=string(da,format='(i8.8)')
484da=jul2date(time[jpt-1])
485cda1=string(da,format='(i8.8)')
486print, 'sst in tropflux first date ', cda0
487print, 'sst in ws_correction_ncdf last date ' , cda1
488sst=reform(sst-273.15)
489swd=read_ncdf('swr',yyyymmddb-.5d,yyyymmdde,file=fullfilename_swr,/nostr)
490timein=24.d*(time-julday(1,1,1957,0,0,0))
491jpt=n_elements(timein)
492da=jul2date(time[0])
493cda0=string(da,format='(i8.8)')
494da=jul2date(time[jpt-1])
495cda1=string(da,format='(i8.8)')
496print, 'swr in tropflux first date ', cda0
497print, 'swr in ws_correction_ncdf last date ' , cda1
498lw=read_ncdf('lwr',yyyymmddb-.5d,yyyymmdde,file=fullfilename_lwr,/nostr)
499timein=24.d*(time-julday(1,1,1957,0,0,0))
500jpt=n_elements(timein)
501da=jul2date(time[0])
502cda0=string(da,format='(i8.8)')
503da=jul2date(time[jpt-1])
504cda1=string(da,format='(i8.8)')
505print, 'lwr in tropflux first date ', cda0
506print, 'lwr in ws_correction_ncdf last date ' , cda1
507swd=swd/0.94  ; converting from net swr to downward swr
508;
509t2m=read_ncdf('t2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_t2m,/nostr)-273.15   ; in C
510timein=24.d*(time-julday(1,1,1957,0,0,0))
511jpt=n_elements(timein)
512da=jul2date(time[0])
513cda0=string(da,format='(i8.8)')
514da=jul2date(time[jpt-1])
515cda1=string(da,format='(i8.8)')
516print, 't2m in tropflux first date ', cda0
517print, 't2m in ws_correction_ncdf last date ' , cda1
518q2m=read_ncdf('q2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_q2m,/nostr)    ; in g/kg
519timein=24.d*(time-julday(1,1,1957,0,0,0))
520jpt=n_elements(timein)
521da=jul2date(time[0])
522cda0=string(da,format='(i8.8)')
523da=jul2date(time[jpt-1])
524cda1=string(da,format='(i8.8)')
525print, 'q2m in tropflux first date ', cda0
526print, 'q2m in ws_correction_ncdf last date ' , cda1
527;
528w=sqrt(ws*ws+wg*wg)  ; wind corrected for gustiness
529w=ws
530tmask=msk
531help, ws,w,wg,u,sst,swd,t2m,q2m
532ocean=where(msk eq 1,compl=land)
533valmask=1.e20
534time=tt
535jpt=n_elements(time)
536;
537; Constants for flux computation
538;
539zu=10.                          ; height of wind speed measurement (m)
540us=0.                           ; surf current (m/s)
541zt=2.                           ; Height of air T measurement (m)
542zq=2.                           ; height of humidity measurement (m)
543P=1008.                         ; Pressure
544zi=600.                         ; Inversion height (m)
545jcool=0                         ; Compute cool-skin
546jwave=0                         ; No waves
547twave=5.
548hwave=1.
549;
550caldat, time,mon,day,yea
551swr=fltarr(jpi,jpj,jpt)+1.e20
552lwr=fltarr(jpi,jpj,jpt)+1.e20
553lat=fltarr(jpi,jpj,jpt)+1.e20
554sen=fltarr(jpi,jpj,jpt)+1.e20
555lwnet_clrk=fltarr(jpi,jpj,jpt)+1.e20
556;Ch=fltarr(jpi,jpj,jpt)+1.e20
557;Ce=fltarr(jpi,jpj,jpt)+1.e20
558junk=fltarr(jpi,jpj,jpt)+1.e20
559;
560for jt=0,jpt-1 do begin
561  jday=time[jt]-julday(1,1,yea[jt])
562  print, 'Computing Fluxes ',jt,' / ',jpt-1
563;
564;  P=msl(*,*,jt)
565;  P=P(ocean)
566;
567  ; wind speed (m/s)
568  wn=w[*,*,jt]
569  wn=wn[ocean]
570  ; Bulk sst (°C)
571  ts=sst[*,*,jt]
572  ts=ts[ocean]
573  ; 2m Air T (°C)
574  t=t2m[*,*,jt]
575  t=t[ocean]
576  ; Sea surface sat. spec. humidity (g/kg)
577  qs=qsee(ts,P)
578  ; 2m AIr specific humidity  (g/kg)
579  q=q2m[*,*,jt]
580  q=q[ocean]
581  ; Downward solar flux (W/m2)
582  Rs=swd[*,*,jt]
583  Rs=Rs[ocean]
584  ylat=gphit[ocean]
585  ;  cld=calc_cloud(jday,Rs,ylat)
586  cld=calc_cloud_vlat(jday,Rs,ylat)
587  ; Downward IR flux (W/m2)
588  ;  Rl=lwdown_clark(ts,q,cld,t,P)
589  Rl=lw[*,*,jt]
590  Rl=Rl[ocean]
591  rain=0.
592  lw_clrk=-lwnet_clark(ts,q,cld,t,P)
593;  junk[*,*,jt]=lw_clrk
594;
595;stop
596  y=cor30a(wn,us,ts,t,Qs,Q,Rs,Rl,rain,zi,P,zu,zt,zq,ylat,jcool,jwave,twave,hwave)
597; A few punctual missing values (coare does not converge): filled by spatial extrapolation
598  tab=fltarr(jpi,jpj)+!values.f_nan
599  x=reform(y[*,0])
600  tab[ocean]=x
601  m=finite(tab)
602  help, tab, m, swr
603  tab=extrapolate(tab,m)
604  swr[*,*,jt]=tab*msk+valmask*(1-msk)
605;
606  tab=fltarr(jpi,jpj)+!values.f_nan
607  x=reform(y[*,1])
608  tab[ocean]=x
609  m=finite(tab)
610  help, tab, m, lwr
611  ;!!!!!!!!!!!!+++++++++++++++  tab=extrapolate(tab,m)
612  print, 'www : extrapolation for lwr is not done'
613  tab=tab
614  lwr[*,*,jt]=tab*msk+valmask*(1-msk)
615;
616  tab=fltarr(jpi,jpj)+!values.f_nan
617  x=reform(y[*,2])
618  tab[ocean]=x
619  m=finite(tab)
620  help, tab, m, lat
621  ;!!!!!!!!!!!!+++++++++++++++  tab=extrapolate(tab,m)
622  print, 'www : extrapolation for lat is not done'
623  tab=tab
624  lat[*,*,jt]=tab*msk+valmask*(1-msk)
625  tab=fltarr(jpi,jpj)+!values.f_nan
626  x=reform(y[*,3])
627  tab[ocean]=x
628  m=finite(tab)
629  help, tab, m, sen
630  ;!!!!!!!!!!!!+++++++++++++++  tab=extrapolate(tab,m)
631  print, 'www : extrapolation for sen is not done'
632  tab=tab
633  sen[*,*,jt]=tab*msk+valmask*(1-msk)
634  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(lw_clrk) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & lwnet_clrk[*,*,jt]=tab*msk+valmask*(1-msk)
635  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,5]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & tau[*,*,jt]=tab*msk+valmask*(1-msk)
636  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,6]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & Ch[*,*,jt]=tab*msk+valmask*(1-msk)
637  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,7]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & Ce[*,*,jt]=tab*msk+valmask*(1-msk)
638  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,8]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & wg[*,*,jt]=tab*msk+valmask*(1-msk)
639endfor
640jpt=n_elements(time)
641;
642cda0=string(jul2date(time[0]),format='(i8.8)')
643cda1=string(jul2date(time[jpt-1]),format='(i8.8)')
644time=time-julday(1,1,1950,00,00,00)
645xlon=reform(glamt[*,0])
646ylat=reform(gphit[0,*])
647;
648ncfile='!' + fullfilename_out
649lon_attr={units:'degrees_east',long_name:'Longitude'}
650lat_attr={units:'degrees_north',long_name:'Latitude'}
651time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
652globattr={source:'Fluxes for the Global Tropical Ocean - TropFlux',timerange:cda0+' - '+cda1}
653swr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net shortwave radiation',short_name:'swr',axis:'TYX'}
654lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation',short_name:'lwr',axis:'TYX'}
655lwr_clrk_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation from clark',short_name:'lwr',axis:'TYX'}
656lhf_attr={units:'W/m2',missing_value:valmask,long_name:'Surface latent flux',short_name:'lhf',axis:'TYX'}
657shf_attr={units:'W/m2',missing_value:valmask,long_name:'Surface sensible flux',short_name:'shf',axis:'TYX'}
658wg_attr={units:'m/s',missing_value:valmask,long_name:'COARE convective gustiness',short_name:'wg',axis:'TYX'}
659tau_attr={units:'N/m2',missing_value:valmask,long_name:'Wind stress magnitude',short_name:'tau',axis:'TYX'}
660;
661help, swr,lwr,lat,sen,time,xlon,ylat
662;
663ncfields = 'tau[longitude,latitude,time]=tau:tau_attr; ' $
664         + 'wg[longitude,latitude,time]=wg:wg_attr; ' $
665         + 'swr[longitude,latitude,time]=swr:swr_attr; ' $
666;         +'lwr_coare[longitude,latitude,time]=lwr:lwr_attr; ' $
667         +'lwr[longitude,latitude,time]=lwnet_clrk:lwr_clrk_attr; ' $
668         +'lhf[longitude,latitude,time]=lat:lhf_attr; ' $
669         +'shf[longitude,latitude,time]=sen:shf_attr; ' $
670;         +'Ch[longitude,latitude,time]=Ch:Ch_attr; ' $
671;         +'Ce[longitude,latitude,time]=Ce:Ce_attr; ' $
672         + 'longitude[]=xlon:lon_attr; ' $
673         + 'latitude[]=ylat:lat_attr; ' $
674         + 'time[*time]=time:time_attr ' $
675         + ' @ globattr'
676;
677@ncdf_quickwrite
678;
679result = 0
680return, result
681;
682end
Note: See TracBrowser for help on using the repository browser.