You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by ja...@apache.org on 2016/11/11 14:39:08 UTC
climate git commit: CLIMATE-863 - Address warning,
etc within Travis-CI log output
Repository: climate
Updated Branches:
refs/heads/master 6156eff08 -> ae0ade234
CLIMATE-863 - Address warning, etc within Travis-CI log output
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/ae0ade23
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/ae0ade23
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/ae0ade23
Branch: refs/heads/master
Commit: ae0ade2341e63592a7d2b294190b39f60588e7bf
Parents: 6156eff
Author: Ibrahim Jarif <ja...@gmail.com>
Authored: Thu Nov 10 23:17:47 2016 +0530
Committer: Ibrahim Jarif <ja...@gmail.com>
Committed: Thu Nov 10 23:17:47 2016 +0530
----------------------------------------------------------------------
.noserc | 2 +-
.travis.yml | 3 +++
ocw/data_source/local.py | 2 --
ocw/dataset_processor.py | 45 +++++++++++++++++++++++++++----------------
4 files changed, 32 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/ae0ade23/.noserc
----------------------------------------------------------------------
diff --git a/.noserc b/.noserc
index 59b8a69..a1be0c2 100644
--- a/.noserc
+++ b/.noserc
@@ -17,7 +17,7 @@
[nosetests]
where=ocw/tests/
-verbosity=3
+verbosity=2
with-coverage=1
cover-package=ocw
nocapture=1
http://git-wip-us.apache.org/repos/asf/climate/blob/ae0ade23/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9cac19c..a1c4e8b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,6 +49,9 @@ install:
- source activate test-environment
- python setup.py install
+ # Install coverage plugin
+ - pip install coverage
+
# Workaround to get travis build working with matplotlib
before_script:
- "export DISPLAY=:99.0"
http://git-wip-us.apache.org/repos/asf/climate/blob/ae0ade23/ocw/data_source/local.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py
index 626dee5..fecf25c 100644
--- a/ocw/data_source/local.py
+++ b/ocw/data_source/local.py
@@ -509,9 +509,7 @@ def load_dataset_from_multiple_netcdf_files(variable_name,
y_index, x_index = numpy.where(mask_dataset.values == mask_value)
times = []
- nfile = len(nc_files)
for ifile, file in enumerate(nc_files):
- print('NC file ' + str(ifile + 1) + '/' + str(nfile), file)
file_object0 = load_file(file, variable_name, lat_name=lat_name,
lon_name=lon_name, time_name=time_name)
values0 = file_object0.values
http://git-wip-us.apache.org/repos/asf/climate/blob/ae0ade23/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 6579677..b4c1b41 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -146,9 +146,8 @@ def temporal_rebin_with_time_index(target_dataset, nt_average):
"""
nt = target_dataset.times.size
if nt % nt_average != 0:
- msg = ('Warning: length of time dimension must '
- 'be a multiple of nt_average')
- print(msg)
+ logger.warning('Length of time dimension must '
+ 'be a multiple of nt_average')
# nt2 is the length of time dimension in the rebinned dataset
nt2 = nt // nt_average
binned_dates = target_dataset.times[np.arange(nt2) * nt_average]
@@ -301,7 +300,8 @@ def spatial_regrid(target_dataset, new_latitudes, new_longitudes,
for axis in (0, 1):
q_shifted = np.roll(values_original, shift=shift, axis=axis)
idx = ~q_shifted.mask * values_original.mask
- values_original.data[idx] = q_shifted[idx]
+ indices = np.where(idx)[0]
+ values_original.data[indices] = q_shifted[indices]
new_values[i] = map_coordinates(values_original,
[new_lats_indices.flatten(),
new_lons_indices.flatten()],
@@ -310,8 +310,10 @@ def spatial_regrid(target_dataset, new_latitudes, new_longitudes,
# Make a masking map using nearest neighbour interpolation -use this to
# determine locations with MDI and mask these
qmdi = np.zeros_like(values_original)
- qmdi[values_original.mask == True] = 1.
- qmdi[values_original.mask == False] = 0.
+ values_true_indices = np.where(values_original.mask == True)[0]
+ values_false_indices = np.where(values_original.mask == False)[0]
+ qmdi[values_true_indices] = 1.
+ qmdi[values_false_indices] = 0.
qmdi_r = map_coordinates(qmdi, [new_lats_indices.flatten(
), new_lons_indices.flatten()], order=1).reshape(new_lats.shape)
mdimask = (qmdi_r != 0.0)
@@ -932,13 +934,17 @@ def _rcmes_spatial_regrid(spatial_values, lat, lon, lat2, lon2, order=1):
lati = lati.copy()
# Now, we'll set points outside the boundaries to lie along an edge
- loni[loni > lon.max()] = lon.max()
- loni[loni < lon.min()] = lon.min()
+ loni_max_indices = np.where(loni > lon.max())
+ loni_min_indices = np.where(loni < lon.min())
+ loni[loni_max_indices] = lon.max()
+ loni[loni_min_indices] = lon.min()
# To deal with the "hard" break, we'll have to treat y differently,
# so we're just setting the min here...
- lati[lati > lat.max()] = lat.max()
- lati[lati < lat.min()] = lat.min()
+ lati_max_indices = np.where(lati > lat.max())
+ lati_min_indices = np.where(lati < lat.min())
+ lati[lati_max_indices] = lat.max()
+ lati[lati_min_indices] = lat.min()
# We need to convert these to (float) indicies
# (xi should range from 0 to (nx - 1), etc)
@@ -972,7 +978,8 @@ def _rcmes_spatial_regrid(spatial_values, lat, lon, lat2, lon2, order=1):
for axis in (0, 1):
q_shifted = np.roll(spatial_values, shift=shift, axis=axis)
idx = ~q_shifted.mask * spatial_values.mask
- spatial_values.data[idx] = q_shifted[idx]
+ indices = np.where(idx)
+ spatial_values.data[indices] = q_shifted[indices]
# Now we actually interpolate
# map_coordinates does cubic interpolation by default,
@@ -994,8 +1001,10 @@ def _rcmes_spatial_regrid(spatial_values, lat, lon, lat2, lon2, order=1):
# Make second map using nearest neighbour interpolation -use this to
# determine locations with MDI and mask these
qmdi = np.zeros_like(spatial_values)
- qmdi[spatial_values.mask == True] = 1.
- qmdi[spatial_values.mask == False] = 0.
+ spatial_indices_true = np.where(spatial_values.mask)
+ spatial_indices_false = np.where(not spatial_values.mask)
+ qmdi[spatial_indices_true] = 1.
+ qmdi[spatial_indices_false] = 0.
qmdi_r = map_coordinates(qmdi, [lati, loni], order=order)
qmdi_r = qmdi_r.reshape([nlat2, nlon2])
mdimask = (qmdi_r != 0.0)
@@ -1057,14 +1066,15 @@ def _rcmes_calc_average_on_new_time_unit(data, dates, unit):
:returns: meanstorem, newTimesList
:rtype: 3D numpy masked array the same shape as the input array,
list of python datetime objects
+ :raises: ValueError
"""
# Check if the user-selected temporal grid is valid. If not, EXIT
acceptable = ((unit == 'full') | (unit == 'annual') |
(unit == 'monthly') | (unit == 'daily'))
if not acceptable:
- print('Error: unknown unit type selected for time averaging: EXIT')
- return - 1, - 1, - 1, - 1
+ raise ValueError('Error: unknown unit type selected '
+ 'for time averaging: EXIT')
nt, ny, nx = data.shape
if unit == 'full':
@@ -1131,14 +1141,15 @@ def _rcmes_calc_average_on_new_time_unit_K(data, dates, unit):
:returns: meanstorem, newTimesList
:rtype: 3D numpy masked array the same shape as the input array,
list of python datetime objects
+ :raises: ValueError
"""
# Check if the user-selected temporal grid is valid. If not, EXIT
acceptable = ((unit == 'full') | (unit == 'annual') |
(unit == 'monthly') | (unit == 'daily'))
if not acceptable:
- print('Error: unknown unit type selected for time averaging: EXIT')
- return - 1, - 1, - 1, - 1
+ raise ValueError('Error: unknown unit type selected '
+ 'for time averaging: EXIT')
# Calculate arrays of: annual timeseries: year (2007,2007),
# monthly time series: year-month (200701,200702),