Changeset 558 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jul 3, 2015, 4:18:55 PM (10 years ago)
Author:
lfita
Message:

Fixing `day' issue on 'CFtimes_plot'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r549 r558  
    19341934        mindvals = np.min(vdobj[:])
    19351935        maxdvals = np.max(vdobj[:])
     1936        dimt = len(vvobj[:])
    19361937
    19371938        if mindvals < mintval: mintval = mindvals
     
    19511952    timefmt = timevals.split('|')[3]
    19521953
    1953     dtvals = (maxtval - mintval)/5.
     1954    dtvals = (maxtval - mintval)/dimt
    19541955    tvals = np.arange(mintval, maxtval, dtvals/2.)
    19551956
  • trunk/tools/drawing_tools.py

    r549 r558  
    18741874        quit()
    18751875
     1876    secsYear = 365.*24.*3600.
     1877    secsWeek = 7.*24.*3600.
     1878    secsDay = 24.*3600.
     1879    secsHour = 3600.
     1880    secsMinute = 60.
     1881    secsMilisecond = 1./1000.
     1882    secsMicrosecond = 1./1000000.
     1883
    18761884# Does reference date contain a time value [YYYY]-[MM]-[DD] [HH]:[MI]:[SS]
    18771885##
     
    19461954    chdate= lastTvec - firstTvec
    19471955    chTvec = np.where (chdate != 0., True, False)
     1956   
     1957    TOTdt = lastTdt - firstTdt
     1958    TOTdtsecs = TOTdt.days*secsDay + TOTdt.seconds + TOTdt.microseconds*secsMicrosecond
    19481959
    19491960    timeout = []
     
    19641975        basedt = np.zeros((9), dtype=np.float)
    19651976        basedt[0] = (365.*100. + 25.)*24.*3600.
    1966         basedt[1] = 365.*24.*3600.
     1977        basedt[1] = secsYear
    19671978        basedt[2] = 31.*24.*3600.
    1968         basedt[3] = 7.*24.*3600.
    1969         basedt[4] = 24.*3600.
    1970         basedt[5] = 3600.
    1971         basedt[6] = 60.
     1979        basedt[3] = secsWeek
     1980        basedt[4] = secsDay
     1981        basedt[5] = secsHour
     1982        basedt[6] = secsMinute
    19721983        basedt[7] = 1.
    1973         basedt[8] = 1000.
     1984        basedt[8] = secsMilisecond
    19741985
    19751986# Increment according to the units of the CF dates
    19761987        if trefunits == 'weeks':
    1977             basedt = basedt/(7.*24.*3600.)
     1988            basedt = basedt/(secsWeek)
    19781989        elif trefunits == 'days':
    1979             basedt = basedt/(24.*3600.)
     1990            basedt = basedt/(secsDay)
    19801991        elif trefunits == 'hours':
    1981             basedt = basedt/(3600.)
     1992            basedt = basedt/(secsHour)
    19821993        elif trefunits == 'minutes':
    1983             basedt = basedt/(60.)
     1994            basedt = basedt/(secsMinute)
    19841995        elif trefunits == 'seconds':
    19851996            basedt = basedt
    19861997        elif trefunits == 'milliseconds':
    1987             basedt = basedt*1000.
     1998            basedt = basedt*secsMilisecond
    19881999
    19892000        if tu == 'c':
     
    19922003            centi = firstTvec[0] / 100
    19932004
    1994             for it in range((tf - ti)/(Nunits*100) + 1):
    1995                 timeout.append(dt.datetime(centi+it*Nunits*100, 1, 1, 0, 0, 0))
     2005            datev = firstTdt
     2006            while datev < lastTdt:
     2007                yr = datev.year + Nunits*100
     2008                mon = datev.month
     2009                datev = dt.datetime(yr, mon, 1, 0, 0, 0)
     2010                timeout.append(datev)
     2011
    19962012        elif tu == 'y':
    19972013            ti = firstTvec[0]
     
    19992015            yeari = firstTvec[0]
    20002016
    2001             for it in range((tf - ti)/(Nunits) + 1):
    2002                 timeout.append(dt.datetime(yeari+it*Nunits, 1, 1, 0, 0, 0))
     2017            TOTsteps = int(TOTdtsecs/(Nunits*31*secsDay)) + 1
     2018
     2019            datev = firstTdt
     2020            while datev < lastTdt:
     2021                yr = datev.year + Nunits
     2022                mon = datev.month
     2023                datev = dt.datetime(yr, mon, 1, 0, 0, 0)
     2024                timeout.append(datev)
     2025
    20032026        elif tu == 'm':
    20042027            ti = firstTvec[1]
    20052028            tf = lastTvec[1]
     2029           
    20062030            yr = firstTvec[0]
    20072031            mon = firstTvec[1]
    20082032
    2009             for it in range((tf - ti)/(Nunits) + 1):
    2010                 mon = mon+it*Nunits
     2033            TOTsteps = int(TOTdtsecs/(Nunits*31*secsDay)) + 1
     2034
     2035            datev = firstTdt
     2036            while datev < lastTdt:
     2037                mon = datev.month + Nunits
    20112038                if mon > 12:
    20122039                    yr = yr + 1
    20132040                    mon = 1
    2014 
    2015                 timeout.append(dt.datetime(yr, mon, 1, 0, 0, 0))
     2041                datev = dt.datetime(yr, mon, 1, 0, 0, 0)
     2042                timeout.append(datev)
     2043
    20162044        elif tu == 'w':
    20172045            datev=firstTdt
     
    20392067                timeout.append(datev)
    20402068                it = it + 1
     2069
    20412070        elif tu == 'h':
    20422071            datev=firstTdt
Note: See TracChangeset for help on using the changeset viewer.