Changeset 1950 in lmdz_wrf


Ignore:
Timestamp:
Jul 22, 2018, 7:05:36 PM (7 years ago)
Author:
lfita
Message:

Definitive working version of adding a wmo_code units into `create_OBSnetcdf.py'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/create_OBSnetcdf.py

    r1949 r1950  
    1111
    1212# version
    13 version=1.1
     13version=1.2
    1414
    1515# Filling values for floats, integer and string
     
    10281028    """ Function to add a variabe providing description of a units based on WMO code
    10291029      unitsn= name of the units (all WMO codes derived units must be labelled as
    1030         'codeWMO_[num]' associated to a file valled wmo_[num].code)
     1030        'wmo_code_[num]' associated to a file valled wmo_[num].code)
    10311031      onc= netCDF object file to add the description
    10321032      Lstrcode= length of description of codes
    10331033
    10341034      wmo_[num].code must have the structure: ('#' for comments)
    1035         reference:web page, document reference with the code
    1036         short_description:main description of the code
    1037         long_description:long description of the code
    1038         codeTYPE:type of the code (andy of 'D', 'F', 'I', 'S')
    1039         @: Values line giving the start of the values
    1040         [val1]=[meaning of first value]
     1035        reference|web page, document reference with the code
     1036        short_description|main description of the code
     1037        long_description|long description of the code
     1038        codeTYPE|type of the code (andy of 'D', 'F', 'I', 'S')
     1039        @| Values line giving the start of the values
     1040        [val1]|[meaning of first value]
    10411041        (...)
    1042         [valN]=[meaning of last value]
     1042        [valN]|[meaning of last value]
    10431043    """
    10441044    fname = 'WMOcodevar'
     
    10471047    folder = os.path.dirname(os.path.realpath(__file__))
    10481048
    1049     code = unitsn.split('_')[1]
     1049    code = unitsn.split('_')[2]
    10501050
    10511051    infile = folder + '/wmo_' + code +'.code'
     
    10561056        return
    10571057    # main expected values
    1058     descvals = ['reference', 'short_description', 'long_description', 'codeTYPE',    \
    1059       '@']
     1058    descvals = ['wmo_code', 'reference', 'short_description', 'long_description',    \
     1059      'codeTYPE', '@']
    10601060
    10611061    availcodetype = ['D', 'F', 'I', 'S']
     
    10691069        if len(line) > 1 and line[0:1] != '#':
    10701070            linev = line.replace('\n','').replace('\t','    ').replace('\r','')
    1071             print inivals, '<>', linev
    10721071            if not inivals:
    1073                 Sv = linev.split(':')[0]
    1074                 Vv = linev.split(':')[1]
     1072                Sv = linev.split('|')[0]
     1073                Vv = linev.split('|')[1]
    10751074                if searchInlist(descvals, Sv):
    10761075                    if Sv != '@': codevalues[Sv] = Vv
    10771076                    else: inivals = True
    10781077            else:
    1079                 Svv = linev.split('=')[0]
    1080                 Vvv = linev.split('=')[1]
    1081                 print 'Lluis Sv:', Svv, 'Vv:', Vvv
     1078                Svv = linev.split('|')[0]
     1079                Vvv = linev.split('|')[1]
    10821080                codvals.append(Svv)
    10831081                codmeanings.append(Vvv)
     
    10881086          " code descriptions"
    10891087        newdim = onc.createDimension('Lstringcode', Lstrcode)
    1090     print 'Lluis Svv:', Svv
    10911088    Ncodes = len(codvals)
    10921089    codedimn = 'wmo_code_' + str(code)
     
    11231120    # Variable with the meaning of the code
    11241121    if not onc.variables.has_key(codedimn+'_meaning'):
     1122        print '  '+fname+": Adding '" + codedimn + "_meaning' variable for code " +  \
     1123          "description"
    11251124        newvar = onc.createVariable(codedimn+'_meaning','c',(codedimn,'Lstringcode'))
    1126         print 'Lluis len Vc:', len(Vvv), 'Ncodes:', Ncodes
    11271125        writing_str_nc(newvar, codmeanings, Lstrcode)
    11281126        newvar.setncattr('description', 'meaning of WMO code ' + str(code))
     
    13391337    # Getting new variables to describe certain units as codeWMO_[num] from an
    13401338    #   external file
    1341     if description['varU'][ivar][0:7] == 'codeWMO':
     1339    if description['varU'][ivar][0:8] == 'wmo_code':
    13421340        WMOcodevar(description['varU'][ivar], objfile)
    13431341
     
    14171415
    14181416set_attribute(objfile,'author_nc','Lluis Fita')
    1419 set_attribute(objfile,'institution_nc','Laboratoire de Meteorology Dynamique, ' +    \
    1420   'LMD-Jussieu, UPMC, Paris')
    1421 set_attribute(objfile,'country_nc','France')
     1417set_attribute(objfile,'institution_nc','Centro de Investigaciones del Mar y la ' +   \
     1418  'Atmosfera (CIMA), CONICET-UBA, CNRS UMI-IFAECI, C.A. Buenos Aires')
     1419set_attribute(objfile,'country_nc','Argentina')
    14221420set_attribute(objfile,'script_nc','create_OBSnetcdf.py')
    14231421set_attribute(objfile,'version_script',version)
    14241422set_attribute(objfile,'information',                                                 \
    1425   'http://www.lmd.jussieu.fr/~lflmd/ASCIIobs_nc/index.html')
     1423  'http://www.lluísfb.cat/python/PyNCplot/')
    14261424
    14271425objfile.sync()
  • trunk/tools/wmo_0509.code

    r1949 r1950  
    1 reference:http://artefacts.ceda.ac.uk/badc_datadocs/surface/code.html
    2 short_description:High cloud type
    3 WMOcode:0509
    4 long_description:Clouds of genera Cirrus, Cirrocumulus and Cirrostratus.           
    5 codeTYPE:S
    6 @: Values
    7 /=cirrus, cirrocumulus & cirrostratus invisible owing to darkness, fog, blowing dust or sand, or other phenomena, or more often because of the presence of a continuous layer of lower clouds
    8 0=no cirrus, cirrocumulus or cirrostratus clouds
    9 1=cirrus in the form of filaments, strands or hooks, not progressively invading the sky.
    10 2=dense cirrus, in patches or entangled sheaves, which usually do not increase & sometimes seem to be the remains of the upper part of a cumulonimbus; or cirrus with sproutings in the form of small turrets; or cirrus having the appearance of cumuliform tufts
    11 3=dense cirrus, often in the form of an anvil, being the remains of the upper part of cumulonimbus
    12 4=cirrus in the form of hooks, filaments, or both, progressively invading the sky; they generally become denser as a whole.
    13 5=cirrus (often in bands converging towards 1 point or 2 opposite points of the horizon) and cirrostratus, or cirrostratus alone;in either case, they are progressively invading the sky, and generally growing denser as a whole, but the continuous veil does not reach 45 degrees above the horizon.
    14 6=cirrus (often in bands converging towards 1 point or 2 opposite points of the horizon) and cirrostratus, or cirrostratus alone;in either case, they are progressively invading the sky, and generally growing denser as a whole; the continuous veil extends more than 45 degrees above the horizon, without the sky being totally covered.
    15 7=veil of cirrostratus covering the celestial dome
    16 8=cirrostratus not progressively invading the sky and not completely covering the celestial dome.
    17 9=cirrocumulus alone, or cirrocumulus accompanied by cirrus or cirrostratus, or both, but cirrocumulus is predominant
     1reference|http://artefacts.ceda.ac.uk/badc_datadocs/surface/code.html
     2short_description|High cloud type
     3wmo_code|0509
     4long_description|Clouds of genera Cirrus, Cirrocumulus and Cirrostratus.           
     5codeTYPE|S
     6@| Values
     7/|cirrus, cirrocumulus & cirrostratus invisible owing to darkness, fog, blowing dust or sand, or other phenomena, or more often because of the presence of a continuous layer of lower clouds
     80|no cirrus, cirrocumulus or cirrostratus clouds
     91|cirrus in the form of filaments, strands or hooks, not progressively invading the sky.
     102|dense cirrus, in patches or entangled sheaves, which usually do not increase & sometimes seem to be the remains of the upper part of a cumulonimbus; or cirrus with sproutings in the form of small turrets; or cirrus having the appearance of cumuliform tufts
     113|dense cirrus, often in the form of an anvil, being the remains of the upper part of cumulonimbus
     124|cirrus in the form of hooks, filaments, or both, progressively invading the sky; they generally become denser as a whole.
     135|cirrus (often in bands converging towards 1 point or 2 opposite points of the horizon) and cirrostratus, or cirrostratus alone;in either case, they are progressively invading the sky, and generally growing denser as a whole, but the continuous veil does not reach 45 degrees above the horizon.
     146|cirrus (often in bands converging towards 1 point or 2 opposite points of the horizon) and cirrostratus, or cirrostratus alone;in either case, they are progressively invading the sky, and generally growing denser as a whole; the continuous veil extends more than 45 degrees above the horizon, without the sky being totally covered.
     157|veil of cirrostratus covering the celestial dome
     168|cirrostratus not progressively invading the sky and not completely covering the celestial dome.
     179|cirrocumulus alone, or cirrocumulus accompanied by cirrus or cirrostratus, or both, but cirrocumulus is predominant
Note: See TracChangeset for help on using the changeset viewer.