You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2014/11/08 00:33:37 UTC
[1/4] climate git commit: CLIMATE-487 - Improve error message when
local dataset load fails
Repository: climate
Updated Branches:
refs/heads/master 227b5de93 -> 8d3ab4eae
CLIMATE-487 - Improve error message when local dataset load fails
- Explicit RuntimeErrors are not properly handled to alert the user that
the supplied file path is invalid. This helps clarify user
controllable failures.
- Attempt to make the generic error on dataset loading a bit more
descriptive to help users.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c5a694dc
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c5a694dc
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c5a694dc
Branch: refs/heads/master
Commit: c5a694dcb0d01b57be69788b4762afa87a5c8f6b
Parents: 227b5de
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Nov 7 13:49:04 2014 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Nov 7 13:49:04 2014 -0800
----------------------------------------------------------------------
ocw/data_source/local.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/c5a694dc/ocw/data_source/local.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py
index 0cbecad..384a781 100644
--- a/ocw/data_source/local.py
+++ b/ocw/data_source/local.py
@@ -134,10 +134,14 @@ def load_file(file_path, variable_name, elevation_index=0):
try:
netcdf = netCDF4.Dataset(file_path, mode='r')
+ except RuntimeError:
+ err = "Dataset filepath is invalid. Please ensure it is correct."
+ raise ValueError(err)
except:
err = (
- "The given file cannot be loaded "
- "(Only NetCDF file can be supported)."
+ "The given file cannot be loaded. Please ensure that it is a valid "
+ "NetCDF file. If problems persist, report them to the project's "
+ "mailing list."
)
raise ValueError(err)
[4/4] climate git commit: Resolve CLIMATE-371. Merge PR #132.
Posted by jo...@apache.org.
Resolve CLIMATE-371. Merge PR #132.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/8d3ab4ea
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/8d3ab4ea
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/8d3ab4ea
Branch: refs/heads/master
Commit: 8d3ab4eaeccc1e984ab72cec9ad4148c7a24a08a
Parents: 2d2da85 e3e5978
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Nov 7 15:33:13 2014 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Nov 7 15:33:13 2014 -0800
----------------------------------------------------------------------
ocw/data_source/local.py | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/8d3ab4ea/ocw/data_source/local.py
----------------------------------------------------------------------
[2/4] climate git commit: CLIMATE-371 - Allow user to pass variable
names to local.py
Posted by jo...@apache.org.
CLIMATE-371 - Allow user to pass variable names to local.py
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e3e59787
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e3e59787
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e3e59787
Branch: refs/heads/master
Commit: e3e59787667e8a360c5e43d93111625e6b8ffafc
Parents: 227b5de
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Nov 7 14:20:02 2014 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Nov 7 14:26:16 2014 -0800
----------------------------------------------------------------------
ocw/data_source/local.py | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/e3e59787/ocw/data_source/local.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py
index 0cbecad..18b053d 100644
--- a/ocw/data_source/local.py
+++ b/ocw/data_source/local.py
@@ -109,19 +109,34 @@ def _get_netcdf_variable_name(valid_var_names, netcdf, netcdf_var):
)
raise ValueError(error)
-def load_file(file_path, variable_name, elevation_index=0):
+def load_file(file_path,
+ variable_name,
+ elevation_index=0,
+ lat_name=None,
+ lon_name=None,
+ time_name=None):
''' Load a NetCDF file into a Dataset.
:param file_path: Path to the NetCDF file to load.
:type file_path: String
:param variable_name: The variable name to load from the NetCDF file.
:type variable_name: String
- :param elevation_index: The elevation index for which data should be
- returned. Climate data is often times 4 dimensional data. Some datasets
- will have readins at different height/elevation levels. OCW expects
- 3D data so a single layer needs to be stripped out when loading. By
- default, the first elevation layer is used. If desired you may specify
- the elevation value to use.
+ :param elevation_index: (Optional) The elevation index for which data should
+ be returned. Climate data is often times 4 dimensional data. Some
+ datasets will have readins at different height/elevation levels. OCW
+ expects 3D data so a single layer needs to be stripped out when loading.
+ By default, the first elevation layer is used. If desired you may
+ specify the elevation value to use.
+ :type elevation_index: Integer
+ :param lat_name: (Optional) The latitude variable name to extract from the
+ dataset.
+ :type lat_name: String
+ :param lon_name: (Optional) The longitude variable name to extract from the
+ dataset.
+ :type lon_name: String
+ :param time_name: (Optional) The time variable name to extract from the
+ dataset.
+ :type time_name: String
:returns: An OCW Dataset object with the requested variable's data from
the NetCDF file.
@@ -141,9 +156,12 @@ def load_file(file_path, variable_name, elevation_index=0):
)
raise ValueError(err)
- lat_name = _get_netcdf_variable_name(LAT_NAMES, netcdf, variable_name)
- lon_name = _get_netcdf_variable_name(LON_NAMES, netcdf, variable_name)
- time_name = _get_netcdf_variable_name(TIME_NAMES, netcdf, variable_name)
+ if not lat_name:
+ lat_name = _get_netcdf_variable_name(LAT_NAMES, netcdf, variable_name)
+ if not lon_name:
+ lon_name = _get_netcdf_variable_name(LON_NAMES, netcdf, variable_name)
+ if not time_name:
+ time_name = _get_netcdf_variable_name(TIME_NAMES, netcdf, variable_name)
lats = netcdf.variables[lat_name][:]
lons = netcdf.variables[lon_name][:]
[3/4] climate git commit: Resolve CLIMATE-487. Merge PR #131.
Posted by jo...@apache.org.
Resolve CLIMATE-487. Merge PR #131.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/2d2da85b
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/2d2da85b
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/2d2da85b
Branch: refs/heads/master
Commit: 2d2da85bb2be4c69c4a59658ab8ca0e5b3213d97
Parents: 227b5de c5a694d
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Nov 7 15:32:24 2014 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Nov 7 15:32:24 2014 -0800
----------------------------------------------------------------------
ocw/data_source/local.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------