Skip to content

Commit a28596f

Browse files
authored
center map sample data (#87)
* center map sample data * changelog
1 parent 314b6bd commit a28596f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
### Deprecations
66

7+
### Breaking changes
8+
9+
- `sample_data_map` now offsets the lon data such that the first grid cell does not wrap
10+
around ([#87](https://github.com/mathause/mplotutils/pull/87)).
11+
712
### Enhancements
813

914
### Bug fixes

mplotutils/cartopy_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def sample_data_map(nlons, nlats):
3737
"""
3838

3939
dlat = 180.0 / nlats / 2
40-
dlon = 360.0 / nlons
40+
dlon = 360.0 / nlons / 2
4141

4242
lat = np.linspace(-90 + dlat, 90 - dlat, nlats)
43-
lon = np.linspace(0, 360 - dlon, nlons)
43+
lon = np.linspace(dlon, 360 - dlon, nlons)
4444

4545
lons, lats = np.meshgrid(np.deg2rad(lon), np.deg2rad(lat))
4646
wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)

mplotutils/tests/test_sample_data_map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ def test_lat():
2020
__, lat, __ = sample_data_map(36, 9)
2121

2222
expected_lat = np.arange(-80, 81, 20)
23-
assert np.allclose(lat, expected_lat)
23+
np.testing.assert_allclose(lat, expected_lat)
2424

2525

2626
def test_lon():
2727
lon, __, __ = sample_data_map(36, 9)
2828

29-
expected_lon = np.arange(0, 351, 10)
30-
assert np.allclose(lon, expected_lon)
29+
expected_lon = np.arange(5, 356, 10)
30+
np.testing.assert_allclose(lon, expected_lon)
3131

3232

3333
@pytest.mark.parametrize("nlon", [5, 10])

0 commit comments

Comments
 (0)