- Timestamp:
- Jul 3, 2015, 4:18:55 PM (10 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r549 r558 1934 1934 mindvals = np.min(vdobj[:]) 1935 1935 maxdvals = np.max(vdobj[:]) 1936 dimt = len(vvobj[:]) 1936 1937 1937 1938 if mindvals < mintval: mintval = mindvals … … 1951 1952 timefmt = timevals.split('|')[3] 1952 1953 1953 dtvals = (maxtval - mintval)/ 5.1954 dtvals = (maxtval - mintval)/dimt 1954 1955 tvals = np.arange(mintval, maxtval, dtvals/2.) 1955 1956 -
trunk/tools/drawing_tools.py
r549 r558 1874 1874 quit() 1875 1875 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 1876 1884 # Does reference date contain a time value [YYYY]-[MM]-[DD] [HH]:[MI]:[SS] 1877 1885 ## … … 1946 1954 chdate= lastTvec - firstTvec 1947 1955 chTvec = np.where (chdate != 0., True, False) 1956 1957 TOTdt = lastTdt - firstTdt 1958 TOTdtsecs = TOTdt.days*secsDay + TOTdt.seconds + TOTdt.microseconds*secsMicrosecond 1948 1959 1949 1960 timeout = [] … … 1964 1975 basedt = np.zeros((9), dtype=np.float) 1965 1976 basedt[0] = (365.*100. + 25.)*24.*3600. 1966 basedt[1] = 365.*24.*3600.1977 basedt[1] = secsYear 1967 1978 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 1972 1983 basedt[7] = 1. 1973 basedt[8] = 1000.1984 basedt[8] = secsMilisecond 1974 1985 1975 1986 # Increment according to the units of the CF dates 1976 1987 if trefunits == 'weeks': 1977 basedt = basedt/( 7.*24.*3600.)1988 basedt = basedt/(secsWeek) 1978 1989 elif trefunits == 'days': 1979 basedt = basedt/( 24.*3600.)1990 basedt = basedt/(secsDay) 1980 1991 elif trefunits == 'hours': 1981 basedt = basedt/( 3600.)1992 basedt = basedt/(secsHour) 1982 1993 elif trefunits == 'minutes': 1983 basedt = basedt/( 60.)1994 basedt = basedt/(secsMinute) 1984 1995 elif trefunits == 'seconds': 1985 1996 basedt = basedt 1986 1997 elif trefunits == 'milliseconds': 1987 basedt = basedt* 1000.1998 basedt = basedt*secsMilisecond 1988 1999 1989 2000 if tu == 'c': … … 1992 2003 centi = firstTvec[0] / 100 1993 2004 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 1996 2012 elif tu == 'y': 1997 2013 ti = firstTvec[0] … … 1999 2015 yeari = firstTvec[0] 2000 2016 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 2003 2026 elif tu == 'm': 2004 2027 ti = firstTvec[1] 2005 2028 tf = lastTvec[1] 2029 2006 2030 yr = firstTvec[0] 2007 2031 mon = firstTvec[1] 2008 2032 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 2011 2038 if mon > 12: 2012 2039 yr = yr + 1 2013 2040 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 2016 2044 elif tu == 'w': 2017 2045 datev=firstTdt … … 2039 2067 timeout.append(datev) 2040 2068 it = it + 1 2069 2041 2070 elif tu == 'h': 2042 2071 datev=firstTdt
Note: See TracChangeset
for help on using the changeset viewer.