Ignore:
Timestamp:
Jul 4, 2011, 2:40:25 PM (14 years ago)
Author:
aslmd
Message:

MESOSCALE: python graphics. added the nowind case plus corrected a few minor things.

Location:
trunk/MESOSCALE/PLOT/PYTHON
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MESOSCALE/PLOT/PYTHON/mylib/api_g95.sh

    r186 r191  
    11#! /bin/bash
    22
    3 f2py -c -m api ~/Science/MODELES/MESOSCALE/LMD_MM_MARS/SRC/POSTPROC/api.F90 --fcompiler=g95 -L$NETCDF/lib -lnetcdf -lm -I$NETCDF/include --f90flags="-Wall -Wno=112,141,137,155 -fno-second-underscore -ffree-form" > ~/logc 2> ~/loge
     3#NETCDF=/distrib/local/netcdf-4.0.1/g95_4.0.3_64/
     4#echo $NETCDF
     5
     6touch logc
     7touch loge
     8\rm logc
     9\rm loge
     10f2py -c -m api ../../../LMD_MM_MARS/SRC/POSTPROC/api.F90 --fcompiler=g95 -L$NETCDF/lib -lnetcdf -lm -I$NETCDF/include --f90flags="-Wall -Wno=112,141,137,155 -fno-second-underscore -ffree-form" > logc 2> loge
  • trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py

    r188 r191  
    3535        return wlon,wlat
    3636
     37#def landers (map)
     38#    map.plot(blue_calf_lon,blue_calf_lat, 'gs')
     39#    return
     40
    3741def api_onelevel (  path_to_input   = None, \
    3842                    input_name      = 'wrfout_d0?_????-??-??_??:00:00', \
  • trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py

    r189 r191  
    11#!/usr/bin/env python
    22
    3 ### A. Spiga -- LMD -- 30/05/2011
     3### A. Spiga -- LMD -- 30/06/2011 to 04/07/2011
    44### Thanks to A. Colaitis for the parser trick
    55
     
    1616           numplot=4,\
    1717           var=None,\
    18            colorb=None):
     18           colorb=None,\
     19           winds=True):
    1920
    2021    #################################
     
    3233    ### Recognize predefined file types
    3334    if 'controle' in nc.variables:   typefile = 'gcm'
    34     elif 'Um' in nc.variables:       typefile = 'mesoapi'
     35    elif 'vert' in nc.variables:     typefile = 'mesoapi'
    3536    elif 'U' in nc.variables:        typefile = 'meso'
    3637    else:                           
    3738        print "typefile not supported."
     39        print nc.variables
    3840        exit()
    3941
     
    7476    ##############################################################################
    7577    ### Get winds and know if those are meteorological winds (ie. zon, mer) or not
    76     if typefile is 'mesoapi':
    77         [u,v] = getwinds(nc)
    78         metwind = True  ## meteorological (zon/mer)
    79     elif typefile is 'gcm':
    80         [u,v] = getwinds(nc,charu='u',charv='v')
    81         metwind = True  ## meteorological (zon/mer)
    82     elif typefile is 'meso':
    83         [u,v] = getwinds(nc,charu='U',charv='V')
    84         metwind = False ## geometrical (wrt grid)
    85         print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)."
    86 
    87     ####################################################
     78    if winds:
     79        if typefile is 'mesoapi':
     80            [u,v] = getwinds(nc)
     81            metwind = True  ## meteorological (zon/mer)
     82        elif typefile is 'gcm':
     83            [u,v] = getwinds(nc,charu='u',charv='v')
     84            metwind = True  ## meteorological (zon/mer)
     85        elif typefile is 'meso':
     86            [u,v] = getwinds(nc,charu='U',charv='V')
     87            metwind = False ## geometrical (wrt grid)
     88            print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)."
     89
     90    #####################################################
    8891    ### Load the chosen variables, whether it is 2D or 3D
    8992    if var:
     
    9699            elif dimension == 3:   field = nc.variables[var][:,:,:]
    97100            elif dimension == 4:   field = nc.variables[var][:,nvert,:,:] 
    98     nt = len(u[:,0,0,0])
     101
     102    ###########################
     103    ### Get length of time axis
     104    if winds:               nt = len(u[:,0,0,0])
     105    elif var: 
     106        if dimension == 2:  nt = 1
     107        else             :  nt = len(field[:,0,0])
    99108
    100109    #########################################
    101110    ### Name for title and graphics save file
    102     basename = "WINDS"
     111    if winds:   basename = "WINDS_"
     112    else:       basename = ""
    103113    if var:
    104         basename = basename + "_" + var
     114        basename = basename + var
    105115    if   typefile is 'meso':                    stralt = "_lvl" + str(nvert)
    106116    elif typefile is 'mesoapi': 
     
    187197
    188198       ### Vector plot
    189        if   typefile in ['mesoapi','meso']:   
    190            [vecx,vecy] = [dumpbdy(u[i,nvert,:,:]), dumpbdy(v[i,nvert,:,:])]
    191            key = True
    192        elif typefile in ['gcm']:               
    193            [vecx,vecy] = [        u[i,nvert,:,:] ,         v[i,nvert,:,:] ]
    194            key = False
    195        if metwind:  [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d)
    196        if var == None and back == "vishires":  colorvec = 'w'
    197        else:                                   colorvec = 'k'
    198        vectorfield(vecx, vecy,\
     199       if winds:
     200           if   typefile in ['mesoapi','meso']:   
     201               [vecx,vecy] = [dumpbdy(u[i,nvert,:,:]), dumpbdy(v[i,nvert,:,:])]
     202               key = True
     203           elif typefile in ['gcm']:               
     204               [vecx,vecy] = [        u[i,nvert,:,:] ,         v[i,nvert,:,:] ]
     205               key = False
     206           if metwind:  [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d)
     207           if var == None and back == "vishires":  colorvec = 'w'
     208           else:                                   colorvec = 'k'
     209           vectorfield(vecx, vecy,\
    199210                      x, y, stride=stride, csmooth=stride,\
    200211                      scale=15., factor=300., color=colorvec, key=key)
     
    247258    parser.add_option('-i', action='store', dest='interp',      type="int",     default=None,  help='interpolation method (2: press, 3: z-amr, 4:z-als)')
    248259    parser.add_option('-c', action='store', dest='colorb',      type="string",  default=None,  help='colorbar')
     260    parser.add_option('-x', action='store_false', dest='winds',                 default=True,  help='flag: no wind vectors')
    249261    (opt,args) = parser.parse_args()
    250262    if opt.namefile is None:
     
    258270    if opt.interp is not None:
    259271        if opt.nvert is 0 and opt.interp is 4:  zelevel = 0.010
    260         if   opt.var is None    :  zefields = 'uvmet'
    261         else                    :  zefields = 'uvmet,'+opt.var
     272        ### winds or no winds
     273        if opt.winds            :  zefields = 'uvmet'
     274        else                    :  zefields = ''
     275        ### var or no var
     276        if opt.var is None      :  pass
     277        elif zefields == ''     :  zefields = opt.var
     278        else                    :  zefields = zefields + "," + opt.var
     279        print zefields
    262280        zefile = api_onelevel (  path_to_input   = '', \
    263281                                 input_name      = zefile, \
     
    269287
    270288    winds (zefile,int(zelevel),\
    271            proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb)
     289           proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds)
Note: See TracChangeset for help on using the changeset viewer.