source: trunk/MESOSCALE/PLOT/SPEC/LES/THERMALS/gettherm.pro @ 205

Last change on this file since 205 was 205, checked in by acolaitis, 13 years ago

Small commit to add A.C. thermals diagnostics IDL routines. gettherm is for extracting data and saving it in thermiques.dat, and thermiques is the monstruous 4000 lines plotting routine.

File size: 118.2 KB
Line 
1PRO gettherm
2
3spawn, 'clear'
4print, ''
5print, '** Thermals Analysis **'
6print, ' (usine à gaz) '
7print, ''
8
9full='true'
10f_offset='false'
11overplot_convadj='false'
12plot_3d = 'false'
13
14lctu_gcm = 8.
15
16; *********** Best values for LES thermals with tau =0.5
17betalpha = 1.3
18afact = 1.8
19fact_epsilon = 0.0008
20detr_min = 0.0007
21
22
23;betalpha = 1.
24;afact = 2.4
25;fact_epsilon = 0.0007
26;detr_min = 0.0007
27
28; --------
29
30; *********** Best values for LES thermals with tau =1.
31;betalpha = 1.
32;afact = 1.1
33;fact_epsilon = 0.00025
34;detr_min = 0.0007
35; --------
36
37;datname='thermiques.dat.scale1.2'
38;datname='thermiques.dat.scale1.4'
39;datname='thermiques.dat.scale0.6'
40datname='thermiques.dat'
41;datname='thermiques.dat.scale0.8'
42;datname='thermiques.dat'           ;scale =1.0, sigmao =1.0
43
44ns = 0     ; number of points for time-smoothing of LES data : 2*ns+1 points, ns = 9 eq to 30mn (-15mn//+15mn)
45nstot = float(2.*ns+1.)
46
47GcmSubCase = ''
48LayerCase=''
49s_trac1 = 'qtrac1'
50s_trac2 = 'qtrac2'
51got_pdt = 'true'
52TestCase = 'Case_A'
53SubCase = '_11_shorter'
54Histo = 'true'
55newtest = ''
56visualization_mode = 'false'
57label_init:
58spawn, 'clear'
59print, ' Available simulations :'
60print, '----'
61print, ' 1/ Case_A_11 : 45x45x71,   ztop=10km,dx=100m,dz=140m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
62print, ' 2/ Case_A_4  : 101x101x201 ztop=15km,dx=100m,dz= 75m,Ls=47.1°,(21.8N;205.0E),55tiu,A=0.275,Tau=0.5'
63print, ' 3/ Case_A_4_shorter  : Case A4 with Dtrac1 = 5 mn and Dtrac2 = 10 mn (compared to 20 and 100)'
64print, ' 4/ Case_A_4_shorter_winds  : Case A4_shorter with bckgrnd wind u=10 m/s'
65print, ' 5/ Case_A_4_shorter_winds_30  : Case A4_shorter with bckgrnd wind u=30 m/s'
66print, ' 6/ Case_A_4_shorter_winds_tau1  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=1'
67print, ' 7/ Case_A_4_shorter_winds_tau2  : Case A4_shorter with bckgrnd wind u=10 m/s and tau=2'
68print, ' 8/ Case_ExtremeCase  : 101x101x201 ztop=15km,dx=100m,dz=75m,Ls=0°,(0.N;0.E),50tiu,A=0.1,Tau=0.05'
69print, '----'
70print, ' 9/ Case_C_4_shorter_winds  : '
71print, ' 10/ Case_I_4_shorter_winds  : '
72print, ' 11/ Case_Z_4_shorter_winds  : '
73print, ' 12/ 1D : 124 layers'
74print, ' 13/ 1D : 32 layers'
75print, ' 14/ 1D : low dt'
76print, ''
77print, ' 0/ PLUME VISUALISATION : '+visualization_mode
78print, ' 999/ CLEAR thermiques.dat for considered case'
79print, ' 100/ OVERPLOT CONVADJ ONLY RESULTS : '+overplot_convadj
80print, ''
81print, ' SIMULATION NUMBER  : '
82print, ' ** '+TestCase+SubCase+LayerCase+' ** '
83print, ''
84print, 'Any change ? (number of new case to change, or any other key to continue)'
85read, newtest
86if (newtest eq '1') then begin
87TestCase = 'Case_A'
88SubCase = '_11'
89pGround = 867.5594
90goto,label_init
91endif
92if (newtest eq '2') then begin
93TestCase = 'Case_A'
94SubCase = '_4'
95got_pdt = 'false'
96pGround = 867.5594
97goto,label_init
98endif
99if (newtest eq '3') then begin
100TestCase = 'Case_A'
101SubCase = '_4_shorter'
102;s_trac1 = 'qtrac2'
103;s_trac2 = 'qtrac1'
104full = 'true'
105f_offset='false'
106pGround = 867.5594
107goto,label_init
108endif
109if (newtest eq '4') then begin
110TestCase = 'Case_A'
111SubCase = '_4_shorter_wind'
112;s_trac1 = 'qtrac2'
113;s_trac2 = 'qtrac1'
114full = 'true'
115f_offset='false'
116pGround = 867.5594
117goto,label_init
118endif
119if (newtest eq '5') then begin
120TestCase = 'Case_A'
121SubCase = '_4_shorter_wind_30'
122GcmSubCase = '_wind_30'
123;s_trac1 = 'qtrac2'
124;s_trac2 = 'qtrac1'
125full = 'true'
126pGround = 867.5594
127f_offset='false'
128goto,label_init
129endif
130if (newtest eq '6') then begin
131TestCase = 'Case_A'
132SubCase = '_4_shorter_wind_tau1'
133GcmSubCase = '_tau1'
134;s_trac1 = 'qtrac2'
135;s_trac2 = 'qtrac1'
136full = 'true'
137f_offset='false'
138pGround = 867.5594
139goto,label_init
140endif
141if (newtest eq '7') then begin
142TestCase = 'Case_A'
143SubCase = '_4_shorter_wind_tau2'
144GcmSubCase = '_tau2'
145;s_trac1 = 'qtrac2'
146;s_trac2 = 'qtrac1'
147full = 'true'
148f_offset='false'
149pGround = 867.5594
150goto,label_init
151endif
152if (newtest eq '8') then begin
153TestCase = 'ExtremeCase'
154SubCase = ''
155GcmSubCase = ''
156;s_trac1 = 'qtrac2'
157;s_trac2 = 'qtrac1'
158full = 'true'
159f_offset='false'
160pGround = 677.722
161;lctu_gcm = 6.
162goto,label_init
163endif
164if (newtest eq '9') then begin
165TestCase = 'Case_C'
166SubCase = '_4_shorter_wind'
167;s_trac1 = 'qtrac2'
168;s_trac2 = 'qtrac1'
169full = 'true'
170f_offset='false'
171pGround = 483.
172goto,label_init
173endif
174if (newtest eq '10') then begin
175TestCase = 'Case_I'
176SubCase = '_4_shorter_wind'
177;s_trac1 = 'qtrac2'
178;s_trac2 = 'qtrac1'
179full = 'true'
180f_offset='false'
181pGround = 630.
182goto,label_init
183endif
184if (newtest eq '11') then begin
185TestCase = 'Case_Z'
186SubCase = '_4_shorter_wind'
187;s_trac1 = 'qtrac2'
188;s_trac2 = 'qtrac1'
189full = 'true'
190f_offset='false'
191pGround = 266.
192goto,label_init
193endif
194if (newtest eq '12') then begin
195LayerCase=''
196goto,label_init
197endif
198if (newtest eq '13') then begin
199LayerCase='_32lev'
200goto,label_init
201endif
202if (newtest eq '14') then begin
203LayerCase='_low_dt'
204goto,label_init
205endif
206if (newtest eq '100') then begin
207if (overplot_convadj eq 'true') then overplot_convadj = 'false' else overplot_convadj = 'true'
208goto,label_init
209endif
210if (newtest eq '0') then begin
211visualization_mode = 'true'
212spawn, 'clear'
213print, 'The first timestep of the considered file will be shown.'
214print, 'Defaut file is : file 6 (lt ~ 13h10)'
215print, 'Which file do you want ? (lt ~= file_number + 7)'
216loop_special = '6'
217read, loop_special
218print, 'Do you wish to plot histograms or manipulate volumic data ?'
219print, '1/ Histogram'
220print, '2/ Volumic data'
221x=''
222read, x
223if (x eq '1') then Histo='true' else Histo='false'
224goto,label_init
225endif
226
227;les_path='/san0/acolmd/SIMUS/LES_'+TestCase+SubCase
228;gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+LayerCase+'_2'
229;gcm_path='/san0/acolmd/SIMUS/GCM_'+TestCase+GcmSubCase+LayerCase
230;gcm_convadj_path=gcm_path+'_convadj'
231
232;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau05/'
233;les_path='/data/acolmd/Thermiques/LES_Case_A_257x257x301_wind10_tau05'
234;les_path='/data/acolmd/Thermiques/LES_Case_E_257x257x301_wind10_tau005'
235;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind30_tau05/'
236;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau1/'
237;les_path='/data/acolmd/Thermiques/LES_Case_A_4_2trac_wind10_tau2/'
238;les_path='/data/acolmd/Thermiques/LES_Case_C_4_2trac_wind10_tau05/'
239;les_path='/data/acolmd/Thermiques/LES_Case_I_4_2trac_wind10_tau05/'
240;les_path='/data/acolmd/Thermiques/LES_Case_Z_4_2trac_wind10_tau05/'
241;les_path='/data/acolmd/Thermiques/ExtremeCase/'
242
243;les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind10_tau05_gcmsoil/'
244;les_path='/data/acolmd/Thermiques/LES_Case_E_101x101x201_tracup_wind10_tau005_gcmsoil/'
245;les_path='/data/acolmd/Thermiques/LES_Case_C_101x101x201_tracup_wind10_tau05_gcmsoil'
246;les_path='/data/acolmd/Thermiques/LES_Case_I_101x101x201_tracup_wind10_tau05_gcmsoil'
247;les_path='/data/acolmd/Thermiques/LES_Case_Z_101x101x201_tracup_wind10_tau05_gcmsoil'
248;les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind30_tau05_gcmsoil'
249les_path='/data/acolmd/Thermiques/LES_Case_A_101x101x201_tracup_wind10_tau2_gcmsoil'
250
251gcm_path='/data/acolmd/Thermiques/THgcm/'
252gcm_convadj_path=gcm_path+'_convadj'
253
254
255if (newtest eq '999') then spawn, 'rm -f '+les_path+'/'+datname
256print, ''
257print, ' -- Loading LES data -- '
258
259print, 'LES DATA IN : '
260print, les_path
261print, 'GCM DATA IN : '
262print, gcm_path
263
264p0=610. & t0=220. & r_cp=1./3.89419 & grav=3.72 & R=191.182
265history_interval_s = 100.
266;lctu_gcm = 8.                      ; Initial local time of gcm 1d simu
267scale = 1.                         ; Scaling factor for conditional sampling
268decimate = 10.                     ; Coeff for subsampling the data for sigma integral
269sigmao= 0.3                        ; multiplicative coeff for the computation of Sigma0 in the CS
270sigmao_ude = 0.2                   ; number of standard deviation away from mean for the selection of downdraft in UDE
271NBINS=100.
272
273openr,unit,les_path+'/'+datname,/get_lun,error=err
274IF (err ne 0) THEN BEGIN
275
276OPENR, 22, les_path+'/input_coord' & READF, 22, lonu & READF, 22, latu & READF, 22, lsu & READF, 22, lctu & CLOSE, 22
277OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
278
279domain='d01' & filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??') & nf=n_elements(filesWRF)
280;print, filesWRF
281;domain='d01' & filesWRF = les_path+'/'+['wrfout_d01_9999-01-01_03:05:00','wrfout_d01_9999-01-01_04:06:40'] & nf=n_elements(filesWRF)
282;ce fichier utilise aussi offset_localtime = 3.05
283
284; WARNING WARNING : FOR THE CASE 4_SHORTER, THE TRAC2 HAS 10 MN LIFETIME, WE WANT TO USE IT MORE EXTENSIVELY THAN THE TRAC1 (5mn) SO
285; we switch the names of trac1 and trac2 in the initialization of this routine, in the "case".
286
287; WARNING WARNING : in this version (thermiques2), one of the tracers in the data is just a neutral tracer which will be used to compute the turbulent flux of tracer MMR.  This is a priori done by the tracer 2 (after inversion)
288
289id=ncdf_open(filesWRF(0))
290NCDF_DIMINQ, id, NCDF_DIMID(id, 'west_east'    ), dummy, nx & NCDF_DIMINQ, id, NCDF_DIMID(id, 'south_north'  ), dummy, ny
291NCDF_DIMINQ, id, NCDF_DIMID(id, 'bottom_top'   ), dummy, nz & NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, nt
292NCDF_CLOSE, id
293id=ncdf_open(filesWRF(nf-1))  ;; for interrupted runs
294NCDF_DIMINQ, id, NCDF_DIMID(id, 'Time'         ), dummy, ntlast
295NCDF_CLOSE, id
296nttot = (nf-1)*nt + ntlast
297wt  = fltarr(nz,nttot) & wq = fltarr(nz,nttot) & wq_updraft = fltarr(nz,nttot) & wq_downdraft = fltarr(nz,nttot) & wq_env_ude=fltarr(nz,nttot)
298q_mean_up = fltarr(nz,nttot) & q_mean_down = fltarr(nz,nttot) & q_mean_env_ude = fltarr(nz,nttot) & q_mean = fltarr(nz,nttot)
299tke_les = fltarr(nz,nttot) & ztke = fltarr(nz,nttot) & t = fltarr(nz,nttot)
300p = fltarr(nz) & ph = fltarr(nz) & pht = fltarr(nz,nttot) & pt = fltarr(nz,nttot)
301xtke = fltarr(nz,nttot) & ytke = fltarr(nz,nttot) & temp_les = fltarr(nz,nttot)
302wmax = fltarr(nttot)
303alpha1 = fltarr(nz) & alpha2 = fltarr(nz)
304alpha1out = fltarr(nz,nttot) & alpha2out = fltarr(nz,nttot)
305zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
306sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
307sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
308fm_trac1_les = fltarr(nz,nttot) & fm_trac2_les = fltarr(nz,nttot)
309anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
310e_trac1_les = fltarr(nz,nttot) & e_trac2_les = fltarr(nz,nttot)
311dtempdztmp = fltarr(nx,ny,nz)
312localtime = lctu + history_interval_s*findgen(nttot)/3700.
313w_mean1 = fltarr(nz,nttot) & w_mean2 = fltarr(nz,nttot)
314w_mean1_env = fltarr(nz,nttot) & w_mean1_down = fltarr(nz,nttot)
315w_mean1_env_ude = fltarr(nz,nttot) & w_mean1_full = fltarr(nz,nttot)
316buoyancy1_les = fltarr(nz,nttot) & buoyancy2_les = fltarr(nz,nttot)
317e1_term2 = fltarr(nz,nttot) & e1_term3 = fltarr(nz,nttot)
318dtetadttmp = fltarr(nx,ny,nz)
319rhomoy1 = fltarr(nz,nttot)
320plumeIndex1out = make_array(nx*ny,nz,VALUE=-1.) & envIndex1out = make_array(nx*ny,nz,VALUE=-1.)
321hf1tmp = fltarr(nz,nttot) & hf1tmpenv = fltarr(nz,nttot)
322tplume1moy = fltarr(nz,nttot) & tenv1moy = fltarr(nz,nttot) & tenv1moy_ude = fltarr(nz,nttot)
323tmoy_full = fltarr(nz,nttot) & tdown1moy = fltarr(nz,nttot)
324dteta1moydt_entr = fltarr(nz,nttot) & dteta1moydt_detr = fltarr(nz,nttot)
325d1_term1 = fltarr(nz,nttot) & d1_term2 = fltarr(nz,nttot) & d1_term3=fltarr(nz,nttot)
326hf1_term1 = fltarr(nz,nttot) & hf1_term2 = fltarr(nz,nttot) & hf1_term3 = fltarr(nz,nttot)
327d1_term1_ude = fltarr(nz,nttot) & d1_term2_ude = fltarr(nz,nttot) & d1_term3_ude=fltarr(nz,nttot)
328e1_term1_ude = fltarr(nz,nttot) & e1_term2_ude = fltarr(nz,nttot) & e1_term3_ude=fltarr(nz,nttot)
329downward_flux1 = fltarr(nz,nttot) & beta1out = fltarr(nz,nttot)
330hf1_ude_term1 = fltarr(nz,nttot) & hf1_ude_term2 = fltarr(nz,nttot) & hf1_ude_term3 = fltarr(nz,nttot) & hf1_ude_term4 = fltarr(nz,nttot)
331hf1tmpenv_ude = fltarr(nz,nttot) & hf1tmp_down = fltarr(nz,nttot)
332dTeta_phys = make_array(nz,nttot)
333exner = fltarr(nz,nttot)
334uv_moy = fltarr(nz,nttot)
335tsurf = fltarr(nttot)
336Gamma_1 = fltarr(nz,nttot) & Gamma_2 = fltarr(nz,nttot) & Gamma_3 = fltarr(nz,nttot)
337Gamma_1_tmp = fltarr(nz,nttot) & dgamma1tmp = fltarr(nz,nttot)
338ptotprime = fltarr(nx,ny,nz) & anomalptot = fltarr(nx,ny,nz) & dptotprimedztmp  = fltarr(nx,ny,nz)
339hfx = fltarr(nttot) & flxrad = fltarr(nttot) & flxgrd = fltarr(nttot) & lwdownz = fltarr(nttot) & swdownz = fltarr(nttot)
340
341;wBin = fltarr(NBINS,nttot) & wBinEnv_ude = fltarr(NBINS,nttot) & wBinUp = fltarr(NBINS,nttot) & wBinDown = fltarr(NBINS,nttot)
342l=0
343
344FOR loop  = 0, nf-1 DO BEGIN
345  timetime = SYSTIME(1)
346  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
347  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
348        FOR loop2 = loop2_init, nloop2-1 DO BEGIN
349        pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
350        ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
351        ENDFOR
352        print, 'computing altitudes, file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
353ENDFOR
354altitudes_LES  = 1000.*(TEMPORARY(ph)  - hgtu/1000.)  ;; altitude above ground
355pht = fltarr(nz,nttot)
356ph = fltarr(nz)
357
358FOR loop  = 0, nf-1 DO BEGIN
359  timetime = SYSTIME(1)
360  if (loop ne nf-1) then nloop2=nt else nloop2=ntlast
361  if (loop ne 0) then loop2_init=0 else loop2_init=1                ;le tout premier pas de temps est l'initialisation, certains champs sont à 0 => bug
362        FOR loop2 = loop2_init, nloop2-1 DO BEGIN
363       
364        anomalt = 1. & anomalu = 1. & anomalv = 1. & anomalw = 1.
365        ; --------------------------------------------------------
366        ; u' = u and v' = v   (car PAS de background wind !)
367        ; tke = 0.5 ( <u'^2> + <v'^2> + <w'^2> ) ; u' = u ; v' = v
368        ; --------------------------------------------------------
369       
370        tprime = getget(filesWRF(loop), 'T', anomaly=anomalt, count=[0,0,0,1], offset=[0,0,0,loop2])  ;; t' = t - <t>
371        t(*,l) = t0 + temporary(anomalt)
372        ztke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
373        xtke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'U', anomaly=anomalu, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
374        ytke(*,l) = 0.5 * TOTAL(TOTAL(getget(filesWRF(loop), 'V', anomaly=anomalv, count=[0,0,0,1], offset=[0,0,0,loop2])^2,1),1) / float(nx) / float(ny)
375        uv_moy(*,l) = TOTAL(TOTAL(sqrt(getget(filesWRF(loop), 'U', count=[0,0,0,1], offset=[0,0,0,loop2])^2 + getget(filesWRF(loop), 'V', count=[0,0,0,1], offset=[0,0,0,loop2])^2),1),1) / float(nx) / float(ny)
376        tke_les(*,l) = xtke(*,l) + ytke(*,l) + ztke(*,l)
377        wprime = getget(filesWRF(loop), 'W', anomaly=anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
378        pht(*,l) = TOTAL(TOTAL(getget(filesWRF(loop), 'PHTOT',  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny) / 1000. / 3.72
379        pt(*,l)  = TOTAL(TOTAL(getget(filesWRF(loop), 'PTOT' ,  count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny)
380        tsurf(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'TSURF' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
381        hfx(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'HFX' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
382        flxrad(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'FLXRAD' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
383        flxgrd(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'FLXGRD' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
384        lwdownz(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'LWDOWNZ' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
385        swdownz(l) = TOTAL(TOTAL(getget(filesWRF(loop), 'SWDOWNZ' ,  count=[0,0,1], offset=[0,0,loop2]),1),1) / float(nx) / float(ny)
386
387        temp_les(*,l) = t(*,l)*(pt(*,l)/p0)^r_cp
388        IF (got_pdt eq 'true') then begin
389        exner(*,l) = (pt(*,l)/p0)^r_cp
390        dTeta_phys(*,l) = (TOTAL(TOTAL(getget(filesWRF(loop), 'PDT', count=[0,0,0,1], offset=[0,0,0,loop2]),1),1) / float(nx) / float(ny))/exner(*,l)
391        ENDIF
392        ph = TEMPORARY(ph) + pht(*,l) / (nttot-1)
393        p  = TEMPORARY(p ) + pt(*,l) / nttot
394        ptotprime = getget(filesWRF(loop), 'PTOT', count=[0,0,0,1], offset=[0,0,0,loop2])
395        FOR k=0, nz-1 DO BEGIN
396                rhomoy1(*,l) = TOTAL(TOTAL(reform(((ptotprime(*,*,k)/(R*(t(k,l)+tprime(*,*,k))))*(p0/ptotprime(*,*,k))^r_cp)),1),1)/(float(nx)*float(ny))
397                anomalptot(*,*,k) = ptotprime(*,*,k) - total(total(ptotprime(*,*,k),1),1)/ float(nx) / float(ny)    ; prime par rapport a la moyenne du niveau (plus continu)
398        ENDFOR
399        zqtrac1 = getget(filesWRF(loop), s_trac1, count=[0,0,0,1], offset=[0,0,0,loop2])
400;        zqtrac2 = getget(filesWRF(loop), s_trac2, count=[0,0,0,1], offset=[0,0,0,loop2])
401        FOR i=0,nx-1 DO BEGIN
402                FOR j=0, ny-1 DO BEGIN
403                        dtempdztmp(i,j,*) = deriv(altitudes_LES, tprime(i,j,*) + t(*,l))
404                        dptotprimedztmp(i,j,*) = deriv(altitudes_LES, anomalptot(i,j,*))
405                ENDFOR
406        ENDFOR
407
408        FOR k=0,nz-1 DO BEGIN
409                anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
410;                anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
411                sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
412                IF (k ne 0) THEN BEGIN
413                        subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
414                        sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
415                ENDIF ELSE BEGIN
416                        sigmazminqtrac1(k) = sigmazqtrac1(k)
417                ENDELSE
418                plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
419                envIndex1 = WHERE((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.))
420;               plumeIndex1 =  WHERE(anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
421;               envIndex1 = WHERE(anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)]))
422                IF(plumeIndex1(0) EQ -1) THEN BEGIN
423                fm_trac1_les(k,l)=0.
424                e_trac1_les(k,l)=0.
425                alpha1out(k,l)=0.
426                buoyancy1_les(k,l)=0.
427                w_mean1(k,l)=0.
428                w_mean1_env(k,l)=0.
429                w_mean1_down(k,l)=0.
430                w_mean1_full(k,l)=0.
431                w_mean1_env_ude(k,l)=0.
432                e1_term2(k,l)=0.
433                e1_term3(k,l)=0.
434                e1_term1_ude(k,l)=0.
435                e1_term2_ude(k,l)=0.
436                e1_term3_ude(k,l)=0.
437                hf1tmp(k,l)=0.
438                hf1tmpenv(k,l)=0.
439                Gamma_1_tmp(k,l)=0.
440                plumeIndex1out(*,k)=-1.
441                envIndex1out(*,k)=-1.
442                d1_term1(k,l)=0.
443                d1_term2(k,l)=0.
444                d1_term3(k,l)=0.
445                d1_term1_ude(k,l)=0.
446                d1_term2_ude(k,l)=0.
447                d1_term3_ude(k,l)=0.
448                downward_flux1(k,l)=0.
449                beta1out(k,l)=0.
450                tmoy_full(k,l)=0.
451                tdown1moy(k,l)=0.
452                wq_updraft(k,l)=0.
453                wq_downdraft(k,l)=0.
454                q_mean_up(k,l)=0.
455                q_mean_down(k,l)=0.
456                Gamma_2(k,l)=0.
457                Gamma_3(k,l)=0.
458                ENDIF ELSE BEGIN
459                FOR n=0L,n_elements(plumeIndex1)-1 DO BEGIN
460                        plumeIndex1out(n,k)=plumeIndex1(n)
461                ENDFOR
462                FOR n=0L,n_elements(envIndex1)-1 DO BEGIN
463                        envIndex1out(n,k)=envIndex1(n)
464                ENDFOR
465                alpha1(k) = n_elements(plumeIndex1) / float(nx) / float(ny)
466                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
467                w_mean1_full(k,l) = mean(wprimetmp)
468                w_mean1(k,l) = mean(wprimetmp(plumeIndex1))
469                w_mean1_env(k,l) = mean(wprimetmp(envIndex1))
470                downdraft_index1 = WHERE((abs(anomalw(k)+wprime(*,*,k)) gt sigmao_ude*STDDEV(wprimetmp(envIndex1))) and (anomalw(k)+wprime(*,*,k) lt 0.))
471               
472                envIndex1_ude = WHERE(((abs(anomalw(k)+wprime(*,*,k)) le sigmao_ude*STDDEV(wprimetmp(envIndex1))) or (anomalw(k)+wprime(*,*,k) ge 0.)) AND ((anomalqtrac1(*,*,k) LE scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) OR ((anomalw(k)+wprime(*,*,k)) LE 0.)))
473                IF (envIndex1_ude(0) ne -1) THEN w_mean1_env_ude(k,l) = mean(wprimetmp(envIndex1_ude)) ELSE w_mean1_env_ude(k,l) =0.
474                if (downdraft_index1(0) ne -1) then begin
475                w_mean1_down(k,l)=mean(wprimetmp(downdraft_index1))
476                wprimetmp=0.
477                beta1 = n_elements(downdraft_index1) / float(nx) / float(ny)
478                beta1out(k,l)=beta1
479                downward_flux1(k,l) = beta1*rhomoy1(k,l)*w_mean1_down(k,l)
480                endif else begin
481                downward_flux1(k,l)=0.
482                beta1out(k,l)=0.
483                w_mean1_down(k,l)=0.
484                tdown1moy(k,l)=0.
485                endelse
486                fm_trac1_les(k,l) = alpha1(k)*rhomoy1(k,l)*w_mean1(k,l)
487                dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
488                alpha1out(k,l)=alpha1(k)
489                tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
490                if (downdraft_index1(0) ne -1) then tdown1moy(k,l)=mean(tfull(downdraft_index1))
491                tplume1moy(k,l)=mean(tfull(plumeIndex1))
492                tenv1moy(k,l)=mean(tfull(envIndex1))
493                if (envIndex1_ude(0) ne -1) then tenv1moy_ude(k,l) = mean(tfull(envIndex1_ude)) else tenv1moy_ude(k,l)=0.
494                tmoy_full(k,l) = mean(tfull)
495                buoyancy1_les(k,l)=grav*(tplume1moy(k,l)/tenv1moy(k,l)-1.)
496                e_trac1_les(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
497                d1_term1(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1))),1)/float(n_elements(envIndex1))
498                if (envIndex1_ude(0) ne -1) then begin
499                e1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(dtempdztmplin(plumeIndex1)),1)/float(n_elements(plumeIndex1))
500                d1_term1_ude(k,l) = fm_trac1_les(k,l)*TOTAL((1./(tenv1moy_ude(k,l)-tplume1moy(k,l)))*(temporary(dtempdztmplin(envIndex1_ude))),1)/float(n_elements(envIndex1_ude))
501                endif else begin
502                e1_term1_ude(k,l) = 0.
503                d1_term1_ude(k,l) = 0.
504                endelse
505                wtmp=reform(wprime(*,*,k)+anomalw(k),[nx*ny,1])
506                ttmp=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
507                qtmp=reform(zqtrac1(*,*,k),[nx*ny,1])
508                pttmp=reform(ptotprime(*,*,k),[nx*ny,1])
509                pt_mean1=mean(pttmp(plumeIndex1))
510                pttmp=0.
511;                anomalptot(*,*,k) = ptotprime(*,*,k) - temporary(pt_mean1)    ;prime par rapport a la moyenne dans la plume (oscille fortement : probleme de bonne definition verticale de la plume)
512                Gamma_1_tmp(k,l) = alpha1out(k,l)*rhomoy1(k,l)*TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))^2,1) / float(n_elements(plumeIndex1))
513                anomalptotlin = reform(anomalptot(*,*,k),[nx*ny,1])
514                dptotprimedztmplin = reform(dptotprimedztmp(*,*,k),[nx*ny,1])
515                Gamma_2(k,l) = -(TOTAL(dptotprimedztmplin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/rhomoy1(k,l)
516                Gamma_3(k,l) = -grav*(TOTAL(anomalptotlin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/pt(k,l)
517                hf1tmp(k,l) = TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))*(ttmp(plumeIndex1)-tplume1moy(k,l)),1) / float(n_elements(plumeIndex1))
518                hf1tmpenv(k,l) = TOTAL((wtmp(envIndex1)-w_mean1_env(k,l))*(ttmp(envIndex1)-tenv1moy(k,l)),1) / float(n_elements(envIndex1))
519                q_mean_up(k,l)=mean(qtmp(plumeIndex1))
520                wq_updraft(k,l) = TOTAL((wtmp(plumeIndex1)-w_mean1(k,l))*(qtmp(plumeIndex1)-mean(qtmp(plumeIndex1))),1) / float(n_elements(plumeIndex1))
521
522                if (envIndex1_ude(0) ne -1) then begin
523                hf1tmpenv_ude(k,l) = TOTAL((wtmp(envIndex1_ude)-w_mean1_env_ude(k,l))*(ttmp(envIndex1_ude)-tenv1moy_ude(k,l)),1) / float(n_elements(envIndex1_ude))
524                q_mean_env_ude(k,l)=mean(qtmp(envIndex1_ude))
525                wq_env_ude(k,l)= TOTAL((wtmp(envIndex1_ude)-mean(wtmp(envIndex1_ude)))*(qtmp(envIndex1_ude)-mean(qtmp(envIndex1_ude))),1) / float(n_elements(envIndex1_ude))
526                endif else begin
527                hf1tmpenv_ude(k,l) =0.
528                wq_env_ude(k,l)=0.
529                endelse
530                if (downdraft_index1(0) ne -1) then begin
531                hf1tmp_down(k,l) = TOTAL((wtmp(downdraft_index1)-w_mean1_down(k,l))*(ttmp(downdraft_index1)-tdown1moy(k,l)),1) / float(n_elements(downdraft_index1))
532                q_mean_down(k,l)=mean(qtmp(downdraft_index1))
533                wq_downdraft(k,l) = TOTAL((wtmp(downdraft_index1)-mean(wtmp(downdraft_index1)))*(qtmp(downdraft_index1)-mean(qtmp(downdraft_index1))),1) / float(n_elements(downdraft_index1))
534                endif else begin
535                hf1tmp_down(k,l)=0.
536                wq_downdraft(k,l)=0.
537                endelse
538                q_mean(k,l)=mean(qtmp)
539                IF((n_elements(plumeIndex1) + n_elements(envIndex1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env : ', n_elements(plumeIndex1), n_elements(envIndex1)
540;               IF((n_elements(plumeIndex1) + n_elements(envIndex1_ude) + n_elements(downdraft_index1)) ne float(nx*ny)) then print, 'WARNING : INDEX PROBLEM : plume / env / downdraft : ', n_elements(plumeIndex1), n_elements(envIndex1_ude), n_elements(downdraft_index1)
541                ENDELSE
542        ENDFOR
543
544;        FOR i=0, nx-1 DO BEGIN
545;            FOR j=0, ny-1 DO BEGIN
546;                dptotprimedztmp(i,j,*) = deriv(altitudes_LES, anomalptot(i,j,*))
547;            ENDFOR
548;        ENDFOR
549;
550;        FOR k=0, nz-1 DO BEGIN
551;               IF(plumeIndex1out(0,k) eq -1) THEN BEGIN
552;                       Gamma_2(k,l)=0.
553;                ENDIF ELSE BEGIN
554;                       wpi=where(plumeIndex1out ne -1)
555;                       plumeIndex1=reform(plumeIndex1out(temporary(wpi),k))
556;                       dptotprimedztmplin = reform(dptotprimedztmp(*,*,k),[nx*ny,1])
557;                       Gamma_2(k,l) = -(TOTAL(dptotprimedztmplin(plumeIndex1),1)/float(n_elements(plumeIndex1)))/rhomoy1(k,l)
558;               ENDELSE
559;       ENDFOR
560
561        dgamma1tmp(*,l) = deriv(altitudes_LES,Gamma_1_tmp(*,l))
562        FOR k=0, nz-1 DO BEGIN
563                IF (alpha1out(k,l) ne 0.) THEN BEGIN
564                        Gamma_1(k,l) = -(1./(alpha1out(k,l)*rhomoy1(k,l)))*dgamma1tmp(k,l)
565                ENDIF ELSE BEGIN
566                        Gamma_1(k,l)=0.
567                ENDELSE
568        ENDFOR
569        drhoahfdztmp = deriv(altitudes_LES,rhomoy1(*,l)*alpha1out(*,l)*hf1tmp(*,l))
570        drhoahfdztmpDetr = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l))*hf1tmpenv(*,l))
571        drhoahfdztmpDetr_ude = deriv(altitudes_LES,rhomoy1(*,l)*(1.-alpha1out(*,l)-beta1out(*,l))*hf1tmpenv_ude(*,l))
572
573;       wBin(*,l)=HISTOGRAM(wtmp,nbins=NBINS)
574;       wBinEnv_ude(*,l)=HISTOGRAM(wtmp(envIndex1_ude),nbins=NBINS)
575;       wBinUp(*,l)=HISTOGRAM(wtmp(plumeIndex1),nbins=NBINS)
576;       wBinDown(*,l)=HISTOGRAM(wtmp(downdraft_index1),nbins=NBINS)
577        wtmp=0.
578        ttmp=0.
579       
580        FOR k=0,nz-1 DO BEGIN
581                IF(plumeIndex1out(0,k) eq -1) THEN BEGIN
582                e1_term2(k,l)=0.
583                e1_term2_ude(k,l)=0.
584                ENDIF ELSE BEGIN
585                e1_term2(k,l)=drhoahfdztmp(k)/(tenv1moy(k,l)-tplume1moy(k,l))
586                e1_term2_ude(k,l)=drhoahfdztmp(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
587                ENDELSE
588
589                IF(envIndex1out(0,k) eq -1) THEN BEGIN
590                d1_term2(k,l)=0.
591                d1_term2_ude(k,l)=0.
592                ENDIF ELSE BEGIN
593                d1_term2(k,l)=-drhoahfdztmpDetr(k)/(tenv1moy(k,l)-tplume1moy(k,l))
594                d1_term2_ude(k,l)=-drhoahfdztmpDetr_ude(k)/(tenv1moy_ude(k,l)-tplume1moy(k,l))
595                ENDELSE
596        ENDFOR
597
598
599        tfull1=0.
600
601        zqtrac1=0.
602;        zqtrac2 = getget(filesWRF(loop), s_trac2, count=[0,0,0,1], offset=[0,0,0,loop2])
603;        FOR k=0,nz-1 DO BEGIN
604;               anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
605;                sigmazqtrac2(k) = STDDEV(zqtrac2(*,*,k))
606;               IF (k ne 0) THEN BEGIN
607;                       subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
608;                       sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
609;               ENDIF ELSE BEGIN
610;                       sigmazminqtrac2(k) = sigmazqtrac2(k)
611;               ENDELSE
612;                plumeIndex2 = WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((wprime(*,*,k)+anomalw(k)) GT 0.))
613;                envIndex2 = WHERE((anomalqtrac2(*,*,k) LE scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) OR ((wprime(*,*,k)+anomalw(k)) LE 0.))
614;                IF(plumeIndex2(0) EQ -1) THEN BEGIN
615;                fm_trac2_les(k,l)=0.
616;                e_trac2_les(k,l)=0.
617;                alpha2out(k,l)=0.
618;                buoyancy2_les(k,l)=0.
619;               w_mean2(k,l)=0.
620;                ENDIF ELSE BEGIN
621;               alpha2(k) = n_elements(plumeIndex2) / float(nx) / float(ny)
622;                wprimetmp = reform(reform((anomalw(k)+wprime(*,*,k))),[nx*ny,1])
623;                w_mean2(k,l) = mean(wprimetmp(plumeIndex2))
624;               wprimetmp=0.
625;                fm_trac2_les(k,l) = alpha2(k)*rhomoy1(k,l)*w_mean2(k,l)
626;                tprimetmp = reform(reform(-tprime(*,*,k)),[nx*ny,1])
627;                dtempdztmplin = reform(reform(dtempdztmp(*,*,k)),[nx*ny,1])
628;                e_trac2_les(k,l) = TOTAL((1./(temporary(tprimetmp(plumeIndex2))))*(temporary(dtempdztmplin(plumeIndex2))),1)/n_elements(plumeIndex2)
629;                alpha2out(k,l)=alpha2(k)
630;                tfull=reform(tprime(*,*,k)+t(k,l),[nx*ny,1])
631;                tplume2moy=mean(tfull(plumeIndex2))
632;                tenv2moy=mean(tfull(envIndex2))
633;                buoyancy2_les(k,l)=grav*(tplume2moy/tenv2moy-1.)
634;               ENDELSE
635;        ENDFOR
636;        zqtrac2=0.
637
638        wt(*,l) = TOTAL(TOTAL(TEMPORARY(tprime)*wprime,1),1) / float(nx) / float(ny)
639        wq(*,l) = TOTAL(TOTAL(TEMPORARY(wprime)*anomalqtrac1,1),1) / float(nx) / float(ny)
640
641        wmax(l) = max(w_mean1(*,l))
642        l=l+1
643        ENDFOR
644        print, 'file '+string(loop+1,'(I0)'), SYSTIME(1) - timetime, ' s'
645
646ENDFOR
647
648hf1_term1 = hf1tmp*alpha1out
649hf1_term2 = temporary(hf1tmpenv)*(1.-alpha1out)
650hf1_term3 = alpha1out*(1.-alpha1out)*(w_mean1 - w_mean1_env)*(tplume1moy - tenv1moy)
651
652hf1_ude_term1 = temporary(hf1tmp)*alpha1out
653hf1_ude_term2 = temporary(hf1tmp_down)*beta1out
654hf1_ude_term3 = temporary(hf1tmpenv_ude)*(1.-(alpha1out+beta1out))
655hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
656
657FOR k=0, nz-1 DO BEGIN
658;       dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
659;       dteta1moydt_detr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. + dTeta_phys(k,*)
660        dteta1moydt_entr(k,*) = deriv(localtime,tplume1moy(k,*))/3700. - dTeta_phys(k,*)
661        dteta1moydt_detr(k,*) =  dTeta_phys(k,*) - deriv(localtime,tplume1moy(k,*))/3700.
662ENDFOR
663
664FOR k=0, nz-1 DO BEGIN
665        FOR l=0, nttot-1 DO BEGIN
666                IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN e1_term3(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE e1_term3(k,l)=0.
667                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN e1_term3_ude(k,l) = rhomoy1(k,l)*alpha1out(k,l)*dteta1moydt_entr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE e1_term3_ude(k,l)=0
668;               IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
669                IF (tenv1moy(k,l) ne tplume1moy(k,l)) THEN d1_term3(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy(k,l)-tplume1moy(k,l)) ELSE d1_term3(k,l)=0.
670                IF (tenv1moy_ude(k,l) ne tplume1moy(k,l)) THEN d1_term3_ude(k,l) = rhomoy1(k,l)*(1.-alpha1out(k,l)-beta1out(k,l))*dteta1moydt_detr(k,l)/(tenv1moy_ude(k,l)-tplume1moy(k,l)) ELSE d1_term3_ude(k,l)=0.
671        ENDFOR
672ENDFOR
673
674
675ht = TEMPORARY(pht) - hgtu/1000.
676save, hfx, flxrad, flxgrd, lwdownz, swdownz, q_mean_up, q_mean_down, q_mean_env_ude, q_mean, Gamma_1, Gamma_2, Gamma_3, w_mean1_env, tsurf, wq, wq_updraft, wq_downdraft, wq_env_ude, d1_term1_ude, d1_term2_ude, d1_term3_ude, e1_term1_ude, e1_term2_ude, e1_term3_ude, tplume1moy, tdown1moy, w_mean1_full, tmoy_full, tenv1moy_ude, w_mean1_env_ude, uv_moy, hf1_ude_term1, hf1_ude_term2, hf1_ude_term3, hf1_ude_term4, w_mean1_down, downward_flux1, beta1out, hf1_term1, hf1_term2, hf1_term3, d1_term1, d1_term2, d1_term3, e1_term2, e1_term3, buoyancy1_les, buoyancy2_les, w_mean1, w_mean2, nx, ny, alpha1out, alpha2out, e_trac1_les, e_trac2_les, tke_les, ztke, altitudes_LES, ht, t, p, pt, localtime, xtke, ytke, wt, temp_les, wmax, fm_trac1_les, fm_trac2_les,filename=les_path+'/'+datname
677
678nz = n_elements(altitudes_LES)
679
680ENDIF ELSE BEGIN
681
682print, 'OK, file is here'
683restore, filename=les_path+'/'+datname
684nz = n_elements(altitudes_LES)
685nttot = n_elements(tmoy_full(0,*))
686
687OPENR, 23, les_path+'/input_more' & READF, 23, hgtu, tsurfu & CLOSE, 23
688
689ENDELSE
690
691tenv1moy = tplume1moy/((buoyancy1_les/grav)+1.)
692
693taverage = string((localtime(nstot)-localtime(1))*3700./60.)
694print, ''
695print, ' -- Loading testphys1d data -- '
696
697file1=gcm_path+'/diagfi.nc'
698file2=gcm_convadj_path+'/diagfi.nc'
699file3='/san0/acolmd/SIMUS/GCM3D_TestBed/diagfi.nc'
700
701getcdf, file=file1, charvar='q2', invar=tke_gcm
702getcdf, file=file1, charvar='aps', invar=aps
703getcdf, file=file1, charvar='bps', invar=bps
704getcdf, file=file1, charvar='co2col', invar=co2_col
705;getcdf, file=file1, charvar='arcol', invar=ar_col
706getcdf, file=file1, charvar='tkecol', invar=tke_col
707;getcdf, file=file1, charvar='ar', invar=ar
708getcdf, file=file1, charvar='heatFlux_up', invar=heatFlux_up
709getcdf, file=file1, charvar='heatFlux_down', invar=heatFlux_down
710getcdf, file=file1, charvar='pplay', invar=pplay
711getcdf, file=file1, charvar='pplev', invar=pplev
712getcdf, file=file1, charvar='temp', invar=temp_gcm
713getcdf, file=file1, charvar='zw2', invar=zw2_lev
714getcdf, file=file1, charvar='fm_therm', invar=fm_therm_gcm_lev
715getcdf, file=file1, charvar='entr_therm', invar=zdz_entr_therm_gcm
716getcdf, file=file1, charvar='detr_therm', invar=zdz_detr_therm_gcm
717getcdf, file=file1, charvar='fraca', invar=alpha_gcm_lev
718getcdf, file=file1, charvar='buoyancyOut', invar=buoyancy_gcm
719getcdf, file=file1, charvar='buoyancyEst', invar=buoyancy_est_gcm
720getcdf, file=file1, charvar='zkh', invar=zkh
721getcdf, file=file1, charvar='zh', invar=zh
722getcdf, file=file1, charvar='tsurf', invar=tsurf_gcm
723
724if (overplot_convadj eq 'true') then begin
725getcdf, file=file2, charvar='temp', invar=temp_gcm_convadj
726getcdf, file=file2, charvar='pplay', invar=pplay_convadj
727endif
728if (plot_3d eq 'true') then begin
729getcdf, file=file3, charvar='temp', invar=temp_gcm_3d
730getcdf, file=file3, charvar='pplay', invar=pplay_3d
731getcdf, file=file3, charvar='latitude', invar=latitude_3d
732getcdf, file=file3, charvar='longitude', invar=longitude_3d
733nWEmx_3d = n_elements(reform(temp_gcm_3d(*,0,0,0)))
734nNSmx_3d = n_elements(reform(temp_gcm_3d(0,*,0,0)))
735nZmx_3d = n_elements(reform(temp_gcm_3d(0,0,*,0)))
736nTmx_3d = n_elements(reform(temp_gcm_3d(0,0,0,*)))
737ndays_3d = 1.
738lctu_gcm_3d = 0.
739history_interval_s_gcm_3d = ndays_3d*88800./float(nTmx_3d)  ; Timestep interval of gcm 1d simu in sec
740localtime_lon0 = lctu_gcm_3d + history_interval_s_gcm_3d*findgen(nTmx_3d)/3700.
741Xc = 205.
742Yc = 21.8
743plot_index_x = (Xc-longitude_3d(0))/(longitude_3d(1)-longitude_3d(0))
744plot_index_y = (Yc-latitude_3d(0))/(latitude_3d(1)-latitude_3d(0))
745localtime_true = localtime_lon0 -(12./180.)*Xc
746endif
747
748
749nTmx = n_elements(reform(temp_gcm(0,*)))
750if (overplot_convadj eq 'true') then begin
751nTmx_convadj = n_elements(reform(temp_gcm_convadj(0,*)))
752endif else begin
753nTmx_convadj =  10000.
754endelse
755ndays = 1.
756print, ''
757print, 'WARNING ----------------------- '
758print, 'CONFIGURATION : '+string(ndays,format='(I0)')+' days simulation'
759print, ''
760history_interval_s_gcm = ndays*88800./float(nTmx)  ; Timestep interval of gcm 1d simu in sec
761history_interval_s_gcm_convadj = ndays*88800./float(nTmx_convadj)
762localtime_gcm = lctu_gcm + history_interval_s_gcm*findgen(nTmx)/3700.
763localtime_gcm_convadj = lctu_gcm + history_interval_s_gcm_convadj*findgen(nTmx_convadj)/3700.
764; **********************************
765; ******** PLOTS ******************
766if (f_offset eq 'true') then begin
767offset_localtime = 3.108100
768endif else begin
769offset_localtime = 0.
770endelse
771localtime=localtime+offset_localtime
772print, '****************************************************************************************************'
773print, 'local time LES'
774print, localtime
775print, '****************************************************************************************************'
776print, 'local time GCM'
777print, localtime_gcm
778print, '****************************************************************************************************'
779
780time_offset = (ndays-1.)*24.
781
782lt_plot_ini = 8.
783lt_plotindex_les_ini = where(localtime eq lt_plot_ini)
784lt_plotindex_gcm_ini = where(localtime_gcm eq (lt_plot_ini+time_offset))
785
786lt_plot0 = 10.
787lt_plotindex_les0 = where(localtime eq lt_plot0)
788lt_plotindex_gcm0 = where(localtime_gcm eq (lt_plot0+time_offset))
789lt_plotindex_gcm_convadj0 = where(localtime_gcm_convadj eq (lt_plot0+time_offset))
790
791;lt_plot = 8.25
792lt_plot = 12.
793lt_plotindex_les = where((localtime lt lt_plot+0.01) and (localtime gt lt_plot-0.01))
794lt_plotindex_gcm = where(localtime_gcm eq (lt_plot+time_offset))
795lt_plotindex_gcm_convadj = where(localtime_gcm_convadj eq (lt_plot+time_offset))
796print, 'lt plotindex les 12h'
797print, lt_plotindex_les
798
799lt_plot2 = 14.
800lt_plotindex_les2 = where(localtime eq lt_plot2)
801lt_plotindex_gcm2 = where(localtime_gcm eq (lt_plot2+time_offset))
802lt_plotindex_gcm_convadj2 = where(localtime_gcm_convadj eq (lt_plot2+time_offset))
803
804lt_plot3 = 16.
805lt_plotindex_les3 = where(localtime eq lt_plot3)
806lt_plotindex_gcm3 = where(localtime_gcm eq (lt_plot3+time_offset))
807lt_plotindex_gcm_convadj3 = where(localtime_gcm_convadj eq (lt_plot3+time_offset))
808
809lt_plot4 = 18.
810lt_plotindex_les4 = where(localtime eq lt_plot4)
811lt_plotindex_gcm4 = where(localtime_gcm eq (lt_plot4+time_offset))
812lt_plotindex_gcm_convadj4 = where(localtime_gcm_convadj eq (lt_plot4+time_offset))
813;--------------------------------------------------------------------------------
814;---------------------------------------------------------------------------------
815
816nTmx_les=n_elements(reform(wt(0,*)))
817nZmx=n_elements(aps)          ; number of vertical levels
818H_low=9650.                   ; scale height at low altitudes
819H_high=15000.                 ; scale height at high altitudes
820trans_window=10.              ; # of levels over which H(:) goes from H_low to H_high
821lev_trans=32.+trans_window/2. ; level at which H(lev_trans)=(H_low+H_high)/2
822P_ref=p0                    ; reference surface pressure used to build zsurface -610 Pa-
823Hgcm = make_array(nZmx)
824altitudes_GCM = make_array(nZmx)
825; Build scale heights
826;FOR k=0,nZmx-1 DO BEGIN
827;        Hgcm(k)=H_low+(H_high-H_low)*0.5*(1.0+tanh(6.*(k-lev_trans)/trans_window))
828;ENDFOR
829
830FOR k=0,nZmx-1 DO BEGIN
831        Hgcm(k)=R*temp_gcm(k,lt_plotindex_gcm)/grav
832ENDFOR
833print, 'Hgcm'
834print, Hgcm
835; Compute altitudes_GCM
836FOR k=0,nZmx-1 DO BEGIN
837        altitudes_GCM(k)=-Hgcm(k)*alog(pplay(k,lt_plotindex_gcm)/pGround)
838ENDFOR
839Hgcm=0.
840
841teta_gcm = temp_gcm * (p0/pplay)^r_cp
842if (overplot_convadj eq 'true') then begin
843teta_gcm_convadj = temp_gcm_convadj * (p0/pplay_convadj)^r_cp
844endif
845
846OPENR, 1, gcm_path+'/profile'
847data=FLTARR(nZmx+1)
848READF, 1, data
849temp_gcm_0_ground = data(0)
850temp_gcm_0 = data(1:nZmx-1)
851data = 0.
852CLOSE, 1
853
854teta_gcm_0 = temp_gcm_0 * (p0/pplay)^r_cp
855approx_zdz_gcm = make_array(nZmx)
856approx_zdz_gcm(0)=altitudes_GCM(1)
857FOR k=1, nZmx-2 DO BEGIN
858       approx_zdz_gcm(k) = altitudes_GCM(k+1) - altitudes_GCM(k)
859ENDFOR
860approx_zdz_gcm(nZmx-1)=approx_zdz_gcm(nZmx-2)
861
862print, 'approx zdz gcm'
863print, approx_zdz_gcm
864
865print, '****************************************************************************************************'
866print, 'altitudes LES based on phtot : inter-levels'
867print, altitudes_LES
868print, '****************************************************************************************************'
869print, 'altitudes GCM based on pplay : inter-levels'
870print, altitudes_GCM
871print, '****************************************************************************************************'
872
873; Compute tracer deviation :
874
875co2_col = co2_col/co2_col(0)
876;ar_col = ar_col/ar_col(0)
877tke_col = tke_col+1.
878
879; Compute <teta> les
880
881teta_les = temporary(t)
882
883
884; ========================================================================
885; ========================================================================
886
887IF (visualization_mode eq 'true') THEN BEGIN
888
889print,' *****************************************-----------------------------------'
890print,' ************ PLUME **********************-----------------------------------'
891print,' *****************************************-----------------------------------'
892
893; We are evaluating the first time-step element of the file number 'loop-1' :
894; file 1 starts at 8h (loop =0, loop2 =0)
895; file 6 starts at 13h  (roughly)  (loop =5, loops2=0)
896; file 12 starts at 18h (roughly) (loop = 11,loop2 = 0)
897
898loop=uint(loop_special)-1
899;loop2=34
900loop2=10
901domain='d01'
902filesWRF = FindFile(les_path+'/wrfout_'+domain+'_????-??-??_??:??:??')
903anomalw=1.
904
905zqtrac1 = dblarr(nx,ny,nz) & zqtrac2 = dblarr(nx,ny,nz)
906sigmazqtrac1 = fltarr(nz) & sigmazqtrac2 = fltarr(nz)
907sigmazminqtrac1 = fltarr(nz) & sigmazminqtrac2 = fltarr(nz)
908anomalqtrac1 = fltarr(nx,ny,nz) & anomalqtrac2 = fltarr(nx,ny,nz)
909zqtrac1 = getget(filesWRF(loop), 'qtrac1', count=[0,0,0,1], offset=[0,0,0,loop2])
910zqtrac2 = getget(filesWRF(loop), 'qtrac2', count=[0,0,0,1], offset=[0,0,0,loop2])
911wprime = getget(filesWRF(loop), 'W', anomaly = anomalw, count=[0,0,0,1], offset=[0,0,0,loop2])
912supermask1 = fltarr(nx,ny,nz)
913supermask2 = fltarr(nx,ny,nz)
914k_out_histo = 8
915k_out_hist = [1,10,25,50,70,85]
916nbtest=n_elements(k_out_hist)
917b=0
918FOR k=0,nz-1 DO BEGIN
919        mask1=fltarr(nx*ny)
920        mask2=fltarr(nx*ny)
921        anomalqtrac1(*,*,k) = zqtrac1(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac1(*,*,k)),1),1)/ float(nx) / float(ny)
922        sigmazqtrac1(k) = STDDEV(REFORM(zqtrac1(*,*,k)))
923        IF (k ne 0) THEN BEGIN
924                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
925                sigmazminqtrac1(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac1(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
926        ENDIF ELSE BEGIN
927                sigmazminqtrac1(k) = sigmazqtrac1(k)
928        ENDELSE
929        print, sigmazqtrac1(k),sigmazminqtrac1(k)
930        plumeIndex1 =  WHERE((anomalqtrac1(*,*,k) GT scale*MAX([sigmazqtrac1(k),sigmazminqtrac1(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
931;        anomalqtrac2(*,*,k) = zqtrac2(*,*,k) - TOTAL(TOTAL(REFORM(zqtrac2(*,*,k)),1),1)/ float(nx) / float(ny)
932;        sigmazqtrac2(k) = STDDEV(REFORM(zqtrac2(*,*,k)))
933        IF (k ne 0) THEN BEGIN
934                subsampledAltitudes = INTERPOL(altitudes_LES(0:k),findgen(k+1),findgen(decimate*k+1)/decimate)
935;                sigmazminqtrac2(k) = (sigmao/(altitudes_LES(k)-altitudes_LES(0)))*INT_TABULATED(subsampledAltitudes,INTERPOL(sigmazqtrac2(0:k),altitudes_LES(0:k),subsampledAltitudes),/DOUBLE)
936        ENDIF ELSE BEGIN
937;                sigmazminqtrac2(k) = sigmazqtrac2(k)
938        ENDELSE
939;        plumeIndex2 =  WHERE((anomalqtrac2(*,*,k) GT scale*MAX([sigmazqtrac2(k),sigmazminqtrac2(k)])) AND ((anomalw(k)+wprime(*,*,k)) GT 0.))
940        IF(plumeIndex1(0) NE -1 ) THEN BEGIN
941        mask1(plumeIndex1) = 1.
942        ENDIF ELSE BEGIN
943        mask1(*)=0.
944        ENDELSE
945        IF(plumeIndex2(0) NE -1 ) THEN BEGIN
946        mask2(plumeIndex2) = 1.
947        ENDIF ELSE BEGIN
948        mask2(*)=0.
949        ENDELSE
950        mask1 = reform(mask1,[nx,ny])
951        supermask1(*,*,k) = mask1(*,*)
952        mask2 = reform(mask2,[nx,ny])
953        supermask2(*,*,k) = mask2(*,*)
954;       IF (k eq k_out_histo) THEN BEGIN
955;               plume1_out = plumeIndex1
956;               plume2_out = plumeIndex2
957;       ENDIF   
958
959        IF (k eq k_out_hist(0)) THEN BEGIN
960                c1=plumeIndex1
961                c2=plumeIndex2
962        ENDIF
963        IF (k eq k_out_hist(1)) THEN BEGIN
964                d1=plumeIndex1
965                d2=plumeIndex2
966        ENDIF
967        IF (k eq k_out_hist(2)) THEN BEGIN
968                e1=plumeIndex1
969                e2=plumeIndex2
970        ENDIF
971        IF (k eq k_out_hist(3)) THEN BEGIN
972                f1=plumeIndex1
973                f2=plumeIndex2
974        ENDIF
975        IF (k eq k_out_hist(4)) THEN BEGIN
976                g1=plumeIndex1
977                g2=plumeIndex2
978        ENDIF
979        IF (k eq k_out_hist(5)) THEN BEGIN
980                h1=plumeIndex1
981                h2=plumeIndex2
982        ENDIF
983ENDFOR
984
985IF (Histo eq 'false') THEN BEGIN
986IVOLUME, supermask1
987IVOLUME, supermask2
988ENDIF ELSE BEGIN
989
990; -------------------------------------------------------------------------------
991; THIS IS THE ULTRA-GORE UN-ESTHETIC UGLY-AS-HELL LOOP FOR CONCENTRATION PLOTTING
992; but well, this is just because idl cannot handle arrays as well as I would like
993; -------------------------------------------------------------------------------
994filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Distrib.ps'
995PSOPEN, THICK=100, CHARSIZE=60, FILE = filename, FONT = 5, TFONT = 5,XPLOTS=2,YPLOTS=3,MARGIN=2000
996
997FOR n=0, nbtest-1 DO BEGIN
998
999CASE n OF
1000        0:BEGIN
1001                plume1_out=c1 & plume2_out=c2
1002        END
1003        1:BEGIN
1004                plume1_out=d1 & plume2_out=d2
1005        END
1006        2:BEGIN
1007                plume1_out=e1 & plume2_out=e2
1008        END
1009        3:BEGIN
1010                plume1_out=f1 & plume2_out=f2
1011        END
1012        4:BEGIN
1013                plume1_out=g1 & plume2_out=g2
1014        END
1015        5:BEGIN
1016                plume1_out=h1 & plume2_out=h2
1017        END
1018ENDCASE
1019 
1020ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
1021;ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
1022svmin1=min(ToBin1) & svmin2=min(ToBin2)
1023svmax1=max(ToBin1) & svmax2=max(ToBin2)
1024NBINS=100
1025ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
1026Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
1027Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
1028Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
1029Bin2=INTERPOL(HISTOGRAM(ToBin2,nbins=NBINS),Xaxis2,Xaxis1,/SPLINE)
1030
1031what_I_plot = [[Bin1],[Bin2]]
1032labels=['LES tracer 1 conc. distrib.','LES tracer 2 conc. distrib.']
1033
1034title_user = TestCase+SubCase+' LES tracer 1&2 concentration distribution at '+string(altitudes_LES(k_out_hist(n)))+'m AGL'
1035IF (n lt 3) THEN BEGIN
1036        POS, XPOS=1, YPOS=uint(n+1)
1037ENDIF ELSE BEGIN
1038        POS, XPOS=2, YPOS=uint(n+1)-3
1039ENDELSE
1040MAP
1041CS, SCALE=28
1042GSET, XMIN=0, XMAX=20, YMIN=0, YMAX=300, TITLE=title_user
1043cols=INDGEN(2)+2
1044GPLOT, X=Xaxis1, Y=what_I_plot, /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
1045AXES, XSTEP = 4, XTITLE='Trac concentration (kg/kg)', YSTEP=50, YTITLE='Counts',NDECS=1
1046
1047ToBin1 = reform(zqtrac1(*,*,k_out_hist(n)),[nx*ny,1])
1048ToBin2 = reform(zqtrac2(*,*,k_out_hist(n)),[nx*ny,1])
1049ToBin1 = ToBin1(plume1_out)
1050ToBin2 = ToBin2(plume2_out)
1051svmin1=min(ToBin1) & svmin2=min(ToBin2)
1052svmax1=max(ToBin1) & svmax2=max(ToBin2)
1053NBINS=50
1054ds1=(svmax1-svmin1+1.)/(NBINS-1) & ds2=(svmax2-svmin2+1.)/(NBINS-1)
1055Xaxis1 = svmin1+((svmax1-svmin1)/(NBINS-1))*indgen(NBINS)
1056Xaxis2 = svmin2+((svmax2-svmin2)/(NBINS-1))*indgen(NBINS)
1057Bin1=HISTOGRAM(ToBin1,nbins=NBINS)
1058Bin2=HISTOGRAM(ToBin2,nbins=NBINS)
1059oplot,  Xaxis1, Bin1, psym=4
1060oplot,  Xaxis2, Bin2, psym=5
1061
1062ENDFOR
1063
1064PSCLOSE, /NOVIEW
1065spawn, 'ps2png '+filename
1066
1067ENDELSE
1068
1069ENDIF ELSE BEGIN
1070
1071; =========================================================================
1072; =========================================================================
1073
1074print, '........ ALPHA'
1075
1076alpha_interlay_gcm = make_array(nZmx)
1077FOR k=0, nZmx-2 DO BEGIN
1078        alpha_interlay_gcm(k) = (alpha_gcm_lev(k,lt_plotindex_gcm)+alpha_gcm_lev(k+1,lt_plotindex_gcm))/2.
1079ENDFOR
1080alpha_interlay_gcm(nZmx-1)=0.
1081
1082smoothed_alpha1_les = make_array(nz)
1083smoothed_alpha2_les = make_array(nz)
1084smoothed_beta1_les = make_array(nz)
1085FOR t=-ns,ns DO BEGIN
1086        smoothed_alpha1_les = smoothed_alpha1_les + REFORM(alpha1out(*,lt_plotindex_les+t))
1087        smoothed_alpha2_les = smoothed_alpha2_les + REFORM(alpha2out(*,lt_plotindex_les+t))
1088        smoothed_beta1_les = smoothed_beta1_les + REFORM(beta1out(*,lt_plotindex_les+t))
1089ENDFOR
1090
1091smoothed_alpha1_les = smoothed_alpha1_les/nstot
1092smoothed_alpha2_les = smoothed_alpha2_les/nstot
1093smoothed_beta1_les = smoothed_beta1_les/nstot
1094
1095; =========================================================================
1096
1097; *** Temperatures ***
1098
1099print, '........ TEMPERATURES'
1100
1101xmin = 190
1102xmax = 250
1103if (TestCase eq 'Case_Z') then begin
1104xmin = 170
1105xmax = 250
1106endif
1107
1108
1109what_I_plot = [[reform(temp_gcm(*,lt_plotindex_gcm_ini))],[reform(temp_gcm(*,lt_plotindex_gcm0))],[reform(temp_gcm(*,lt_plotindex_gcm))],[reform(temp_gcm(*,lt_plotindex_gcm2))],[reform(temp_gcm(*,lt_plotindex_gcm3))],[reform(temp_gcm(*,lt_plotindex_gcm4))]]
1110labels=['TH temp 1d, lt='+string(lt_plot_ini),'TH temp 1d, lt='+string(lt_plot0),'TH temp 1d, lt='+string(lt_plot),'TH temp 1d, lt='+string(lt_plot2),'TH temp 1d, lt='+string(lt_plot3),'TH temp 1d, lt='+string(lt_plot4)]
1111title_user = TestCase+SubCase+LayerCase+' Temperatures Comparison'
1112filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Temperature.ps'
1113PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1114CS, SCALE=28
1115GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=12, TITLE=title_user
1116cols=INDGEN(6)+2
1117GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1118AXES, XSTEP = 5, XTITLE='Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
1119
1120oplot, temp_les(*,lt_plotindex_les_ini), altitudes_LES/1000., psym=4
1121oplot, temp_les(*,lt_plotindex_les0), altitudes_LES/1000., psym=4
1122oplot, temp_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
1123oplot, temp_les(*,lt_plotindex_les2), altitudes_LES/1000., psym=4
1124oplot, temp_les(*,lt_plotindex_les3), altitudes_LES/1000., psym=4
1125oplot, temp_les(*,lt_plotindex_les4), altitudes_LES/1000., psym=4
1126
1127if(overplot_convadj EQ 'true') then begin
1128oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj0), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
1129oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
1130oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj2), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
1131oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj3), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
1132oplot, temp_gcm_convadj(*,lt_plotindex_gcm_convadj4), altitudes_GCM/1000., thick=0.1,color=8,linestyle=3
1133endif
1134
1135
1136PSCLOSE, /NOVIEW
1137
1138spawn, 'ps2png '+filename
1139
1140; *** Pressions ***
1141
1142print, '........ PRESSURES'
1143
1144;what_I_plot = make_array(nZmx)
1145;labels=['TH P 1d, lt='+string(lt_plot)]
1146;title_user = TestCase+SubCase+' Pressure Comparisons'
1147;filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
1148;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1149;CS, SCALE=28
1150;GSET, XMIN=600, XMAX=900, YMIN=0, YMAX=0.5, TITLE=title_user
1151;cols=INDGEN(1)+2
1152;GPLOT, X=pplay(*,lt_plotindex_gcm), Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1153;AXES, XSTEP = 25, XTITLE='Log P', YSTEP=0.1, YTITLE='Altitude (km)',NDECS=1
1154;
1155;oplot, pt(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
1156;
1157;PSCLOSE, /NOVIEW
1158;
1159;spawn, 'ps2png '+filename
1160
1161what_I_plot = make_array(nZmx)
1162labels=['TH P 1d, lt='+string(lt_plot)]
1163title_user = TestCase+SubCase+LayerCase+' Pressure Comparisons'
1164filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Pressure.ps'
1165PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1166CS, SCALE=28
1167GSET, XMIN=400, XMAX=900, YMIN=0, YMAX=10, TITLE=title_user
1168cols=INDGEN(1)+2
1169GPLOT, X=pplay(*,lt_plotindex_gcm), Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1170AXES, XSTEP = 25, XTITLE='Pression (Pa)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
1171
1172oplot, pt(*,lt_plotindex_les),altitudes_LES/1000., psym=4
1173
1174PSCLOSE, /NOVIEW
1175
1176spawn, 'ps2png '+filename
1177
1178
1179; *** Temperatures potentielles ***
1180if(full eq 'true') then begin
1181
1182xmin = 185
1183xmax = 240
1184if (TestCase eq 'Case_C') then begin
1185xmin = 200
1186xmax = 255
1187endif
1188if (TestCase eq 'Case_I') then begin
1189xmin = 195
1190xmax = 250
1191endif
1192if (TestCase eq 'Case_Z') then begin
1193xmin = 230
1194xmax = 290
1195endif
1196if (TestCase eq 'ExtremeCase') then begin
1197xmin = 195
1198xmax = 260
1199endif
1200
1201print, '........ POTENTIAL TEMPERATURES'
1202what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
1203labels=['TH teta 1d, lt='+string(lt_plot_ini),'TH teta 1d, lt='+string(lt_plot0),'TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3),'TH teta 1d, lt='+string(lt_plot4)]
1204title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
1205filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
1206PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1207CS, SCALE=28
1208GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=1.4, TITLE=title_user
1209cols=INDGEN(6)+2
1210GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1211AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
1212
1213oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1214oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1215oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1216oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1217oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1218oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1219if(overplot_convadj EQ 'true') then begin
1220oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
1221oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
1222oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
1223oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
1224oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
1225endif
1226oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
1227
1228PSCLOSE, /NOVIEW
1229
1230spawn, 'ps2png '+filename
1231
1232xmin = 230
1233xmax = 245
1234what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm)),tsurf_gcm(lt_plotindex_gcm)],[reform(teta_gcm(*,lt_plotindex_gcm2)),tsurf_gcm(lt_plotindex_gcm2)]]
1235labels=['TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2)]
1236title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
1237filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta_zoom.ps'
1238PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1239CS, SCALE=28
1240GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=0.05, TITLE=title_user
1241cols=INDGEN(2)+2
1242GPLOT, X=what_I_plot, Y=[0.,-alog(pplay(*,lt_plotindex_gcm)/pGround)], /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1243AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.005, YTITLE='-Log(P/P0) ',NDECS=1
1244
1245;oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1246;oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1247oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1248oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1249;oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1250;oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1251if(overplot_convadj EQ 'true') then begin
1252;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj0), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj0)/pGround), thick=0.1,color=8,linestyle=3
1253oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj)/pGround), thick=0.1,color=8,linestyle=3
1254oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj2), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj2)/pGround), thick=0.1,color=8,linestyle=3
1255;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj3), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj3)/pGround), thick=0.1,color=8,linestyle=3
1256;oplot, teta_gcm_convadj(*,lt_plotindex_gcm_convadj4), -alog(pplay_convadj(*,lt_plotindex_gcm_convadj4)/pGround), thick=0.1,color=8,linestyle=3
1257endif
1258;oplot, teta_gcm_0(*), -alog(pplay(*,lt_plotindex_gcm)/pGround)
1259
1260PSCLOSE, /NOVIEW
1261
1262spawn, 'ps2png '+filename
1263
1264
1265if (plot_3d eq 'true') then begin
1266what_I_plot = [[reform(teta_gcm(*,lt_plotindex_gcm_ini))],[reform(teta_gcm(*,lt_plotindex_gcm0))],[reform(teta_gcm(*,lt_plotindex_gcm))],[reform(teta_gcm(*,lt_plotindex_gcm2))],[reform(teta_gcm(*,lt_plotindex_gcm3))],[reform(teta_gcm(*,lt_plotindex_gcm4))]]
1267labels=['TH teta 1d, lt='+string(lt_plot_ini),'TH teta 1d, lt='+string(lt_plot0),'TH teta 1d, lt='+string(lt_plot),'TH teta 1d, lt='+string(lt_plot2),'TH teta 1d, lt='+string(lt_plot3),'TH teta 1d, lt='+string(lt_plot4)]
1268title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
1269filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
1270PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1271CS, SCALE=28
1272GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=1.4, TITLE=title_user
1273cols=INDGEN(6)+2
1274GPLOT, X=what_I_plot, Y=-alog(pplay_3d(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1275AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
1276
1277oplot, teta_les(*,lt_plotindex_les_ini), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1278oplot, teta_les(*,lt_plotindex_les0), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1279oplot, teta_les(*,lt_plotindex_les), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1280oplot, teta_les(*,lt_plotindex_les2), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1281oplot, teta_les(*,lt_plotindex_les3), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1282oplot, teta_les(*,lt_plotindex_les4), -alog(pt(*,lt_plotindex_les)/pGround), psym=4
1283
1284PSCLOSE, /NOVIEW
1285
1286spawn, 'ps2png '+filename
1287endif
1288
1289endif else begin
1290
1291print, '........ POTENTIAL TEMPERATURES'
1292
1293what_I_plot = reform(teta_gcm(*,lt_plotindex_gcm))
1294labels=['TH teta 1d, lt='+string(lt_plot)]
1295title_user = TestCase+SubCase+LayerCase+' Teta comparisons (recomputed from T and P)'
1296filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Teta.ps'
1297PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1298CS, SCALE=28
1299GSET, XMIN=210, XMAX=240, YMIN=0, YMAX=2, TITLE=title_user
1300cols=INDGEN(1)+2
1301GPLOT, X=what_I_plot, Y=-alog(pplay(*,lt_plotindex_gcm)/pGround), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1302AXES, XSTEP = 5, XTITLE='Potential temperature (K)', YSTEP=0.2, YTITLE='-Log(P/P0) ',NDECS=1
1303
1304oplot, teta_les(*,lt_plotindex_les),-alog(pt(*,lt_plotindex_les)/pGround), psym=4
1305PSCLOSE, /NOVIEW
1306
1307spawn, 'ps2png '+filename
1308endelse
1309
1310print, '........ SURFACE TEMPERATURES'
1311what_I_plot = tsurf_gcm
1312labels=['TH 1d tsurf']
1313title_user = TestCase+SubCase+LayerCase+' Surface temperatures (recomputed from T and P)'
1314filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tsurf.ps'
1315PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1316CS, SCALE=28
1317GSET, XMIN=6, XMAX=18, YMIN=200, YMAX=300, TITLE=title_user
1318cols=INDGEN(1)+2
1319GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1320AXES, XSTEP = 1, XTITLE='local time (h)', YSTEP=5., YTITLE='Surface temperature',NDECS=1
1321
1322oplot, localtime, tsurf, psym=4
1323PSCLOSE, /NOVIEW
1324
1325spawn, 'ps2png '+filename
1326
1327
1328; ---------------------- *** Vitesses verticales *** -------------------------------
1329; ------------ Verification de l'approx terrestre wmax = vmoy dans la couche instable
1330
1331print, '........ CHECKING wmax = vmoy in unstable layer'
1332
1333what_I_plot = uv_moy(*,lt_plotindex_les)
1334labels=['LES uv_moy']
1335title_user = TestCase+SubCase+LayerCase+' LES mean UV comp to max W in plume trac1'
1336filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_UV.ps'
1337PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1338CS, SCALE=28
1339GSET, XMIN=0, XMAX=10, YMIN=0, YMAX=10, TITLE=title_user
1340cols=INDGEN(1)+2
1341GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1342AXES, YSTEP = 1, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Mean horizontal velocity inside domain (m/s)',NDECS=1
1343
1344oplot, make_array(nz,value=wmax(lt_plotindex_les)), altitudes_LES/1000., psym=4
1345
1346PSCLOSE, /NOVIEW
1347
1348spawn, 'ps2png '+filename
1349
1350; ------------ Profil de vitesse
1351
1352print, '........ VERTICAL VELOCITY'
1353
1354what_I_plot = make_array(nZmx)
1355FOR k=0, nZmx-2 DO BEGIN
1356        what_I_plot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
1357ENDFOR
1358what_I_plot(nZmx-1) = 0.
1359
1360smoothed_w_mean1_les = make_array(nz)
1361smoothed_w_mean2_les = make_array(nz)
1362smoothed_w_mean1_down_les = make_array(nz)
1363FOR t=-ns,ns DO BEGIN
1364        smoothed_w_mean1_les = smoothed_w_mean1_les + REFORM(w_mean1(*,lt_plotindex_les+t))
1365        smoothed_w_mean2_les = smoothed_w_mean2_les + REFORM(w_mean2(*,lt_plotindex_les+t))
1366        smoothed_w_mean1_down_les = smoothed_w_mean1_down_les + REFORM(w_mean1_down(*,lt_plotindex_les+t))
1367ENDFOR
1368
1369smoothed_w_mean1_les = smoothed_w_mean1_les/nstot
1370smoothed_w_mean2_les = smoothed_w_mean2_les/nstot
1371smoothed_w_mean1_down_les = smoothed_w_mean1_down_les/nstot
1372
1373ratio = make_array(nz)
1374FOR k=0, nz-1 DO BEGIN
1375        IF(smoothed_w_mean1_les(k) ne 0.) then ratio(k) = smoothed_w_mean1_down_les(k)/smoothed_w_mean1_les(k) else ratio(k)=0.
1376ENDFOR
1377
1378labels=['TH 1d w, lt='+string(lt_plot)]
1379title_user = TestCase+SubCase+LayerCase+' Vertical velocity comparisons (inside thermal)'
1380filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Wprofile.ps'
1381PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1382CS, SCALE=28
1383GSET, XMIN=-6, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
1384cols=INDGEN(1)+2
1385GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1386AXES, YSTEP = 2, YTITLE='Altitude (km)', XSTEP=1, XTITLE='Vertical velocity inside thermal (m/s)',NDECS=1
1387
1388oplot, smoothed_w_mean1_les, altitudes_LES/1000., psym=4
1389oplot, smoothed_w_mean2_les, altitudes_LES/1000., psym=5
1390oplot, smoothed_w_mean1_down_les, altitudes_LES/1000., psym=6
1391
1392PSCLOSE, /NOVIEW
1393
1394spawn, 'ps2png '+filename
1395
1396
1397; *** Static stability ***
1398
1399print, '........ STATIC STABILITY'
1400
1401dteta_dz_gcm = deriv(altitudes_GCM,reform(teta_gcm(*,lt_plotindex_gcm)))
1402dteta_dz_les = deriv(altitudes_LES,reform(teta_les(*,lt_plotindex_les)))
1403
1404what_I_plot = dteta_dz_gcm
1405labels=['TH static stability 1d']
1406title_user = TestCase+SubCase+LayerCase+' Static stability comparison'
1407filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dTetadz.ps'
1408PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1409CS, SCALE=28
1410GSET, XMIN=-0.002, XMAX=0.006, YMIN=0, YMAX=10, TITLE=title_user
1411cols=INDGEN(1)+2
1412GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1413AXES, XSTEP = 0.0005 , XTITLE='Static stability (K.m-1)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
1414
1415oplot, dteta_dz_les, altitudes_LES/1000., psym=4
1416
1417PSCLOSE, /NOVIEW
1418
1419spawn, 'ps2png '+filename
1420
1421print,' -----------------------------------------------------------------------------------------------------------------------'
1422print,' ***  LES diagnostics of the PLUME *** MUAHAHAHAHAHA'
1423print,' V2 with E and D computed for a UDE plume'
1424print,' -----------------------------------------------------------------------------------------------------------------------'
1425
1426print, '........ EXTRACTING DATA'
1427
1428; --- Reinterpolation of F
1429
1430fm_therm_gcm_interlay = make_array(nZmx,nTmx)
1431
1432FOR k=0, nZmx-2 DO BEGIN
1433        fm_therm_gcm_interlay(k,*) = (fm_therm_gcm_lev(k,*) + fm_therm_gcm_lev(k+1,*))/2.
1434ENDFOR
1435fm_therm_gcm_interlay(nZmx-1,*)=0.
1436
1437; --- Calculation of gcm df/dz using entrainment and detrainments and NOT F
1438
1439df_dz_gcm = deriv(altitudes_GCM,reform(fm_therm_gcm_interlay(*,lt_plotindex_gcm)))
1440 
1441; --- Smoothing of the mass flux on a user-defined window
1442
1443smoothed_fm_trac1_les = make_array(nz)
1444smoothed_fm_trac2_les = make_array(nz)
1445smoothed_downward_fm_trac1_les = make_array(nz)
1446FOR t=-ns,ns DO BEGIN
1447        smoothed_fm_trac1_les = smoothed_fm_trac1_les + REFORM(fm_trac1_les(*,lt_plotindex_les+t))
1448        smoothed_fm_trac2_les = smoothed_fm_trac2_les + REFORM(fm_trac2_les(*,lt_plotindex_les+t))
1449        smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les + REFORM(downward_flux1(*,lt_plotindex_les+t))
1450ENDFOR
1451
1452smoothed_fm_trac1_les = smoothed_fm_trac1_les/nstot
1453smoothed_fm_trac2_les = smoothed_fm_trac2_les/nstot
1454smoothed_downward_fm_trac1_les = smoothed_downward_fm_trac1_les/nstot
1455
1456; --- Calculation of the entrainement rate according to Rio(2010)
1457; done in the heavy part at the begining (reeaaaally heavy)
1458
1459; --- Smoothing of the entrainment on a ~30min window
1460
1461; term 1
1462
1463
1464smoothed_e_term1_trac1_les = make_array(nz)
1465smoothed_e_term1_trac2_les = make_array(nz)
1466FOR t=-ns,ns DO BEGIN
1467        smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les + REFORM(e_trac1_les(*,lt_plotindex_les+t))
1468        smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les + REFORM(e_trac2_les(*,lt_plotindex_les+t))
1469ENDFOR
1470
1471smoothed_e_term1_trac1_les = smoothed_e_term1_trac1_les/nstot
1472smoothed_e_term1_trac2_les = smoothed_e_term1_trac2_les/nstot
1473
1474smoothed_e_rate_term1_trac1_les = make_array(nz)
1475smoothed_e_rate_trac2_les = smoothed_e_term1_trac2_les
1476
1477; it already is an entrainment rate ! KIND OF : it is E/Mc, and Mc is not F !! NOW it is Mc/deltaTeta * dchi/dz
1478FOR k=0, nz-1 DO BEGIN
1479        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_trac1_les(k) = smoothed_e_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_trac1_les(k) =0.
1480;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_e_rate_trac2_les(k) = smoothed_e_trac2_les(k)/smoothed_fm_trac2_les(k) ELSE smoothed_e_rate_trac2_les(k) =0.
1481ENDFOR
1482
1483; term 2  & 3
1484
1485
1486smoothed_e_term2_trac1_les = make_array(nz)
1487smoothed_e_term3_trac1_les = make_array(nz)
1488smoothed_e_term1_ude_trac1_les = make_array(nz)
1489smoothed_e_term2_ude_trac1_les = make_array(nz)
1490smoothed_e_term3_ude_trac1_les = make_array(nz)
1491
1492FOR t=-ns,ns DO BEGIN
1493        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
1494        smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les + REFORM(e1_term2(*,lt_plotindex_les+t))
1495        smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les + REFORM(e1_term1_ude(*,lt_plotindex_les+t))
1496        smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les + REFORM(e1_term2_ude(*,lt_plotindex_les+t))
1497        smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les + REFORM(e1_term3_ude(*,lt_plotindex_les+t))
1498ENDFOR
1499
1500smoothed_e_term2_trac1_les = smoothed_e_term2_trac1_les/nstot
1501smoothed_e_term3_trac1_les = smoothed_e_term3_trac1_les/nstot
1502smoothed_e_term1_ude_trac1_les = smoothed_e_term1_ude_trac1_les/nstot
1503smoothed_e_term2_ude_trac1_les = smoothed_e_term2_ude_trac1_les/nstot
1504smoothed_e_term3_ude_trac1_les = smoothed_e_term3_ude_trac1_les/nstot
1505
1506smoothed_e_rate_term2_trac1_les = make_array(nz)
1507smoothed_e_rate_term3_trac1_les = make_array(nz)
1508smoothed_e_rate_term1_ude_trac1_les = make_array(nz)
1509smoothed_e_rate_term2_ude_trac1_les = make_array(nz)
1510smoothed_e_rate_term3_ude_trac1_les = make_array(nz)
1511
1512FOR k=0, nz-1 DO BEGIN
1513        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_trac1_les(k) = smoothed_e_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_trac1_les(k) =0.
1514        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_trac1_les(k) = smoothed_e_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_trac1_les(k) =0.
1515        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term1_ude_trac1_les(k) = smoothed_e_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term1_ude_trac1_les(k) =0.
1516        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term2_ude_trac1_les(k) = smoothed_e_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term2_ude_trac1_les(k) =0.
1517        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_e_rate_term3_ude_trac1_les(k) = smoothed_e_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_e_rate_term3_ude_trac1_les(k) =0.
1518
1519ENDFOR
1520
1521; --- Summing...
1522
1523smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les + smoothed_e_rate_term3_trac1_les
1524smoothed_e_rate_ude_trac1_les = smoothed_e_rate_term1_ude_trac1_les + smoothed_e_rate_term2_ude_trac1_les + smoothed_e_rate_term3_ude_trac1_les
1525
1526;print, 'ommiting term3'
1527;smoothed_e_rate_trac1_les = smoothed_e_rate_term1_trac1_les + smoothed_e_rate_term2_trac1_les
1528
1529; --- Smoothing of the detrainment rate
1530
1531smoothed_d_term1_trac1_les = make_array(nz)
1532smoothed_d_term2_trac1_les = make_array(nz)
1533smoothed_d_term3_trac1_les = make_array(nz)
1534smoothed_d_term1_ude_trac1_les = make_array(nz)
1535smoothed_d_term2_ude_trac1_les = make_array(nz)
1536smoothed_d_term3_ude_trac1_les = make_array(nz)
1537
1538FOR t=-ns,ns DO BEGIN
1539        smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les + REFORM(d1_term1(*,lt_plotindex_les+t))
1540        smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les + REFORM(d1_term2(*,lt_plotindex_les+t))
1541        smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les + REFORM(d1_term3(*,lt_plotindex_les+t))
1542        smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les + REFORM(d1_term1_ude(*,lt_plotindex_les+t))
1543        smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les + REFORM(d1_term2_ude(*,lt_plotindex_les+t))
1544        smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les + REFORM(d1_term3_ude(*,lt_plotindex_les+t))
1545ENDFOR
1546
1547smoothed_d_term1_trac1_les = smoothed_d_term1_trac1_les/nstot
1548smoothed_d_term2_trac1_les = smoothed_d_term2_trac1_les/nstot
1549smoothed_d_term3_trac1_les = smoothed_d_term3_trac1_les/nstot
1550smoothed_d_term1_ude_trac1_les = smoothed_d_term1_ude_trac1_les/nstot
1551smoothed_d_term2_ude_trac1_les = smoothed_d_term2_ude_trac1_les/nstot
1552smoothed_d_term3_ude_trac1_les = smoothed_d_term3_ude_trac1_les/nstot
1553
1554smoothed_d_rate_term1_trac1_les = make_array(nz)
1555smoothed_d_rate_term2_trac1_les = make_array(nz)
1556smoothed_d_rate_term3_trac1_les = make_array(nz)
1557smoothed_d_rate_term1_ude_trac1_les = make_array(nz)
1558smoothed_d_rate_term2_ude_trac1_les = make_array(nz)
1559smoothed_d_rate_term3_ude_trac1_les = make_array(nz)
1560
1561FOR k=0, nz-1 DO BEGIN
1562        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term1_trac1_les(k) = smoothed_d_term1_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term1_trac1_les(k) =0.
1563        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term2_trac1_les(k) = smoothed_d_term2_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term2_trac1_les(k) =0.
1564        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_term3_trac1_les(k) = smoothed_d_term3_trac1_les(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_term3_trac1_les(k) =0.
1565        IF (smoothed_fm_trac1_les(k) ne 0.) THEN BEGIN
1566        smoothed_d_rate_term1_ude_trac1_les(k) = smoothed_d_term1_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
1567        smoothed_d_rate_term2_ude_trac1_les(k) = smoothed_d_term2_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
1568        smoothed_d_rate_term3_ude_trac1_les(k) = smoothed_d_term3_ude_trac1_les(k)/smoothed_fm_trac1_les(k)
1569        ENDIF ELSE BEGIN
1570        smoothed_d_rate_term1_ude_trac1_les(k)=0.
1571        smoothed_d_rate_term2_ude_trac1_les(k)=0.
1572        smoothed_d_rate_term3_ude_trac1_les(k)=0.
1573        ENDELSE
1574ENDFOR
1575
1576; --- Summing...
1577
1578smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les+smoothed_d_rate_term3_trac1_les
1579smoothed_d_rate_ude_trac1_les = smoothed_d_rate_term1_ude_trac1_les+smoothed_d_rate_term2_ude_trac1_les+smoothed_d_rate_term3_ude_trac1_les
1580;print, 'ommiting term3'
1581;smoothed_d_rate_trac1_les = smoothed_d_rate_term1_trac1_les+smoothed_d_rate_term2_trac1_les
1582
1583; --- PLOTTING : BUOYANCY TERM
1584
1585smoothed_buoyancy_trac1_les = make_array(nz)
1586smoothed_buoyancy_ude_trac1_les = make_array(nz)
1587smoothed_buoyancy_trac2_les = make_array(nz)
1588smoothed_buoyancy_downdraft1_les_ude = make_array(nz)
1589
1590FOR t=-ns,ns DO BEGIN
1591        smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les + REFORM(buoyancy1_les(*,lt_plotindex_les+t))
1592        smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les + REFORM(grav*(tplume1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
1593        smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les + REFORM(buoyancy2_les(*,lt_plotindex_les+t))
1594        smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude + REFORM(grav*(tdown1moy(*,lt_plotindex_les+t)/tenv1moy_ude(*,lt_plotindex_les+t)-1.))
1595ENDFOR
1596
1597smoothed_buoyancy_trac1_les = smoothed_buoyancy_trac1_les/nstot
1598smoothed_buoyancy_ude_trac1_les = smoothed_buoyancy_ude_trac1_les/nstot
1599smoothed_buoyancy_trac2_les = smoothed_buoyancy_trac2_les/nstot
1600smoothed_buoyancy_downdraft1_les_ude = smoothed_buoyancy_downdraft1_les_ude/nstot
1601
1602print, '........ BUOYANCY'
1603
1604what_I_plot = [[buoyancy_gcm(*,lt_plotindex_gcm)],[buoyancy_est_gcm(*,lt_plotindex_gcm)]]
1605labels=['TH buoyancy term','TH estimated buoyancy in plume']
1606title_user = TestCase+SubCase+LayerCase+' UDE plume buoyancy'
1607filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_B.ps'
1608PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1609CS, SCALE=28
1610GSET, XMIN=-0.06, XMAX=0.06, YMIN=0, YMAX=10, TITLE=title_user
1611cols=INDGEN(2)+2
1612GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1613AXES, XSTEP = 0.01 , XTITLE='N.m-1', YSTEP=1, YTITLE=' Altitude (km)',NDECS=3
1614
1615;oplot, smoothed_buoyancy_trac1_les, altitudes_LES/1000., psym=4
1616;oplot, smoothed_buoyancy_trac2_les, altitudes_LES/1000., psym=5
1617print, smoothed_buoyancy_ude_trac1_les
1618oplot, smoothed_buoyancy_ude_trac1_les, altitudes_LES/1000., psym=4
1619oplot, smoothed_buoyancy_downdraft1_les_ude, altitudes_LES/1000., psym=7
1620
1621PSCLOSE, /NOVIEW
1622
1623spawn, 'ps2png '+filename
1624
1625
1626; --- PLOTTING : MASS FLUX
1627
1628print, '........ MASS FLUX'
1629
1630f_gcm = fm_therm_gcm_interlay(*,lt_plotindex_gcm)
1631what_I_plot = f_gcm
1632labels=['TH mass flux']
1633title_user = TestCase+SubCase+LayerCase+' mass flux comparison, average over '+taverage+' mn'
1634filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_f.ps'
1635PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1636CS, SCALE=28
1637GSET, XMIN=-0.008, XMAX=0.008, YMIN=0, YMAX=10, TITLE=title_user
1638cols=INDGEN(1)+2
1639GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1640AXES, XSTEP = 0.002 , XTITLE='Kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
1641
1642oplot, smoothed_fm_trac1_les, altitudes_LES/1000., psym=4
1643oplot, smoothed_fm_trac2_les, altitudes_LES/1000., psym=5
1644oplot, smoothed_downward_fm_trac1_les, altitudes_LES/1000., psym=6
1645
1646PSCLOSE, /NOVIEW
1647
1648spawn, 'ps2png '+filename
1649
1650
1651; --- PLOTTING : MASS FLUX DERIVATIVE
1652
1653print, '........ MASS FLUX DERIVATIVE'
1654
1655df_dz_les1 = deriv(altitudes_LES,reform(smoothed_fm_trac1_les))
1656df_dz_les2 = deriv(altitudes_LES,reform(smoothed_fm_trac2_les))
1657
1658what_I_plot = df_dz_gcm
1659labels=['TH mass flux vertical derivative']
1660title_user = TestCase+SubCase+LayerCase+' mass flux vertical derivative comparison, average over '+taverage+' mn'
1661filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdz.ps'
1662PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1663CS, SCALE=28
1664GSET, XMIN=-0.00002, XMAX=0.00002, YMIN=0, YMAX=10, TITLE=title_user
1665cols=INDGEN(1)+2
1666GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1667AXES, XSTEP = 0.000005 , XTITLE='Kg.m-3.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=6
1668oplot, df_dz_les1, altitudes_LES/1000., psym=4
1669oplot, df_dz_les2, altitudes_LES/1000., psym=5
1670
1671PSCLOSE, /NOVIEW
1672
1673spawn, 'ps2png '+filename
1674
1675; --- PLOTTING : ENTRAINMENT RATE e = E/f
1676
1677print, '........ ENTRAINMENT RATE'
1678
1679e_gcm = make_array(nZmx)
1680
1681FOR k=0, nZmx-1 DO BEGIN
1682        IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
1683                e_gcm(k) = zdz_entr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
1684        ENDIF ELSE BEGIN
1685                e_gcm(k) = 0.
1686        ENDELSE
1687ENDFOR
1688
1689
1690what_I_plot = e_gcm
1691labels=['TH entrainment rate']
1692title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
1693filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e.ps'
1694PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1695CS, SCALE=28
1696GSET, XMIN=-0.003, XMAX=0.003, YMIN=0, YMAX=10, TITLE=title_user
1697cols=INDGEN(1)+2
1698GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1699AXES, XSTEP = 0.0006 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
1700
1701oplot, smoothed_e_rate_ude_trac1_les, altitudes_LES/1000., psym=4
1702;oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
1703;oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
1704
1705PSCLOSE, /NOVIEW
1706
1707spawn, 'ps2png '+filename
1708
1709; --- PLOTTING : EXTENDED ENTRAINMENT RATE
1710
1711print, '........ EXTENDED ENTRAINMENT RATE'
1712
1713;what_I_plot = [[smoothed_e_rate_term1_trac1_les],[smoothed_e_rate_term2_trac1_les],[smoothed_e_rate_term3_trac1_les],[smoothed_e_rate_trac1_les]]
1714what_I_plot = [[smoothed_e_rate_term1_ude_trac1_les],[smoothed_e_rate_term2_ude_trac1_les],[smoothed_e_rate_term3_ude_trac1_les],[smoothed_e_rate_ude_trac1_les]]
1715labels=['LES base entrainment rate','LES term2 e rate','LES term3 e rate','LES total e rate']
1716title_user = TestCase+SubCase+LayerCase+' UDE entrainment rate comparison, average over '+taverage+' mn'
1717filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_terms.ps'
1718PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1719CS, SCALE=28
1720GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
1721cols=INDGEN(4)+2
1722GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1723AXES, XSTEP = 0.005 , XTITLE='entrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
1724
1725PSCLOSE, /NOVIEW
1726
1727spawn, 'ps2png '+filename
1728
1729
1730; --- PLOTTING : EXTENDED DETRAINMENT RATE
1731
1732print, '........ EXTENDED DETRAINMENT RATE'
1733
1734what_I_plot = [[smoothed_d_rate_term1_ude_trac1_les],[smoothed_d_rate_term2_ude_trac1_les],[smoothed_d_rate_term3_ude_trac1_les],[smoothed_d_rate_ude_trac1_les]]
1735labels=['LES term 1 detrainment rate','LES term2 d rate','LES term3 d rate','LES Total d rate']
1736title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
1737filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_terms.ps'
1738PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1739CS, SCALE=28
1740GSET, XMIN=-0.01, XMAX=0.01, YMIN=0, YMAX=10, TITLE=title_user
1741cols=INDGEN(4)+2
1742GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1743AXES, XSTEP = 0.002 , XTITLE='detrainment rate m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
1744
1745PSCLOSE, /NOVIEW
1746
1747spawn, 'ps2png '+filename
1748
1749; --- PLOTTING : DETRAINMENT RATE d = D/f
1750
1751print, '........ DETRAINMENT RATE'
1752
1753;smoothed_d_rate_trac2_les = make_array(nz)
1754;
1755;FOR k=0, nz-1 DO BEGIN
1756;        IF (smoothed_fm_trac1_les(k) ne 0.) THEN smoothed_d_rate_trac1_les(k) = smoothed_e_rate_trac1_les(k) - df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE smoothed_d_rate_trac1_les(k) =0.
1757;        IF (smoothed_fm_trac2_les(k) ne 0.) THEN smoothed_d_rate_trac2_les(k) = smoothed_e_rate_trac2_les(k) - df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE smoothed_d_rate_trac2_les(k) =0.
1758;ENDFOR
1759;
1760d_gcm = make_array(nZmx)
1761FOR k=0, nZmx-1 DO BEGIN
1762        IF (fm_therm_gcm_interlay(k,lt_plotindex_gcm) ne 0.) THEN BEGIN
1763                d_gcm(k) = zdz_detr_therm_gcm(k,lt_plotindex_gcm)/(approx_zdz_gcm(k)*fm_therm_gcm_interlay(k,lt_plotindex_gcm))
1764        ENDIF ELSE BEGIN
1765                d_gcm(k) = 0.
1766        ENDELSE
1767ENDFOR
1768
1769what_I_plot = d_gcm
1770labels=['TH detrainment rate']
1771title_user = TestCase+SubCase+LayerCase+' UDE detrainment rate comparison, average over '+taverage+' mn'
1772filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d.ps'
1773PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1774CS, SCALE=28
1775GSET, XMIN=0., XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
1776cols=INDGEN(1)+2
1777GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1778AXES, XSTEP = 0.005 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
1779
1780oplot, smoothed_d_rate_ude_trac1_les, altitudes_LES/1000., psym=4
1781;oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
1782;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
1783
1784PSCLOSE, /NOVIEW
1785spawn, 'ps2png '+filename
1786
1787; --- PLOTTING : FRACTION COVERAGE
1788
1789print, '........ EXTENDED ALPHA'
1790
1791what_I_plot = alpha_interlay_gcm
1792labels=['TH alpha']
1793title_user = TestCase+SubCase+LayerCase+' fraction coverage comparison, average over '+taverage+' mn'
1794filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_alpha.ps'
1795PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1796CS, SCALE=28
1797GSET, XMIN=0., XMAX=1., YMIN=0, YMAX=10, TITLE=title_user
1798cols=INDGEN(1)+2
1799GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1800AXES, XSTEP = 0.1 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
1801
1802oplot, smoothed_alpha1_les, altitudes_LES/1000., psym=4
1803oplot, smoothed_alpha2_les, altitudes_LES/1000., psym=5
1804oplot, smoothed_beta1_les, altitudes_LES/1000., psym=6
1805
1806PSCLOSE, /NOVIEW
1807spawn, 'ps2png '+filename
1808
1809; --- PLOTTING : THEORETICAL ENTRAINMENT RATE FROM LES DATA
1810
1811print, '........ PARAMETRIZED RATES'
1812
1813approx_zdz_les = make_array(nz)
1814
1815approx_zdz_les(0)=altitudes_LES(1)
1816FOR k=1, nz-2 DO BEGIN
1817        approx_zdz_les(k) = altitudes_LES(k+1) - altitudes_LES(k)
1818ENDFOR
1819approx_zdz_les(nz-1)=approx_zdz_les(nz-2)
1820
1821
1822theoretical_e_trac1_les = make_array(nz)
1823theoretical_e_trac2_les = make_array(nz)
1824
1825
1826FOR k=0, nz-1 DO BEGIN
1827        theoretical_e_trac1_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.)) - fact_epsilon)])
1828        theoretical_e_trac2_les(k) = MAX([0.,(betalpha/(1.+betalpha))*((afact*smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.)) - fact_epsilon)])
1829ENDFOR
1830
1831
1832what_I_plot = [[theoretical_e_trac1_les],[theoretical_e_trac2_les]]
1833labels=['LES TH theo e rate trac1','LES TH theo e rate trac2']
1834title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. rate comparison, average over '+taverage+' mn'
1835filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_theoretical.ps'
1836PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1837CS, SCALE=28
1838GSET, XMIN=-0.015, XMAX=0.03, YMIN=0, YMAX=10, TITLE=title_user
1839cols=INDGEN(2)+2
1840GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1841AXES, XSTEP = 0.003 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=3
1842
1843oplot, smoothed_e_rate_trac1_les, altitudes_LES/1000., psym=4
1844oplot, smoothed_e_rate_trac2_les, altitudes_LES/1000., psym=5
1845
1846PSCLOSE, /NOVIEW
1847
1848spawn, 'ps2png '+filename
1849
1850; --- PLOTTING : THEORETICAL DETRAINMENT RATE FROM LES DATA
1851; ZDZ STUFF REMOVED
1852
1853print, '........ PARAMETRIZED DETRAINMENT'
1854
1855theoretical_d_trac1_les = make_array(nz)
1856theoretical_d_trac2_les = make_array(nz)
1857
1858FOR k=0, nz-1 DO BEGIN
1859        theoretical_d_trac1_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac1_les(k)/((smoothed_w_mean1_les(k))^2.))])
1860        theoretical_d_trac2_les(k) = MAX([detr_min,-afact*(betalpha/(1.+betalpha))*(smoothed_buoyancy_trac2_les(k)/((smoothed_w_mean2_les(k))^2.))])
1861ENDFOR
1862
1863what_I_plot = [[theoretical_d_trac1_les],[theoretical_d_trac2_les]]
1864labels=['LES TH theo d rate trac1','LES TH theo d rate trac2']
1865title_user = TestCase+SubCase+LayerCase+' comp. theor. detr. rate comparison, average over '+taverage+' mn'
1866filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_theoretical.ps'
1867PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1868CS, SCALE=28
1869GSET, XMIN=-0.1, XMAX=0.1, YMIN=0, YMAX=10, TITLE=title_user
1870cols=INDGEN(2)+2
1871GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1872AXES, XSTEP = 0.01 , XTITLE='m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=2
1873
1874oplot, smoothed_d_rate_trac1_les, altitudes_LES/1000., psym=4
1875;oplot, smoothed_d_rate_trac2_les, altitudes_LES/1000., psym=5
1876
1877PSCLOSE, /NOVIEW
1878
1879spawn, 'ps2png '+filename
1880
1881; --- PLOTTING : THEORETICAL E-D  RATE FROM LES DATA
1882
1883print, '........ PARAMETRIZED MASS FLUX DERIVATIVE'
1884
1885theoretical_dfdz_f_trac1_les = make_array(nz)
1886theoretical_dfdz_f_trac2_les = make_array(nz)
1887
1888theoretical_dfdz_f_trac1_les = theoretical_e_trac1_les - theoretical_d_trac1_les
1889theoretical_dfdz_f_trac2_les = theoretical_e_trac2_les - theoretical_d_trac2_les
1890
1891df_dz_f_les1 = make_array(nz)
1892df_dz_f_les2 = make_array(nz)
1893
1894FOR k=0, nz-1 DO BEGIN
1895        IF (smoothed_fm_trac1_les(k) ne 0.) THEN df_dz_f_les1(k) = df_dz_les1(k)/smoothed_fm_trac1_les(k) ELSE df_dz_f_les1(k)=0.
1896        IF (smoothed_fm_trac2_les(k) ne 0.) THEN df_dz_f_les2(k) = df_dz_les2(k)/smoothed_fm_trac2_les(k) ELSE df_dz_f_les2(k)=0.
1897ENDFOR
1898
1899what_I_plot = [[theoretical_dfdz_f_trac1_les],[theoretical_dfdz_f_trac2_les]]
1900labels=['LES TH theo 1/f df/dz trac1','LES TH theo 1/f df/dz trac2']
1901title_user = TestCase+SubCase+LayerCase+' comp. theor. entr. - detr. rate comparison, average over '+taverage+' mn'
1902filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_dfdzf_theoretical.ps'
1903PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1904CS, SCALE=28
1905GSET, XMIN=-0.02, XMAX=0.02, YMIN=0, YMAX=10, TITLE=title_user
1906cols=INDGEN(2)+2
1907GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
1908AXES, XSTEP = 0.01 , XTITLE='entr - detr (rates) m-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
1909
1910oplot, df_dz_f_les1, altitudes_LES/1000., psym=4
1911oplot, df_dz_f_les2, altitudes_LES/1000., psym=5
1912
1913PSCLOSE, /NOVIEW
1914
1915spawn, 'ps2png '+filename
1916
1917; --- PLOTTING : e versus B/w2
1918
1919print, '........ BUOYANCY AND VERTICAL VELOCITY ENTRAINMENT RATE DEPENDENCY'
1920
1921B_w2_trac1 = make_array(nz)
1922B_w2_trac2 = make_array(nz)
1923;dwdz_trac1 = deriv(altitudes_LES,smoothed_w_mean1_les)
1924;dwdz_trac2 = deriv(altitudes_LES,smoothed_w_mean2_les)
1925;full_dwdz_trac1 = make_array(nz,nttot)
1926;full_dadz_trac1 = make_array(nz,nttot)
1927;FOR l=0, nttot -1 DO BEGIN
1928;       full_dwdz_trac1(*,l) = deriv(altitudes_LES,w_mean1(*,l))
1929;       full_dadz_trac1(*,l) = deriv(altitudes_LES,alpha1out(*,l))
1930;ENDFOR
1931;alpha = 0.
1932
1933FOR k=0, nz-1 DO BEGIN
1934        IF (smoothed_e_rate_trac1_les(k) ne 0.) THEN B_w2_trac1(k) = smoothed_buoyancy_ude_trac1_les(k)/(smoothed_w_mean1_les(k))^2 ELSE B_w2_trac1(k)=-0.
1935;       IF (smoothed_e_rate_trac2_les(k) ne 0.) THEN B_w2_trac2(k) = smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 ELSE B_w2_trac2(k)=-0.
1936ENDFOR
1937
1938;FOR zzz=0.,30 DO BEGIN
1939
1940;alpha = zzz/10.
1941;
1942;FOR k=0, nz-1 DO BEGIN
1943;        IF (smoothed_e_rate_trac1_les(k) ne 0. and smoothed_w_mean1_les(k) ne 0.) THEN B_w2_trac1(k) = 0.5*(smoothed_buoyancy_trac1_les(k)/(smoothed_w_mean1_les(k))^2 - alpha*(1./smoothed_w_mean1_les(k))*dwdz_trac1(k)) ELSE B_w2_trac1(k)=0.
1944;        IF (smoothed_e_rate_trac2_les(k) ne 0. and smoothed_w_mean2_les(k) ne 0.) THEN B_w2_trac2(k) = 0.5*(smoothed_buoyancy_trac2_les(k)/(smoothed_w_mean2_les(k))^2 - alpha*(1./smoothed_w_mean2_les(k))*dwdz_trac2(k)) ELSE B_w2_trac2(k)=0.
1945;ENDFOR
1946
1947;print, smoothed_buoyancy_trac1_les(*)/(smoothed_w_mean1_les(*))^2
1948;print, (1./smoothed_w_mean1_les(*))*dwdz_trac1(*)
1949
1950full_e1 = make_array(nz,nttot)
1951full_bw2 = make_array(nz,nttot)
1952FOR k=0, nz-1 DO BEGIN
1953FOR l=0, nttot-1 DO BEGIN
1954        if(fm_trac1_les(k,l) ne 0.) then full_e1(k,l)=(e1_term1_ude(k,l)+e1_term2_ude(k,l)+e1_term3_ude(k,l))/fm_trac1_les(k,l) else full_e1(k,l)=0.
1955        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=grav*(tplume1moy(k,l)/tenv1moy_ude(k,l) -1.)/(w_mean1(k,l)^2) else full_bw2(k,l)=-0.
1956;        if(w_mean1(k,l) ne 0.) then full_bw2(k,l)=0.5*(alpha*buoyancy1_les(k,l)/(w_mean1(k,l)^2) - full_dwdz_trac1(k,l)/w_mean1(k,l)) else full_bw2(k,l)=0.
1957ENDFOR
1958ENDFOR
1959
1960what_I_plot = smoothed_e_rate_ude_trac1_les
1961labels=['e_rate trac1']
1962title_user = TestCase+SubCase+LayerCase+' LES UDE entrainment rate dep with B/w2, average over '+taverage+' mn,'
1963;filename = TestCase+SubCase+LayerCase+string(alpha,format='(F3.1)')+'Gcm_Les_Comp_e_Bw2.ps'
1964filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_e_Bw2.ps'
1965PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
1966CS, SCALE=28
1967GSET, XMIN=0., XMAX=0.4, YMIN=0., YMAX=0.4, TITLE=title_user
1968cols=INDGEN(1)+2
1969GPLOT, X=what_I_plot, Y=B_w2_trac1, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
1970AXES, XSTEP = 0.05 , XTITLE='LES Entrainment rate m-1', YSTEP=0.05, YTITLE='Parametrized entrainement rate m-1',NDECS=4
1971
1972;oplot, smoothed_e_rate_trac2_les, B_w2_trac2, psym=5
1973FOR l=0, nttot-1 DO BEGIN
1974        oplot, full_e1(*,l),full_bw2(*,l),thick=0.05,psym=1
1975ENDFOR
1976;mean_full_e1 = make_array(nz) & mean_full_bw2 = make_array(nz)
1977;FOR k=0, nz-1 DO BEGIN
1978;       mean_full_e1(k) = MEAN(reform(full_e1(k,*)))
1979;       mean_full_bw2(k) = MEAN(reform(full_bw2(k,*)))
1980;ENDFOR
1981;oplot, mean_full_e1, mean_full_bw2, thick=0.3, psym = 2,color=5
1982;oplot, theoretical_e_trac1_les, B_w2_trac1,psym=2,thick=0.8,color=7
1983oplot,(B_w2_trac1)/2.2222 + 0.0005,B_w2_trac1,thick=0.3,color=7
1984;oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=7
1985oplot, 0.0113*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=7
1986oplot, 0.0105*(B_w2_trac1/0.048)^(1./1.7),B_w2_trac1,thick=0.3,color=6
1987;oplot, alog((B_w2_trac1 - 0.000942361)/0.0444855) - 3.85453, B_w2_trac1, thick=0.3,color=7
1988
1989;print, alog((B_w2_trac1)/0.0444855) - 3.85453
1990
1991PSCLOSE, /NOVIEW
1992
1993spawn, 'ps2png '+filename
1994
1995;ENDFOR
1996
1997what_I_plot = full_bw2(*,lt_plotindex_les)
1998labels=['B/w2']
1999title_user = TestCase+SubCase+LayerCase+' LES UDE B/w2, average over '+taverage+' mn,'
2000filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_Bw2.ps'
2001PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2002CS, SCALE=28
2003GSET, XMIN=-0.01, XMAX=0.01, YMIN=0., YMAX=6., TITLE=title_user
2004cols=INDGEN(1)+2
2005GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2006AXES, XSTEP = 0.002 , XTITLE='B/w2 term in LES UDE', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=4
2007
2008;FOR l=0, nttot-1 DO BEGIN
2009;        oplot, full_bw2(*,l),altitudes_LES/1000.,thick=0.05,psym=1
2010;ENDFOR
2011
2012PSCLOSE, /NOVIEW
2013
2014spawn, 'ps2png '+filename
2015
2016
2017print, '........ BUOYANCY AND VERTICAL VELOCITY DETRAINMENT RATE DEPENDENCY'
2018
2019full_d1 = make_array(nz,nttot)
2020;full_dSiebesma = make_array(nz,nttot)
2021
2022
2023FOR k=0, nz-1 DO BEGIN
2024FOR l=0, nttot-1 DO BEGIN
2025        if(fm_trac1_les(k,l) ne 0.) then full_d1(k,l)=(d1_term1_ude(k,l)+d1_term2_ude(k,l)+d1_term3_ude(k,l))/fm_trac1_les(k,l) else full_d1(k,l)=-0.
2026;        if(w_mean1(k,l) ne 0.) then full_dSiebesma(k,l)=0.5*buoyancy1_les(k,l)/(w_mean1(k,l)^2) -1.5*full_dwdz_trac1(k,l)/w_mean1(k,l) - full_dadz_trac1(k,l)/alpha1out(k,l) else full_dSiebesma(k,l)=-0.
2027ENDFOR
2028ENDFOR
2029
2030what_I_plot = smoothed_d_rate_ude_trac1_les
2031labels=['d_rate trac1']
2032title_user = TestCase+SubCase+LayerCase+' LES UDE detrainment rate dep with B/w2, average over '+taverage+' mn'
2033filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_d_Bw2.ps'
2034PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2035CS, SCALE=28
2036GSET, XMIN=-0, XMAX=0.4, YMIN=0., YMAX=0.4, TITLE=title_user
2037cols=INDGEN(1)+2
2038GPLOT, X=what_I_plot, Y=full_bw2(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30, SYM=5, /NOLINES
2039AXES, XSTEP = 0.05 , XTITLE='Detrainment rate m-1', YSTEP=0.05, YTITLE='B/w²',NDECS=4
2040
2041FOR l=0, nttot-1 DO BEGIN
2042        oplot, full_d1(*,l),full_bw2(*,l),thick=0.05,psym=1
2043ENDFOR
2044;oplot, theoretical_d_trac1_les, full_bw2(*,lt_plotindex_les),psym=2,thick=0.8,color=7
2045;oplot,B_w2_trac1/2.7 + 0.0002,B_w2_trac1,thick=0.3,color=7
2046oplot,B_w2_trac1/2.222 + 0.0002,B_w2_trac1,thick=0.3,color=7
2047oplot, 0.0105*(B_w2_trac1/0.048)^(1./1.7),B_w2_trac1,thick=0.3,color=7
2048oplot, 0.0118*(B_w2_trac1/0.043)^(1./1.65),B_w2_trac1,thick=0.3,color=6
2049
2050PSCLOSE, /NOVIEW
2051
2052spawn, 'ps2png '+filename
2053
2054
2055; --- PLOTTING : 0.5*dwu2/dz
2056print, '........ ///////////// starting local thermal model ///////////'
2057
2058print, ' -> alimentation'
2059a_star = make_array(nz, value=0.)
2060f_star = make_array(nz, value=0.)
2061f_star(0) = 1.
2062teta_est = make_array(nz, value=0.)
2063teta_p = make_array(nz, value=0.)
2064zw2 = make_array(nz,value=0.)
2065w_est = make_array(nz,value=0.)
2066entr_star = make_array(nz,value=0.)
2067detr_star = make_array(nz,value=0.)
2068zbuoy_est = make_array(nz,value=0.)
2069zbuoy = make_array(nz,value=0.)
2070a_star_tot = 0.
2071
2072zw2(1)= 0.4*0.3811552*2*grav*(teta_les(0,lt_plotindex_les)/teta_les(1,lt_plotindex_les) -1.)*approx_zdz_les(0)
2073w_est(1) = zw2(1)
2074FOR k=0, nz-2 DO BEGIN
2075        if ((teta_les(k,lt_plotindex_les) GT (teta_les(k+1,lt_plotindex_les) +0.1)) AND (teta_les(0,lt_plotindex_les) GE teta_les(k,lt_plotindex_les))) then begin
2076        a_star(k) = MAX([(teta_les(k,lt_plotindex_les)-teta_les(k+1,lt_plotindex_les)),0.])*sqrt(altitudes_LES(k))
2077        a_star_tot = a_star_tot + a_star(k)
2078        lalim = k+1.
2079        endif
2080ENDFOR
2081FOR k=0, nz-1 DO BEGIN
2082        a_star(k) = a_star(k)/a_star_tot
2083ENDFOR
2084print, 'alimentation :'
2085;print, a_star
2086f_star(0)=0.
2087f_star(1) = a_star(0)
2088teta_p(0) = teta_les(0,lt_plotindex_les)
2089teta_est(0) = teta_les(0,lt_plotindex_les)
2090print, ' -> plume'
2091FOR k=1, nz-2 DO BEGIN
2092        if (k LT lalim) then begin
2093                teta_est(k) = (f_star(k)*teta_p(k-1)+a_star(k)*0.5*(teta_les(k,lt_plotindex_les) + teta_p(k-1)))/(f_star(k) + a_star(k))
2094        endif else begin
2095                teta_est(k) = teta_p(k-1)
2096        endelse
2097        zbuoy_est(k) = grav*(teta_est(k)/teta_les(k,lt_plotindex_les) -1.)
2098        zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
2099        zdw2=afact*zbuoy_est(k)/fact_epsilon
2100        w_est(k+1) = MAX([0.0001,exp(-zw2fact)*(w_est(k)-zdw2)+zdw2])
2101        if (w_est(k+1) lt 0.) then begin
2102                w_est(k+1)=zw2(k)
2103        endif
2104        if (w_est(k+1) gt 0.001) then begin
2105                entr_star(k)=f_star(k)*approx_zdz_les(k)*(betalpha/(1.+betalpha))*MAX([0.,afact*zbuoy_est(k)/w_est(k+1)])
2106                detr_star(k)=f_star(k)*approx_zdz_les(k)*MAX([detr_min,-afact*(betalpha/(1.+betalpha))*zbuoy_est(k)/w_est(k+1)])
2107        endif
2108        if (k lt lalim) then begin
2109          a_star(k)=max([a_star(k),entr_star(k)])
2110          entr_star(k)=0.
2111        endif
2112        if (w_est(k+1) gt 0.001) then begin
2113        f_star(k+1)=f_star(k)+a_star(k)+entr_star(k)-detr_star(k)
2114        if (k lt lalim) then begin
2115        teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*0.5*(teta_p(k-1) + teta_les(k,lt_plotindex_les)))/(f_star(k+1)+detr_star(k))
2116        endif else begin
2117        teta_p(k)=(f_star(k)*teta_p(k-1)+(a_star(k)+entr_star(k))*teta_les(k,lt_plotindex_les))/(f_star(k+1)+detr_star(k))
2118        endelse
2119        zbuoy(k) = grav*(teta_p(k)/teta_les(k,lt_plotindex_les) -1.)
2120        zw2fact=fact_epsilon*2.*approx_zdz_les(k)/(1.+betalpha)
2121        zdw2=afact*zbuoy(k)/fact_epsilon
2122        zw2(k+1) = MAX([0.0001,exp(-zw2fact)*(zw2(k)-zdw2)+zdw2])
2123        endif
2124ENDFOR
2125print, ' -> done'
2126
2127print, '........ CHECKING VERTICAL VELOCITY FORMULATION'
2128what_I_plot = make_array(nz,value=0.)
2129what_I_overplot = make_array(nz,value=0.)
2130FOR k=0, nz-2 DO BEGIN
2131        what_I_plot(k) = 0.5*(sqrt(zw2(k)) + sqrt(zw2(k+1)))
2132ENDFOR
2133FOR k=0, nZmx-2 DO BEGIN
2134        what_I_overplot(k) = 0.5*(zw2_lev(k,lt_plotindex_gcm) + zw2_lev(k+1,lt_plotindex_gcm))
2135ENDFOR
2136labels=['zw2 in les calc as in TH']
2137title_user = TestCase+SubCase+LayerCase+' LES vertical velocity formulation check'
2138filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_w2_check.ps'
2139PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2140CS, SCALE=28
2141GSET, XMIN=0., XMAX=8., YMIN=0., YMAX=7, TITLE=title_user
2142cols=INDGEN(1)+2
2143GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2144AXES, XSTEP = 1 , XTITLE='w2 in LES from TH calc m/s', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
2145
2146oplot, w_mean1(*,lt_plotindex_les), altitudes_LES/1000.
2147oplot, what_I_overplot, altitudes_GCM/1000.,psym =4
2148
2149PSCLOSE, /NOVIEW
2150
2151spawn, 'ps2png '+filename
2152
2153print, '........ CHECKING TETA ESTIMATIONS FORMULATION'
2154
2155what_I_plot = [[teta_est],[teta_p],[tplume1moy(*,lt_plotindex_les)]]
2156labels=['LES estimated teta','LES teta plume calc as in TH','LES teta plume']
2157title_user = TestCase+SubCase+LayerCase+' LES estimated teta formulation check'
2158filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_teta_check.ps'
2159PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2160CS, SCALE=28
2161GSET, XMIN=214., XMAX=220., YMIN=0., YMAX=7, TITLE=title_user
2162cols=INDGEN(3)+2
2163GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2164AXES, XSTEP = 1 , XTITLE='Teta plume and Est in LES from TH calc K', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
2165
2166oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
2167oplot, teta_gcm(*,lt_plotindex_gcm)*(buoyancy_est_gcm(*,lt_plotindex_gcm)/grav +1.), altitudes_GCM/1000.
2168
2169PSCLOSE, /NOVIEW
2170
2171spawn, 'ps2png '+filename
2172
2173print, '........ CHECKING MASS FLUX FORMULATION'
2174
2175what_I_plot = [[f_star/MAX(f_star)],[smoothed_fm_trac1_les(*,lt_plotindex_les)/MAX(smoothed_fm_trac1_les(*,lt_plotindex_les))]]
2176labels=['LES normalized f_star ','LES normalized updraft mass flux']
2177title_user = TestCase+SubCase+LayerCase+' LES normalized f_star formulation check'
2178filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fm_check.ps'
2179PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2180CS, SCALE=28
2181GSET, XMIN=0., XMAX=1., YMIN=0., YMAX=7, TITLE=title_user
2182cols=INDGEN(2)+2
2183GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2184AXES, XSTEP = 0.1 , XTITLE='f*/max(f*) in LES from TH calc', YSTEP=1., YTITLE='Altitude (km)',NDECS=3
2185
2186oplot,fm_therm_gcm_interlay(*,lt_plotindex_gcm)/MAX(fm_therm_gcm_interlay(*,lt_plotindex_gcm)), altitudes_GCM/1000.,psym=4
2187
2188PSCLOSE, /NOVIEW
2189
2190spawn, 'ps2png '+filename
2191
2192; COMPUTING THE CONTINUITY EQUATION IN THE QUASI-BOUSSINESQ APPROX
2193
2194da_dt = make_array(nz,n_elements(localtime))
2195smoothed_da_dt = make_array(nz)
2196FOR k=0, nz-1 DO BEGIN
2197        da_dt(k,*) = deriv(localtime,reform(alpha1out(k,*)))/3700.
2198ENDFOR
2199FOR t=-ns,ns DO BEGIN
2200        smoothed_da_dt = smoothed_da_dt + REFORM(da_dt(*,lt_plotindex_les+t))
2201ENDFOR
2202smoothed_da_dt = smoothed_da_dt/nstot
2203
2204rho = pt/(R*temp_les)
2205smoothed_rho = make_array(nz)
2206FOR t=-ns,ns DO BEGIN
2207        smoothed_rho = smoothed_rho + REFORM(rho(*,lt_plotindex_les+t))
2208ENDFOR
2209smoothed_rho = smoothed_rho/nstot
2210
2211continuity1 = smoothed_rho*smoothed_da_dt + df_dz_les1 - smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les + smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les
2212print, '........ CONTINUITY CHECK'
2213
2214what_I_plot = [[continuity1],[smoothed_rho*smoothed_da_dt],[df_dz_les1],[-smoothed_e_rate_ude_trac1_les*smoothed_fm_trac1_les],[smoothed_d_rate_ude_trac1_les*smoothed_fm_trac1_les]]
2215labels=['total continuity','rho*da/dt','df/dz','-E','D']
2216title_user = TestCase+SubCase+LayerCase+' LES UDE continuity check, average over '+taverage+' mn'
2217filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_continuity.ps'
2218PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2219CS, SCALE=28
2220GSET, XMIN=-0.0005, XMAX=0.0005, YMIN=0, YMAX=10, TITLE=title_user
2221cols=INDGEN(5)+2
2222GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2223AXES, XSTEP = 0.0001 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2224PSCLOSE, /NOVIEW
2225
2226spawn, 'ps2png '+filename
2227
2228; COMPUTING THE E-D TERM FROM THE CONTINUITY EQUATION
2229
2230eminusd1=make_array(nz)
2231FOR k=0, nz-1 DO BEGIN
2232        IF(smoothed_fm_trac1_les(k) ne 0.) THEN eminusd1(k) = (smoothed_rho(k)*smoothed_da_dt(k) - df_dz_les1(k))/smoothed_fm_trac1_les(k) ELSE eminusd1(k)=0.
2233ENDFOR
2234what_I_plot = eminusd1
2235labels=['e-d']
2236title_user = TestCase+SubCase+LayerCase+' LES e-d, average over '+taverage+' mn'
2237filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_EminusD.ps'
2238PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2239CS, SCALE=28
2240GSET, XMIN=-0.002, XMAX=0.002, YMIN=0, YMAX=10, TITLE=title_user
2241cols=INDGEN(1)+2
2242GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2243AXES, XSTEP = 0.0005 , XTITLE='kg.m-2.s-1', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2244PSCLOSE, /NOVIEW
2245
2246spawn, 'ps2png '+filename
2247
2248; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV AND ACTIVE PLUME
2249; TO CHECK CONSISTENCY
2250
2251print, '........ CHECKING CONSISTENCY OF UPDRAFT/ENV DECOMPOSITION'
2252
2253smoothed_hf1_term1 = make_array(nz)
2254smoothed_hf1_term2 = make_array(nz)
2255smoothed_hf1_term3 = make_array(nz)
2256smoothed_wt = make_array(nz)
2257FOR t=-ns,ns DO BEGIN
2258        smoothed_hf1_term1 = smoothed_hf1_term1 + REFORM(hf1_term1(*,lt_plotindex_les+t))
2259        smoothed_hf1_term2 = smoothed_hf1_term2 + REFORM(hf1_term2(*,lt_plotindex_les+t))
2260        smoothed_hf1_term3 = smoothed_hf1_term3 + REFORM(hf1_term3(*,lt_plotindex_les+t))
2261        smoothed_wt = smoothed_wt + REFORM(wt(*,lt_plotindex_les+t))
2262ENDFOR
2263smoothed_hf1_term1 = smoothed_hf1_term1/nstot
2264smoothed_hf1_term2 = smoothed_hf1_term2/nstot
2265smoothed_hf1_term3 = smoothed_hf1_term3/nstot
2266smoothed_wt = smoothed_wt/nstot
2267
2268what_I_plot = [[smoothed_hf1_term1],[smoothed_hf1_term2],[smoothed_hf1_term3],[smoothed_hf1_term1+smoothed_hf1_term2+smoothed_hf1_term3]]
2269labels=['within plume turbulence','within env. turbulence','organized turbulence','TOTAL']
2270title_user = TestCase+SubCase+LayerCase+' LES turbulence decomposition check, average over '+taverage+' mn'
2271filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu.ps'
2272PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2273CS, SCALE=28
2274GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
2275cols=INDGEN(4)+2
2276GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
2277AXES, XSTEP = 0.5 , XTITLE='m.K/s', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2278oplot, smoothed_wt, altitudes_LES/1000.,psym=3
2279PSCLOSE, /NOVIEW
2280spawn, 'ps2png '+filename
2281
2282
2283; COMPUTING THE TURBULENT FLUX DECOMPOSITION IN PASSIVE ENV ,ACTIVE PLUME and ACTIVE DOWNDRAFT
2284; TO CHECK CONSISTENCY
2285
2286print, '........ CHECKING CONSISTENCY OF UPDRAFT/DOWNDRAFT/ENV DECOMPOSITION'
2287
2288smoothed_hf1_ude_term1 = make_array(nz)
2289smoothed_hf1_ude_term2 = make_array(nz)
2290smoothed_hf1_ude_term3 = make_array(nz)
2291smoothed_hf1_ude_term4 = make_array(nz)
2292FOR t=-ns,ns DO BEGIN
2293        smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1 + REFORM(hf1_ude_term1(*,lt_plotindex_les+t))
2294        smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2 + REFORM(hf1_ude_term2(*,lt_plotindex_les+t))
2295        smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3 + REFORM(hf1_ude_term3(*,lt_plotindex_les+t))
2296        smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4 + REFORM(hf1_ude_term4(*,lt_plotindex_les+t))
2297ENDFOR
2298smoothed_hf1_ude_term1 = smoothed_hf1_ude_term1/nstot
2299smoothed_hf1_ude_term2 = smoothed_hf1_ude_term2/nstot
2300smoothed_hf1_ude_term3 = smoothed_hf1_ude_term3/nstot
2301smoothed_hf1_ude_term4 = smoothed_hf1_ude_term4/nstot
2302
2303what_I_plot = [[smoothed_hf1_ude_term1],[smoothed_hf1_ude_term2],[smoothed_hf1_ude_term3],[smoothed_hf1_ude_term4],[smoothed_hf1_ude_term1+smoothed_hf1_ude_term2+smoothed_hf1_ude_term3+smoothed_hf1_ude_term4]]
2304labels=['within plume turbulence','within downdraft turbulence','within env. turbulence','organized turbulence','TOTAL']
2305title_user = TestCase+SubCase+LayerCase+' LES UDE turbulence decomposition check, average over '+taverage+' mn'
2306filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_turbu_ude.ps'
2307PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2308CS, SCALE=28
2309GSET, XMIN=-1, XMAX=1.5, YMIN=0, YMAX=6, TITLE=title_user
2310cols=INDGEN(5)+2
2311GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=9, COL=cols, LABELS=labels, THICK = 30
2312AXES, XSTEP = 0.25 , XTITLE='m.K/s', YSTEP=0.5, YTITLE='Altitude (km)',NDECS=3
2313oplot, smoothed_wt, altitudes_LES/1000.,psym=3
2314PSCLOSE, /NOVIEW
2315
2316spawn, 'ps2png '+filename
2317
2318; CHECK CONSISTENCY OF We = W and THETA e = THETA approximation
2319
2320print, '........ CHECKING CONSISTENCY OF env variable (w_e,theta_e) = mean variable (w_overbar,theta_overbar)'
2321print, 'as well as mean(w) = 0, in the UDE decomposition'
2322
2323smoothed_delta_theta_ude = make_array(nz)
2324smoothed_delta_w_ude = make_array(nz)
2325smoothed_w_mean1_full = make_array(nz)
2326
2327FOR t=-ns,ns DO BEGIN
2328        smoothed_delta_theta_ude = smoothed_delta_theta_ude + REFORM(w_mean1_env_ude(*,lt_plotindex_les+t)-w_mean1_full(*,lt_plotindex_les+t))
2329        smoothed_delta_w_ude = smoothed_delta_w_ude + REFORM(tenv1moy_ude(*,lt_plotindex_les+t)-tmoy_full(*,lt_plotindex_les+t))
2330        smoothed_w_mean1_full = smoothed_w_mean1_full + REFORM(w_mean1_full(*,lt_plotindex_les+t))
2331ENDFOR
2332
2333smoothed_delta_theta_ude = smoothed_delta_theta_ude/nstot
2334smoothed_delta_w_ude = smoothed_delta_w_ude/nstot
2335smoothed_w_mean1_full = smoothed_w_mean1_full/nstot
2336
2337what_I_plot = [[smoothed_delta_theta_ude],[smoothed_delta_w_ude],[smoothed_w_mean1_full]]
2338labels=['theta env_ude - theta moy','w env_ude - w moy','mean w over domain (*,*,k)']
2339title_user = TestCase+SubCase+LayerCase+' LES UDE env/mean approximation check, average over '+taverage+' mn'
2340filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_approx_ude.ps'
2341PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2342CS, SCALE=28
2343GSET, XMIN=-2, XMAX=2, YMIN=0, YMAX=10, TITLE=title_user
2344cols=INDGEN(3)+2
2345GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2346AXES, XSTEP = 0.5 , XTITLE='(m/s) and (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2347PSCLOSE, /NOVIEW
2348
2349spawn, 'ps2png '+filename
2350
2351; GETTING SOME INSIGHT ON PLUME'S INSIDE TEMPERATURES
2352
2353print, '........ STRUCTURE POTENTIAL TEMPERATURES'
2354xmin = 210
2355xmax = 220
2356if (TestCase eq 'Case_Z') then begin
2357xmin = 260
2358xmax = 270
2359endif
2360ztva = teta_gcm*(buoyancy_gcm/grav +1.)
2361ztva_est = teta_gcm*(buoyancy_est_gcm/grav +1.)
2362what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tenv1moy(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
2363labels=['Teta updraft','Teta env ','Teta moy']
2364title_user = TestCase+SubCase+LayerCase+' LES Teta in the structures, no average'
2365filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta.ps'
2366PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2367CS, SCALE=28
2368GSET, XMIN=xmin, XMAX=xmax, YMIN=0, YMAX=6, TITLE=title_user
2369cols=INDGEN(3)+2
2370GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2371AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2372oplot, ztva(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
2373oplot, ztva_est(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
2374oplot, teta_gcm(*,lt_plotindex_gcm), altitudes_GCM/1000., thick=0.3
2375PSCLOSE, /NOVIEW
2376spawn, 'ps2png '+filename
2377
2378
2379print, '........ UDE STRUCTURE POTENTIAL TEMPERATURES'
2380
2381what_I_plot = [[tplume1moy(*,lt_plotindex_les)],[tdown1moy(*,lt_plotindex_les)],[tenv1moy_ude(*,lt_plotindex_les)],[teta_les(*,lt_plotindex_les)]]
2382labels=['Teta updraft','Teta downdraft','Teta env (UDE)','Teta moy']
2383title_user = TestCase+SubCase+LayerCase+' LES UDE Teta in the structures, no average'
2384filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_fullTeta_ude.ps'
2385PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2386CS, SCALE=28
2387GSET, XMIN=210, XMAX=220, YMIN=0, YMAX=6, TITLE=title_user
2388cols=INDGEN(4)+2
2389GPLOT, X=what_I_plot, Y=altitudes_LES/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2390AXES, XSTEP = 1 , XTITLE='Potential Temperature (K)', YSTEP=1, YTITLE='Altitude (km)',NDECS=4
2391PSCLOSE, /NOVIEW
2392
2393spawn, 'ps2png '+filename
2394
2395; -----------------------------------------------------------------------------------------------------------------------
2396; End of PLUME diagnostics
2397; -----------------------------------------------------------------------------------------------------------------------
2398
2399; *** TKE ***
2400
2401print, '........ TKE'
2402
2403what_I_plot = reform(tke_gcm(*,lt_plotindex_gcm))
2404labels=['TH tke 1d']
2405title_user = TestCase+SubCase+LayerCase+' TKE comparison'
2406filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_tke.ps'
2407PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2408CS, SCALE=28
2409GSET, XMIN=-1, XMAX=8, YMIN=0, YMAX=10, TITLE=title_user
2410cols=INDGEN(1)+2
2411GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2412AXES, XSTEP = 1, XTITLE='Turbulent kinetic energy (kg.m-3)', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
2413
2414oplot, tke_les(*,lt_plotindex_les), altitudes_LES/1000., psym=4
2415
2416PSCLOSE, /NOVIEW
2417
2418spawn, 'ps2png '+filename
2419
2420; *** HEAT FLUX ***
2421
2422print, '........ HEAT FLUX'
2423
2424lay_heatFlux_up = make_array(nZmx,nTmx)
2425lay_heatFlux_down = make_array(nZmx,nTmx)
2426
2427FOR k=1, nZmx-1 DO BEGIN
2428        lay_heatFlux_up(k,*) = 0.5*(heatFlux_up(k,*) + heatFlux_up(k-1,*))
2429        lay_heatFlux_down(k,*) = 0.5*(heatFlux_down(k,*) + heatFlux_down(k-1,*))
2430ENDFOR
2431lay_heatFlux_up(0,*)=0.5*(heatFlux_up(0,*))
2432lay_heatFlux_down(0,*)=0.5*(heatFlux_down(0,*))
2433zkh_gcm_int = make_array(nZmx)
2434
2435FOR k=0, nZmx-2 DO BEGIN
2436        zkh_gcm_int(k) = 0.5*(zkh(k,lt_plotindex_gcm) + zkh(k+1,lt_plotindex_gcm))
2437ENDFOR
2438MY_gcm = -zkh_gcm_int*(deriv(altitudes_GCM,reform(zh(*,lt_plotindex_gcm)))); - 0.025*max(lay_heatFlux_up(*,lt_plotindex_gcm)))
2439
2440
2441;what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
2442what_I_plot = [[lay_heatFlux_up(*,lt_plotindex_gcm)],[MY_gcm],[lay_heatFlux_down(*,lt_plotindex_gcm)],[lay_heatFlux_down(*,lt_plotindex_gcm)+lay_heatFlux_up(*,lt_plotindex_gcm)+MY_gcm]]
2443
2444;labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','Total']
2445labels=['TH updraft heat flux','Mellor and Yamada gcm heat flux','TH downdraft heat flux','Total']
2446
2447title_user = TestCase+SubCase+LayerCase+' TH vertical heat flux'
2448filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_WT.ps'
2449PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2450CS, SCALE=28
2451GSET, XMIN=-2, XMAX=3, YMIN=0, YMAX=10, TITLE=title_user
2452;cols=INDGEN(3)+2
2453cols=INDGEN(4)+2
2454GPLOT, X=what_I_plot, Y=altitudes_GCM/1000., /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2455AXES, XSTEP = 1, XTITLE='vertical turbulent heat flux', YSTEP=1, YTITLE='Altitude (km)',NDECS=1
2456
2457;hf1_ude_term4 = alpha1out*(w_mean1 - w_mean1_full)*(tplume1moy - tmoy_full) + beta1out*(w_mean1_down - w_mean1_full)*(tdown1moy - tmoy_full) + (1.- (alpha1out+beta1out))*(w_mean1_env_ude - w_mean1_full)*(tenv1moy_ude - tmoy_full)
2458
2459oplot, alpha1out(*,lt_plotindex_les)*(w_mean1(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tplume1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000., color=2
2460
2461oplot, beta1out(*,lt_plotindex_les)*(w_mean1_down(*,lt_plotindex_les) - w_mean1_full(*,lt_plotindex_les))*(tdown1moy(*,lt_plotindex_les) - tmoy_full(*,lt_plotindex_les)), altitudes_LES/1000.,color=6
2462
2463oplot, smoothed_hf1_ude_term4, altitudes_LES/1000., color = 5
2464
2465;oplot, smoothed_hf1_term1, altitudes_LES/1000.,thick=0.1,LINESTYLE = 5
2466;oplot, smoothed_hf1_term2, altitudes_LES/1000.,color=2,thick=0.1,LINESTYLE = 5
2467;oplot, smoothed_hf1_term3, altitudes_LES/1000.,color=8,thick=0.1,LINESTYLE = 5
2468
2469oplot, wt(*,lt_plotindex_les), altitudes_LES/1000.
2470
2471;oplot, smoothed_hf1_term3(*,lt_plotindex_les), altitudes_LES/1000., psym=7
2472
2473PSCLOSE, /NOVIEW
2474
2475spawn, 'ps2png '+filename
2476
2477; *** TRACERS ***
2478
2479print, '........ TRACER PLOTS DEACTIVATED'
2480
2481; trying stuff
2482
2483buoyancy_downdraft = grav*(tdown1moy/tenv1moy_ude-1.)
2484lmix = make_array(nttot,value=-1.)
2485altitudes_rel_LES = make_array(nz,nttot)
2486FOR l=0, nttot-1 DO BEGIN
2487;       kmax = where(w_mean1(*,l) eq max(w_mean1(*,l)))
2488;       if (kmax(0) ne -1) then lmix(l) = altitudes_LES(kmax(0)) else lmix(l) = -1.
2489;FOR k=nz-2, 1,-1 DO BEGIN
2490;       if ((buoyancy_downdraft(k,l) gt 0.) and (buoyancy_downdraft(k-1,l) lt 0.)) then lmix(l) = 0.5*(altitudes_LES(k)+altitudes_LES(k+1))
2491;ENDFOR
2492FOR k=nz-2, 1,-1 DO BEGIN
2493        if (tdown1moy(k,l) eq 0.) then lmix(l) = altitudes_LES(k)
2494ENDFOR
2495ENDFOR
2496
2497FOR l=0, nttot-1 DO BEGIN
2498FOR k=0, nz-1 DO BEGIN
2499        altitudes_rel_LES(k,l) = altitudes_LES(k)/lmix(l)
2500ENDFOR
2501ENDFOR
2502
2503print, '........ Teta down / Teta up in UDE'
2504
2505stuff2=tdown1moy/tenv1moy_ude
2506
2507what_I_plot = stuff2(*,lt_plotindex_les)
2508labels=['Teta d/Teta env 12h']
2509title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
2510filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.ps'
2511PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2512CS, SCALE=28
2513GSET, XMIN=0.992, XMAX=1.004, YMIN=0, YMAX=1, TITLE=title_user
2514cols=INDGEN(1)+2
2515GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2516AXES, XSTEP = 0.002, XTITLE='Teta d/ Teta env', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
2517
2518FOR i=0,nttot-1 DO BEGIN
2519        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
2520ENDFOR
2521oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2522oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2523oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2524PSCLOSE, /NOVIEW
2525spawn, 'ps2png '+filename
2526
2527print, '........ Teta down / Teta up in UDE'
2528
2529stuff2=tdown1moy/tplume1moy
2530
2531what_I_plot = stuff2(*,lt_plotindex_les)
2532labels=['Teta d/Teta u 12h']
2533title_user = TestCase+SubCase+LayerCase+' TH trying stuff'
2534filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuff2.5.ps'
2535PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2536CS, SCALE=28
2537GSET, XMIN=0.95, XMAX=1.1, YMIN=0, YMAX=1, TITLE=title_user
2538cols=INDGEN(1)+2
2539GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2540AXES, XSTEP = 0.01, XTITLE='Teta d/ Teta u', YSTEP=0.2, YTITLE='Altitude/zi ',NDECS=3
2541
2542FOR i=0,nttot-1 DO BEGIN
2543        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
2544ENDFOR
2545;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.075)/187.931 + 0.9977, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2546;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/19.231 + 0.9938, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2547;oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.60)/(-1333) + 1.00025, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2548PSCLOSE, /NOVIEW
2549spawn, 'ps2png '+filename
2550
2551print, '........ B down / B up in UDE'
2552
2553stuff2 = (tdown1moy/tenv1moy_ude -1.)/(tplume1moy/tenv1moy_ude -1.)
2554what_I_plot = stuff2(*,lt_plotindex_les)
2555labels=['B down/B up 12h']
2556title_user = TestCase+SubCase+LayerCase+' TH trying stuff Bd/Bu'
2557filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffBuBd.ps'
2558PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2559CS, SCALE=28
2560GSET, XMIN=-1, XMAX=1., YMIN=0, YMAX=1, TITLE=title_user
2561cols=INDGEN(1)+2
2562GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2563AXES, XSTEP = 0.1, XTITLE='B down/ B up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
2564
2565FOR i=0,nttot-1 DO BEGIN
2566        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
2567ENDFOR
2568;oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/0.839841)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2569oplot, ((altitudes_rel_LES(*,lt_plotindex_les)-0.06)/1.16847)^2 - 0.3, altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2570oplot, (altitudes_rel_LES(*,lt_plotindex_les)-0.7)/1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2571;oplot, (altitudes_rel_LES(*,lt_plotindex_les))/0.08333333-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2572oplot, sqrt(altitudes_rel_LES(*,lt_plotindex_les)/0.122449)-1., altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2573PSCLOSE, /NOVIEW
2574spawn, 'ps2png '+filename
2575
2576print, '........ F down / F up in UDE'
2577
2578stuff2 = downward_flux1/fm_trac1_les
2579what_I_plot = stuff2(*,lt_plotindex_les)
2580labels=['f down/f up 12h']
2581title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
2582filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stufffufd.ps'
2583PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2584CS, SCALE=28
2585GSET, XMIN=-8, XMAX=0.5, YMIN=0, YMAX=1, TITLE=title_user
2586cols=INDGEN(1)+2
2587GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2588AXES, XSTEP = 0.5, XTITLE='f down/ f up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
2589
2590FOR i=0,nttot-1 DO BEGIN
2591        if(lmix(i) ne -1) then oplot, stuff2(*,i), altitudes_rel_LES(*,i), thick=0.1
2592ENDFOR
2593oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2594;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2595PSCLOSE, /NOVIEW
2596spawn, 'ps2png '+filename
2597
2598print, '........ dFdz down / dzFdz up in UDE'
2599stuff3=make_array(nz,nttot)
2600FOR l=0, nttot-1 DO BEGIN
2601        stuff3(*,l) = deriv(altitudes_LES,downward_flux1(*,l))/deriv(altitudes_LES,fm_trac1_les(*,l))
2602ENDFOR
2603what_I_plot = stuff3(*,lt_plotindex_les)
2604labels=['dfdz down/dfdz up 12h']
2605title_user = TestCase+SubCase+LayerCase+' TH trying stuff f down/f up'
2606filename = TestCase+SubCase+LayerCase+'Gcm_Les_Comp_stuffdfudfd.ps'
2607PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2608CS, SCALE=28
2609GSET, XMIN=-30, XMAX=30, YMIN=0, YMAX=1, TITLE=title_user
2610cols=INDGEN(1)+2
2611GPLOT, X=what_I_plot, Y=altitudes_rel_LES(*,lt_plotindex_les), /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2612AXES, XSTEP = 5, XTITLE='dfdz down/ dfdz up', YSTEP=0.1, YTITLE='Altitude/zi ',NDECS=1
2613
2614FOR i=0,nttot-1 DO BEGIN
2615        if(lmix(i) ne -1) then oplot, stuff3(*,i), altitudes_rel_LES(*,i), thick=0.1
2616ENDFOR
2617;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.0149259)/0.00333)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2618;oplot, -alog(((altitudes_rel_LES(*,lt_plotindex_les)+0.02)/0.006)), altitudes_rel_LES(*,lt_plotindex_les),thick=0.3,color=7
2619PSCLOSE, /NOVIEW
2620spawn, 'ps2png '+filename
2621;
2622;what_I_plot = [[ar_col],[co2_col],[tke_col]]
2623;labels=['Ar deviation','Co2 deviation','TKE deviation']
2624;title_user = TestCase+SubCase+' TH 1d tracer conservation'
2625;filename = TestCase+SubCase+'Gcm_Les_Comp_tracer.ps'
2626;PSOPEN, THICK=200, CHARSIZE=120, FILE = filename, FONT = 5, TFONT = 5
2627;CS, SCALE=28
2628;GSET, XMIN=localtime_gcm(0), XMAX=localtime_gcm(nTmx-1), YMIN=0, YMAX=2, TITLE=title_user
2629;cols=INDGEN(3)+2
2630;GPLOT, X=localtime_gcm, Y=what_I_plot, /LEGEND, LEGPOS=1, COL=cols, LABELS=labels, THICK = 30
2631;AXES, XSTEP = 2, XTITLE='Local time (h)', YSTEP=0.1, YTITLE='Tracer integrated column mass deviation from origin (%)',NDECS=1
2632;
2633;PSCLOSE, /NOVIEW
2634;
2635;spawn, 'ps2png '+filename
2636;
2637;title_user = TestCase+SubCase+' TH argon propagation from first layer'
2638;PS_START, file = TestCase+SubCase+'Gcm_Les_Comp_Argon.ps'
2639;
2640;what_I_plot = transpose(ar(0:6,*))
2641;
2642;maxfield_init = 0.05
2643;minfield_init = 0
2644;pal=33
2645;lim_max = maxfield_init & w=where((what_I_plot ge lim_max) and (what_I_plot le 1e9)) & if (w[0] ne -1) then what_I_plot[w]=lim_max
2646;lim_min = minfield_init & w=where(what_I_plot le lim_min) & if (w[0] ne -1) then what_I_plot[w]=lim_min
2647;
2648;section, $
2649;        what_I_plot, $                          ; 2D field
2650;        localtime_gcm, $                                ; horizontal coordinate
2651;        altitudes_gcm(0:6), $                                ; altitude coordinate
2652;        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
2653;        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
2654;;       minspace=minspace, $                    ; minimum value of space window (=0: calculate)
2655;;       maxspace=maxspace, $                    ; maximum value of space window (=0: calculate)
2656;;       overcontour=overcontour, $              ; another 2D field to overplot with contour lines (=0: no)
2657;;       overvector_x=overvector_x, $            ; wind vector - x component (=0: no)
2658;;       overvector_y=overvector_y, $            ; wind vector - y component (=0: no)
2659;;       colors=colors, $                        ; number of colors/levels (32 is default)
2660;        title_plot=title_user, $                ; title of the plot ('Profile' is default)
2661;        title_axis=['Martian hour (h)','Height above ground (m)'], $                ; title of the [x,y] axis (['Field','Altitude'] is default)
2662;        ct=pal, $                               ; color table (33-rainbow is default)
2663;;       topo=topography, $
2664;        format=format                           ; format of colorbar annotations ('(F6.2)' is default)
2665;
2666;PS_END, /PNG
2667;
2668;INTERVAL_VOLUME, supermask1, 0.5, 1.,verts, conn
2669;conn = TETRA_SURFACE(verts, conn) 
2670;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $ 
2671;   COLOR=[255,255,255], SHADING=1) 
2672;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
2673
2674;INTERVAL_VOLUME, supermask2, 0.5, 1.5,verts, conn
2675;conn = TETRA_SURFACE(verts, conn)
2676;oRain = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=conn, $
2677;   COLOR=[255,255,255], SHADING=1)
2678;XOBJVIEW, oRain, BACKGROUND=[150,200,255]
2679
2680ENDELSE
2681
2682print, ''
2683print, '........ ALL DONE'
2684print, ''
2685
2686END
Note: See TracBrowser for help on using the repository browser.