Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapefile masking #5470

Merged
merged 58 commits into from
Feb 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3b15cd2
Working draft of shapefile masking
acchamber Sep 1, 2023
2ef0d15
Version of shapefile masking with tests and ready for preliminary review
acchamber Sep 5, 2023
6d36d05
Updated tests with proper paths and skip_tests decorator
acchamber Sep 6, 2023
befb1e5
Merge branch 'main' into shapefile_masking
acchamber Sep 7, 2023
6c2ef62
Merge branch 'main' into shapefile_masking
acchamber Oct 2, 2023
7b28fcd
Merge branch 'main' into shapefile_masking
acchamber Nov 8, 2023
6decedf
fixed some paths and removed broken code
acchamber Nov 8, 2023
d3b91d1
Merge branch 'SciTools:main' into shapefile_masking
acchamber Nov 9, 2023
d168f24
Added more tests and split into integration and unit tests. Testing w…
acchamber Nov 9, 2023
4947ffb
Merge branch 'shapefile_masking' of https://github.com/acchamber/iris…
acchamber Nov 9, 2023
1d05f63
responces to comments on utils.py for shapefile masking
acchamber Nov 20, 2023
ca363cc
tests actually pass now
acchamber Nov 20, 2023
23f3640
Moved tests to correct locations and strted changes on _shapefiles.py
acchamber Nov 20, 2023
57af617
some changes to _shapefiles to match review
acchamber Nov 20, 2023
5ba0ebc
added setUp cases to tests
acchamber Nov 20, 2023
cce3f9b
moved test names to lower_case and added acknoledgment
acchamber Nov 20, 2023
3ec7cc3
removed seperate guess_bounds function
acchamber Nov 20, 2023
7baab21
updated structure to properly call coord names/coords when optimal
acchamber Nov 22, 2023
c0aa728
sphnix improvements to docstring
acchamber Nov 22, 2023
44fe0cd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2023
28fcd44
commited dask map_blocks approach and some test improvements
acchamber Nov 23, 2023
87cc28e
replaced bounds rebasing via modulus with vectorized version
acchamber Nov 23, 2023
92d869f
Dask chunk control and some docstrings
acchamber Nov 24, 2023
4b38611
Merge branch 'shapefile_masking' of https://github.com/acchamber/iris…
acchamber Nov 27, 2023
befceeb
reverted behaviour of modulus function to ASCEND and switcher argumen…
acchamber Nov 27, 2023
e391e43
edied tests to work with flipped argument order
acchamber Nov 29, 2023
8b0e869
Improved optimisation by reading shapely docs properly and just using…
acchamber Jan 10, 2024
194aabf
Docstring updates and a 4d integration test
acchamber Feb 6, 2024
9521c2e
Merge branch 'main' into shapefile_masking
trexfeathers Feb 6, 2024
e89634b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2024
162bd45
Update lib/iris/_shapefiles.py
acchamber Feb 6, 2024
07ab745
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2024
e8a23b7
improving readability from martin
acchamber Feb 6, 2024
ea5be9c
Merge branch 'shapefile_masking' of https://github.com/acchamber/iris…
acchamber Feb 6, 2024
64278ca
removed dask.delayed call
acchamber Feb 6, 2024
a46d7c9
Update lib/iris/_shapefiles.py
acchamber Feb 6, 2024
eca46c0
Update lib/iris/_shapefiles.py
acchamber Feb 6, 2024
061b76b
Update lib/iris/util.py
acchamber Feb 6, 2024
cc6016b
Added warning for possible mismatch of mask/cube coords
acchamber Feb 7, 2024
5e7d799
test for new warning
acchamber Feb 7, 2024
440f049
added test
acchamber Feb 7, 2024
3c13e1b
Update lib/iris/_shapefiles.py
acchamber Feb 7, 2024
1e1d711
Added licenses
acchamber Feb 7, 2024
22e2cf7
Merge branch 'shapefile_masking' of https://github.com/acchamber/iris…
acchamber Feb 7, 2024
9cb96b9
fixed doctest failures in example
acchamber Feb 7, 2024
deb5ff9
Improved test coverage
acchamber Feb 7, 2024
6eaa36b
fixed doctest
acchamber Feb 7, 2024
3b7384f
doctest again
acchamber Feb 7, 2024
a0aec74
Docstring tidy up.
trexfeathers Feb 7, 2024
e13e757
Merge pull request #1 from trexfeathers/docstring_tidy
acchamber Feb 7, 2024
b76dabd
fixed prime meridian bug
acchamber Feb 9, 2024
ca380ed
Update lib/iris/_shapefiles.py
acchamber Feb 9, 2024
0518a40
Merge branch 'main' into shapefile_masking
acchamber Feb 9, 2024
404474f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 9, 2024
b924795
Added first draft of user guide page
acchamber Feb 12, 2024
4ab753a
Add What's New entry.
trexfeathers Feb 13, 2024
84a8212
Merge pull request #2 from trexfeathers/shapefile_whatsnew
acchamber Feb 13, 2024
bf3c720
Merge branch 'SciTools:main' into shapefile_masking
acchamber Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions lib/iris/_shapefiles.py
trexfeathers marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,25 @@ def _transform_coord_system(geometry, cube, geometry_system=None):
source_proj = geometry_system.as_cartopy_projection()

trans_geometry = target_proj.project_geometry(geometry, source_proj)
# A default coord system in iris can be either -180 to 180 or 0 to 360
if target_system == DEFAULT_CS and cube.coord(x_name).points[-1] > 180:
# A GeogCS in iris can be either -180 to 180 or 0 to 360. If cube is 0-360, shift geom to match
if (
isinstance(target_system, iris.coord_systems.GeogCS)
and cube.coord(x_name).points[-1] > 180
):
# chop geom at 0 degree line very finely then transform
prime_meridian_line = shapely.LineString([(0, 90), (0, -90)])
trans_geometry = trans_geometry.difference(prime_meridian_line.buffer(0.00001))
trans_geometry = shapely.transform(trans_geometry, _trans_func)
if target_system != DEFAULT_CS and cube.coord(x_name).points[-1] > 180:

if (
isinstance(target_system, iris.coord_systems.GeogCS)
and cube.coord(x_name).points[-1] > 180
):
acchamber marked this conversation as resolved.
Show resolved Hide resolved
# this may lead to incorrect masking or not depending on projection type so warn user
warnings.warn(
"""Cube has x-coordinates over 180E and a non-standard projection time.\n
"""Cube has x-coordinates over 180E and a non-standard projection type.\n
This may lead to incorrect masking. \n
If the result is not as expected, you might want to transform the x coordinate points to -180 to 180 """,
If the result is not as expected, you might want to transform the x coordinate points of your cube to -180-180 """,
category=IrisUserWarning,
)
return trans_geometry
Expand Down
Loading