Changeset 648 in lmdz_wrf


Ignore:
Timestamp:
Sep 23, 2015, 11:23:57 AM (9 years ago)
Author:
lfita
Message:

Adding 'stations-map' as multiple stations at the same time-step

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/create_OBSnetcdf.py

    r587 r648  
    216216            newval = None
    217217        else:
    218             print 'op: **' + op + '**'
    219218            if op != '-':
    220219                opern = op.split(',')[0]
     
    816815  " and time units: 'weeks', 'days', 'hours', 'miuntes', 'seconds')"
    817816
    818 kindobs=['multi-points', 'single-station', 'trajectory']
     817kindobs=['stations-map','multi-points', 'single-station', 'trajectory']
    819818strkObs="kind of observations; 'multi-points': multiple individual punctual obs " +  \
    820819  "(e.g., lightning strikes), 'single-station': single station on a fixed position,"+\
     
    963962# Total number of values
    964963Ntvalues = len(datavalues[description['varN'][0]])
    965 print main + ': total temporal values found:',Ntvalues
     964if obskind == 'stations-map':
     965    print main + ': total values found:',Ntvalues
     966else:
     967    print main + ': total temporal values found:',Ntvalues
    966968
    967969objfile = NetCDFFile(ofile, 'w')
     
    969971# Creation of dimensions
    970972##
    971 objfile.createDimension('time',None)
     973if obskind == 'stations-map':
     974    rowsdim = 'Npoints'
     975    dimlength = Ntvalues
     976else:
     977    rowsdim = 'time'
     978    dimlength = None
     979
     980objfile.createDimension(rowsdim,dimlength)
    972981objfile.createDimension('StrLength',StringLength)
    973982
     
    979988
    980989    if formats[ivar] == 'D':
    981         newvar = objfile.createVariable(varn, 'f32', ('time'), fill_value=fillValueF)
     990        newvar = objfile.createVariable(varn, 'f32', (rowsdim), fill_value=fillValueF)
    982991        basicvardef(newvar, varn, description['varLN'][ivar],                        \
    983992          description['varU'][ivar])
    984993        newvar[:] = np.where(datavalues[varn] is None, fillValueF, datavalues[varn])
    985994    elif formats[ivar] == 'F':
    986         newvar = objfile.createVariable(varn, 'f', ('time'), fill_value=fillValueF)
     995        newvar = objfile.createVariable(varn, 'f', (rowsdim), fill_value=fillValueF)
    987996        basicvardef(newvar, varn, description['varLN'][ivar],                        \
    988997          description['varU'][ivar])
    989998        newvar[:] = np.where(datavalues[varn] is None, fillValueF, datavalues[varn])
    990999    elif formats[ivar] == 'I':
    991         newvar = objfile.createVariable(varn, 'i', ('time'), fill_value=fillValueI)
     1000        newvar = objfile.createVariable(varn, 'i', (rowsdim), fill_value=fillValueI)
    9921001        basicvardef(newvar, varn, description['varLN'][ivar],                        \
    9931002          description['varU'][ivar])
     
    9981007        newvar[:] = vals
    9991008    elif formats[ivar] == 'S':
    1000         newvar = objfile.createVariable(varn, 'c', ('time','StrLength'))
     1009        newvar = objfile.createVariable(varn, 'c', (rowsdim,'StrLength'))
    10011010        basicvardef(newvar, varn, description['varLN'][ivar],                        \
    10021011          description['varU'][ivar])
     
    10581067    basicvardef(newvar, timeCFname, 'time', tunits )
    10591068else:
     1069    newdim = objfile.createDimension('time',None)
    10601070    timeCFname = 'time'
    10611071    newvar = objfile.createVariable( timeCFname, 'f8', ('time'))
     
    10631073
    10641074set_attribute(newvar, 'calendar', 'standard')
    1065 newvar[:] = timevals
     1075if obskind == 'stations-map':
     1076    newvar[:] = timevals[0]
     1077else:
     1078    newvar[:] = timevals
    10661079
    10671080# Global attributes
Note: See TracChangeset for help on using the changeset viewer.