Changeset 2465 in lmdz_wrf


Ignore:
Timestamp:
Apr 24, 2019, 2:38:00 PM (6 years ago)
Author:
lfita
Message:

Update `varinfile'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r2447 r2465  
    299299    varn= variable name
    300300    """
     301    fname = 'varinfile'
    301302    if not ncf.variables.has_key(varn):
    302303        print emsg
    303         print '  file "' + filen + '" does not have ' + vmsg + ' variable "' + varn + '" !!'
    304         print emsg
     304        print '  file "'+filen+'" does not have '+vmsg+ ' variable "' + varn + '" !!'
    305305        ncf.close()
    306         quit(-1)   
     306        Varns = list(ncf.variables.keys())
     307        Varns.sort()
     308        print '    avaialble ones:', Varns
     309        quit(-1)
    307310
    308311    return
     
    3128431287#compress_data(values, '/home/lluis/PY/wrfout_d01_1995-01-01_00:00:00', 'T2,LU_INDEX')
    3128531288
    31286 
    3128731289def CFfile_creation(values, ncfile, variables):
    3128831290    """ Operation to create a file folowing CF-conventions
     
    3150031502#CFfile_creation(values, 'CFtest.nc', varsS)
    3150131503
     31504def CFfile_fixTime(values, ncfile, variable):
     31505    """ Operation to fix a netCDF file with a time axis folowing CF-conventions, but
     31506        with a wrong set-up
     31507      values= [operations]
     31508        [operations]: ';' list of names of operations to perform
     31509          'setRefDate',[YYYYMMDDHHMMSS]: re-set the reference date to [YYYYMMDDHHMMSS]
     31510          'setCalendar': re-set the calendar to gregorian or standard
     31511      ncfile= name of the file to fix its time-axis
     31512      variable= name of the variable time
     31513    """
     31514    fname = 'CFfile_fixTime'
     31515
     31516    if values == 'h':
     31517        print fname + '_____________________________________________________________'
     31518        print CFfile_fixTime.__doc__
     31519        quit()
     31520
     31521    expectargs = '[operations]'
     31522 
     31523    gen.check_arguments(fname,values,expectargs,':')
     31524
     31525    operations = values.split(':')[0]
     31526
     31527    onc = NetCDFFile(ncfile,'a')
     31528    if not onc.variables.has_key(variable):
     31529
     31530
     31531    otime = onc.variables[variable]
     31532
     31533    for op in operations:
     31534
     31535
    3150231536
    3150331537
Note: See TracChangeset for help on using the changeset viewer.