climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From good...@apache.org
Subject [12/18] climate git commit: Normalize temporal_subset function parameter ordering
Date Fri, 29 Jul 2016 17:19:42 GMT
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/CLIMATE-825
Commit: 5024b1c36256067d7efda198c4010b7898ab274a
Parents: e823b03
Author: Ibrahim Jarif <jarifibrahim@gmail.com>
Authored: Tue Jul 26 12:26:02 2016 +0530
Committer: Ibrahim Jarif <jarifibrahim@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)
 


Mime
View raw message