Changeset 2162 in lmdz_wrf
- Timestamp:
- Oct 4, 2018, 4:36:15 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2161 r2162 5052 5052 5053 5053 date1=dt.date(year,month,1) 5054 date2=dt.date(year,month+1,1) 5054 if month+1 > 12: 5055 date2=dt.date(year+1,1,1) 5056 else: 5057 date2=dt.date(year,month+1,1) 5055 5058 5056 5059 diffdate = date2-date1 … … 14081 14084 dcyc = cycvar.shape[0] 14082 14085 # Indices of the beginning and end of the period 14083 print 'cycvar:', cycvar14084 print 'bper:', bper, 'eper:', eper, 'val:', val14085 14086 14086 bind = index_vec(cycvar,bper) 14087 14087 eind = index_vec(cycvar,eper) … … 14089 14089 # Index of the value 14090 14090 vind = index_vec(cycvar,val) 14091 14092 print 'bind:', bind, 'eind:', eind, 'vind:', vind14093 14091 14094 14092 if eind < bind: … … 14148 14146 Ncyctimes = Ncyctimes + 1 14149 14147 14150 print 'cyctimes:', cyctimes14151 14152 14148 iit = 0 14153 14149 itt = 0 … … 14159 14155 ttv = mattimes[it,imat] 14160 14156 timeslice[1] = it 14161 print it, ttv, 'ip:', ip, 'ep:', ep, '<>', (ttv >= ip and ttv < ep)14162 14157 if not (ttv >= ip and ttv < ep): 14163 14158 slices.append(timeslice) … … 14186 14181 ttv = mattimes[it,imat] 14187 14182 timeslice[1] = it 14188 print it, '.', itt, '|', ttv, 'ip:', ip, 'ep:', ep, '<>', cyclevar_within(cyctimes, ip, ep, ttv)14189 14183 if not (cyclevar_within(cyctimes, ip, ep, ttv)): 14190 14184 slices.append(timeslice) … … 14196 14190 elif per == 'day': 14197 14191 imat = 2 14198 # Getting unique values 14199 years = list(mattimes[:,imat]) 14200 setvar = set(years) 14201 utimes = list(setvar) 14202 utimes.sort() 14203 Nutimes = len(utimes) 14204 14205 # introducing amounts 14206 print ' unique ', Nutimes, 'times:', utimes, '<>', utimes[0], utimes[Nutimes-1]+amount, amount 14207 atimes = np.arange(utimes[0], utimes[Nutimes-1]+amount, amount) 14208 Ntimes = len(atimes) 14209 print ' amount ', Ntimes, 'periods:', atimes 14192 14193 for it in range(dimt): 14194 14195 # cycle for days as function of the month 14196 Ncyctimes = days_month(mattimes[it,0],mattimes[it,1]) 14197 cyctimes = np.arange(Ncyctimes)+1 14210 14198 14211 itt = 0 14212 for iat in range(Ntimes-1): 14199 print 'cyctimes:', cyctimes 14200 14201 # First cycle time from first time 14202 iit = 0 14203 itt = index_vec(cyctimes,mattimes[0,imat]) 14204 ip = cyctimes[itt] 14205 ep = cyclevar(cyctimes, itt+amount) 14206 14213 14207 # timeslice: [ini_slice, end_slice, freq_slice] 14214 timeslice = [itt,itt,1] 14215 ip = atimes[iat] 14216 ep = atimes[iat+1] 14217 14218 for it in range(itt,dimt): 14219 if mattimes[it,imat] >= ip and mattimes[it,imat] < ep: 14220 timeslice[1] = it 14221 else: 14222 timeslice[1] = it 14223 slices.append(timeslice) 14224 itt = it + 0 14225 break 14208 timeslice = [iit,iit,1] 14209 ttv = mattimes[it,imat] 14210 timeslice[1] = it 14211 if not (cyclevar_within(cyctimes, ip, ep, ttv)): 14212 slices.append(timeslice) 14213 iit = it + 0 14214 itt = itt + amount 14215 ip = cyclevar(cyctimes,itt) 14216 ep = cyclevar(cyctimes,itt+amount) 14226 14217 else: 14227 14218 print errormsg … … 14238 14229 tv = [] 14239 14230 values = [] 14240 totT = 30.14241 dT = 7. 14231 totT = 24.*60. 14232 dT = 7.*60. 14242 14233 for it in range(0,10): 14243 14234 for itt in range(3): … … 14247 14238 vals = np.array(values) 14248 14239 itdim = 0 14249 tu = ' days since 1949-12-01 00:00:00'14250 per = ' month'14240 tu = 'minutes since 1949-12-01 00:00:00' 14241 per = 'day' 14251 14242 calend = 'standard' 14252 14243 amount = 1
Note: See TracChangeset
for help on using the changeset viewer.