Add a function to calculate time series

Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/6f49bd5e
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/6f49bd5e
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/6f49bd5e

Branch: refs/heads/master
Commit: 6f49bd5ebfa9a138148ed38a853add6dcc0e2bae
Parents: 5207dda
Author: Kim Whitehall <[email protected]>
Authored: Sun Mar 22 10:23:20 2015 -0700
Committer: Kim Whitehall <[email protected]>
Committed: Fri Apr 10 15:04:00 2015 -0700

----------------------------------------------------------------------
 ocw/utils.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/6f49bd5e/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index 00a6a01..f367dab 100644
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -273,7 +273,7 @@ def calc_climatology_year(dataset):
     else:
         # Get values reshaped to (num_year, 12, num_lats, num_lons)
         values = reshape_monthly_to_annually(dataset)
-        # Calculate mean values over year (num_year, num_lats, num_lons)
+       # Calculate mean values over year (num_year, num_lats, num_lons)
         annually_mean = values.mean(axis=1)
         # Calculate mean values over all years (num_lats, num_lons)
         total_mean = annually_mean.mean(axis=0)
@@ -345,3 +345,17 @@ def calc_climatology_monthly(dataset):
                 for x in range(12)])
         return values, times
 
+def calc_time_series(dataset):
+    ''' Calculate time series mean values for a dataset
+
+    :param dataset: Dataset object 
+    :type dataset: :class:`dataset.Dataset`
+
+    :returns: time series for the dataset of shape (nT)
+    '''
+
+    t_series =[]
+    for t in xrange(dataset.values.shape[0]):
+        t_series.append(dataset.values[t,:,:].mean())
+    
+    return t_series

Reply via email to