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 BA59717CFB for ; Mon, 27 Oct 2014 19:18:43 +0000 (UTC) Received: (qmail 12490 invoked by uid 500); 27 Oct 2014 19:18:43 -0000 Delivered-To: apmail-climate-commits-archive@climate.apache.org Received: (qmail 12455 invoked by uid 500); 27 Oct 2014 19:18:43 -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 12446 invoked by uid 99); 27 Oct 2014 19:18:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2014 19:18:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 36E4790AE08; Mon, 27 Oct 2014 19:18:43 +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: Mon, 27 Oct 2014 19:18:42 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: CLIMATE-538 - Add optional parameter for elevation level Repository: climate Updated Branches: refs/heads/master c93ba05b0 -> 335512307 CLIMATE-538 - Add optional parameter for elevation level - Add an optional parameter for selecting elevation level when loading a dataset. By default it is set to 0 (which is the current value used) to ensure backwards compatibility. Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/370bbd8b Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/370bbd8b Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/370bbd8b Branch: refs/heads/master Commit: 370bbd8b1db891aa611cd09dad075e13acbae872 Parents: 6d47a57 Author: Michael Joyce Authored: Fri Oct 24 08:30:13 2014 -0700 Committer: Michael Joyce Committed: Fri Oct 24 08:30:13 2014 -0700 ---------------------------------------------------------------------- ocw/data_source/local.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/370bbd8b/ocw/data_source/local.py ---------------------------------------------------------------------- diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py index 79e3ba8..260029e 100644 --- a/ocw/data_source/local.py +++ b/ocw/data_source/local.py @@ -193,7 +193,7 @@ def _get_value_name(possible_value_name): return value_variable_name -def load_file(file_path, variable_name): +def load_file(file_path, variable_name, elevation_index=0): '''Load netCDF file, get the all variables name and get the data. :param file_path: NetCDF directory with file name @@ -257,12 +257,12 @@ def load_file(file_path, variable_name): lat_lon_time_var_names = [lat_name, lon_name, time_name] level_index = value_dimensions_names.index(list(set(value_dimensions_names) - set(lat_lon_time_var_names))[0]) if level_index == 0: - values = values [0,:,:,:] + values = values [elevation_index,:,:,:] elif level_index == 1: - values = values [:,0,:,:] + values = values [:,elevation_index,:,:] elif level_index == 2: - values = values [:,:,0,:] + values = values [:,:,elevation_index,:] else: - values = values [:,:,:,0] + values = values [:,:,:,elevation_index] return Dataset(lats, lons, times, values, variable_name)