Changeset 801 in lmdz_wrf
- Timestamp:
- Jun 2, 2016, 10:33:06 AM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r792 r801 1951 1951 pointsizes = [np.float(pointsizes0)] 1952 1952 1953 timename = timevals.split('|')[0] 1954 timeunit = timevals.split('|')[1].replace('!',' ') 1955 timekind = timevals.split('|')[2] 1956 timefmt = timevals.split('|')[3] 1957 1953 1958 # Getting values 1954 1959 ## … … 2012 2017 2013 2018 # Getting period 2019 if ifn > 0: 2020 # Referring all times to the same reference time! 2021 reftvals = drw.coincident_CFtimes(vdobj[:], timeunit, vdobj.units) 2022 else: 2023 reftvals = vdobj[:] 2024 2014 2025 dimt = len(vdobj[:]) 2015 2026 2016 2027 if period == '-1': 2017 2028 varvalues.append(vvobj[:]) 2018 dimvalues.append( vdobj[:])2019 mindvals = np.min( vdobj[:])2020 maxdvals = np.max( vdobj[:])2029 dimvalues.append(reftvals) 2030 mindvals = np.min(reftvals) 2031 maxdvals = np.max(reftvals) 2021 2032 else: 2022 2033 ibeg=-1 … … 2026 2037 2027 2038 for it in range(dimt-1): 2028 if vdobj[it] <= tbeg and vdobj[it+1] > tbeg: ibeg = it2029 if vdobj[it] <= tend and vdobj[it+1] > tend: iend = it + 12039 if reftvals[it] <= tbeg and reftvals[it+1] > tbeg: ibeg = it 2040 if reftvals[it] <= tend and reftvals[it+1] > tend: iend = it + 1 2030 2041 if ibeg != -1 and iend != -1: break 2031 2042 2032 2043 if ibeg == -1 and iend == -1: 2033 print errormsg2044 print warnmsg 2034 2045 print ' ' + fname + ': Period:',tbeg,',',tend,'not found!!' 2035 2046 print ' ibeg:',ibeg,'iend:',iend 2036 print ' period in file:',np.min(vdobj[:]), np.max(vdobj[:]) 2037 quit(-1) 2047 print ' period in file:',np.min(reftvals), np.max(reftvals) 2048 print ' getting all the period in file !!!' 2049 ibeg = 0 2050 iend = dimt 2038 2051 elif iend == -1: 2039 2052 iend = dimt … … 2042 2055 print ' getting last available time instead' 2043 2056 print ' ibeg:',ibeg,'iend:',iend 2044 print ' period in file:',np.min( vdobj[:]), np.max(vdobj[:])2057 print ' period in file:',np.min(reftvals), np.max(reftvals) 2045 2058 elif ibeg == -1: 2046 2059 ibeg = 0 … … 2050 2063 print ' getting first available time instead' 2051 2064 print ' ibeg:',ibeg,'iend:',iend 2052 print ' period in file:',np.min( vdobj[:]), np.max(vdobj[:])2065 print ' period in file:',np.min(reftvals), np.max(reftvals) 2053 2066 2054 2067 varvalues.append(vvobj[ibeg:iend]) 2055 dimvalues.append( vdobj[ibeg:iend])2056 mindvals = np.min( vdobj[ibeg:iend])2057 maxdvals = np.max( vdobj[ibeg:iend])2068 dimvalues.append(reftvals[ibeg:iend]) 2069 mindvals = np.min(reftvals[ibeg:iend]) 2070 maxdvals = np.max(reftvals[ibeg:iend]) 2058 2071 2059 2072 dimt = iend - ibeg … … 2061 2074 if mindvals < mintval: mintval = mindvals 2062 2075 if maxdvals > maxtval: maxtval = maxdvals 2076 # print ' ' + fname + ": file '" + filen + "' period:", ibeg, '->', iend, \ 2077 # reftvals[ibeg], '->', reftvals[np.min([iend,dimt-1])], timeunit 2063 2078 2064 2079 if ifn == 0: … … 2070 2085 2071 2086 # Times 2072 timename = timevals.split('|')[0]2073 timeunit = timevals.split('|')[1].replace('!',' ')2074 timekind = timevals.split('|')[2]2075 timefmt = timevals.split('|')[3]2076 2087 2077 2088 dtvals = (maxtval - mintval)/dimt 2078 tvals = np.arange(mintval, maxtval, dtvals/2.) 2089 # dti = mintval-dtvals/2. 2090 # dte = maxtval+dtvals/2. 2091 dti = mintval 2092 dte = maxtval 2093 tvals = np.arange(dti, dte, dtvals) 2094 2095 dtiS = drw.datetimeStr_conversion(str(dti) + ',' + timeunit, 'cfTime', \ 2096 'Y/m/d H-M-S') 2097 dteS = drw.datetimeStr_conversion(str(dte) + ',' + timeunit, 'cfTime', \ 2098 'Y/m/d H-M-S') 2099 2100 print ' ' + fname + ': plotting from: ' + dtiS + ' to ' + dteS 2079 2101 2080 2102 timepos, timelabels = drw.CFtimes_plot(tvals, timeunit, timekind, timefmt) 2103 2104 # print 'Lluis min/max tval +/- dtval/2:', mintval-dtvals/2., maxtval+dtvals/2.,'dt:', len(tvals) 2105 # for it in range(len(timepos)): 2106 # print timepos[it], timelabels[it] 2081 2107 2082 2108 if leglabels != 'None': -
trunk/tools/drawing_tools.py
r798 r801 392 392 else: 393 393 refdate = datetimeStr_datetime( yrref + '-' + monref + '-' + dayref + \ 394 +'_00:00:00')394 '_00:00:00') 395 395 396 396 if tunits == 'weeks': … … 1964 1964 if trefu == 'l': timev = timev - secs0001_1901*1000. 1965 1965 1966 if refdate.year < 1901:1967 print warnmsg1968 print ' ' + fname + ': changing reference date: ',refdate, \1969 'to 1901-01-01_00:00:00 !!!'1970 diffrefs = dt.datetime(1901,1,1,0,0,0) - refdate1971 if gen.searchInlist(dir(diffrefs), 'total_seconds'):1972 secsref_1901 = diffrefs.total_seconds()1973 else:1974 secsref_1901 = diffrefs.days()*3600*24. + diffrefs.seconds()*1.1975 refdate = datetimeStr_datetime('1901-01-01_00:00:00')1976 print 'time 0 :', timev[0]1977 if trefu == 'w': timev = timev - secsref_1901/(7.*24.*3600.)1978 if trefu == 'd': timev = timev - secsref_1901/(24.*3600.)1979 if trefu == 'h': timev = timev - secsref_1901/(3600.)1980 if trefu == 'm': timev = timev - secsref_1901/(60.)1981 if trefu == 's': timev = timev - secsref_19011982 if trefu == 'l': timev = timev - secsref_1901*1000.1983 print 'time 0 after:', timev[0]1966 # if refdate.year < 1901: 1967 # print warnmsg 1968 # print ' ' + fname + ': changing reference date: ',refdate, \ 1969 # 'to 1901-01-01_00:00:00 !!!' 1970 # diffrefs = dt.datetime(1901,1,1,0,0,0) - refdate 1971 # if gen.searchInlist(dir(diffrefs), 'total_seconds'): 1972 # secsref_1901 = diffrefs.total_seconds() 1973 # else: 1974 # secsref_1901 = diffrefs.days()*3600*24. + diffrefs.seconds()*1. 1975 # refdate = datetimeStr_datetime('1901-01-01_00:00:00') 1976 # print 'time 0 :', timev[0] 1977 # if trefu == 'w': timev = timev - secsref_1901/(7.*24.*3600.) 1978 # if trefu == 'd': timev = timev - secsref_1901/(24.*3600.) 1979 # if trefu == 'h': timev = timev - secsref_1901/(3600.) 1980 # if trefu == 'm': timev = timev - secsref_1901/(60.) 1981 # if trefu == 's': timev = timev - secsref_1901 1982 # if trefu == 'l': timev = timev - secsref_1901*1000. 1983 # print 'time 0 after:', timev[0] 1984 1984 1985 1985 firstT = timev[0] … … 2061 2061 ti = firstTvec[0] 2062 2062 tf = lastTvec[0] 2063 year i= firstTvec[0]2063 year = firstTvec[0] 2064 2064 2065 2065 TOTsteps = int(TOTdtsecs/(Nunits*31*secsDay)) + 1 2066 2066 2067 if np.sum(firstTvec[1:5]) > 0: 2068 firstTdt = dt.datetime(year, 1, 1, 0, 0, 0) 2069 datev = dt.datetime(year, 1, 1, 0, 0, 0) 2070 2067 2071 datev = firstTdt 2068 while datev < lastTdt: 2072 timeout.append(datev) 2073 yr = datev.year 2074 while yr + Nunits <= tf : 2069 2075 yr = datev.year + Nunits 2070 2076 mon = datev.month
Note: See TracChangeset
for help on using the changeset viewer.