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 5F7A81113F for ; Sat, 5 Apr 2014 05:05:35 +0000 (UTC) Received: (qmail 54368 invoked by uid 500); 5 Apr 2014 05:05:33 -0000 Delivered-To: apmail-climate-commits-archive@climate.apache.org Received: (qmail 54296 invoked by uid 500); 5 Apr 2014 05:05:32 -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 53960 invoked by uid 99); 5 Apr 2014 05:05:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Apr 2014 05:05:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7A23F943EAF; Sat, 5 Apr 2014 05:05:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: joyce@apache.org To: commits@climate.apache.org Date: Sat, 05 Apr 2014 05:05:30 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/16] git commit: CLIMATE-392 - Documentation clarifications CLIMATE-392 - Documentation clarifications Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/b0a762da Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/b0a762da Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/b0a762da Branch: refs/heads/master Commit: b0a762da4a887cd3eb973f93ddaa18b5214f8dfd Parents: 6e99a98 Author: Michael Joyce Authored: Fri Apr 4 21:32:13 2014 -0700 Committer: Michael Joyce Committed: Fri Apr 4 21:32:13 2014 -0700 ---------------------------------------------------------------------- ocw/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/b0a762da/ocw/utils.py ---------------------------------------------------------------------- diff --git a/ocw/utils.py b/ocw/utils.py index 671b2f2..4b8f7fe 100644 --- a/ocw/utils.py +++ b/ocw/utils.py @@ -164,18 +164,19 @@ def parse_base_time_string(time_format): def normalize_lat_lon_values(lats, lons, values): ''' Normalize lat/lon values - Ensure that lat/lon values are withing [-180, 180)/[-90, 90) as well - as monotonically increasing. If they aren't they are adjusted accordingly. + Ensure that lat/lon values are within [-180, 180)/[-90, 90) as well + as sorted. If the values are off the grid they are shifted into the + expected range. - :param lats: A 1D numpy array of lat values. + :param lats: A 1D numpy array of sorted lat values. :type lats: Numpy Array - :param lons: A 1D numpy array of lon values. + :param lons: A 1D numpy array of sorted lon values. :type lons: Numpy Array :param values: A 3D array of data values. :returns: A tuple of the form (adjust_lats, adjusted_lons, adjusted_values) - :raises ValueError: If the lat or lon values are not monotonically increasing. + :raises ValueError: If the lat/lon values are not sorted. ''' # Avoid unnecessary shifting if all lons are higher than 180 if lons.min() > 180: @@ -190,11 +191,11 @@ def normalize_lat_lon_values(lats, lons, values): # If the lat values are unsorted then raise an exception if not lats_reversed and lats_decreasing.any(): - raise ValueError('Latitudes must be monotonically increasing.') + raise ValueError('Latitudes must be sorted.') # Perform same checks now for lons if not lons_reversed and lons_decreasing.any(): - raise ValueError('Longitudes must be monotonically increasing.') + raise ValueError('Longitudes must be sorted.') # Also check if lons go from [0, 360), and convert to [-180, 180) # if necessary