climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [1/2] git commit: CLIMATE-538 - Add optional parameter for elevation level
Date Mon, 27 Oct 2014 19:18:42 GMT
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 <joyce@apache.org>
Authored: Fri Oct 24 08:30:13 2014 -0700
Committer: Michael Joyce <joyce@apache.org>
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)


Mime
View raw message