Repository: climate Updated Branches: refs/heads/master 911509681 -> bb61395ce
separating CLIMATE-850 Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/bb6ce4a0 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/bb6ce4a0 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/bb6ce4a0 Branch: refs/heads/master Commit: bb6ce4a03124e6c2fbae5befaceae34727c9b083 Parents: d9e3c7e Author: huikyole <huiky...@argo.jpl.nasa.gov> Authored: Mon Aug 15 22:04:12 2016 -0700 Committer: huikyole <huiky...@argo.jpl.nasa.gov> Committed: Mon Aug 15 22:04:12 2016 -0700 ---------------------------------------------------------------------- ocw/dataset_processor.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/bb6ce4a0/ocw/dataset_processor.py ---------------------------------------------------------------------- diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py index 09edbaa..99a7f48 100755 --- a/ocw/dataset_processor.py +++ b/ocw/dataset_processor.py @@ -683,6 +683,28 @@ def mask_missing_data(dataset_array): masked_array.append(dataset) return [masked_dataset for masked_dataset in masked_array] +def deseasonalize_dataset(dataset): + '''Calculate daily climatology and subtract the climatology from + the input dataset + + :param dataset: The dataset to convert. + :type dataset: :class:`dataset.Dataset` + + :returns: A Dataset with values converted to new units. + :rtype: :class:`dataset.Dataset` + ''' + days = [d.month*100. + d.day for d in dataset.times] + days_sorted = np.unique(days) + ndays = days_sorted.size + nt, ny, nx = dataset.values.shape + values_clim = ma.zeros([ndays, ny, nx]) + for iday, day in enumerate(days_sorted): + t_index = np.where(days == day)[0] + values_clim[iday,:] = ma.mean(dataset.values[t_index,:], axis=0) + for iday, day in enumerate(days_sorted): + t_index = np.where(days == day)[0] + dataset.values[t_index,:] = dataset.values[t_index,:] - values_clim[iday,:] + return dataset def _rcmes_spatial_regrid(spatial_values, lat, lon, lat2, lon2, order=1): '''