Changeset 4309 for BOL/Multi_atlas
- Timestamp:
- Oct 26, 2022, 1:16:12 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BOL/Multi_atlas/atlas/atlas_none.py
r3915 r4309 12 12 13 13 # Répertoire de base pour les entrées et les résultats 14 #dir_default='/data/hourdin/LMDZ6/SE/ORIG' 15 #dir_default='/prodigfs/fabric/LMDZ6/SE/ORIG' 16 #dir_default='/prodigfs/ipslfs/dods/fabric/lmdz/SE/ORIG' 14 dir_default='/thredds/ipsl/fabric/lmdz/SE/ORIG' 17 15 18 16 # Gestion des options et arguments d'appel … … 23 21 parser.add_option("-i", "--input", help="repertoire des donnes d'entree(defaut : %s)", 24 22 action="store",default=None) 25 parser.add_option("-g", "--grid", help="nom de grille (default: VLR)", action="store",default='VLR') 26 parser.add_option("-r", "--region", help="nom de zone (default: GLOB)", action="store",default='GLOB') 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 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)", 28 30 action="store", default='YEAR') 29 31 parser.add_option("-s", "--simulation", help="simulation+annees a traiter (sim_YYY1_YYY2) - laisser vide pour lister", … … 38 40 parser.add_option("--dirpng",help="Path of the simulation directory", action="store",default=None) 39 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') 40 47 (opts, args) = parser.parse_args() 41 48 49 print 'pmin = ',opts.pmin 50 centerlon=float(opts.lonmax)-180 51 print 'centerlon = ',centerlon 52 #quit() 42 53 #--------------------------------------------------------------------------------- 43 54 import math … … 51 62 # 52 63 clog('debug') 53 crm(pattern='pme')54 crm(pattern='hflsevap')64 #crm(pattern='pme') 65 #crm(pattern='hflsevap') 55 66 #crm(pattern='tasmax') 56 67 #crm(pattern='tasmin') … … 87 98 # 88 99 # -- Declare the script ml2pl for vertical interpolation 89 cscript("ml2pl", "/home/ jservon/Evaluation/CliMAF/Atlas_LMDz/ml2pl.sh -p ${var_2} -m ${var_1} ${in_1} ${out} ${in_2}",100 cscript("ml2pl", "/home/fabric/LMDZ/atlas/ml2pl.sh -p ${var_2} -m ${var_1} ${in_1} ${out} ${in_2}", 90 101 commuteWithTimeConcatenation=True, commuteWithSpaceConcatenation=True) 91 102 # -- Vertical levels for the vertical interpolation … … 106 117 # interpolates the model on the ref, both vertically and horizontally, and returns the difference) 107 118 if is3d(variable) : 108 simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid) 109 simu = ml2pl(simu,simu_pres) 110 if (ref != 'OBS' ) : 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 111 127 reff_pres = svsg(opts.reference,'pres',opts.season,opts.grid) 112 128 reff = ml2pl(reff,reff_pres) 113 simu = zonmean(simu) 114 reff = zonmean(reff) 115 diff = diff_zonmean(simu,reff) 116 else: 117 if (opts.grid == '' ) : reff=regrid(reff,simu) 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) 118 168 diff=minus(simu,reff) 119 169 120 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 121 175 vertical_interval = 'trYMaxF=1000|trYMinF=1' 122 176 stringFontHeight=0.018 123 177 if is3d(variable): 124 pparams.update({'options':vertical_interval}) 178 #pparams.update({'options':vertical_interval, 'y':'lin'}) 179 pparams.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) 125 180 stringFontHeight=0.03 126 181 # Map for simulation 127 simu_fig=plot(simu,title="", 182 simu_fig=plot(llbox(simu,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), 183 title="", 128 184 gsnLeftString=variable, 129 185 gsnCenterString=opts.simulation, 130 186 gsnRightString=opts.season, 131 187 gsnStringFontHeightF=stringFontHeight, 132 mpCenterLonF= 0,188 mpCenterLonF=centerlon, 133 189 **pparams) 134 # ##11052021 begin135 ## Single figures190 # mpCenterLonF=0, 191 # Single figures 136 192 page=cpage([[simu_fig]],orientation='landscape', page_trim=True, fig_trim=True) 137 193 pdf_page=cpage([[simu_fig]],orientation='landscape', 138 page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) 139 #pdfargs.append(cfile(pdf_page,target='/home/fabric/users/musat/myatlas/simu_fig.pdf')) 140 #pdffile="atlas_"+opts.simulation+"_"+opts.season+".pdf" 141 #pdfargs.append(cfile(pdf_page,target=opts.simumapp)) 142 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+variable+".pdf")) 143 # 144 ###11052021 end 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")) 145 197 simu_avg=cvalue(space_average(simu)) 146 198 # 147 199 # Map for reference 148 ref_fig=plot(reff,title="", 200 ref_fig=plot(llbox(reff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), 201 title="", 149 202 gsnLeftString=variable, 150 203 gsnCenterString=ref, 151 204 gsnRightString=opts.season, 152 205 gsnStringFontHeightF=stringFontHeight, 153 mpCenterLonF=0,206 mpCenterLonF=centerlon, 154 207 **pparams) 155 # ##11052021 begin208 # mpCenterLonF=0, 156 209 # # Single figures ref_fig 157 210 page=cpage([[ref_fig]],orientation='landscape', page_trim=True, fig_trim=True) 158 211 pdf_page=cpage([[ref_fig]],orientation='landscape', 159 212 page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) 160 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+variable+".pdf")) 161 ###11052021 end 213 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+opts.region+"/"+variable+".pdf")) 162 214 ref_avg=cvalue(space_average(reff)) 163 215 # … … 183 235 # 184 236 if is3d(variable): 185 p.update({'options':vertical_interval}) 237 #p.update({'options':vertical_interval, 'y':'lin'}) 238 p.update({'options':vertical_interval+'|gsnYAxisIrregular2Linear=True'}) 186 239 if variable in ['ua','va','ta','hus','hur']: 187 240 tmp_levs = tmp_aux_params['colors'] 188 241 p.update({'contours':tmp_levs}) 189 diff_fig=plot(diff,wreff,title="", format='png', mpCenterLonF=0, 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', 190 245 gsnLeftString=variable, 191 246 gsnCenterString=opts.simulation+' - '+ref, … … 197 252 pdf_page=cpage([[diff_fig]],orientation='landscape', 198 253 page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) 199 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+ variable+".pdf"))254 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+opts.region+"/"+variable+".pdf")) 200 255 else: 201 256 p.update({'contours':1}) 202 diff_fig=plot(diff,title="", format='png', mpCenterLonF=0, 257 diff_fig=plot(llbox(diff,lonmin=opts.lonmin,lonmax=opts.lonmax,latmin=opts.latmin,latmax=opts.latmax), 258 title="", format='png', 203 259 gsnLeftString=variable, 204 260 gsnCenterString=opts.simulation+' - '+ref, 205 261 gsnRightString=opts.season, 206 262 gsnStringFontHeightF=stringFontHeight, 263 mpCenterLonF=centerlon, 207 264 **p) 265 # mpCenterLonF=0, 208 266 209 267 # … … 218 276 msimu = mul(wsimu,mask) 219 277 # -- Compute the zonal mean 220 278 zmean=ccdo(msimu, operator='zonmean') 221 279 ref_zmean=ccdo(wreff, operator='zonmean') 222 280 # … … 254 312 'gsnStringFontHeightF='+str(stringFontHeight)) 255 313 # # Single figures 256 257 258 259 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+ variable+".pdf"))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")) 260 318 # # Single figures ref_fig 261 262 263 264 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.reference+"/MAP/"+ variable+".pdf"))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")) 265 323 # # Single figures diff_fig 266 267 268 269 pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/DMAP_"+opts.reference+"/"+ variable+".pdf"))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")) 270 328 # Creation du Pdf multi-pages 271 329 comm=subprocess.Popen(pdfargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 272 330 # # Composite figure 273 331 if is3d(variable): … … 279 337 pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,zmean_fig]],orientation='landscape', 280 338 page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation) 339 pdfargs.append(cfile(pdf_page)) 281 340 # 282 341 thumbnail_size = 200 … … 307 366 index += close_table() 308 367 index += trailer() 309 #out="index_example.html"310 368 out="index_"+opts.region+"_"+opts.season+"_"+opts.simulation+".html" 311 369 with open(out,"w") as filout : filout.write(index)
Note: See TracChangeset
for help on using the changeset viewer.