コード例 #1
0
class TairMosaic():
	'''
	A class for containing the full mosaic of arrays
	'''
	def __init__(self, 
if __name__ == '__main__': 

	#Example code for calculating annual trends for a TopoWx tile and outputting them as a GeoTiff
	workspace = 'E:\\TOPOWX\\h06v02\\topowx_tile_output\\' 
	directories = ['h06v02','h06v03','h06v04','h07v02','h07v03','h07v04','h08v02'] #file structure for the NetCDF4 files
	variables = ['tmin']#, 'tmax']
	mosaic_tair = [] # create an empty mosaic to store the outputs and string arrays together
	for i in range(1):
		for v in variables:
			filename = '%s%s\\%s_%s.nc' %(workspace, directories[i],directories[i], v)
			nc_ds = Dataset(filename)
			days = utld.get_days_metadata_dates(num2date(nc_ds.variables['time'][:], units=nc_ds.variables['time'].units))
			tair_trend = twxs.TairTrend(days,1948,2012)
				#tair_agg = twxs.TairAggregate(days)
				#Doing this in one shot will take ~10GB of memory
				#For less memory usage, process in chunks
			tair = nc_ds.variables[v][:]
			tair_ann = tair_trend.get_ann_trend(tair)
			mosaic_tair.append(tair_ann)
			#tair_mon_agg = tair_agg.daily_to_mthly(tair)
			#tair_ann_agg = tair_agg.daily_to_ann(tair)
			#figure out the non-spatial average
			#Output results
	
    #twx_tile_to_gtiff(nc_ds, tair_ann, 'E:\\TOPOWX\\topowx_tile_output\\h06v02\\h06v02_tmin_trend.tiff')
コード例 #2
0
if __name__ == '__main__':

    startyear = 1948
    endyear = 2012
    workspace = 'E:\\TOPOWX\\annual\\'
    var = ['tmin']  #,'tmax']
    i = 0
    dataset = []
    for year in range(startyear, endyear + 1):
        filename = '%s%s\\%s_%s.nc' % (workspace, var[i], var[i], str(year))
        nc_ds = Dataset(filename)
        dataset.append(nc_ds)

        days = utld.get_days_metadata_dates(
            num2date(nc_ds.variables['time'][:],
                     units=nc_ds.variables['time'].units))
        tair_trend = twxs.TairTrend(days, 2012)
        #tair_agg = twxs.TairAggregate(days)
        #Doing this in one shot will take ~10GB of memory
        #For less memory usage, process in chunks
        tair = nc_ds.variables[v][:]
        tair_ann = tair_trend.get_ann_trend(tair)
        ymin = nc_ds.variables['lat'][-1]
        ymax = nc_ds.variables['lat'][0]
        xmin = nc_ds.variables['lon'][0]
        xmax = nc_ds.variables['lon'][-1]
        bbox = [xmin, xmax, ymin, ymax]
        mosaic_tair.append([tair_ann, bbox])
        #tair_mon_agg = tair_agg.daily_to_mthly(tair)
        #tair_ann_agg = tair_agg.daily_to_ann(tair)
コード例 #3
0
		ens_trend.append((topowx_trend[i]+prism_trend[i])/2)
		mask.append(np.abs(diff_mask[i]))
		threshold.append(np.std(diff_mask[i])*2) #check for values twice the standard deviation
		binary_mask.append(np.where(mask[0]> threshold[0], 0,np.nan))
	
	for i in range(2):
		plt.subplot(2,2,i+1)
		plt.imshow(topowx_trend[i])
		
		
	#look at the elevation trend
	n = np.shape(elevation)[0]*np.shape(elevation)[1]
	trend_series = [np.reshape(ens_trend[0],n),np.reshape(ens_trend[1],n)]
	elev_series = np.reshape(elevation,n)
	
	days = utld.get_days_metadata_dates(num2date(nc_ds.variables['time'][:], units=nc_ds.variables['time'].units))
		tair_trend = twxs.TairTrend(days,2012)
				#tair_agg = twxs.TairAggregate(days)
				#Doing this in one shot will take ~10GB of memory
				#For less memory usage, process in chunks
		tair = nc_ds.variables[var[0]][:]
		tair_ann = tair_trend.get_ann_trend(tair)
		ymin = nc_ds.variables['lat'][-1]
		ymax = nc_ds.variables['lat'][0]
		xmin = nc_ds.variables['lon'][0]
		xmax = nc_ds.variables['lon'][-1]
		bbox = [xmin, xmax, ymin, ymax]
		mosaic_tair.append([tair_ann, bbox])
			#tair_mon_agg = tair_agg.daily_to_mthly(tair)
			#tair_ann_agg = tair_agg.daily_to_ann(tair)
			#figure out the non-spatial average