You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by wh...@apache.org on 2015/04/08 01:09:48 UTC
[1/4] climate git commit: - Update the times array of the DS object
when monthly climo is calculated
Repository: climate
Updated Branches:
refs/heads/master 6ff8fd694 -> d6710a448
- Update the times array of the DS object when monthly climo is calculated
- Update docs and remove duplicate documentation
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/da7c2003
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/da7c2003
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/da7c2003
Branch: refs/heads/master
Commit: da7c2003cc7e0428ebb988f49d08f3ce767b2bea
Parents: 9a2be2e
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Sun Mar 22 10:23:20 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Thu Mar 26 01:34:13 2015 -0700
----------------------------------------------------------------------
ocw/utils.py | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/da7c2003/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index c4b640f..00a6a01 100644
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -20,6 +20,7 @@
import sys
import datetime as dt
import numpy as np
+import datetime
from mpl_toolkits.basemap import shiftgrid
from dateutil.relativedelta import relativedelta
@@ -235,7 +236,6 @@ def reshape_monthly_to_annually(dataset):
:type dataset: :class:`dataset.Dataset`
:returns: Dataset values array with shape (num_year, 12, num_lat, num_lon)
- :rtype: :class:`numpy.ndarray`
'''
values = dataset.values[:]
@@ -254,14 +254,13 @@ def reshape_monthly_to_annually(dataset):
def calc_climatology_year(dataset):
''' Calculate climatology of dataset's values for each year
-
+
:param dataset: Monthly binned Dataset object with an evenly divisible
number of months.
:type dataset: :class:`dataset.Dataset`
:returns: Mean values for each year (annual_mean) and mean values for all
years (total_mean)
- :rtype: A :func:`tuple` of two :class:`numpy.ndarray`
:raise ValueError: If the number of monthly bins is not evenly divisible
by 12.
@@ -283,7 +282,7 @@ def calc_climatology_year(dataset):
def calc_climatology_season(month_start, month_end, dataset):
''' Calculate seasonal mean and time series for given months.
-
+
:param month_start: An integer for beginning month (Jan=1)
:type month_start: :class:`int`
@@ -293,10 +292,9 @@ def calc_climatology_season(month_start, month_end, dataset):
:param dataset: Dataset object with full-year format
:type dataset: :class:`dataset.Dataset`
- :returns:
- t_series - monthly average over the given season
+ :returns: t_series - monthly average over the given season
means - mean over the entire season
- :rtype: A :func:`tuple` of two :class:`numpy.ndarray`
+
'''
if month_start > month_end:
@@ -312,19 +310,23 @@ def calc_climatology_season(month_start, month_end, dataset):
t_series = reshape_data[:, month_index].mean(axis=1)
means = t_series.mean(axis=0)
+
return t_series, means
def calc_climatology_monthly(dataset):
''' Calculate monthly mean values for a dataset.
+ Follow COARDS climo stats calculation, the year can be given as 0
+ but the min year allowed in Python is 1
+ http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology
:param dataset: Monthly binned Dataset object with the number of months
divisible by 12
:type dataset: :class:`dataset.Dataset`
- :returns: Mean values for each month of the year
- :rtype: A 3D :class:`numpy.ndarray` of shape (12, num_lats, num_lons)
-
+ :returns: Mean values for each month of the year of shape (12, num_lats, num_lons)
+ and times array of datetime objects of length 12
+
:raise ValueError: If the number of monthly bins is not divisible by 12
'''
@@ -335,5 +337,11 @@ def calc_climatology_monthly(dataset):
)
raise ValueError(error)
else:
- return reshape_monthly_to_annually(dataset).mean(axis=0)
+ values = reshape_monthly_to_annually(dataset).mean(axis=0)
+
+ # A year can commence from any month
+ first_month = dataset.times[0].month
+ times = np.array([datetime.datetime(1, first_month, 1) + relativedelta(months = x)
+ for x in range(12)])
+ return values, times
[3/4] climate git commit: Resolve CLIMATE-598. Merge 'PR #110'.
Posted by wh...@apache.org.
Resolve CLIMATE-598. Merge 'PR #110'.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/36d23815
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/36d23815
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/36d23815
Branch: refs/heads/master
Commit: 36d2381514d5fe80c3fd13a31243ce1a8c62a827
Parents: fd4875d d3fe34e
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Tue Apr 7 07:06:40 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Tue Apr 7 07:06:40 2015 -0700
----------------------------------------------------------------------
ocw/tests/test_utils.py | 4 +++-
ocw/utils.py | 30 +++++++++++++++++++-----------
2 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
[4/4] climate git commit: Merge branch 'master' of
https://github.com/apache/climate
Posted by wh...@apache.org.
Merge branch 'master' of https://github.com/apache/climate
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/d6710a44
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/d6710a44
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/d6710a44
Branch: refs/heads/master
Commit: d6710a448c82e659790a6c5d5baf39d9d16ba529
Parents: 36d2381 6ff8fd6
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Tue Apr 7 07:43:43 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Tue Apr 7 07:43:43 2015 -0700
----------------------------------------------------------------------
easy-ocw/install-ubuntu.sh | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
[2/4] climate git commit: - Update the nosetests to test times array
Posted by wh...@apache.org.
- Update the nosetests to test times array
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/d3fe34ec
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/d3fe34ec
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/d3fe34ec
Branch: refs/heads/master
Commit: d3fe34ece9ae84334e4e83c0f9c02262f8ddf987
Parents: da7c200
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Sun Mar 22 10:23:48 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Thu Mar 26 01:35:43 2015 -0700
----------------------------------------------------------------------
ocw/tests/test_utils.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/d3fe34ec/ocw/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_utils.py b/ocw/tests/test_utils.py
index da5ad42..a5c8db6 100644
--- a/ocw/tests/test_utils.py
+++ b/ocw/tests/test_utils.py
@@ -213,8 +213,10 @@ class TestCalcClimatologyMonthly(unittest.TestCase):
def test_calc_climatology_monthly(self):
expected_result = np.ones(300).reshape(12, 5, 5)
- actual_result = utils.calc_climatology_monthly(self.dataset)
+ expected_times = np.array([datetime.datetime(1, 1, 1) + relativedelta(months = x) for x in range(12)])
+ actual_result, actual_times = utils.calc_climatology_monthly(self.dataset)
np.testing.assert_array_equal(actual_result, expected_result)
+ np.testing.assert_array_equal(actual_times, expected_times)
if __name__ == '__main__':