Changeset 492 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 15, 2015, 12:14:14 PM (10 years ago)
Author:
lfita
Message:

Adding description of the station

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/validation_sim.py

    r491 r492  
    985985        return self.__values[elem]
    986986
     987def adding_station_desc(onc,stdesc):
     988    """ Function to add a station description in a netCDF file
     989      onc= netCDF object
     990      stdesc= station description lon, lat, height
     991    """
     992    fname = 'adding_station_desc'
     993
     994    newvar = objfile.createVariable( 'station', 'c', ('StrLength'))
     995    newvar[0:len(stdesc[0])] = stdesc[0]
     996
     997    newdim = onc.createDimension('nst',1)
     998
     999    if onc.variables.has_key('lon'):
     1000        print warnmsg
     1001        print '  ' + fname + ": variable 'lon' already exist !!"
     1002        print "    renaming it as 'lonst'"
     1003        lonname = 'lonst'
     1004    else:
     1005        lonname = 'lon'
     1006
     1007    newvar = objfile.createVariable( lonname, 'f4', ('nst'))
     1008    basicvardef(newvar, lonname, 'longitude', 'degrees_West' )
     1009    newvar[:] = stdesc[1]
     1010
     1011    if onc.variables.has_key('lat'):
     1012        print warnmsg
     1013        print '  ' + fname + ": variable 'lat' already exist !!"
     1014        print "    renaming it as 'latst'"
     1015        latname = 'latst'
     1016    else:
     1017        latname = 'lat'
     1018
     1019    newvar = objfile.createVariable( latname, 'f4', ('nst'))
     1020    basicvardef(newvar, lonname, 'latitude', 'degrees_North' )
     1021    newvar[:] = stdesc[2]
     1022
     1023    if onc.variables.has_key('height'):
     1024        print warnmsg
     1025        print '  ' + fname + ": variable 'height' already exist !!"
     1026        print "    renaming it as 'heightst'"
     1027        heightname = 'heightst'
     1028    else:
     1029        heightname = 'height'
     1030
     1031    newvar = objfile.createVariable( heightname, 'f4', ('nst'))
     1032    basicvardef(newvar, heightname, 'height above sea level', 'm' )
     1033    newvar[:] = stdesc[3]
     1034
     1035    return
     1036
    9871037####### ###### ##### #### ### ## #
    9881038
     
    10291079  help=strkObs, metavar="FILE")
    10301080parser.add_option("-l", "--stationLocation", dest="stloc", 
    1031   help="longitude, latitude and height of the station (only for 'single-station')",
     1081  help="name, longitude, latitude and height of the station (only for 'single-station')",
    10321082  metavar="FILE")
    10331083parser.add_option("-o", "--observation", dest="fobs",
     
    11061156            quit(-1)
    11071157        else:
    1108             stationdesc = [np.float(opts.stloc.split(',')[0]),                       \
    1109               np.float(opts.stloc.split(',')[1]), np.float(opts.stloc.split(',')[2])]
     1158            stationdesc = [opts.stloc.split(',')[0],                                 \
     1159              np.float(opts.stloc.split(',')[1]), np.float(opts.stloc.split(',')[2]),\
     1160              np.float(opts.stloc.split(',')[3])]
    11101161
    11111162if opts.fobs is None:
     
    11761227    else:
    11771228        if dn == 'X':
    1178             valdimobs[dn] = stationdesc[0]
     1229            valdimobs[dn] = stationdesc[1]
    11791230        elif dn == 'Y':
    1180             valdimobs[dn] = stationdesc[1]
     1231            valdimobs[dn] = stationdesc[2]
    11811232        elif dn == 'Z':
    1182             valdimobs[dn] = stationdesc[2]
     1233            valdimobs[dn] = stationdesc[3]
    11831234
    11841235osim = NetCDFFile(opts.fsim, 'r')
     
    17281779newvar[:] = trjsim.transpose()
    17291780
     1781# Adding three variables with the station location, longitude, latitude and height
     1782if obskind == 'single-station':
     1783    adding_station_desc(objfile,stationdesc)
     1784
    17301785# Global attributes
    17311786##
Note: See TracChangeset for help on using the changeset viewer.