Skip to content

Commit

Permalink
Remove rotation of cube when negative longitudes were present for gri…
Browse files Browse the repository at this point in the history
…dded->ungridded collocation which was unnecassary and causing a subtle bug when auxilliary and derived coordinates were present in the cube.
  • Loading branch information
duncanwp committed Sep 2, 2015
1 parent 02282e1 commit aca5cea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion cis/collocation/col_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def collocate(self, points, data, constraint, kernel):
if constraint is not None and not isinstance(constraint, DummyConstraint):
raise ValueError("A constraint cannot be specified with kernel nn_gridded or li")
data_points = data
_fix_cube_longitude_range(points.coords(), data)
else:
data_points = data.get_non_masked_points()
_fix_longitude_range(points.coords(), data_points)
Expand Down
12 changes: 7 additions & 5 deletions cis/test/unit/colocate/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def test_colocation_of_pres_points_on_hybrid_pressure_coordinates(self):
assert_almost_equal(new_data.data[0], 221.5, decimal=5)
# Exactly on the lat, lon, points, interpolated over time and pressure
assert_almost_equal(new_data.data[1], 226.5, decimal=7)
# Exactly on the lat, time points, interpolated over latitude and pressure
# Exactly on the lat, time points, interpolated over longitude and pressure
assert_almost_equal(new_data.data[2], 330.5, decimal=7)
# Outside of the pressure bounds - extrapolation off
assert_equal(new_data.data[3], np.inf)
Expand Down Expand Up @@ -791,11 +791,13 @@ def test_colocation_of_alt_points_on_hybrid_altitude_and_pressure_coordinates(se
sample_points = UngriddedData.from_points_array(
# Test point with both pressure and altitude should interpolate over the altitude only (since that is also
# present in the data cube)
[HyperPoint(lat=0.0, lon=0.0, alt=200.5, t=dt.datetime(1984, 8, 28,0,0,0))])
[HyperPoint(lat=0.0, lon=0.0, alt=234.5, t=dt.datetime(1984, 8, 28,0,0,0)),
HyperPoint(lat=5.0, lon=5.0, alt=355.5, t=dt.datetime(1984, 8, 28, 0, 0))])

col = GeneralUngriddedCollocator(fill_value=np.NAN)
new_data = col.collocate(sample_points, cube, None, li())[0]
assert_almost_equal(new_data.data[0], 221.5, decimal=7)
assert_almost_equal(new_data.data[0], 225.5, decimal=7)
assert_almost_equal(new_data.data[1], 346.5, decimal=7)

def test_colocation_of_alt_pres_points_on_hybrid_altitude_and_pressure_coordinates(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, li, DummyConstraint
Expand All @@ -806,11 +808,11 @@ def test_colocation_of_alt_pres_points_on_hybrid_altitude_and_pressure_coordinat
sample_points = UngriddedData.from_points_array(
# Test point with both pressure and altitude should interpolate over the altitude only (since that is also
# present in the data cube)
[HyperPoint(lat=0.0, lon=0.0, alt=200.5, pres=1000, t=dt.datetime(1984, 8, 28,0,0,0))])
[HyperPoint(lat=0.0, lon=0.0, alt=234.5, pres=1000, t=dt.datetime(1984, 8, 28,0,0,0))])

col = GeneralUngriddedCollocator(fill_value=np.NAN)
new_data = col.collocate(sample_points, cube, None, li())[0]
assert_almost_equal(new_data.data[0], 221.5, decimal=7)
assert_almost_equal(new_data.data[0], 225.5, decimal=7)

if __name__ == '__main__':
unittest.main()

0 comments on commit aca5cea

Please sign in to comment.