Changeset 2230 in lmdz_wrf for trunk/tools
- Timestamp:
- Nov 14, 2018, 9:47:26 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2229 r2230 14619 14619 if timesec != 'season': 14620 14620 for it in range(dimt): 14621 if timesec == 'year': print it, ':', mattimes[it,:]14622 14621 for tvv in tvals: 14623 14622 if mattimes[it,itsec] == tvv: … … 14646 14645 tvsec[tvv] = vvv 14647 14646 break 14648 print it, 'Lluis:', mattimes[it,:], tvv, mattimes[it,1]14649 14647 14650 14648 temporal_desc[timesec]=tvsec … … 14693 14691 quit(-1) 14694 14692 14695 14696 14693 mattimes = CFtimesvar_datetime(tv, tu, cal) 14697 14694 … … 14931 14928 pern = per[3:Lper] 14932 14929 vtemp_desc = temp_desc[pern] 14933 print vtemp_desc14934 14930 vvtdesc = list(vtemp_desc.keys()) 14935 14931 vvtdesc.sort() … … 14939 14935 for islc in range(Nslices): 14940 14936 vvtemp_desc = vtemp_desc[vvtdesc[islc]] 14941 print 'islc,', islc, 'vtemp:', vvtemp_desc14942 14937 Ltt = len(vvtemp_desc) 14943 14938 slices.append(vvtemp_desc) … … 14975 14970 return slices, Nslices 14976 14971 14977 tv = [] 14978 values = [] 14979 totT = 24. 14980 dT = 7.345 14981 iTT = 29. 14982 for it in range(0,10): 14983 for itt in range(3): 14984 days = iTT+it*totT+dT*itt 14985 tv.append(days) 14986 #values.append((it*3+itt)*1.) 14987 Nyear = int((days-31)/365) 14988 dyear = (days-31) - Nyear*365 14989 if dyear < 59: 14990 values.append(0.) 14991 elif dyear >= 59 and dyear < 151: 14992 values.append(1.) 14993 elif dyear >= 151 and dyear < 243: 14994 values.append(2.) 14995 elif dyear >= 243 and dyear < 334: 14996 values.append(3.) 14997 14998 for it in range(len(values)): 14999 print it, tv[it], values[it] 15000 15001 vals = np.array(values) 15002 itdim = 0 15003 tu = 'days since 1949-12-01 00:00:00' 15004 per = 'season' 15005 calend = 'standard' 15006 amount = 1 15007 15008 tdes = temporal_desc(tv, tu, calend) 15009 15010 tslc, Ntslc = time_slices(tv, tu, calend, per, amount, tdes) 15011 15012 statn = 'mean' 15013 tstat = np.ones((Ntslc), dtype=np.float) 15014 for islc in range(Ntslc): 15015 timeslcv = tslc[islc] 15016 if per[0:3] != 'agg': 15017 timeslc = [slice(timeslcv[0],timeslcv[1],timeslcv[2])] 15018 tvals = vals[tuple(timeslc)] 15019 else: 15020 newshape = list(vals.shape) 15021 aggslc = tslc[islc] 15022 NNtslc = len(aggslc) 15023 newshape[itdim] = NNtslc 15024 tvals = np.zeros(tuple(newshape), dtype=vals.dtype) 15025 origshape = list(vals.shape) 15026 iishape = list(vals.shape) 15027 for iislc in range(NNtslc): 15028 origshape[itdim] = aggslc[iislc] 15029 iishape[itdim] = iislc 15030 print iislc, ':', iishape, '<>', origshape, vals[tuple(origshape)] 15031 tvals[tuple(iishape)] = vals[tuple(origshape)] 15032 15033 if statn == 'min': 15034 tstat[islc] = np.min(tvals, axis=itdim) 15035 elif statn == 'max': 15036 tstat[islc] = np.max(tvals, axis=itdim) 15037 elif statn == 'mean': 15038 tstat[islc] = np.mean(tvals, axis=itdim) 15039 elif statn == 'mean2': 15040 tstat[islc] = np.mean(tvals**2, axis=itdim) 15041 elif statn == 'std': 15042 tstat[islc] = np.std(tvals, axis=itdim) 15043 15044 timeslc = tslc[islc] 15045 itime = tv[timeslc[0]] 15046 etime = tv[timeslc[1]] 15047 print islc, ':', itime, '-', etime, '<>', tvals, '=', tstat[islc] 15048 quit() 15049 15050 14972 #quit() 14973 14974
Note: See TracChangeset
for help on using the changeset viewer.