[3684] | 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 |
---|
[4309] | 14 | dir_default='/thredds/ipsl/fabric/lmdz/SE/ORIG' |
---|
[3684] | 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) |
---|
[4309] | 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') |
---|
[3684] | 27 | parser.add_option("-p", "--season", help="saison a traiter " "(eg : JJA, DJF, YEAR, defaut=%YEAR)", |
---|
[4309] | 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)", |
---|
[3684] | 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) |
---|
[3915] | 40 | parser.add_option("--dirpng",help="Path of the simulation directory", action="store",default=None) |
---|
[3684] | 41 | parser.add_option("-o", "--pdf", help="nom du pdf de sortie (default: atlas_<SIMU>_<SAISON>.pdf)", action="store") |
---|
[4309] | 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') |
---|
[3684] | 47 | (opts, args) = parser.parse_args() |
---|
| 48 | |
---|
[4320] | 49 | print('pmin = ',opts.pmin) |
---|
[4309] | 50 | centerlon=float(opts.lonmax)-180 |
---|
[4320] | 51 | print('centerlon = ',centerlon) |
---|
| 52 | |
---|
[3684] | 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 | # |
---|
[4696] | 63 | #clog('debug') |
---|
| 64 | clog('critical') |
---|
[4309] | 65 | #crm(pattern='pme') |
---|
| 66 | #crm(pattern='hflsevap') |
---|
[3684] | 67 | #crm(pattern='tasmax') |
---|
| 68 | #crm(pattern='tasmin') |
---|
| 69 | def apply_scale_offset(dat,scale,offset): |
---|
| 70 | return ccdo(ccdo(dat,operator='mulc,'+str(float(scale))),operator='addc,'+str(float(offset))) |
---|
| 71 | # |
---|
| 72 | #craz() |
---|
| 73 | if opts.simulation is None: |
---|
[4320] | 74 | print("Available simulations at %s are : "%opts.input,) |
---|
| 75 | for s in all_SE_simulations() : print(s,) |
---|
[3684] | 76 | exit(0) |
---|
| 77 | # |
---|
| 78 | lvars=opts.variables |
---|
| 79 | if lvars is not None : lvars=lvars.split(',') |
---|
| 80 | else : lvars=variables_list |
---|
| 81 | # |
---|
| 82 | # Preparons une commande pour assembler les sorties Pdf |
---|
| 83 | if opts.pdf : pdffile=opts.pdf |
---|
| 84 | else: pdffile="atlas_"+opts.simulation+"_"+opts.season+".pdf" |
---|
| 85 | pdfargs=["pdfjam","--landscape","-o ",pdffile] |
---|
| 86 | # |
---|
| 87 | # Initialisation de l'index html |
---|
| 88 | index= header("LMDZ Atlas for "+opts.simulation+ " versus "+opts.reference+" ("+opts.season+")") |
---|
| 89 | index += cell('PDF',pdffile) |
---|
| 90 | index += section("2d vars", level=4) |
---|
| 91 | index += open_table() |
---|
| 92 | # |
---|
| 93 | # Titres de colonnes |
---|
| 94 | ref=opts.reference ; |
---|
| 95 | if (ref == 'OBS' ) : text_diff='bias' |
---|
| 96 | else: text_diff='diff' |
---|
| 97 | index+=open_line('VARIABLE')+cell('bias')+cell('rmse')+cell('mean')+cell(ref)+cell(text_diff)+\ |
---|
| 98 | cell('zonal')+cell('all')+cell('pdf')+close_line() |
---|
| 99 | # |
---|
| 100 | # -- Declare the script ml2pl for vertical interpolation |
---|
[4309] | 101 | cscript("ml2pl", "/home/fabric/LMDZ/atlas/ml2pl.sh -p ${var_2} -m ${var_1} ${in_1} ${out} ${in_2}", |
---|
[3684] | 102 | commuteWithTimeConcatenation=True, commuteWithSpaceConcatenation=True) |
---|
| 103 | # -- Vertical levels for the vertical interpolation |
---|
| 104 | fixed_fields("ml2pl",("press_levels.txt","/home/fabric/LMDZ/atlas/press_levels.txt")) |
---|
| 105 | # |
---|
| 106 | for variable in lvars : |
---|
| 107 | # Get the model and the reference |
---|
| 108 | if opts.root: |
---|
| 109 | simu=svsg(opts.simulation,variable,opts.season,opts.grid, root=opts.root) |
---|
| 110 | else: |
---|
| 111 | simu=svsg(opts.simulation,variable,opts.season,opts.grid) |
---|
[4320] | 112 | print('variable = ',variable) |
---|
[3684] | 113 | reff=svsg(opts.reference,variable,opts.season,opts.grid) |
---|
| 114 | # |
---|
| 115 | # If the variable is a 3D field: |
---|
| 116 | # - interpolate the variable on the standard pressure levels with ml2pl (L. Guez) |
---|
| 117 | # - Compute the difference model-ref with diff_zonmean (computes the zonal mean lat/pressure fields, |
---|
| 118 | # interpolates the model on the ref, both vertically and horizontally, and returns the difference) |
---|
| 119 | if is3d(variable) : |
---|
[4309] | 120 | #cas1 sim2 != sim1 ; sim1 != OBS ; sim2 != OBS |
---|
| 121 | if (opts.simulation != 'OBS' and opts.reference != 'OBS' and opts.simulation != opts.reference ) : |
---|
[4320] | 122 | print('simu = ',opts.simulation) |
---|
| 123 | print('reff = ',opts.reference) |
---|
[4309] | 124 | simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid) |
---|
| 125 | simu = ml2pl(simu,simu_pres) |
---|
| 126 | simu = zonmean(simu) |
---|
[4320] | 127 | print('simu = ',simu) |
---|
[3885] | 128 | reff_pres = svsg(opts.reference,'pres',opts.season,opts.grid) |
---|
| 129 | reff = ml2pl(reff,reff_pres) |
---|
[4309] | 130 | reff = zonmean(reff) |
---|
[4320] | 131 | print('reff = ',reff) |
---|
[4309] | 132 | ### IM250821 : projection grille horizontale |
---|
| 133 | # reff=regrid(reff,simu) |
---|
| 134 | simu=regrid(simu,reff) |
---|
| 135 | diff=minus(simu,reff) |
---|
[4320] | 136 | print('diff_zonmean simu = ',diff) |
---|
| 137 | print(' cas1 sim ref on pressure levels w/ zonmean ') |
---|
[4309] | 138 | #cas2 sim !=$ OBS ; ref = OBS |
---|
| 139 | elif (opts.simulation != 'OBS' and opts.reference == 'OBS' ) : |
---|
[4320] | 140 | print('cas2') |
---|
[4309] | 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 |
---|
[4320] | 145 | simu = zonmean(simu) |
---|
[4309] | 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) |
---|
[4320] | 152 | print(' cas2 sim ref on pressure levels w/ zonmean ') |
---|
[4309] | 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) |
---|
[4320] | 160 | print(' cas3 sim ref on pressure levels w/ zonmean ') |
---|
[4309] | 161 | else : |
---|
[4320] | 162 | print(' Cas non prevu !! ') |
---|
| 163 | print(' Modifier l appel de atlas_none.py et relancer ') |
---|
[4309] | 164 | exit(0) |
---|
[3684] | 165 | else: |
---|
[4309] | 166 | #27.11.21 if (opts.grid == '' ) : reff=regrid(reff,simu) |
---|
[4320] | 167 | if ( opts.simulation != opts.reference ) : reff=regrid(reff,simu) |
---|
| 168 | diff=minus(simu,reff) |
---|
[3684] | 169 | |
---|
| 170 | pparams = plot_params(variable,'full_field') |
---|
| 171 | vertical_interval = 'trYMaxF=1000|trYMinF=1' |
---|
[4309] | 172 | #vertical_interval = 'trYMaxF=1000|trYMinF=100' |
---|
| 173 | #vertical_interval = 'trYMaxF=1000|trYMinF='+opts.pmin |
---|
| 174 | vertical_interval = 'trYMaxF=1000|trYMinF=1' |
---|
[3684] | 175 | stringFontHeight=0.018 |
---|
| 176 | if is3d(variable): |
---|
[4309] | 177 | #pparams.update({'options':vertical_interval, 'y':'lin'}) |
---|
| 178 | pparams.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) |
---|
[3684] | 179 | stringFontHeight=0.03 |
---|
| 180 | # Map for simulation |
---|
[4309] | 181 | simu_fig=plot(llbox(simu,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
---|
| 182 | title="", |
---|
[3684] | 183 | gsnLeftString=variable, |
---|
| 184 | gsnCenterString=opts.simulation, |
---|
| 185 | gsnRightString=opts.season, |
---|
| 186 | gsnStringFontHeightF=stringFontHeight, |
---|
[4309] | 187 | mpCenterLonF=centerlon, |
---|
[3684] | 188 | **pparams) |
---|
[4309] | 189 | # mpCenterLonF=0, |
---|
| 190 | # Single figures |
---|
[3915] | 191 | page=cpage([[simu_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
---|
| 192 | pdf_page=cpage([[simu_fig]],orientation='landscape', |
---|
[4309] | 193 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
---|
[4320] | 194 | print('PB = ',opts.dirpng,opts.season,opts.simulation,'MAP',opts.region,variable) |
---|
| 195 | print('DIRpng/im.pdf=',opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf") |
---|
[4309] | 196 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf")) |
---|
[3684] | 197 | simu_avg=cvalue(space_average(simu)) |
---|
| 198 | # |
---|
| 199 | # Map for reference |
---|
[4309] | 200 | ref_fig=plot(llbox(reff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
---|
| 201 | title="", |
---|
[3684] | 202 | gsnLeftString=variable, |
---|
| 203 | gsnCenterString=ref, |
---|
| 204 | gsnRightString=opts.season, |
---|
| 205 | gsnStringFontHeightF=stringFontHeight, |
---|
[4309] | 206 | mpCenterLonF=centerlon, |
---|
[3684] | 207 | **pparams) |
---|
[4309] | 208 | # mpCenterLonF=0, |
---|
[3915] | 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) |
---|
[4309] | 213 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+opts.region+"/"+variable+".pdf")) |
---|
[3684] | 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: |
---|
[4320] | 225 | offset=0.0 |
---|
[3684] | 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): |
---|
[4309] | 237 | #p.update({'options':vertical_interval, 'y':'lin'}) |
---|
| 238 | p.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) |
---|
[3684] | 239 | if variable in ['ua','va','ta','hus','hur']: |
---|
| 240 | tmp_levs = tmp_aux_params['colors'] |
---|
| 241 | p.update({'contours':tmp_levs}) |
---|
[4309] | 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', |
---|
[3684] | 245 | gsnLeftString=variable, |
---|
| 246 | gsnCenterString=opts.simulation+' - '+ref, |
---|
| 247 | gsnRightString=opts.season, |
---|
| 248 | gsnStringFontHeightF=stringFontHeight, |
---|
| 249 | aux_options='cnLineThicknessF=2|cnLineLabelsOn=True', **p) |
---|
[3915] | 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) |
---|
[4309] | 254 | pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+opts.region+"/"+variable+".pdf")) |
---|
[3684] | 255 | else: |
---|
| 256 | p.update({'contours':1}) |
---|
[4309] | 257 | diff_fig=plot(llbox(diff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), |
---|
| 258 | title="", format='png', |
---|
[3684] | 259 | gsnLeftString=variable, |
---|
| 260 | gsnCenterString=opts.simulation+' - '+ref, |
---|
| 261 | gsnRightString=opts.season, |
---|
| 262 | gsnStringFontHeightF=stringFontHeight, |
---|
[4309] | 263 | mpCenterLonF=centerlon, |
---|
[3684] | 264 | **p) |
---|
[4309] | 265 | # mpCenterLonF=0, |
---|
[3684] | 266 | |
---|
| 267 | # |
---|
| 268 | # Bias mean value, and RMSD/RMSE |
---|
| 269 | diff_avg=cvalue(space_average(diff)) |
---|
[4330] | 270 | rmsd=math.sqrt(cvalue(space_average(ccdo(diff,operator='b F64 sqr')))) |
---|
[3684] | 271 | # |
---|
| 272 | # Zonal means |
---|
| 273 | if not is3d(variable): |
---|
| 274 | # -- apply a mask corresponding to the reference |
---|
[4345] | 275 | #IMorig mask = div(reff,reff) |
---|
| 276 | #IMorig msimu = mul(wsimu,mask) |
---|
[4320] | 277 | # -- Compute the zonal mean |
---|
[4345] | 278 | #IMorig zmean=ccdo(msimu, operator='zonmean') |
---|
| 279 | #IMorig ref_zmean=ccdo(wreff, operator='zonmean') |
---|
[3684] | 280 | # |
---|
[4345] | 281 | #IMorig sim=opts.simulation |
---|
[4320] | 282 | #if variable in ['zg500']: |
---|
| 283 | # ref_zmean = ccdo(ref_zmean,operator='-b F32 mulc,1') |
---|
[3684] | 284 | # zmean = ccdo(zmean,operator='-b F32 mulc,1') |
---|
[4345] | 285 | #IMorig zmean_fig=curves(cens([sim,ref],zmean,ref_zmean), |
---|
| 286 | #IMorig title="", |
---|
| 287 | #IMorig lgcols=3, |
---|
| 288 | #IMorig options=#'tiYAxisString=""|'+\ |
---|
| 289 | #IMorig #'+\'+\ |
---|
| 290 | #IMorig 'tmYROn=True|'+\ |
---|
| 291 | #IMorig 'tmYRBorderOn=True|'+\ |
---|
| 292 | #IMorig 'tmYLOn=False|'+\ |
---|
| 293 | #IMorig 'tmYUseRight=True|'+\ |
---|
| 294 | #IMorig 'vpXF=0|'+\ |
---|
| 295 | #IMorig 'vpWidthF=0.66|'+\ |
---|
| 296 | #IMorig 'vpHeightF=0.33|'+\ |
---|
| 297 | #IMorig 'tmYRLabelsOn=True|'+\ |
---|
| 298 | #IMorig 'tmXBLabelFontHeightF=0.018|'+\ |
---|
| 299 | #IMorig 'tmYLLabelFontHeightF=0.016|'+\ |
---|
| 300 | #IMorig 'lgLabelFontHeightF=0.018|'+\ |
---|
| 301 | #IMorig #'pmLegendSide=Bottom|'+\ |
---|
| 302 | #IMorig 'pmLegendOrthogonalPosF=-0.32|'+\ |
---|
| 303 | #IMorig 'pmLegendParallelPosF=1.0|'+\ |
---|
| 304 | #IMorig 'tmXMajorGrid=True|'+\ |
---|
| 305 | #IMorig 'tmYMajorGrid=True|'+\ |
---|
| 306 | #IMorig 'tmXMajorGridLineDashPattern=2|'+\ |
---|
| 307 | #IMorig 'tmYMajorGridLineDashPattern=2|'+\ |
---|
| 308 | #IMorig 'xyLineThicknessF=8|'+\ |
---|
| 309 | #IMorig 'gsnLeftString='+variable+'|'+\ |
---|
| 310 | #IMorig 'gsnCenterString='+opts.simulation+' vs '+ref+'|'+\ |
---|
| 311 | #IMorig 'gsnRightString='+opts.season+'|'+\ |
---|
| 312 | #IMorig 'gsnStringFontHeightF='+str(stringFontHeight)) |
---|
[3915] | 313 | # # Single figures |
---|
[4309] | 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")) |
---|
[3915] | 318 | # # Single figures ref_fig |
---|
[4309] | 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")) |
---|
[3915] | 323 | # # Single figures diff_fig |
---|
[4309] | 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")) |
---|
[3915] | 328 | # Creation du Pdf multi-pages |
---|
[4309] | 329 | comm=subprocess.Popen(pdfargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
---|
[3684] | 330 | # # Composite figure |
---|
| 331 | if is3d(variable): |
---|
[4320] | 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', |
---|
[3684] | 334 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
---|
| 335 | else: |
---|
[4345] | 336 | #IMorig page=cpage([[simu_fig,ref_fig],[diff_fig,zmean_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
---|
| 337 | page=cpage([[simu_fig,ref_fig],[diff_fig,diff_fig]],orientation='landscape', page_trim=True, fig_trim=True) |
---|
| 338 | #IMorig pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,zmean_fig]],orientation='landscape', |
---|
| 339 | pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,diff_fig]],orientation='landscape', |
---|
[3684] | 340 | page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) |
---|
[4309] | 341 | pdfargs.append(cfile(pdf_page)) |
---|
[3684] | 342 | # |
---|
| 343 | thumbnail_size = 200 |
---|
| 344 | if is3d(variable): |
---|
[4320] | 345 | index+=open_line(varlongname(variable)+' ('+variable+')')+\ |
---|
| 346 | cell("%.2g"%diff_avg,cfile(diff_fig))+\ |
---|
| 347 | cell("%.2g"%rmsd,cfile(diff_fig))+\ |
---|
| 348 | cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 349 | cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 350 | cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 351 | ' '+\ |
---|
| 352 | cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 353 | cell('Pdf',cfile(pdf_page)) |
---|
| 354 | close_line() |
---|
[3684] | 355 | else: |
---|
[4320] | 356 | index+=open_line(varlongname(variable)+' ('+variable+')')+\ |
---|
| 357 | cell("%.2g"%diff_avg,cfile(diff_fig))+\ |
---|
| 358 | cell("%.2g"%rmsd,cfile(diff_fig))+\ |
---|
| 359 | cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 360 | cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 361 | cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
[4345] | 362 | cell('zonal mean',cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
[4320] | 363 | cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 364 | cell('Pdf',cfile(pdf_page)) |
---|
| 365 | close_line() |
---|
[4345] | 366 | #IMorig: au-dessus cell('zonal mean',cfile(zmean_fig),thumbnail=thumbnail_size,hover=False)+\ |
---|
| 367 | |
---|
[3684] | 368 | # Finalisons l'index html |
---|
| 369 | index += close_table() |
---|
| 370 | index += trailer() |
---|
[3885] | 371 | out="index_"+opts.region+"_"+opts.season+"_"+opts.simulation+".html" |
---|
[3684] | 372 | with open(out,"w") as filout : filout.write(index) |
---|
| 373 | # |
---|
| 374 | # Creation du Pdf multi-pages |
---|
| 375 | comm=subprocess.Popen(pdfargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
---|
| 376 | # |
---|
| 377 | import os,os.path ; |
---|
| 378 | # print("Attendez un bon peu : lancemement de firefox sur Ciclad....") |
---|
| 379 | # os.system("firefox file://"+os.path.abspath(os.path.curdir)+"/"+out+"&") |
---|