Repository: climate Updated Branches: refs/heads/master 8cf58f88f -> 85a4e348d
CLIMATE-936 - Added instructions on where to find input files for the example. Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/21ec176d Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/21ec176d Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/21ec176d Branch: refs/heads/master Commit: 21ec176dfa5f3320a465ad67af4af43b60a4fc85 Parents: 41412ca Author: Michael Anderson <michaelanderson@Michaels-iMac.local> Authored: Fri Dec 1 05:22:15 2017 -0500 Committer: Michael Anderson <michaelanderson@Michaels-iMac.local> Committed: Fri Dec 1 05:22:15 2017 -0500 ---------------------------------------------------------------------- examples/temperature_trends_over_CONUS.py | 46 ++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/21ec176d/examples/temperature_trends_over_CONUS.py ---------------------------------------------------------------------- diff --git a/examples/temperature_trends_over_CONUS.py b/examples/temperature_trends_over_CONUS.py index 028c8a2..8510294 100644 --- a/examples/temperature_trends_over_CONUS.py +++ b/examples/temperature_trends_over_CONUS.py @@ -24,6 +24,10 @@ 1. Load the local file nClimDiv/nClimDiv_tave_1895-2005.nc into OCW Dataset Objects. *** Note *** It is assume this file exists locally in a subdirectory nClimDiv located + *** Note *** The files can be downloaded from : + https://rcmes.jpl.nasa.gov/RCMES_Turtorial_data/NCA-CMIP_examples.tar.gz + *** Note *** Additional information about the file content can be found here: + https://rcmes.jpl.nasa.gov/content/nca-cmip-analysis-using-rcmes in the same directory as the example. 2. Load the CMIP5 simulations into a list of OCW Dataset Objects. 3. Spatially subset the observed dataset into state and regional boundaries. @@ -51,8 +55,8 @@ import ocw.metrics as metrics import ocw.plotter as plotter import ocw.utils as utils -# nClimDiv observation file -file_obs = 'nClimDiv/nClimDiv_tave_1895-2005.nc' +# nClimGrid observation file +file_obs = 'nClimGrid/nClimGrid_tave_1895-2005.nc' # CMIP5 simulations model_file_path = 'CMIP5_historical' @@ -65,7 +69,7 @@ nmodel = len(dataset_name) # number of CMIP5 simulations start_date = datetime.datetime(1979, 12, 1) end_date = datetime.datetime(2005, 8, 31) -nyear = 26 +nyear = 26 month_start = 6 # June month_end = 8 # August @@ -85,39 +89,39 @@ plotter.fill_US_states_with_color(regions, 'NCA_seven_regions', colors=True, n_region = 7 # number of regions # CONUS regional boundaries -NW_bounds = Bounds(boundary_type='us_states', +NW_bounds = Bounds(boundary_type='us_states', us_states=regions[0]) -SW_bounds = Bounds(boundary_type='us_states', +SW_bounds = Bounds(boundary_type='us_states', us_states=regions[1]) -NGP_bounds = Bounds(boundary_type='us_states', +NGP_bounds = Bounds(boundary_type='us_states', us_states=regions[2]) -SGP_bounds = Bounds(boundary_type='us_states', +SGP_bounds = Bounds(boundary_type='us_states', us_states=regions[3]) -MW_bounds = Bounds(boundary_type='us_states', +MW_bounds = Bounds(boundary_type='us_states', us_states=regions[4]) -NE_bounds = Bounds(boundary_type='us_states', +NE_bounds = Bounds(boundary_type='us_states', us_states=regions[5]) -SE_bounds = Bounds(boundary_type='us_states', +SE_bounds = Bounds(boundary_type='us_states', us_states=regions[6]) regional_bounds = [NW_bounds, SW_bounds, NGP_bounds, SGP_bounds, MW_bounds, NE_bounds, SE_bounds] -""" Load nClimDiv file into OCW Dataset """ -obs_dataset = local.load_file(file_obs, variable_name='tave') +""" Load nClimGrid file into OCW Dataset """ +obs_dataset = local.load_file(file_obs, variable_name='tave') """ Load CMIP5 simulations into a list of OCW Datasets""" model_dataset = local.load_multiple_files(file_path=model_file_path, variable_name='tas', - dataset_name=dataset_name, variable_unit='K') + dataset_name=dataset_name, variable_unit='K') """ Temporal subset of obs_dataset """ -obs_dataset_subset = dsp.temporal_slice(obs_dataset, +obs_dataset_subset = dsp.temporal_slice(obs_dataset, start_time=start_date, end_time=end_date) obs_dataset_season = dsp.temporal_subset(obs_dataset_subset, month_start, month_end, average_each_year=True) """ Temporal subset of model_dataset """ -model_dataset_subset = [dsp.temporal_slice(dataset,start_time=start_date, end_time=end_date) +model_dataset_subset = [dsp.temporal_slice(dataset,start_time=start_date, end_time=end_date) for dataset in model_dataset] model_dataset_season = [dsp.temporal_subset(dataset, month_start, month_end, average_each_year=True) for dataset in model_dataset_subset] @@ -129,7 +133,7 @@ model_timeseries = np.zeros([nmodel, nyear, n_region]) for iregion in np.arange(n_region): obs_timeseries[:, iregion] = utils.calc_time_series( - dsp.subset(obs_dataset_season, regional_bounds[iregion])) + dsp.subset(obs_dataset_season, regional_bounds[iregion])) for imodel in np.arange(nmodel): model_timeseries[imodel, :, iregion] = utils.calc_time_series( dsp.subset(model_dataset_season[imodel], regional_bounds[iregion])) @@ -150,20 +154,20 @@ for iregion in np.arange(n_region): regional_trends_model[imodel, iregion], regional_trends_model_error[iregion] = utils.calculate_temporal_trend_of_time_series( year, model_timeseries[imodel, :, iregion]) regional_trends_ens[iregion], regional_trends_ens_error[iregion] = utils.calculate_ensemble_temporal_trends( - model_timeseries[:, :, iregion]) + model_timeseries[:, :, iregion]) """ Generate plots """ -plotter.fill_US_states_with_color(regions, 'nClimDiv_tave_trends_JJA_1980-2005', +plotter.fill_US_states_with_color(regions, 'nClimGrid_tave_trends_JJA_1980-2005', values=regional_trends_obs, region_names=['%.3f' %(10*i) for i in regional_trends_obs]) -plotter.fill_US_states_with_color(regions, 'CMIP5_ENS_tave_trends_JJA_1980-2005', +plotter.fill_US_states_with_color(regions, 'CMIP5_ENS_tave_trends_JJA_1980-2005', values=regional_trends_ens, region_names=['%.3f' %(10*i) for i in regional_trends_ens]) bias_ens = regional_trends_ens - regional_trends_obs -plotter.fill_US_states_with_color(regions, 'CMIP5_ENS_tave_trends_bias_from_nClimDiv_JJA_1980-2005', +plotter.fill_US_states_with_color(regions, 'CMIP5_ENS_tave_trends_bias_from_nClimGrid_JJA_1980-2005', values=bias_ens, region_names=['%.3f' %(10*i) for i in bias_ens]) @@ -171,7 +175,7 @@ obs_data = np.vstack([regional_trends_obs, regional_trends_obs_error]) ens_data = np.vstack([regional_trends_ens, regional_trends_ens_error]) plotter.draw_plot_to_compare_trends(obs_data, ens_data, regional_trends_model, - fname='Trends_comparison_btn_CMIP5_and_nClimDiv', + fname='Trends_comparison_btn_CMIP5_and_nClimGrid', data_labels=['NW','SW','NGP','SGP','MW','NE','SE'], xlabel='NCA regions', ylabel='tas trend [K/year]')