| 1 | # -*- coding: iso-8859-1 -*- |
|---|
| 2 | # Created : S.Sénési - nov 2015 |
|---|
| 3 | |
|---|
| 4 | # |
|---|
| 5 | desc="\nCreation d'un atlas pour une simu, une grille et une liste de variables et de saisons \n"+\ |
|---|
| 6 | " Exemples : \n"+\ |
|---|
| 7 | " >>> python ./atlas.py -v tas,hfls -s NPv3.1ada_1982_1991\n"+\ |
|---|
| 8 | "" |
|---|
| 9 | # Avec CliMAF, cette etape est loin d'etre necessaire; on la réalise pour 'exposer' ces fichiers |
|---|
| 10 | # dans une arborescence à laquelle sont habitues certains utilisateurs |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | # Répertoire de base pour les entrées et les résultats |
|---|
| 14 | dir_default='/thredds/ipsl/fabric/lmdz/SE/ORIG' |
|---|
| 15 | |
|---|
| 16 | # Gestion des options et arguments d'appel |
|---|
| 17 | from optparse import OptionParser |
|---|
| 18 | parser = OptionParser(desc) ; parser.set_usage("%%prog [-h]\n%s" % desc) |
|---|
| 19 | #parser.add_option("-i", "--input", help="repertoire des donnes d'entree(defaut : %s)"%dir_default, |
|---|
| 20 | # action="store",default=dir_default) |
|---|
| 21 | parser.add_option("-i", "--input", help="repertoire des donnes d'entree(defaut : %s)", |
|---|
| 22 | action="store",default=None) |
|---|
| 23 | #parser.add_option("-g", "--grid", help="nom de grille (default: VLR)", action="store",default='VLR') |
|---|
| 24 | parser.add_option("-g", "--grid", help="nom de grille (default: VLR)", action="store",default='') |
|---|
| 25 | |
|---|
| 26 | parser.add_option("-r", "--region", help="nom de zone (GLOB, ATLTN, etc; default: GLOB)", action="store",default='GLOB') |
|---|
| 27 | parser.add_option("-p", "--season", help="saison a traiter " "(eg : JJA, DJF, YEAR, defaut=%YEAR)", |
|---|
| 28 | #parser.add_option("--season", help="saison a traiter " "(eg : JJA, DJF, YEAR, defaut=%YEAR)", |
|---|
| 29 | #parser.add_option("-r", "--region", help="région a traiter " "(eg : GLOB, ATLTN, defaut=%GLOB)", |
|---|
| 30 | action="store", default='YEAR') |
|---|
| 31 | parser.add_option("-s", "--simulation", help="simulation+annees a traiter (sim_YYY1_YYY2) - laisser vide pour lister", |
|---|
| 32 | action="store",default=None) |
|---|
| 33 | parser.add_option("-t", "--reference", help="simulation de reference (sim_YYY1_YYY2, default=OBS) ", |
|---|
| 34 | action="store",default='OBS') |
|---|
| 35 | parser.add_option("-v", "--variables", help="liste des variables (separees par des virgules)", action="store",default=None) |
|---|
| 36 | #parser.add_option("--root", help="Path to the root directory", action="store",default=None) |
|---|
| 37 | parser.add_option("--root", help="Path to the root directory", action="store",default=None) |
|---|
| 38 | parser.add_option("-f", "--force", help="force le recalcul de champs existants", |
|---|
| 39 | action="store_true",default=None) |
|---|
| 40 | parser.add_option("--dirpng",help="Path of the simulation directory", action="store",default=None) |
|---|
| 41 | parser.add_option("-o", "--pdf", help="nom du pdf de sortie (default: atlas_<SIMU>_<SAISON>.pdf)", action="store") |
|---|
| 42 | parser.add_option("--lonmin", help="longitude minimale",action="store",default='0') |
|---|
| 43 | parser.add_option("--lonmax", help="longitude maximale",action="store",default='360') |
|---|
| 44 | parser.add_option("--latmin", help="latitude minimale",action="store",default='-90') |
|---|
| 45 | parser.add_option("--latmax", help="latitude maximale",action="store",default='90') |
|---|
| 46 | parser.add_option("--pmin", help="pression minimale",action="store",default='1') |
|---|
| 47 | (opts, args) = parser.parse_args() |
|---|
| 48 | |
|---|
| 49 | print 'pmin = ',opts.pmin |
|---|
| 50 | centerlon=float(opts.lonmax)-180 |
|---|
| 51 | print 'centerlon = ',centerlon |
|---|
| 52 | #quit() |
|---|
| 53 | #--------------------------------------------------------------------------------- |
|---|
| 54 | import math |
|---|
| 55 | from climaf.api import * |
|---|
| 56 | from climaf.html import * |
|---|
| 57 | # La description de l'organisation des données SE et des alias et rescalings |
|---|
| 58 | # est partagée dans une micro-librairie : |
|---|
| 59 | from lmdz_SE import * # svsg, all_SE_simulations |
|---|
| 60 | from plot_params import plot_params |
|---|
| 61 | #--------------------------------------------------------------------------------- |
|---|
| 62 | # |
|---|
| 63 | clog('debug') |
|---|
| 64 | #crm(pattern='pme') |
|---|
| 65 | #crm(pattern='hflsevap') |
|---|
| 66 | #crm(pattern='tasmax') |
|---|
| 67 | #crm(pattern='tasmin') |
|---|
| 68 | def apply_scale_offset(dat,scale,offset): |
|---|
| 69 | return ccdo(ccdo(dat,operator='mulc,'+str(float(scale))),operator='addc,'+str(float(offset))) |
|---|
| 70 | # |
|---|
| 71 | #craz() |
|---|
| 72 | if opts.simulation is None: |
|---|
| 73 | print "Available simulations at %s are : "%opts.input, |
|---|
| 74 | for s in all_SE_simulations() : print s, |
|---|
| 75 | exit(0) |
|---|
| 76 | # |
|---|
| 77 | lvars=opts.variables |
|---|
| 78 | if lvars is not None : lvars=lvars.split(',') |
|---|
| 79 | else : lvars=variables_list |
|---|
| 80 | # |
|---|
| 81 | # Preparons une commande pour assembler les sorties Pdf |
|---|
| 82 | if opts.pdf : pdffile=opts.pdf |
|---|
| 83 | else: pdffile="atlas_"+opts.simulation+"_"+opts.season+".pdf" |
|---|
| 84 | pdfargs=["pdfjam","--landscape","-o ",pdffile] |
|---|
| 85 | # |
|---|
| 86 | # Initialisation de l'index html |
|---|
| 87 | index= header("LMDZ Atlas for "+opts.simulation+ " versus "+opts.reference+" ("+opts.season+")") |
|---|
| 88 | index += cell('PDF',pdffile) |
|---|
| 89 | index += section("2d vars", level=4) |
|---|
| 90 | index += open_table() |
|---|
| 91 | # |
|---|
| 92 | # Titres de colonnes |
|---|
| 93 | ref=opts.reference ; |
|---|
| 94 | if (ref == 'OBS' ) : text_diff='bias' |
|---|
| 95 | else: text_diff='diff' |
|---|
| 96 | index+=open_line('VARIABLE')+cell('bias')+cell('rmse')+cell('mean')+cell(ref)+cell(text_diff)+\ |
|---|
| 97 | cell('zonal')+cell('all')+cell('pdf')+close_line() |
|---|
| 98 | # |
|---|
| 99 | # -- Declare the script ml2pl for vertical interpolation |
|---|
| 100 | cscript("ml2pl", "/home/fabric/LMDZ/atlas/ml2pl.sh -p ${var_2} -m ${var_1} ${in_1} ${out} ${in_2}", |
|---|
| 101 | commuteWithTimeConcatenation=True, commuteWithSpaceConcatenation=True) |
|---|
| 102 | # -- Vertical levels for the vertical interpolation |
|---|
| 103 | fixed_fields("ml2pl",("press_levels.txt","/home/fabric/LMDZ/atlas/press_levels.txt")) |
|---|
| 104 | # |
|---|
| 105 | for variable in lvars : |
|---|
| 106 | # Get the model and the reference |
|---|
| 107 | if opts.root: |
|---|
| 108 | simu=svsg(opts.simulation,variable,opts.season,opts.grid, root=opts.root) |
|---|
| 109 | else: |
|---|
| 110 | simu=svsg(opts.simulation,variable,opts.season,opts.grid) |
|---|
| 111 | print 'variable = ',variable |
|---|
| 112 | reff=svsg(opts.reference,variable,opts.season,opts.grid) |
|---|
| 113 | # |
|---|
| 114 | # If the variable is a 3D field: |
|---|
| 115 | # - interpolate the variable on the standard pressure levels with ml2pl (L. Guez) |
|---|
| 116 | # - Compute the difference model-ref with diff_zonmean (computes the zonal mean lat/pressure fields, |
|---|
| 117 | # interpolates the model on the ref, both vertically and horizontally, and returns the difference) |
|---|
| 118 | if is3d(variable) : |
|---|
| 119 | #cas1 sim2 != sim1 ; sim1 != OBS ; sim2 != OBS |
|---|
| 120 | if (opts.simulation != 'OBS' and opts.reference != 'OBS' and opts.simulation != opts.reference ) : |
|---|
| 121 | print 'simu = ',opts.simulation |
|---|
| 122 | print 'reff = ',opts.reference |
|---|
| 123 | simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid) |
|---|
| 124 | simu = ml2pl(simu,simu_pres) |
|---|
| 125 | simu = zonmean(simu) |
|---|
| 126 | print 'simu = ',simu |
|---|
| 127 | reff_pres = svsg(opts.reference,'pres',opts.season,opts.grid) |
|---|
| 128 | reff = ml2pl(reff,reff_pres) |
|---|
| 129 | reff = zonmean(reff) |
|---|
| 130 | print 'reff = ',reff |
|---|
| 131 | ### IM250821 : projection grille horizontale |
|---|
| 132 | # reff=regrid(reff,simu) |
|---|
| 133 | simu=regrid(simu,reff) |
|---|
| 134 | ### IM250821 end |
|---|
| 135 | diff=minus(simu,reff) |
|---|
| 136 | print 'diff_zonmean simu = ',diff |
|---|
| 137 | print ' cas1 sim ref on pressure levels w/ zonmean ' |
|---|
| 138 | #cas2 sim !=$ OBS ; ref = OBS |
|---|
| 139 | elif (opts.simulation != 'OBS' and opts.reference == 'OBS' ) : |
|---|
| 140 | print 'cas2' |
|---|
| 141 | ### interpolation sur des niveaux de pression |
|---|
| 142 | simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid) |
|---|
| 143 | simu = ml2pl(simu,simu_pres) |
|---|
| 144 | ### moyenne zonale |
|---|
| 145 | simu = zonmean(simu) |
|---|
| 146 | ### moyenne zonale |
|---|
| 147 | reff = zonmean(reff) |
|---|
| 148 | ### projection grille simu |
|---|
| 149 | reff=regrid(reff,simu) |
|---|
| 150 | ### differences moyennes zonales |
|---|
| 151 | diff=minus(simu,reff) |
|---|
| 152 | print ' cas2 sim ref on pressure levels w/ zonmean ' |
|---|
| 153 | #cas3 sim1 = sim2 |
|---|
| 154 | elif ( opts.simulation == opts.reference and opts.simulation != 'OBS') : |
|---|
| 155 | simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid) |
|---|
| 156 | simu = ml2pl(simu,simu_pres) |
|---|
| 157 | simu = zonmean(simu) |
|---|
| 158 | reff = simu |
|---|
| 159 | diff=minus(simu,reff) |
|---|
| 160 | print ' cas3 sim ref on pressure levels w/ zonmean ' |
|---|
| 161 | else : |
|---|
| 162 | print ' Cas non prevu !! ' |
|---|
| 163 | print ' Modifier l appel de atlas_none.py et relancer ' |
|---|
| 164 | exit(0) |
|---|
| 165 | else: |
|---|
| 166 | #27.11.21 if (opts.grid == '' ) : reff=regrid(reff,simu) |
|---|
| 167 | if ( opts.simulation != opts.reference ) : reff=regrid(reff,simu) |
|---|
| 168 | diff=minus(simu,reff) |
|---|
| 169 | |
|---|
| 170 | pparams = plot_params(variable,'full_field') |
|---|
| 171 | #print 'minp',opts.minp |
|---|
| 172 | vertical_interval = 'trYMaxF=1000|trYMinF=1' |
|---|
| 173 | #vertical_interval = 'trYMaxF=1000|trYMinF=100' |
|---|
| 174 | #vertical_interval = 'trYMaxF=1000|trYMinF='+opts.pmin |
|---|
| 175 | vertical_interval = 'trYMaxF=1000|trYMinF=1' |
|---|
| 176 | stringFontHeight=0.018 |
|---|
| 177 | if is3d(variable): |
|---|
| 178 | #pparams.update({'options':vertical_interval, 'y':'lin'}) |
|---|
| 179 | pparams.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) |
|---|
| 180 | stringFontHeight=0.03 |
|---|
| 181 | # Map for simulation |
|---|
| 182 | simu_fig=plot(llbox(simu,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
|---|
| 183 | title="", |
|---|
| 184 | gsnLeftString=variable, |
|---|
| 185 | gsnCenterString=opts.simulation, |
|---|
| 186 | gsnRightString=opts.season, |
|---|
| 187 | gsnStringFontHeightF=stringFontHeight, |
|---|
| 188 | mpCenterLonF=centerlon, |
|---|
| 189 | **pparams) |
|---|
| 190 | # mpCenterLonF=0, |
|---|
| 191 | # Single figures |
|---|
| 192 | page=cpage([[simu_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 193 | pdf_page=cpage([[simu_fig]],orientation='landscape', |
|---|
| 194 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 195 | print 'PB = ',opts.dirpng,opts.season,opts.simulation,'MAP',opts.region,variable |
|---|
| 196 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf")) |
|---|
| 197 | simu_avg=cvalue(space_average(simu)) |
|---|
| 198 | # |
|---|
| 199 | # Map for reference |
|---|
| 200 | ref_fig=plot(llbox(reff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
|---|
| 201 | title="", |
|---|
| 202 | gsnLeftString=variable, |
|---|
| 203 | gsnCenterString=ref, |
|---|
| 204 | gsnRightString=opts.season, |
|---|
| 205 | gsnStringFontHeightF=stringFontHeight, |
|---|
| 206 | mpCenterLonF=centerlon, |
|---|
| 207 | **pparams) |
|---|
| 208 | # mpCenterLonF=0, |
|---|
| 209 | # # Single figures ref_fig |
|---|
| 210 | page=cpage([[ref_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 211 | pdf_page=cpage([[ref_fig]],orientation='landscape', |
|---|
| 212 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 213 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+opts.region+"/"+variable+".pdf")) |
|---|
| 214 | ref_avg=cvalue(space_average(reff)) |
|---|
| 215 | # |
|---|
| 216 | # Bias (or difference between simulations) map |
|---|
| 217 | if (ref == 'OBS' ) : p=plot_params(variable,'bias') |
|---|
| 218 | else: p=plot_params(variable,'model_model') |
|---|
| 219 | tmp_aux_params = plot_params(variable,'full_field') |
|---|
| 220 | scale = 1.0 ; offset = 0.0 |
|---|
| 221 | if 'offset' in tmp_aux_params or 'scale' in tmp_aux_params: |
|---|
| 222 | if 'offset' in tmp_aux_params: |
|---|
| 223 | offset = tmp_aux_params['offset'] |
|---|
| 224 | else: |
|---|
| 225 | offset=0.0 |
|---|
| 226 | if 'scale' in tmp_aux_params: |
|---|
| 227 | scale = tmp_aux_params['scale'] |
|---|
| 228 | else: |
|---|
| 229 | scale=1.0 |
|---|
| 230 | wreff = apply_scale_offset(reff,scale,offset) |
|---|
| 231 | wsimu = apply_scale_offset(simu,scale,offset) |
|---|
| 232 | else: |
|---|
| 233 | wreff = reff |
|---|
| 234 | wsimu = simu |
|---|
| 235 | # |
|---|
| 236 | if is3d(variable): |
|---|
| 237 | #p.update({'options':vertical_interval, 'y':'lin'}) |
|---|
| 238 | p.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) |
|---|
| 239 | if variable in ['ua','va','ta','hus','hur']: |
|---|
| 240 | tmp_levs = tmp_aux_params['colors'] |
|---|
| 241 | p.update({'contours':tmp_levs}) |
|---|
| 242 | diff_fig=plot(llbox(diff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
|---|
| 243 | llbox(wreff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
|---|
| 244 | title="", format='png', |
|---|
| 245 | gsnLeftString=variable, |
|---|
| 246 | gsnCenterString=opts.simulation+' - '+ref, |
|---|
| 247 | gsnRightString=opts.season, |
|---|
| 248 | gsnStringFontHeightF=stringFontHeight, |
|---|
| 249 | aux_options='cnLineThicknessF=2|cnLineLabelsOn=True', **p) |
|---|
| 250 | # # Single figures diff_fig |
|---|
| 251 | page=cpage([[diff_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 252 | pdf_page=cpage([[diff_fig]],orientation='landscape', |
|---|
| 253 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 254 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+opts.region+"/"+variable+".pdf")) |
|---|
| 255 | else: |
|---|
| 256 | p.update({'contours':1}) |
|---|
| 257 | diff_fig=plot(llbox(diff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
|---|
| 258 | title="", format='png', |
|---|
| 259 | gsnLeftString=variable, |
|---|
| 260 | gsnCenterString=opts.simulation+' - '+ref, |
|---|
| 261 | gsnRightString=opts.season, |
|---|
| 262 | gsnStringFontHeightF=stringFontHeight, |
|---|
| 263 | mpCenterLonF=centerlon, |
|---|
| 264 | **p) |
|---|
| 265 | # mpCenterLonF=0, |
|---|
| 266 | |
|---|
| 267 | # |
|---|
| 268 | # Bias mean value, and RMSD/RMSE |
|---|
| 269 | diff_avg=cvalue(space_average(diff)) |
|---|
| 270 | rmsd=math.sqrt(cvalue(space_average(ccdo(diff,operator='-b F64 sqr')))) |
|---|
| 271 | # |
|---|
| 272 | # Zonal means |
|---|
| 273 | if not is3d(variable): |
|---|
| 274 | # -- apply a mask corresponding to the reference |
|---|
| 275 | mask = div(reff,reff) |
|---|
| 276 | msimu = mul(wsimu,mask) |
|---|
| 277 | # -- Compute the zonal mean |
|---|
| 278 | zmean=ccdo(msimu, operator='zonmean') |
|---|
| 279 | ref_zmean=ccdo(wreff, operator='zonmean') |
|---|
| 280 | # |
|---|
| 281 | sim=opts.simulation |
|---|
| 282 | #if variable in ['zg500']: |
|---|
| 283 | # ref_zmean = ccdo(ref_zmean,operator='-b F32 mulc,1') |
|---|
| 284 | # zmean = ccdo(zmean,operator='-b F32 mulc,1') |
|---|
| 285 | zmean_fig=curves(cens([sim,ref],zmean,ref_zmean), |
|---|
| 286 | title="", |
|---|
| 287 | lgcols=3, |
|---|
| 288 | options=#'tiYAxisString=""|'+\ |
|---|
| 289 | #'+\'+\ |
|---|
| 290 | 'tmYROn=True|'+\ |
|---|
| 291 | 'tmYRBorderOn=True|'+\ |
|---|
| 292 | 'tmYLOn=False|'+\ |
|---|
| 293 | 'tmYUseRight=True|'+\ |
|---|
| 294 | 'vpXF=0|'+\ |
|---|
| 295 | 'vpWidthF=0.66|'+\ |
|---|
| 296 | 'vpHeightF=0.33|'+\ |
|---|
| 297 | 'tmYRLabelsOn=True|'+\ |
|---|
| 298 | 'tmXBLabelFontHeightF=0.018|'+\ |
|---|
| 299 | 'tmYLLabelFontHeightF=0.016|'+\ |
|---|
| 300 | 'lgLabelFontHeightF=0.018|'+\ |
|---|
| 301 | #'pmLegendSide=Bottom|'+\ |
|---|
| 302 | 'pmLegendOrthogonalPosF=-0.32|'+\ |
|---|
| 303 | 'pmLegendParallelPosF=1.0|'+\ |
|---|
| 304 | 'tmXMajorGrid=True|'+\ |
|---|
| 305 | 'tmYMajorGrid=True|'+\ |
|---|
| 306 | 'tmXMajorGridLineDashPattern=2|'+\ |
|---|
| 307 | 'tmYMajorGridLineDashPattern=2|'+\ |
|---|
| 308 | 'xyLineThicknessF=8|'+\ |
|---|
| 309 | 'gsnLeftString='+variable+'|'+\ |
|---|
| 310 | 'gsnCenterString='+opts.simulation+' vs '+ref+'|'+\ |
|---|
| 311 | 'gsnRightString='+opts.season+'|'+\ |
|---|
| 312 | 'gsnStringFontHeightF='+str(stringFontHeight)) |
|---|
| 313 | # # Single figures |
|---|
| 314 | page=cpage([[simu_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 315 | pdf_page=cpage([[simu_fig]],orientation='landscape', |
|---|
| 316 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 317 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf")) |
|---|
| 318 | # # Single figures ref_fig |
|---|
| 319 | page=cpage([[ref_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 320 | pdf_page=cpage([[ref_fig]],orientation='landscape', |
|---|
| 321 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 322 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+opts.region+"/"+variable+".pdf")) |
|---|
| 323 | # # Single figures diff_fig |
|---|
| 324 | page=cpage([[diff_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 325 | pdf_page=cpage([[diff_fig]],orientation='landscape', |
|---|
| 326 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 327 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+opts.region+"/"+variable+".pdf")) |
|---|
| 328 | # Creation du Pdf multi-pages |
|---|
| 329 | comm=subprocess.Popen(pdfargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|---|
| 330 | # # Composite figure |
|---|
| 331 | if is3d(variable): |
|---|
| 332 | page=cpage([[simu_fig,ref_fig],[diff_fig,None]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 333 | pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,None]],orientation='landscape', |
|---|
| 334 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 335 | else: |
|---|
| 336 | page=cpage([[simu_fig,ref_fig],[diff_fig,zmean_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
|---|
| 337 | pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,zmean_fig]],orientation='landscape', |
|---|
| 338 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
|---|
| 339 | pdfargs.append(cfile(pdf_page)) |
|---|
| 340 | # |
|---|
| 341 | thumbnail_size = 200 |
|---|
| 342 | if is3d(variable): |
|---|
| 343 | index+=open_line(varlongname(variable)+' ('+variable+')')+\ |
|---|
| 344 | cell("%.2g"%diff_avg,cfile(diff_fig))+\ |
|---|
| 345 | cell("%.2g"%rmsd,cfile(diff_fig))+\ |
|---|
| 346 | cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 347 | cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 348 | cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 349 | ' '+\ |
|---|
| 350 | cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 351 | cell('Pdf',cfile(pdf_page)) |
|---|
| 352 | close_line() |
|---|
| 353 | else: |
|---|
| 354 | index+=open_line(varlongname(variable)+' ('+variable+')')+\ |
|---|
| 355 | cell("%.2g"%diff_avg,cfile(diff_fig))+\ |
|---|
| 356 | cell("%.2g"%rmsd,cfile(diff_fig))+\ |
|---|
| 357 | cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 358 | cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 359 | cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 360 | cell('zonal mean',cfile(zmean_fig),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 361 | cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\ |
|---|
| 362 | cell('Pdf',cfile(pdf_page)) |
|---|
| 363 | close_line() |
|---|
| 364 | # |
|---|
| 365 | # Finalisons l'index html |
|---|
| 366 | index += close_table() |
|---|
| 367 | index += trailer() |
|---|
| 368 | out="index_"+opts.region+"_"+opts.season+"_"+opts.simulation+".html" |
|---|
| 369 | with open(out,"w") as filout : filout.write(index) |
|---|
| 370 | # |
|---|
| 371 | # Creation du Pdf multi-pages |
|---|
| 372 | comm=subprocess.Popen(pdfargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|---|
| 373 | # |
|---|
| 374 | import os,os.path ; |
|---|
| 375 | # print("Attendez un bon peu : lancemement de firefox sur Ciclad....") |
|---|
| 376 | # os.system("firefox file://"+os.path.abspath(os.path.curdir)+"/"+out+"&") |
|---|