You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by ja...@apache.org on 2016/07/28 14:14:57 UTC
[1/5] climate git commit: Normalize temporal_slice function parameter
ordering
Repository: climate
Updated Branches:
refs/heads/master e823b03c9 -> 1398a868b
Normalize temporal_slice function parameter ordering
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/7e3cd37b
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/7e3cd37b
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/7e3cd37b
Branch: refs/heads/master
Commit: 7e3cd37b4532a91b652c989ecc01d571320890a5
Parents: fb5392f
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Tue Jul 26 13:14:49 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Jul 28 19:41:09 2016 +0530
----------------------------------------------------------------------
RCMES/cli_app.py | 3 ++-
ocw/dataset_processor.py | 4 ++--
ocw/tests/test_dataset_processor.py | 12 ++++++------
3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/7e3cd37b/RCMES/cli_app.py
----------------------------------------------------------------------
diff --git a/RCMES/cli_app.py b/RCMES/cli_app.py
index 10ea6c4..9894a35 100644
--- a/RCMES/cli_app.py
+++ b/RCMES/cli_app.py
@@ -646,7 +646,8 @@ def run_screen(model_datasets, models_info, observations_info,
if each_target_dataset.lats.ndim !=2 and each_target_dataset.lons.ndim !=2:
new_model_datasets[member] = dsp.subset(EVAL_BOUNDS, new_model_datasets[member])
else:
- new_model_datasets[member] = dsp.temporal_slice(EVAL_BOUNDS.start, EVAL_BOUNDS.end, each_target_dataset)
+ new_model_datasets[member] = dsp.temporal_slice(
+ each_target_dataset, EVAL_BOUNDS.start, EVAL_BOUNDS.end)
screen.addstr(5, 4, "--> Temporally regridded.")
screen.refresh()
http://git-wip-us.apache.org/repos/asf/climate/blob/7e3cd37b/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 6702e54..d9480e9 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -395,7 +395,7 @@ def subset(target_dataset, subregion, subregion_name=None):
target_dataset.times == subregion.start)[0][0]
end_time_index = np.where(target_dataset.times == subregion.end)[0][0]
target_dataset = temporal_slice(
- start_time_index, end_time_index, target_dataset)
+ target_dataset, start_time_index, end_time_index)
nt, ny, nx = target_dataset.values.shape
y_index, x_index = np.where(
(target_dataset.lats >= subregion.lat_max) | (
@@ -455,7 +455,7 @@ def subset(target_dataset, subregion, subregion_name=None):
)
-def temporal_slice(start_time_index, end_time_index, target_dataset):
+def temporal_slice(target_dataset, start_time_index, end_time_index):
'''Temporally slice given dataset(s) with subregion information. This does not
spatially subset the target_Dataset
http://git-wip-us.apache.org/repos/asf/climate/blob/7e3cd37b/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index 3510463..6564d96 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -206,9 +206,9 @@ class TestTemporalSlice(unittest.TestCase):
end_index = 4
dates = np.array([datetime.datetime(2000, month, 1)
for month in range(start_index + 1, end_index + 2)])
- new_dataset = dp.temporal_slice(start_index,
- end_index,
- self.ten_year_dataset)
+ new_dataset = dp.temporal_slice(self.ten_year_dataset,
+ start_index,
+ end_index)
np.testing.assert_array_equal(new_dataset.times, dates)
def test_returned_dataset_values(self):
@@ -217,9 +217,9 @@ class TestTemporalSlice(unittest.TestCase):
start_index = 1
end_index = 4
values = self.ten_year_dataset.values[start_index:end_index + 1]
- new_dataset = dp.temporal_slice(start_index,
- end_index,
- self.ten_year_dataset)
+ new_dataset = dp.temporal_slice(self.ten_year_dataset,
+ start_index,
+ end_index)
np.testing.assert_array_equal(new_dataset.values, values)
[3/5] climate git commit: Normalize temporal_subset function
parameter ordering
Posted by ja...@apache.org.
Normalize temporal_subset function parameter ordering
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/5024b1c3
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/5024b1c3
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/5024b1c3
Branch: refs/heads/master
Commit: 5024b1c36256067d7efda198c4010b7898ab274a
Parents: e823b03
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Tue Jul 26 12:26:02 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Jul 28 19:41:09 2016 +0530
----------------------------------------------------------------------
RCMES/run_RCMES.py | 4 ++--
.../run_statistical_downscaling.py | 6 +++---
ocw/dataset_processor.py | 2 +-
ocw/tests/test_dataset_processor.py | 20 ++++++++++----------
4 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/5024b1c3/RCMES/run_RCMES.py
----------------------------------------------------------------------
diff --git a/RCMES/run_RCMES.py b/RCMES/run_RCMES.py
index ed48458..bb4f5d5 100644
--- a/RCMES/run_RCMES.py
+++ b/RCMES/run_RCMES.py
@@ -159,9 +159,9 @@ month_start = time_info['month_start']
month_end = time_info['month_end']
average_each_year = time_info['average_each_year']
-ref_dataset = dsp.temporal_subset(month_start, month_end,ref_dataset,average_each_year)
+ref_dataset = dsp.temporal_subset(ref_dataset,month_start, month_end,average_each_year)
for idata,dataset in enumerate(model_datasets):
- model_datasets[idata] = dsp.temporal_subset(month_start, month_end,dataset,average_each_year)
+ model_datasets[idata] = dsp.temporal_subset(dataset,month_start, month_end,average_each_year)
# generate grid points for regridding
if config['regrid']['regrid_on_reference']:
http://git-wip-us.apache.org/repos/asf/climate/blob/5024b1c3/RCMES/statistical_downscaling/run_statistical_downscaling.py
----------------------------------------------------------------------
diff --git a/RCMES/statistical_downscaling/run_statistical_downscaling.py b/RCMES/statistical_downscaling/run_statistical_downscaling.py
index 60c6ac2..9aae618 100644
--- a/RCMES/statistical_downscaling/run_statistical_downscaling.py
+++ b/RCMES/statistical_downscaling/run_statistical_downscaling.py
@@ -132,9 +132,9 @@ print(model_info['future']['scenario_name']+':'+model_info['data_name'] +" value
""" Step 2: Temporal subsetting """
print("Temporal subsetting for the selected month(s)")
-ref_temporal_subset = dsp.temporal_subset(month_start, month_end, ref_dataset)
-model_temporal_subset_present = dsp.temporal_subset(month_start, month_end, model_dataset_present)
-model_temporal_subset_future = dsp.temporal_subset(month_start, month_end, model_dataset_future)
+ref_temporal_subset = dsp.temporal_subset(ref_dataset, month_start, month_end)
+model_temporal_subset_present = dsp.temporal_subset(model_dataset_present, month_start, month_end)
+model_temporal_subset_future = dsp.temporal_subset(model_dataset_future, month_start, month_end)
""" Step 3: Spatial aggregation of observational data into the model grid """
print("Spatial aggregation of observational data near latitude %0.2f and longitude %0.2f " % (grid_lat, grid_lon))
http://git-wip-us.apache.org/repos/asf/climate/blob/5024b1c3/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index bfcad00..9837746 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -32,7 +32,7 @@ import logging
logger = logging.getLogger(__name__)
-def temporal_subset(month_start, month_end, target_dataset,
+def temporal_subset(target_dataset, month_start, month_end,
average_each_year=False):
""" Temporally subset data given month_index.
http://git-wip-us.apache.org/repos/asf/climate/blob/5024b1c3/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index cc8d6d8..bdbfa06 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -37,22 +37,22 @@ class TestTemporalSubset(unittest.TestCase):
self.dataset_times = np.array([datetime.datetime(year, month, 1)
for year in range(2000, 2010)
for month in range(1, 6)])
- self.tempSubset = dp.temporal_subset(1, 5, self.ten_year_dataset)
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset, 1, 5)
np.testing.assert_array_equal(
self.dataset_times, self.tempSubset.times)
def test_temporal_subset_with_average_time(self):
self.dataset_times = np.array([datetime.datetime(year, 2, 1)
for year in range(2000, 2010)])
- self.tempSubset = dp.temporal_subset(1, 3,
- self.ten_year_dataset,
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset,
+ 1, 3,
average_each_year=True)
np.testing.assert_array_equal(self.dataset_times,
self.tempSubset.times)
def test_temporal_subset_with_average_values(self):
- self.tempSubset = dp.temporal_subset(1, 3,
- self.ten_year_dataset,
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset,
+ 1, 3,
average_each_year=True)
self.dataset_values = np.ones([len(self.tempSubset.times),
len(self.ten_year_dataset.lats),
@@ -61,8 +61,8 @@ class TestTemporalSubset(unittest.TestCase):
self.tempSubset.values)
def test_temporal_subset_attributes(self):
- self.tempSubset = dp.temporal_subset(1, 3,
- self.ten_year_dataset,
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset,
+ 1, 3,
average_each_year=True)
self.assertEqual(self.tempSubset.name, self.ten_year_dataset.name)
self.assertEqual(self.tempSubset.variable,
@@ -76,8 +76,8 @@ class TestTemporalSubset(unittest.TestCase):
def test_temporal_subset_equal_start_end_month(self):
self.dataset_times = np.array([datetime.datetime(year, 1, 1)
for year in range(2000, 2010)])
- self.tempSubset = dp.temporal_subset(1, 1,
- self.ten_year_dataset,
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset,
+ 1, 1,
average_each_year=True)
np.testing.assert_array_equal(self.dataset_times,
self.tempSubset.times)
@@ -86,7 +86,7 @@ class TestTemporalSubset(unittest.TestCase):
self.dataset_times = np.array([datetime.datetime(year, month, 1)
for year in range(2000, 2010)
for month in [1, 8, 9, 10, 11, 12]])
- self.tempSubset = dp.temporal_subset(8, 1, self.ten_year_dataset)
+ self.tempSubset = dp.temporal_subset(self.ten_year_dataset, 8, 1)
np.testing.assert_array_equal(
self.dataset_times, self.tempSubset.times)
[2/5] climate git commit: Normallze subset function parameter ordering
Posted by ja...@apache.org.
Normallze subset function parameter ordering
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/fb5392f3
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/fb5392f3
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/fb5392f3
Branch: refs/heads/master
Commit: fb5392f3bf6cdf01d3ac04d7533cc55024343aca
Parents: 5024b1c
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Tue Jul 26 13:00:10 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Jul 28 19:41:09 2016 +0530
----------------------------------------------------------------------
RCMES/run_RCMES.py | 4 ++--
RCMES/test/test.py | 2 +-
docs/source/ocw/overview.rst | 2 +-
examples/knmi_to_cru31_full_bias.py | 2 +-
examples/model_ensemble_to_rcmed.py | 4 ++--
examples/multi_model_evaluation.py | 2 +-
examples/multi_model_taylor_diagram.py | 2 +-
examples/subregions_portrait_diagram.py | 2 +-
examples/taylor_diagram_example.py | 4 ++--
examples/time_series_with_regions.py | 8 +++++---
ocw/dataset_processor.py | 2 +-
ocw/evaluation.py | 9 +++++----
ocw/tests/test_dataset_processor.py | 20 ++++++++++----------
ocw_config_runner/plot_generation.py | 4 ++--
14 files changed, 35 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/RCMES/run_RCMES.py
----------------------------------------------------------------------
diff --git a/RCMES/run_RCMES.py b/RCMES/run_RCMES.py
index bb4f5d5..cd69bc4 100644
--- a/RCMES/run_RCMES.py
+++ b/RCMES/run_RCMES.py
@@ -146,11 +146,11 @@ if ref_data_info['data_source'] == 'rcmed':
max_lon = np.min([max_lon, ref_dataset.lons.max()])
bounds = Bounds(min_lat, max_lat, min_lon, max_lon, start_time, end_time)
-ref_dataset = dsp.subset(bounds,ref_dataset)
+ref_dataset = dsp.subset(ref_dataset, bounds)
if ref_dataset.temporal_resolution() != temporal_resolution:
ref_dataset = dsp.temporal_rebin(ref_dataset, temporal_resolution)
for idata,dataset in enumerate(model_datasets):
- model_datasets[idata] = dsp.subset(bounds,dataset)
+ model_datasets[idata] = dsp.subset(dataset, bounds)
if dataset.temporal_resolution() != temporal_resolution:
model_datasets[idata] = dsp.temporal_rebin(dataset, temporal_resolution)
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/RCMES/test/test.py
----------------------------------------------------------------------
diff --git a/RCMES/test/test.py b/RCMES/test/test.py
index 5071187..677a13f 100644
--- a/RCMES/test/test.py
+++ b/RCMES/test/test.py
@@ -112,7 +112,7 @@ print("Our two datasets have a mis-match in time. We will subset on time to %s y
# Create a Bounds object to use for subsetting
new_bounds = Bounds(min_lat, max_lat, min_lon, max_lon, start_time, end_time)
-knmi_dataset = dsp.subset(new_bounds, knmi_dataset)
+knmi_dataset = dsp.subset(knmi_dataset, new_bounds)
print("CRU31_Dataset.values shape: (times, lats, lons) - %s" % (cru31_dataset.values.shape,))
print("KNMI_Dataset.values shape: (times, lats, lons) - %s \n" % (knmi_dataset.values.shape,))
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/docs/source/ocw/overview.rst
----------------------------------------------------------------------
diff --git a/docs/source/ocw/overview.rst b/docs/source/ocw/overview.rst
index 5aa0ff8..a77f954 100644
--- a/docs/source/ocw/overview.rst
+++ b/docs/source/ocw/overview.rst
@@ -35,7 +35,7 @@ Subsetting is a great way to speed up your processing and keep useless data out
>>> import ocw.dataset_processor as dsp
>>> new_bounds = Bounds(min_lat, max_lat, min_lon, max_lon, start_time, end_time)
->>> knmi_dataset = dsp.subset(new_bounds, knmi_dataset)
+>>> knmi_dataset = dsp.subset(knmi_dataset, new_bounds)
Temporally re-binning a dataset is great when the time step of the data is too fine grain for the desired use. For instance, perhaps we want to see a yearly trend but we have daily data. We would need to make the following call to adjust our dataset::
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/knmi_to_cru31_full_bias.py
----------------------------------------------------------------------
diff --git a/examples/knmi_to_cru31_full_bias.py b/examples/knmi_to_cru31_full_bias.py
index c6aa327..4c0abd9 100644
--- a/examples/knmi_to_cru31_full_bias.py
+++ b/examples/knmi_to_cru31_full_bias.py
@@ -112,7 +112,7 @@ print("Our two datasets have a mis-match in time. We will subset on time to %s y
# Create a Bounds object to use for subsetting
new_bounds = Bounds(min_lat, max_lat, min_lon, max_lon, start_time, end_time)
-knmi_dataset = dsp.subset(new_bounds, knmi_dataset)
+knmi_dataset = dsp.subset(knmi_dataset, new_bounds)
print("CRU31_Dataset.values shape: (times, lats, lons) - %s" % (cru31_dataset.values.shape,))
print("KNMI_Dataset.values shape: (times, lats, lons) - %s \n" % (knmi_dataset.values.shape,))
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/model_ensemble_to_rcmed.py
----------------------------------------------------------------------
diff --git a/examples/model_ensemble_to_rcmed.py b/examples/model_ensemble_to_rcmed.py
index 14b92b9..fef1f9d 100644
--- a/examples/model_ensemble_to_rcmed.py
+++ b/examples/model_ensemble_to_rcmed.py
@@ -131,8 +131,8 @@ cru31_dataset = dsp.temporal_rebin(cru31_dataset, temporal_resolution = 'annual'
new_bounds = Bounds(min_lat, max_lat, min_lon, max_lon, start_time, end_time)
# Subset our model datasets so they are the same size
-knmi_dataset = dsp.subset(new_bounds, knmi_dataset)
-wrf311_dataset = dsp.subset(new_bounds, wrf311_dataset)
+knmi_dataset = dsp.subset(knmi_dataset, new_bounds)
+wrf311_dataset = dsp.subset(wrf311_dataset, new_bounds)
""" Spatially Regrid the Dataset Objects to a 1/2 degree grid """
# Using the bounds we will create a new set of lats and lons on 1/2 degree step
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/multi_model_evaluation.py
----------------------------------------------------------------------
diff --git a/examples/multi_model_evaluation.py b/examples/multi_model_evaluation.py
index a09c526..0755279 100644
--- a/examples/multi_model_evaluation.py
+++ b/examples/multi_model_evaluation.py
@@ -91,7 +91,7 @@ CRU31 = dsp.water_flux_unit_conversion(CRU31)
CRU31 = dsp.temporal_rebin(CRU31, datetime.timedelta(days=30))
for member, each_target_dataset in enumerate(target_datasets):
- target_datasets[member] = dsp.subset(EVAL_BOUNDS, target_datasets[member])
+ target_datasets[member] = dsp.subset(target_datasets[member], EVAL_BOUNDS)
target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
target_datasets[member] = dsp.temporal_rebin(target_datasets[member], datetime.timedelta(days=30))
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/multi_model_taylor_diagram.py
----------------------------------------------------------------------
diff --git a/examples/multi_model_taylor_diagram.py b/examples/multi_model_taylor_diagram.py
index 57dabdd..9ba8746 100644
--- a/examples/multi_model_taylor_diagram.py
+++ b/examples/multi_model_taylor_diagram.py
@@ -86,7 +86,7 @@ CRU31 = dsp.temporal_rebin(CRU31, temporal_resolution = 'monthly')
for member, each_target_dataset in enumerate(target_datasets):
target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
target_datasets[member] = dsp.temporal_rebin(target_datasets[member], temporal_resolution = 'monthly')
- target_datasets[member] = dsp.subset(EVAL_BOUNDS, target_datasets[member])
+ target_datasets[member] = dsp.subset(target_datasets[member], EVAL_BOUNDS)
#Regrid
print("... regrid")
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/subregions_portrait_diagram.py
----------------------------------------------------------------------
diff --git a/examples/subregions_portrait_diagram.py b/examples/subregions_portrait_diagram.py
index d8d982f..525cb26 100644
--- a/examples/subregions_portrait_diagram.py
+++ b/examples/subregions_portrait_diagram.py
@@ -76,7 +76,7 @@ print("... on units")
CRU31 = dsp.water_flux_unit_conversion(CRU31)
for member, each_target_dataset in enumerate(target_datasets):
- target_datasets[member] = dsp.subset(EVAL_BOUNDS, target_datasets[member])
+ target_datasets[member] = dsp.subset(target_datasets[member], EVAL_BOUNDS)
target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
target_datasets[member] = dsp.normalize_dataset_datetimes(target_datasets[member], 'monthly')
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/taylor_diagram_example.py
----------------------------------------------------------------------
diff --git a/examples/taylor_diagram_example.py b/examples/taylor_diagram_example.py
index 90c6708..66ca175 100644
--- a/examples/taylor_diagram_example.py
+++ b/examples/taylor_diagram_example.py
@@ -62,8 +62,8 @@ wrf_dataset = dsp.normalize_dataset_datetimes(wrf_dataset, 'monthly')
# make a Bounds object and use it to subset our datasets.
################################################################################
subset = Bounds(-45, 42, -24, 60, datetime.datetime(1989, 1, 1), datetime.datetime(1989, 12, 1))
-knmi_dataset = dsp.subset(subset, knmi_dataset)
-wrf_dataset = dsp.subset(subset, wrf_dataset)
+knmi_dataset = dsp.subset(knmi_dataset, subset)
+wrf_dataset = dsp.subset(wrf_dataset, subset)
# Temporally re-bin the data into a monthly timestep.
################################################################################
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/examples/time_series_with_regions.py
----------------------------------------------------------------------
diff --git a/examples/time_series_with_regions.py b/examples/time_series_with_regions.py
index ec9516d..8d9e5c0 100644
--- a/examples/time_series_with_regions.py
+++ b/examples/time_series_with_regions.py
@@ -74,7 +74,7 @@ CRU31 = dsp.water_flux_unit_conversion(CRU31)
CRU31 = dsp.normalize_dataset_datetimes(CRU31, 'monthly')
for member, each_target_dataset in enumerate(target_datasets):
- target_datasets[member] = dsp.subset(EVAL_BOUNDS, target_datasets[member])
+ target_datasets[member] = dsp.subset(target_datasets[member], EVAL_BOUNDS)
target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
target_datasets[member] = dsp.normalize_dataset_datetimes(target_datasets[member], 'monthly')
@@ -122,7 +122,7 @@ for regions in region_list:
firstTime = True
subset_name = regions[0]+"_CRU31"
#labels.append(subset_name) #for legend, uncomment this line
- subset = dsp.subset(list_of_regions[region_counter], CRU31, subset_name)
+ subset = dsp.subset(CRU31, list_of_regions[region_counter], subset_name)
tSeries = utils.calc_time_series(subset)
results.append(tSeries)
tSeries=[]
@@ -130,7 +130,9 @@ for regions in region_list:
for member, each_target_dataset in enumerate(target_datasets):
subset_name = regions[0]+"_"+target_datasets[member].name
#labels.append(subset_name) #for legend, uncomment this line
- subset = dsp.subset(list_of_regions[region_counter],target_datasets[member],subset_name)
+ subset = dsp.subset(target_datasets[member],
+ list_of_regions[region_counter],
+ subset_name)
tSeries = utils.calc_time_series(subset)
results.append(tSeries)
tSeries=[]
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 9837746..6702e54 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -362,7 +362,7 @@ def ensemble(datasets):
return ensemble_dataset
-def subset(subregion, target_dataset, subregion_name=None):
+def subset(target_dataset, subregion, subregion_name=None):
'''Subset given dataset(s) with subregion information
:param subregion: The Bounds with which to subset the target Dataset.
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/ocw/evaluation.py
----------------------------------------------------------------------
diff --git a/ocw/evaluation.py b/ocw/evaluation.py
index 8f01a68..cd06450 100644
--- a/ocw/evaluation.py
+++ b/ocw/evaluation.py
@@ -272,11 +272,11 @@ class Evaluation(object):
def _run_subregion_evaluation(self):
results = []
- new_refs = [DSP.subset(s, self.ref_dataset) for s in self.subregions]
+ new_refs = [DSP.subset(self.ref_dataset, s) for s in self.subregions]
for target in self.target_datasets:
results.append([])
- new_targets = [DSP.subset(s, target) for s in self.subregions]
+ new_targets = [DSP.subset(target, s) for s in self.subregions]
for metric in self.metrics:
results[-1].append([])
@@ -313,10 +313,11 @@ class Evaluation(object):
def _run_subregion_unary_evaluation(self):
unary_results = []
if self.ref_dataset:
- new_refs = [DSP.subset(s, self.ref_dataset) for s in self.subregions]
+ new_refs = [DSP.subset(self.ref_dataset, s)
+ for s in self.subregions]
new_targets = [
- [DSP.subset(s, t) for s in self.subregions]
+ [DSP.subset(t, s) for s in self.subregions]
for t in self.target_datasets
]
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index bdbfa06..3510463 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -450,7 +450,7 @@ class TestSubset(unittest.TestCase):
)
def test_subset(self):
- subset = dp.subset(self.subregion, self.target_dataset)
+ subset = dp.subset(self.target_dataset, self.subregion)
self.assertEqual(subset.lats.shape[0], 82)
self.assertSequenceEqual(list(np.array(range(-81, 82, 2))),
list(subset.lats))
@@ -459,12 +459,12 @@ class TestSubset(unittest.TestCase):
self.assertEqual(subset.values.shape, (37, 82, 162))
def test_subset_name(self):
- subset = dp.subset(self.subregion, self.target_dataset)
+ subset = dp.subset(self.target_dataset, self.subregion)
self.assertEqual(subset.name, self.name)
def test_subset_name_propagation(self):
subset_name = 'foo_subset_name'
- subset = dp.subset(self.subregion, self.target_dataset, subset_name)
+ subset = dp.subset(self.target_dataset, self.subregion, subset_name)
self.assertEqual(subset.name, subset_name)
def test_subset_using_non_exact_spatial_bounds(self):
@@ -494,7 +494,7 @@ class TestSubset(unittest.TestCase):
-81, 81,
-161, 161,
)
- subset = dp.subset(self.subregion, self.target_dataset)
+ subset = dp.subset(self.target_dataset, self.subregion)
times = np.array([datetime.datetime(year, month, 1)
for year in range(2000, 2010)
for month in range(1, 13)])
@@ -594,32 +594,32 @@ class TestFailingSubset(unittest.TestCase):
def test_out_of_dataset_bounds_lat_min(self):
self.subregion.lat_min = -90
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
def test_out_of_dataset_bounds_lat_max(self):
self.subregion.lat_max = 90
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
def test_out_of_dataset_bounds_lon_min(self):
self.subregion.lon_min = -180
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
def test_out_of_dataset_bounds_lon_max(self):
self.subregion.lon_max = 180
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
def test_out_of_dataset_bounds_start(self):
self.subregion.start = datetime.datetime(1999, 1, 1)
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
def test_out_of_dataset_bounds_end(self):
self.subregion.end = datetime.datetime(2011, 1, 1)
with self.assertRaises(ValueError):
- dp.subset(self.subregion, self.target_dataset)
+ dp.subset(self.target_dataset, self.subregion)
class TestNetCDFWrite(unittest.TestCase):
http://git-wip-us.apache.org/repos/asf/climate/blob/fb5392f3/ocw_config_runner/plot_generation.py
----------------------------------------------------------------------
diff --git a/ocw_config_runner/plot_generation.py b/ocw_config_runner/plot_generation.py
index 938553e..3fc3adb 100644
--- a/ocw_config_runner/plot_generation.py
+++ b/ocw_config_runner/plot_generation.py
@@ -163,8 +163,8 @@ def _draw_time_series_plot(evaluation, plot_config):
labels = []
subset = dsp.subset(
- bound,
ref_ds,
+ bound,
subregion_name="R{}_{}".format(bound_count, ref_ds.name)
)
@@ -173,8 +173,8 @@ def _draw_time_series_plot(evaluation, plot_config):
for t in target_ds:
subset = dsp.subset(
- bound,
t,
+ bound,
subregion_name="R{}_{}".format(bound_count, t.name)
)
results.append(utils.calc_time_series(subset))
[4/5] climate git commit: Normalize safe_subset function parameter
ordering
Posted by ja...@apache.org.
Normalize safe_subset function parameter ordering
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/36452d3e
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/36452d3e
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/36452d3e
Branch: refs/heads/master
Commit: 36452d3ef2b9bd9dd5271a0004dbb714fc0d3f5a
Parents: 7e3cd37
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Tue Jul 26 13:19:27 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Jul 28 19:42:56 2016 +0530
----------------------------------------------------------------------
ocw-ui/backend/processing.py | 4 ++--
ocw/dataset_processor.py | 2 +-
ocw/tests/test_dataset_processor.py | 8 ++++----
ocw_config_runner/evaluation_creation.py | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/36452d3e/ocw-ui/backend/processing.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/processing.py b/ocw-ui/backend/processing.py
index e45b9c0..f925536 100644
--- a/ocw-ui/backend/processing.py
+++ b/ocw-ui/backend/processing.py
@@ -210,8 +210,8 @@ def run_evaluation():
start,
end)
- ref_dataset = dsp.safe_subset(subset, ref_dataset)
- target_datasets = [dsp.safe_subset(subset, ds)
+ ref_dataset = dsp.safe_subset(ref_dataset, subset)
+ target_datasets = [dsp.safe_subset(ds, subset)
for ds
in target_datasets]
http://git-wip-us.apache.org/repos/asf/climate/blob/36452d3e/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index d9480e9..74536f0 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -483,7 +483,7 @@ def temporal_slice(target_dataset, start_time_index, end_time_index):
return target_dataset
-def safe_subset(subregion, target_dataset, subregion_name=None):
+def safe_subset(target_dataset, subregion, subregion_name=None):
'''Safely subset given dataset with subregion information
A standard subset requires that the provided subregion be entirely
http://git-wip-us.apache.org/repos/asf/climate/blob/36452d3e/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index 6564d96..fcc967e 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -546,7 +546,7 @@ class TestSafeSubset(unittest.TestCase):
def test_partial_spatial_overlap(self):
'''Ensure that safe_subset can handle out of bounds spatial values'''
- ds = dp.safe_subset(self.spatial_out_of_bounds, self.target_dataset)
+ ds = dp.safe_subset(self.target_dataset, self.spatial_out_of_bounds)
spatial_bounds = ds.spatial_boundaries()
self.assertEquals(spatial_bounds[0], -60)
self.assertEquals(spatial_bounds[1], 60)
@@ -555,8 +555,8 @@ class TestSafeSubset(unittest.TestCase):
def test_partial_temporal_overlap(self):
'''Ensure that safe_subset can handle out of bounds temporal values'''
- ds = dp.safe_subset(self.temporal_out_of_bounds, self.target_dataset)
- temporal_bounds = ds.temporal_boundaries()
+ ds = dp.safe_subset(self.target_dataset, self.temporal_out_of_bounds)
+ temporal_bounds = ds.time_range()
start = datetime.datetime(2000, 1, 1)
end = datetime.datetime(2009, 12, 1)
@@ -564,7 +564,7 @@ class TestSafeSubset(unittest.TestCase):
self.assertEquals(temporal_bounds[1], end)
def test_entire_bounds_overlap(self):
- ds = dp.safe_subset(self.everything_out_of_bounds, self.target_dataset)
+ ds = dp.safe_subset(self.target_dataset, self.everything_out_of_bounds)
spatial_bounds = ds.spatial_boundaries()
temporal_bounds = ds.temporal_boundaries()
start = datetime.datetime(2000, 1, 1)
http://git-wip-us.apache.org/repos/asf/climate/blob/36452d3e/ocw_config_runner/evaluation_creation.py
----------------------------------------------------------------------
diff --git a/ocw_config_runner/evaluation_creation.py b/ocw_config_runner/evaluation_creation.py
index 88394de..5236957 100644
--- a/ocw_config_runner/evaluation_creation.py
+++ b/ocw_config_runner/evaluation_creation.py
@@ -129,10 +129,10 @@ def _prepare_datasets_for_evaluation(reference, targets, config_data):
bounds = Bounds(subset[0], subset[1], subset[2], subset[3], start, end)
if reference:
- reference = dsp.safe_subset(bounds, reference)
+ reference = dsp.safe_subset(reference, bounds)
if targets:
- targets = [dsp.safe_subset(bounds, t) for t in targets]
+ targets = [dsp.safe_subset(t, bounds) for t in targets]
if temporal_time_delta:
resolution = timedelta(temporal_time_delta)
[5/5] climate git commit: CLIMATE-486 - Normalize DSP function
parameter ordering
Posted by ja...@apache.org.
CLIMATE-486 - Normalize DSP function parameter ordering
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/1398a868
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/1398a868
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/1398a868
Branch: refs/heads/master
Commit: 1398a868b89222d834b5b28cc4856be85241e647
Parents: 36452d3
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Tue Jul 26 13:22:19 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Jul 28 19:42:56 2016 +0530
----------------------------------------------------------------------
ocw/dataset_processor.py | 12 ++++++------
ocw/tests/test_dataset_processor.py | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/1398a868/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 74536f0..2b5dc9b 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -385,7 +385,7 @@ def subset(target_dataset, subregion, subregion_name=None):
subregion.end = target_dataset.times[-1]
# Ensure that the subregion information is well formed
- _are_bounds_contained_by_dataset(subregion, target_dataset)
+ _are_bounds_contained_by_dataset(target_dataset, subregion)
if not subregion_name:
subregion_name = target_dataset.name
@@ -409,8 +409,8 @@ def subset(target_dataset, subregion, subregion_name=None):
elif target_dataset.lats.ndim == 1 and target_dataset.lons.ndim == 1:
# Get subregion indices into subregion data
- dataset_slices = _get_subregion_slice_indices(subregion,
- target_dataset)
+ dataset_slices = _get_subregion_slice_indices(target_dataset,
+ subregion)
# Slice the values array with our calculated slice indices
if target_dataset.values.ndim == 2:
subset_values = ma.zeros([len(target_dataset.values[
@@ -526,7 +526,7 @@ def safe_subset(target_dataset, subregion, subregion_name=None):
if subregion.end > end:
subregion.end = end
- return subset(subregion, target_dataset, subregion_name)
+ return subset(target_dataset, subregion, subregion_name)
def normalize_dataset_datetimes(dataset, timestep):
@@ -1359,7 +1359,7 @@ def _congrid_neighbor(values, new_dims, minus_one, offset):
return new_values
-def _are_bounds_contained_by_dataset(bounds, dataset):
+def _are_bounds_contained_by_dataset(dataset, bounds):
'''Check if a Dataset fully contains a bounds.
:param bounds: The Bounds object to check.
@@ -1418,7 +1418,7 @@ def _are_bounds_contained_by_dataset(bounds, dataset):
raise ValueError(error_message)
-def _get_subregion_slice_indices(subregion, target_dataset):
+def _get_subregion_slice_indices(target_dataset, subregion):
'''Get the indices for slicing Dataset values to generate the subregion.
:param subregion: The Bounds that specify the subset of the Dataset
http://git-wip-us.apache.org/repos/asf/climate/blob/1398a868/ocw/tests/test_dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset_processor.py b/ocw/tests/test_dataset_processor.py
index fcc967e..627955a 100644
--- a/ocw/tests/test_dataset_processor.py
+++ b/ocw/tests/test_dataset_processor.py
@@ -469,7 +469,7 @@ class TestSubset(unittest.TestCase):
def test_subset_using_non_exact_spatial_bounds(self):
index_slices = dp._get_subregion_slice_indices(
- self.non_exact_spatial_subregion, self.target_dataset)
+ self.target_dataset, self.non_exact_spatial_subregion)
control_index_slices = {"lat_start": 5,
"lat_end": 84,
"lon_start": 10,
@@ -480,7 +480,7 @@ class TestSubset(unittest.TestCase):
def test_subset_using_non_exact_temporal_bounds(self):
index_slices = dp._get_subregion_slice_indices(
- self.non_exact_temporal_subregion, self.target_dataset)
+ self.target_dataset, self.non_exact_temporal_subregion)
control_index_slices = {"lat_start": 5,
"lat_end": 84,
"lon_start": 10,