Return-Path: X-Original-To: apmail-climate-commits-archive@minotaur.apache.org Delivered-To: apmail-climate-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E3C6918593 for ; Mon, 3 Aug 2015 03:29:38 +0000 (UTC) Received: (qmail 20914 invoked by uid 500); 3 Aug 2015 03:29:38 -0000 Delivered-To: apmail-climate-commits-archive@climate.apache.org Received: (qmail 20838 invoked by uid 500); 3 Aug 2015 03:29:38 -0000 Mailing-List: contact commits-help@climate.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@climate.apache.org Delivered-To: mailing list commits@climate.apache.org Received: (qmail 20822 invoked by uid 99); 3 Aug 2015 03:29:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Aug 2015 03:29:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A1186DFC15; Mon, 3 Aug 2015 03:29:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: huikyole@apache.org To: commits@climate.apache.org Date: Mon, 03 Aug 2015 03:29:39 -0000 Message-Id: <63f95e79532c40ea80207b6280adaf91@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] climate git commit: Merge branch 'CLIMATE-651' Merge branch 'CLIMATE-651' Conflicts: ocw/utils.py Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/496f8bb0 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/496f8bb0 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/496f8bb0 Branch: refs/heads/master Commit: 496f8bb055420adcf439a76c8fa0b03b35a3d920 Parents: 7cfd7e9 77227b1 Author: huikyole Authored: Sun Aug 2 20:29:22 2015 -0700 Committer: huikyole Committed: Sun Aug 2 20:29:22 2015 -0700 ---------------------------------------------------------------------- ocw/utils.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/496f8bb0/ocw/utils.py ---------------------------------------------------------------------- diff --cc ocw/utils.py index 7c7776f,d6a5708..0b2f9da --- a/ocw/utils.py +++ b/ocw/utils.py @@@ -344,15 -344,37 +344,51 @@@ def calc_time_series(dataset) return t_series +def get_temporal_overlap(dataset_array): + ''' Find the maximum temporal overlap across the observation and model datasets + + :param dataset_array: an array of OCW datasets + ''' + start_time =[] + end_time =[] + for dataset in dataset_array: + start_time.append(dataset.time_range()[0]) + end_time.append(dataset.time_range()[1]) + + return np.max(start_time), np.min(end_time) ++ + def calc_subregion_area_mean_and_std(dataset_array, subregions): + ''' Calculate area mean and standard deviation values for a given subregions using datasets on common grid points + :param dataset_array: An array of OCW Dataset Objects + :type list: + :param subregions: list of subregions + :type subregions: :class:`numpy.ma.array` + :returns: area averaged time series for the dataset of shape (ntime, nsubregion) + ''' + + ndata = len(dataset_array) + dataset0 = dataset_array[0] + if dataset0.lons.ndim == 1: + lons, lats = np.meshgrid(dataset0.lons, dataset0.lats) + else: + lons = dataset0.lons + lats = dataset0.lats + subregion_array = np.zeros(lons.shape) + mask_array = dataset_array[0].values[0,:].mask + # dataset0.values.shsape[0]: length of the time dimension + # spatial average + t_series =ma.zeros([ndata, dataset0.values.shape[0], len(subregions)]) + # spatial standard deviation + spatial_std =ma.zeros([ndata, dataset0.values.shape[0], len(subregions)]) + + for iregion, subregion in enumerate(subregions): + lat_min, lat_max, lon_min, lon_max = subregion[1] + y_index,x_index = np.where((lats >= lat_min) & (lats <= lat_max) & (lons >= lon_min) & (lons <= lon_max)) + subregion_array[y_index,x_index] = iregion+1 + for idata in np.arange(ndata): + t_series[idata, :, iregion] = ma.mean(dataset_array[idata].values[:,y_index, x_index], axis=1) + spatial_std[idata, :, iregion] = ma.std(dataset_array[idata].values[:,y_index, x_index], axis=1) + subregion_array = ma.array(subregion_array, mask=mask_array) + return t_series, spatial_std, subregion_array + ++>>>>>>> CLIMATE-651