Changeset 361


Ignore:
Timestamp:
Nov 8, 2011, 5:01:15 PM (13 years ago)
Author:
acolaitis
Message:

PYTHON.

Added zrecast capabilites for gcm.py. Interp modes AGL and P are working. Adding more is not difficult.
One should make sure that his zrecast.e is up to date and in his $PATH.

Note: we could also use f2py to compile a python module... However, most people do have zrecast in their path.

Note2: When using inter-file comparisons, such as field differences, one should make sure to use zrecast (or -i with gcm.py) to
make sure that operations are done at the same altitudes ! (levels in different simulations a priori do not represent same altitudes)

Note3: zrecast has been modified in previous commit to work with teta instead of temp, if needed.

Location:
trunk/UTIL/PYTHON
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/gcm.py

    r359 r361  
    11#!/usr/bin/env python
    22
    3 ### T. Navarro + A. Spiga
     3### T. Navarro + A. Spiga + A. Colaitis
    44
    55###########################################################################################
     
    1010    from optparse import OptionParser    ### to be replaced by argparse
    1111    from api_wrapper import api_onelevel
     12    from zrecast_wrapper import call_zrecast
    1213    from netCDF4 import Dataset
    1314    from myplot import getlschar, separatenames, readslices, adjust_length
    1415    from os import system
    1516    from planetoplot import planetoplot
     17   
    1618    import numpy as np
    1719
     
    7173    print "Options:", opt
    7274
    73     #listvar = ''
    74     #if opt.var is None:
    75     #    zerange = [-999999]
    76     #else:
    77     #    zelen = len(opt.var)
    78     #    zerange = range(zelen)
    79     #    #if zelen == 1: listvar = opt.var[0] + ','
    80     #    #else         :
    81     #    for jjj in zerange: listvar += opt.var[jjj] + ','
    82     #    listvar = listvar[0:len(listvar)-1]
    83     #    vmintab = adjust_length (opt.vmin, zelen) 
    84     #    vmaxtab = adjust_length (opt.vmax, zelen)
     75#    listvar = ''
     76#    if opt.var is None:
     77#        zerange = [-999999]
     78#    else:
     79#        zelen = len(opt.var)
     80#        zerange = range(zelen)
     81#        #if zelen == 1: listvar = opt.var[0] + ','
     82#        #else         :
     83#        for jjj in zerange: listvar += opt.var[jjj] + ','
     84#        listvar = listvar[0:len(listvar)-1]
     85#        vmintab = adjust_length (opt.vmin, zelen)
     86#        vmaxtab = adjust_length (opt.vmax, zelen)
    8587
    8688
     
    9799          exit()
    98100
     101    if opt.fref is not None:
     102       if opt.operation is not None:
     103          if opt.interp is not None:
     104             interpref=True
     105
    99106    ################################
    100107
     
    125132       
    126133        zevar = separatenames(opt.var[j])
     134        zevars = zevar[j]
    127135        zevar = zevar[0]
    128136        print "var, zevar", opt.var, zevar
     
    149157        #####################################################
    150158        ### Call Fortran routines for vertical interpolations  -->  zrecast for GCM ?       
     159#        if opt.interp is not None:
     160#            if zelevel == 0. and opt.interp == 4:  zelevel = 0.010
     161#            ### winds or no winds
     162#            if opt.winds            :  zefields = 'uvmet'
     163#            else                    :  zefields = ''
     164#            ### var or no var
     165#            #if opt.var is None      :  pass
     166#            if zefields == ''       :  zefields = listvar
     167#            else                    :  zefields = zefields + "," + listvar
     168#            if opt.var2 is not None : zefields = zefields + "," + opt.var2 
     169#            print zefields
     170#            zefile = api_onelevel (  path_to_input   = '', \
     171#                                     input_name      = zefile, \
     172#                                     fields          = zefields, \
     173#                                     interp_method   = opt.interp, \
     174#                                     interp_level    = ze_interp_levels, \
     175#                                     onelevel        = zelevel, \
     176#                                     nocall          = opt.nocall )
     177#            print zefile
     178#            zelevel = 0 ## so that zelevel could play again the role of nvert
     179
     180# A.C.  #####################################################
     181        ### Call Fortran routines for vertical interpolations  -->  zrecast
     182
    151183        if opt.interp is not None:
    152             if zelevel == 0. and opt.interp == 4:  zelevel = 0.010
    153             ### winds or no winds
    154             if opt.winds            :  zefields = 'uvmet'
    155             else                    :  zefields = ''
    156             ### var or no var
    157             #if opt.var is None      :  pass
    158             if zefields == ''       :  zefields = listvar
    159             else                    :  zefields = zefields + "," + listvar
    160             if opt.var2 is not None : zefields = zefields + "," + opt.var2 
    161             print zefields
    162             zefile = api_onelevel (  path_to_input   = '', \
    163                                      input_name      = zefile, \
    164                                      fields          = zefields, \
    165                                      interp_method   = opt.interp, \
    166                                      interp_level    = ze_interp_levels, \
    167                                      onelevel        = zelevel, \
    168                                      nocall          = opt.nocall )
    169             print zefile
    170             zelevel = 0 ## so that zelevel could play again the role of nvert
    171 
     184           interpolated_files=""
     185           interpolated_files=call_zrecast(interp_mode=opt.interp,\
     186                    input_name=zenamefiles,\
     187                    fields=zevars)
     188
     189           zenamefiles=interpolated_files
     190        if interpref:
     191           interpolated_ref=""
     192           interpolated_ref=call_zrecast(interp_mode=opt.interp,\
     193                    input_name=[opt.fref],\
     194                    fields=zevars)
     195
     196           reffile=interpolated_ref[0]
     197        else:
     198           reffile=opt.fref
    172199
    173200        #############
     
    183210                slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
    184211                outputname=opt.output,resolution=opt.res,\
    185                 ope=opt.operation,fileref=opt.fref,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref)
     212                ope=opt.operation,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref)
    186213        print 'Done: '+name
    187214        system("rm -f to_be_erased")
  • trunk/UTIL/PYTHON/planetoplot.py

    r359 r361  
    55### A. Spiga     -- LMD -- 06~09/2011 -- General building and mapping capabilities
    66### T. Navarro   -- LMD -- 10~11/2011 -- Improved use for GCM and added sections + 1Dplot capabilities
    7 ### A. Colaitis  -- LMD --            -- Mostly minor improvements and inter-plot operation capabilities
     7### A. Colaitis  -- LMD --            -- Mostly minor improvements and inter-plot operation capabilities + zrecast interpolation for gcm
    88
    99def planetoplot (namefiles,\
     
    8383    firstfile = True
    8484    for namefile in namefiles:
    85    
     85      print namefile
    8686      ######################
    8787      ### Load NETCDF object
Note: See TracChangeset for help on using the changeset viewer.