def AreaAvgOverTime(var, model, timeRange, latRange, lonRange): avgOverTime = [] lat = [] lon = [] for i in range(timeRange[0], timeRange[1]): print i g = GetDataMap.getDataMap(latRange, lonRange, i, model, var) if len(lat) == 0: lat = g[0] lon = g[1] TimeAverage = GetDataMap.getTimeAvg(g[2]) if (len(avgOverTime) == 0): for j in range(0, len(TimeAverage)): row = [] for c in range(0, len(TimeAverage[0])): row.append(TimeAverage[j][c]) avgOverTime.append(row) else: for j in range(0, len(TimeAverage)): for c in range(0, len(TimeAverage[0])): avgOverTime[j][c] += TimeAverage[j][c] for i in range(0, len(avgOverTime)): for j in range(0, len(avgOverTime[i])): avgOverTime[i][j] /= len(range(timeRange[0], timeRange[1])) return [lat, lon, avgOverTime]
def AreaAvgOverTime(var, model, timeRange, latRange, lonRange): avgOverTime = [] lat = [] lon = [] for i in range(timeRange[0],timeRange[1]): print i g = GetDataMap.getDataMap(latRange, lonRange, i, model, var) if len(lat) == 0: lat = g[0] lon = g[1] TimeAverage = GetDataMap.getTimeAvg(g[2]) if(len(avgOverTime) == 0): for j in range(0,len(TimeAverage)): row = [] for c in range(0,len(TimeAverage[0])): row.append(TimeAverage[j][c]) avgOverTime.append(row) else: for j in range(0,len(TimeAverage)): for c in range(0,len(TimeAverage[0])): avgOverTime[j][c] += TimeAverage[j][c] for i in range(0, len(avgOverTime)): for j in range(0, len(avgOverTime[i])): avgOverTime[i][j] /= len(range(timeRange[0],timeRange[1])) return [lat, lon, avgOverTime]
def AreaAvgOverTime(var, models, ensemble, monthes, timeRange, latRange, lonRange): avgOverTime = [] lat = [] lon = [] for m in range(0, len(models)): curModelAvg = [] for i in range(timeRange[0],timeRange[1]): print i g = GetDataMap.getDataMap(latRange, lonRange, i, models[m], ensemble, monthes, var) if len(lat) == 0: lat = g[0] lon = g[1] TimeAverage = GetDataMap.getTimeAvg(g[2]) if(len(curModelAvg) == 0): for j in range(0,len(TimeAverage)): row = [] for c in range(0,len(TimeAverage[0])): row.append(TimeAverage[j][c]) curModelAvg.append(row) else: for j in range(0,len(TimeAverage)): for c in range(0,len(TimeAverage[0])): curModelAvg[j][c] += TimeAverage[j][c] for i in range(0, len(curModelAvg)): for j in range(0, len(curModelAvg[i])): curModelAvg[i][j] /= len(range(timeRange[0],timeRange[1])) if len(avgOverTime) == 0: for i in range(0, len(curModelAvg)): row = [] for j in range(0, len(curModelAvg[i])): row.append(curModelAvg[i][j]) avgOverTime.append(row) else: for i in range(0, len(curModelAvg)): for j in range(0, len(curModelAvg[i])): avgOverTime[i][j] += curModelAvg[i][j] for i in range(0, len(avgOverTime)): for j in range(0, len(avgOverTime[i])): avgOverTime[i][j] /= len(models) return [lat, lon, avgOverTime]
import LatLonIndex import GetDataMap upLat = 40 lowLat = 20 lftLon = 70 rgtLon = 100 latLonRange = LatLonIndex.findLatLonRange([lowLat, upLat], [lftLon, rgtLon], []) latRange = latLonRange[0] lonRange = latLonRange[1] Data = GetDataMap.getDataMap(latRange,lonRange,2004,"tasmax") print len(Data[2]) print len(Data[2][0]) Data_average = GetDataMap.getTimeAvg(Data[2]) tempDataLat = Data[0] tempDataLon = Data[1] tempDataData = Data_average[2] flatTLat = np.array(tempDataLat) flatTLon = np.array(tempDataLon) flatTData = np.array(tempDataData) m = Basemap(width=10000000/5,height=7000000/5, resolution='l',projection='stere',\ lat_ts=40,lat_0=(upLat+lowLat)/2,lon_0=(lftLon+rgtLon)/2) lon, lat = np.meshgrid(flatTLon[0,:], flatTLat[:,0]) x, y = m(lon,lat) cs = m.pcolor(x,y,np.squeeze(flatTData), vmin=min(min(x) for x in flatTData), vmax=max(max(x) for x in flatTData))
import GetDataMap upLat = 40 lowLat = 20 lftLon = 70 rgtLon = 100 latLonRange = LatLonIndex.findLatLonRange([lowLat, upLat], [lftLon, rgtLon], []) latRange = latLonRange[0] lonRange = latLonRange[1] Data = GetDataMap.getDataMap(latRange, lonRange, 2004, "tasmax") print len(Data[2]) print len(Data[2][0]) Data_average = GetDataMap.getTimeAvg(Data[2]) tempDataLat = Data[0] tempDataLon = Data[1] tempDataData = Data_average[2] flatTLat = np.array(tempDataLat) flatTLon = np.array(tempDataLon) flatTData = np.array(tempDataData) m = Basemap(width=10000000/5,height=7000000/5, resolution='l',projection='stere',\ lat_ts=40,lat_0=(upLat+lowLat)/2,lon_0=(lftLon+rgtLon)/2) lon, lat = np.meshgrid(flatTLon[0, :], flatTLat[:, 0]) x, y = m(lon, lat) cs = m.pcolor(x,