Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'CLIMATE-936' of https://github.com/MichaelArthurAnderso…
  • Loading branch information
agoodm committed Dec 2, 2017
2 parents 8cf58f8 + 4c52367 commit 85a4e348ddf923af37712866075cf2b9b8a2602f
Showing 1 changed file with 25 additions and 21 deletions.
@@ -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.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 @@
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 @@
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 @@

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,28 +154,28 @@
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])

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]')

0 comments on commit 85a4e34

Please sign in to comment.