You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by hu...@apache.org on 2015/07/14 20:26:58 UTC
[2/6] climate git commit: Now the seasonal average calculation works
for any OCW dataset objects
Now the seasonal average calculation works for any OCW dataset objects
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/4d8fee64
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/4d8fee64
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/4d8fee64
Branch: refs/heads/master
Commit: 4d8fee64a2af4280ee90ba23566418703197fc34
Parents: 30d9ff4
Author: huikyole <hu...@jpl.nasa.gov>
Authored: Tue May 12 01:20:11 2015 -0700
Committer: huikyole <hu...@jpl.nasa.gov>
Committed: Tue May 12 01:20:11 2015 -0700
----------------------------------------------------------------------
ocw/dataset_processor.py | 31 ++++++++++++++++++++++++++++++-
ocw/utils.py | 32 --------------------------------
2 files changed, 30 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/4d8fee64/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 469eb76..a536794 100644
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -64,7 +64,36 @@ def temporal_subset(target_dataset, month_index):
target_dataset.name)
return new_dataset
-def temporal_rebin(target_dataset, temporal_resolution):
+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`
+
+ :param month_end: An integer for ending month (Jan=1)
+ :type month_end: :class:`int`
+
+ :param dataset: OCW dataset object with full-year format
+ :type dataset: :class:`dataset.Dataset`
+
+ :returns: t_series - monthly average over the given season
+ means - mean over the entire season
+
+ '''
+
+ if month_start > month_end:
+ month_index = range(month_start,13)
+ month_index.extend(range(1, month_end+1))
+ else:
+ month_index = range(month_start, month_end+1)
+
+ # t_series only includes data of months in month_index
+ t_series = temporal_subset(dataset, month_index)
+ means = ma.mean(t_series.values, axis=0)
+
+ return t_series, means
+
+def temporal_rebin(target_dataset, temporal_resolution):
""" Rebin a Dataset to a new temporal resolution
:param target_dataset: Dataset object that needs temporal rebinned
http://git-wip-us.apache.org/repos/asf/climate/blob/4d8fee64/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index 607b218..536aa09 100644
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -24,7 +24,6 @@ import datetime
from mpl_toolkits.basemap import shiftgrid
from dateutil.relativedelta import relativedelta
-import ocw.dataset_processor as dsp
def decode_time_values(dataset, time_var_name):
''' Decode NetCDF time values into Python datetime objects.
@@ -284,37 +283,6 @@ def calc_climatology_year(dataset):
return annually_mean, total_mean
-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`
-
- :param month_end: An integer for ending month (Jan=1)
- :type month_end: :class:`int`
-
- :param dataset: OCW dataset object with full-year format
- :type dataset: :class:`dataset.Dataset`
-
- :returns: t_series - monthly average over the given season
- means - mean over the entire season
-
- '''
-
- if month_start > month_end:
- month_index = range(month_start,13)
- month_index.extend(range(1, month_end+1))
- else:
- month_index = range(month_start, month_end+1)
-
- # t_series only includes data of months in month_index
- t_series = dsp.temporal_subset(dataset, month_index).values
- print dsp.temporal_subset(dataset, month_index).times
- 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