Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge branch 'CLIMATE-965'
Browse files Browse the repository at this point in the history
  • Loading branch information
huikyole committed Jun 17, 2019
2 parents 8d9ef65 + c8a1001 commit 8ba9330
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions RCMES/CORDEX/templates/CORDEX.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ output_netcdf_filename: {{ basename }}.nc
time:
maximum_overlap_period: True
temporal_resolution: monthly
adjust_model_years_for_climatology_calculation: True
{% if season == "winter" %}
month_start: 12
month_end: 2
Expand Down
58 changes: 58 additions & 0 deletions RCMES/CORDEX/templates/CORDEX_evaluation_run.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% set domain = models_info[0].domain %}
{% set instrument = obs_info.instrument %}
{% set variable = models_info[0].variable %}
{% set basename = [variable, instrument, domain, season]|join('_') %}
workdir: {{ [output_dir, domain, instrument, variable, season]|join('/') }}
output_netcdf_filename: {{ basename }}.nc

# (RCMES will temporally subset data between month_start and month_end.
# If average_each_year is True (False), seasonal mean in each year is (not) calculated and used for metrics calculation.)
time:
maximum_overlap_period: True
temporal_resolution: monthly
adjust_model_years_for_climatology_calculation: False
{% if season == "winter" %}
month_start: 12
month_end: 2
{% elif season == "summer" %}
month_start: 6
month_end: 8
{% else %}
month_start: 1
month_end: 12
{% endif %}
average_each_year: True

space:
boundary_type: CORDEX {{ domain[:3] }}

regrid:
regrid_on_reference: True

datasets:
- loader_name: local_split
name: {{ instrument }}
file_path: {{ obs_info.filename }}
variable_name: {{ obs_info.variable }}
{% for model_info in models_info %}
- loader_name: local_split
name: {{ model_info.model }}
file_path: {{ model_info.filename }}
variable_name: {{ model_info.variable }}
lat_name: lat
lon_name: lon
{% endfor %}

number_of_metrics_and_plots: 2

metrics1: Map_plot_bias_of_multiyear_climatology

plots1:
file_name: {{ basename }}_bias

metrics2: Taylor_diagram_spatial_pattern_of_multiyear_climatology

plots2:
file_name: {{ basename }}_taylor

use_subregions: False
3 changes: 3 additions & 0 deletions RCMES/run_RCMES.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def load_datasets_from_config(extra_opts, *loader_opts):

""" Step 2: Subset the data for temporal and spatial domain """
# Create a Bounds object to use for subsetting
if 'adjust_model_years_for_climatology_calculation' in time_info:
if time_info['adjust_model_years_for_climatology_calculation']:
datasets = utils.adjust_model_years_for_climatology_calculation(datasets)
if maximum_overlap_period:
start_time, end_time = utils.get_temporal_overlap(datasets)
print('Maximum overlap period')
Expand Down
15 changes: 13 additions & 2 deletions ocw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ def get_temporal_overlap(dataset_array):
''' Find the maximum temporal overlap across the observation and model datasets
:param dataset_array: an array of OCW datasets
:param idx: start and end indices to denote subset of months used.
:type idx: class:`tuple`
'''
start_times = []
end_times = []
Expand All @@ -397,6 +395,19 @@ def get_temporal_overlap(dataset_array):

return np.max(start_times), np.min(end_times)

def adjust_model_years_for_climatology_calculation(dataset_array):
''' Using the time length of the first element in the input dataset_array,
adjust years in the rest ofi the dataset_array so that every dataset ends in the same year.
:param dataset_array: an array of OCW datasets
'''
slc = trim_dataset(dataset_array[0])
obs_times = dataset_array[0].times[slc]
for idata, dataset in enumerate(dataset_array[1:]):
year_diff = obs_times[-1].year - dataset.times[-1].year
nt = dataset.times.size
for it in np.arange(nt):
dataset.times[it] = dataset.times[it].replace(year = dataset.times[it].year + year_diff)
return dataset_array

def trim_dataset(dataset):
''' Trim datasets such that first and last year of data have all 12 months
Expand Down

0 comments on commit 8ba9330

Please sign in to comment.