Changeset 4320 for BOL/Multi_atlas


Ignore:
Timestamp:
Nov 3, 2022, 12:02:26 PM (2 years ago)
Author:
musat
Message:

Correction prints et alignements cf. python 3.
IonelaMusat?

Location:
BOL/Multi_atlas/atlas
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BOL/Multi_atlas/atlas/atlas_none.py

    r4309 r4320  
    4747(opts, args) = parser.parse_args()
    4848
    49 print 'pmin = ',opts.pmin
     49print('pmin = ',opts.pmin)
    5050centerlon=float(opts.lonmax)-180
    51 print 'centerlon = ',centerlon
    52 #quit()
     51print('centerlon = ',centerlon)
     52
    5353#---------------------------------------------------------------------------------
    5454import math
     
    7171#craz()
    7272if opts.simulation is None:
    73     print "Available simulations at %s are : "%opts.input,
    74     for s in all_SE_simulations() : print s,
     73    print("Available simulations at %s are : "%opts.input,)
     74    for s in all_SE_simulations() : print(s,)
    7575    exit(0)
    7676#
     
    109109    else:
    110110       simu=svsg(opts.simulation,variable,opts.season,opts.grid)
    111     print 'variable = ',variable
     111    print('variable = ',variable)
    112112    reff=svsg(opts.reference,variable,opts.season,opts.grid)
    113113    #
     
    119119#cas1 sim2 != sim1 ; sim1 != OBS ; sim2 != OBS
    120120       if (opts.simulation != 'OBS' and opts.reference != 'OBS' and opts.simulation != opts.reference ) :
    121            print 'simu = ',opts.simulation
    122            print 'reff = ',opts.reference
     121           print('simu = ',opts.simulation)
     122           print('reff = ',opts.reference)
    123123           simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid)
    124124           simu = ml2pl(simu,simu_pres)
    125125           simu = zonmean(simu)
    126            print 'simu = ',simu
     126           print('simu = ',simu)
    127127           reff_pres = svsg(opts.reference,'pres',opts.season,opts.grid)
    128128           reff = ml2pl(reff,reff_pres)
    129129           reff = zonmean(reff)
    130            print 'reff = ',reff
     130           print('reff = ',reff)
    131131### IM250821 : projection grille horizontale
    132132#          reff=regrid(reff,simu)
    133133           simu=regrid(simu,reff)
    134 ### IM250821 end
    135134           diff=minus(simu,reff)
    136            print 'diff_zonmean simu = ',diff
    137            print ' cas1 sim ref on pressure levels w/ zonmean '
     135           print('diff_zonmean simu = ',diff)
     136           print(' cas1 sim ref on pressure levels w/ zonmean ')
    138137#cas2 sim !=$ OBS ; ref = OBS
    139138       elif (opts.simulation != 'OBS' and opts.reference == 'OBS' ) :
    140            print 'cas2'
     139           print('cas2')
    141140### interpolation sur des niveaux de pression
    142141           simu_pres = svsg(opts.simulation,'pres',opts.season,opts.grid)
    143142           simu = ml2pl(simu,simu_pres)
    144143### moyenne zonale
    145            simu = zonmean(simu)
     144           simu = zonmean(simu)
    146145### moyenne zonale
    147146           reff = zonmean(reff)
     
    150149### differences moyennes zonales
    151150           diff=minus(simu,reff)
    152            print ' cas2 sim ref on pressure levels w/ zonmean '
     151           print(' cas2 sim ref on pressure levels w/ zonmean ')
    153152#cas3 sim1 = sim2
    154153       elif ( opts.simulation == opts.reference and opts.simulation != 'OBS') :
     
    158157           reff = simu
    159158           diff=minus(simu,reff)
    160            print ' cas3 sim ref on pressure levels w/ zonmean '
     159           print(' cas3 sim ref on pressure levels w/ zonmean ')
    161160       else :
    162            print ' Cas non prevu !! '
    163            print ' Modifier l appel de atlas_none.py et relancer '
     161           print(' Cas non prevu !! ')
     162           print(' Modifier l appel de atlas_none.py et relancer ')
    164163           exit(0)
    165164    else:
    166165#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)
     166       if ( opts.simulation != opts.reference ) : reff=regrid(reff,simu)
     167    diff=minus(simu,reff)
    169168
    170169    pparams = plot_params(variable,'full_field')
    171     #print 'minp',opts.minp
    172170    vertical_interval = 'trYMaxF=1000|trYMinF=1'
    173171    #vertical_interval = 'trYMaxF=1000|trYMinF=100'
     
    193191    pdf_page=cpage([[simu_fig]],orientation='landscape',
    194192    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
     193    print('PB = ',opts.dirpng,opts.season,opts.simulation,'MAP',opts.region,variable)
     194    print('DIRpng/im.pdf=',opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf")
    196195    pdfargs.append(cfile(pdf_page,target=opts.dirpng+"/"+opts.season+"/"+opts.simulation+"/MAP/"+opts.region+"/"+variable+".pdf"))
    197196    simu_avg=cvalue(space_average(simu))
     
    223222          offset = tmp_aux_params['offset']
    224223       else:
    225           offset=0.0
     224          offset=0.0
    226225       if 'scale' in tmp_aux_params:
    227226          scale = tmp_aux_params['scale']
     
    273272    if not is3d(variable):
    274273        # -- apply a mask corresponding to the reference
    275         mask = div(reff,reff)
    276         msimu = mul(wsimu,mask)
    277         # -- Compute the zonal mean
     274        mask = div(reff,reff)
     275        msimu = mul(wsimu,mask)
     276        # -- Compute the zonal mean
    278277        zmean=ccdo(msimu, operator='zonmean')
    279         ref_zmean=ccdo(wreff, operator='zonmean')
     278        ref_zmean=ccdo(wreff, operator='zonmean')
    280279        #
    281         sim=opts.simulation
    282         #if variable in ['zg500']:
    283         #   ref_zmean = ccdo(ref_zmean,operator='-b F32 mulc,1')
     280        sim=opts.simulation
     281        #if variable in ['zg500']:
     282        #   ref_zmean = ccdo(ref_zmean,operator='-b F32 mulc,1')
    284283        #   zmean = ccdo(zmean,operator='-b F32 mulc,1')
    285         zmean_fig=curves(cens([sim,ref],zmean,ref_zmean),
     284        zmean_fig=curves(cens([sim,ref],zmean,ref_zmean),
    286285                         title="",
    287286                         lgcols=3,
     
    330329    #    # Composite figure
    331330    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',
     331        page=cpage([[simu_fig,ref_fig],[diff_fig,None]],orientation='landscape', page_trim=True, fig_trim=True)
     332        pdf_page=cpage([[simu_fig,ref_fig],[diff_fig,None]],orientation='landscape',
    334333                   page_trim=True, fig_trim=True, format='pdf', title=variable+" "+opts.simulation)
    335334    else:
     
    341340    thumbnail_size = 200
    342341    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()
     342            index+=open_line(varlongname(variable)+' ('+variable+')')+\
     343                    cell("%.2g"%diff_avg,cfile(diff_fig))+\
     344                    cell("%.2g"%rmsd,cfile(diff_fig))+\
     345                    cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\
     346                    cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\
     347                    cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\
     348                    ' '+\
     349                    cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\
     350                    cell('Pdf',cfile(pdf_page))
     351            close_line()
     352    else:
     353            index+=open_line(varlongname(variable)+' ('+variable+')')+\
     354                    cell("%.2g"%diff_avg,cfile(diff_fig))+\
     355                    cell("%.2g"%rmsd,cfile(diff_fig))+\
     356                    cell(simu,cfile(simu_fig),thumbnail=thumbnail_size,hover=False)+\
     357                    cell(ref,cfile(ref_fig),thumbnail=thumbnail_size,hover=False)+\
     358                    cell(text_diff,cfile(diff_fig),thumbnail=thumbnail_size,hover=False)+\
     359                    cell('zonal mean',cfile(zmean_fig),thumbnail=thumbnail_size,hover=False)+\
     360                    cell('page',cfile(page),thumbnail=thumbnail_size,hover=False)+\
     361                    cell('Pdf',cfile(pdf_page))
     362            close_line()
    364363#
    365364# Finalisons l'index html
  • BOL/Multi_atlas/atlas/lmdz_SE.py

    r3745 r4320  
    3232# Saisons gérées et leur traduction CDO
    3333#########################################################################################
    34 seasons={ 'YEAR':"", 'DJF' : "-timavg -selmon,1,2,12", 'JJA' : "-timavg -selmon,6,7,8" , 'JJAS' : "-timavg -selmon,6,7,8,9" }
    3534#seasons={ 'YEAR':"", 'DJF' : " selmon,1,2,12", 'JJA' : " selmon,6,7,8" , 'JJAS' : "-timavg -selmon,6,7,8,9" }
    36 
     35#seasons={ 'YEAR':"", 'DJF' : "-timavg -selmon,1,2,12", 'JJA' : "-timavg -selmon,6,7,8" , 'JJAS' : "-timavg -selmon,6,7,8,9" }
     36seasons={ 'YEAR':"", 'DJF' : "-timavg -selmon,1,2,12", 'JJA' : "-timavg -selmon,6,7,8" , 'JJAS' : "-timavg -selmon,6,7,8,9", 'MAM' : "-timavg -selmon,3,4,5", 'SON' : "-timavg -selmon,9,10,11" }
    3737
    3838
     
    4040# Definitions pour l'acces aux obs gérées par Ionela
    4141#########################################################################################
    42 cproject('OBS', ('period','fx'),   ('root','/modfs/ipslfs/dods/fabric/lmdz/SE/CMOR/OBS'))  #, '/data/musat/LMDZ6/SE/CMOR/OBS'))
     42cproject('OBS', ('period','fx'),   ('root','/thredds/ipsl/fabric/lmdz/SE/CMOR/OBS'))  #, '/data/musat/LMDZ6/SE/CMOR/OBS'))
    4343dataloc(project='OBS',url='${root}/${variable}.nc')
    4444# Définiton de variables dérivées pour ce projet
     
    101101derive('OBS','dtr','minus','tasmax','tasmin')
    102102
     103calias('OBS', 'hflsevap', 'hfls', scale=1./2.5e6)
    103104
    104105#########################################################################################
     
    117118         ('period','fx'),
    118119         'years',
    119          ('root','/modfs/ipslfs/dods/aidelkad/lmdz/SE/ORIG'),
     120         ('root','/thredds/ipsl/musat/lmdz/SE/ORIG'),
    120121         separator='|')
    121122#exemple de nom de fichier : NPv3.1ada_SE_1982_1991_1M_histmthCOSP.nc
     
    164165calias('SE','hur','rhum', scale=100.)
    165166calias('SE','clt','cldt', scale=100.)
    166 calias('SE','cltcalipso', scale=100.)
    167 calias('SE','clhcalipso', scale=100.)
    168 calias('SE','clmcalipso', scale=100.)
    169 calias('SE','cllcalipso', scale=100.)
     167calias('SE','cltcalipso','cltcalipso', scale=100.)
     168calias('SE','clhcalipso','clhcalipso', scale=100.)
     169calias('SE','clmcalipso','clmcalipso', scale=100.)
     170calias('SE','cllcalipso','cllcalipso', scale=100.)
    170171
    171172# Variables dérivées
     
    257258
    258259
    259 def svsg(simulation,variable,season='YEAR',grid='',root='/modfs/ipslfs/dods/aidelkad/lmdz/SE/ORIG'):
     260def svsg(simulation,variable,season='YEAR',grid='',root='/thredds/ipsl/musat/lmdz/SE/ORIG'):
    260261    """
    261262    Rend l'objet CliMAF pour une variable d'une simulation, pour les  données
     
    289290    if grid != '' :
    290291        if grid not in grid_remapfiles :
    291             print "La grille %s n'est pas connue"%options.grid ;
     292            print("La grille %s n'est pas connue"%options.grid) ;
    292293            return None
    293294        rds=regrid(seas,fds(grid_remapfiles[grid],period='fx'))
    294295    return rds
    295296
    296 def bias_SE(simu,variable,season='YEAR',grid='',root='/modfs/ipslfs/dods/aidelkad/lmdz/SE/ORIG') :
     297def bias_SE(simu,variable,season='YEAR',grid='',root='/thredds/ipsl/musat/lmdz/SE/ORIG') :
    297298    """
    298299    Calcule le biais pour une variable d'une simu, vs 'OBS'
     
    320321   shortvarname = longvarname = variable
    321322   if variable=='tas':
    322         longvarname  = '2M Temperature'
    323         shortvarname = '2M Temp.'
     323        longvarname  = '2M Temperature'
     324        shortvarname = '2M Temp.'
    324325   if variable=='tasmax':
    325         longvarname  = '2M daymax Temperature'
    326         shortvarname = '2M daymx Temp.'
     326        longvarname  = '2M daymax Temperature'
     327        shortvarname = '2M daymx Temp.'
    327328   if variable=='tasmin':
    328         longvarname  = '2M daymin Temperature'
    329         shortvarname = '2M daymn Temp.'
     329        longvarname  = '2M daymin Temperature'
     330        shortvarname = '2M daymn Temp.'
    330331   if variable=='DRT':
    331         longvarname  = '2M diurnal amplitude temperature'
    332         shortvarname = '2M dtr '
     332        longvarname  = '2M diurnal amplitude temperature'
     333        shortvarname = '2M dtr '
    333334   if variable=='pr':
    334335        longvarname  = 'Precipitation'
     
    495496   #
    496497   if short:
    497         return shortvarname
     498        return shortvarname
    498499   else:
    499         return longvarname
    500 
    501 
    502 
     500        return longvarname
     501
     502
     503
Note: See TracChangeset for help on using the changeset viewer.