Changeset 2483 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Apr 29, 2019, 8:51:11 PM (7 years ago)
Author:
lfita
Message:

Adding `calendar_type' as possible 'calendar' attribute

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r2481 r2483  
    25842584                self.unitsval = units
    25852585
    2586                 if not gen.searchInlist(attvar, 'calendar'):
     2586                if not gen.searchInlist(attvar, 'calendar') or                       \
     2587                  not gen.searchInlist(attvar, 'calendar_type'):
    25872588                    print warnmsg
    25882589                    print '  ' + fname + ": time variable '", tname, "' does not " + \
     
    25912592                    cal = 'gregorian'
    25922593                else:
    2593                     self.calendar = times.getncattr('calendar')
     2594                    atimes = times.ncattrs()
     2595                    if gen.searchInlist(atimes, 'calendar'):
     2596                        self.calendar = times.getncattr('calendar')
     2597                    elif gen.searchInlist(atimes, 'calendar_type'):
     2598                        self.calendar = times.getncattr('calendar_type')
    25942599                    cal = times.getncattr('calendar')
    25952600 
     
    2555725562    # Checking calendar consistency
    2555825563    if calendar != timec:
    25559         print errmsg
     25564        print errormsg
    2556025565        print '  ' + fname + ": different calendars found !!"
    2556125566        print "    input calendar: '" + calendar + "' calendar in data '" +timec + "'"
     
    3172131726          'since [YYYY]-[MM]-[DD] [HH]:[MM]:[SS]'
    3172231727        quit(-1)
    31723     if not gen.searchInlist(timeattrs,'calendar'):
     31728    if not gen.searchInlist(timeattrs,'calendar') or                                 \
     31729      not gen.searchInlist(timeattrs,'calendar_type'):
    3172431730        print warnmsg
    3172531731        print '  ' + fname + ": time variable '" + variable + "' without calendar !!"
     
    3172831734        origcal = 'gregorian'
    3172931735    else:
    31730         origcal = otime.getncattr('calendar')
     31736        if gen.searchInlist(timeattrs,'calendar'):
     31737            origcal = otime.getncattr('calendar')
     31738        if gen.searchInlist(timeattrs,'calendar_type'):
     31739            origcal = otime.getncattr('calendar_type')
     31740            otime.delncattr('calendar_type')
     31741            otime.setncattr('calendar',origcal)
    3173131742
    3173231743    for opn in operations:
Note: See TracChangeset for help on using the changeset viewer.