return round_data( x ) def round_data_clamp_clt( x ): x[ x < 0.0 ] = 0.0 x[ x > 100.0 ] = 100.0 # per Stephanie McAfee return round_data( x ) if variable == 'hur': post_downscale_function = round_data_clamp_hur if variable == 'clt': post_downscale_function = round_data_clamp_clt else: post_downscale_function = round_data # FOR CRU WE PASS THE interp=True so we interpolate across space first when creating the Dataset() historical = Dataset( cru_ts, variable, model, scenario, project, units, metric, method='linear', ncpus=32 ) # ar5 = DeltaDownscale( baseline, clim_begin, clim_end, historical, future=None, # downscaling_operation=downscaling_operation, mask=mask, mask_value=0, ncpus=32, # src_crs={'init':'epsg:4326'}, src_nodata=None, dst_nodata=None, # post_downscale_function=round_it, varname=out_varname, modelname=None, anom=True ) # FOR CRU WE PASS THE interp=True so we interpolate across space first when creating the Dataset() ar5 = DeltaDownscale( baseline, clim_begin, clim_end, historical, future=None, downscaling_operation=downscaling_operation, mask=mask, mask_value=0, ncpus=32, src_crs={'init':'epsg:4326'}, src_nodata=None, dst_nodata=None, post_downscale_function=post_downscale_function, varname=out_varname, modelname=None, anom=anom, interp=interp, find_bounds=find_bounds, fix_clim=fix_clim, aoi_mask=aoi_mask ) if not os.path.exists( output_path ): os.makedirs( output_path )
# RUN 2.0 filelist = glob.glob(os.path.join(clim_path, '*.tif')) filelist = [fn for fn in filelist if not '_14_' in fn] baseline = Baseline(filelist) # DOWNSCALE mask = rasterio.open(baseline.filelist[0]).read_masks(1) clim_begin = '1961' clim_end = '1990' # FOR CRU WE PASS THE interp=True so we interpolate across space first when creating the Dataset() historical = Dataset(cru_ts, variable, model, scenario, project, units, metric=metric, interp=True, method='linear', ncpus=32) ar5 = DeltaDownscale( baseline, clim_begin, clim_end, historical, future=None, \ downscaling_operation='add', mask=mask, mask_value=0, ncpus=32, \ src_crs={'init':'epsg:4326'}, src_nodata=None, dst_nodata=None, post_downscale_function=None, varname=out_varname, modelname=None ) # -9999 if not os.path.exists(output_path): os.makedirs(output_path) ar5.downscale(output_dir=output_path)