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

ENH: Node get_bounds method. #486

Merged
merged 4 commits into from
Aug 3, 2021
Merged

ENH: Node get_bounds method. #486

merged 4 commits into from
Aug 3, 2021

Conversation

jmilloy
Copy link
Collaborator

@jmilloy jmilloy commented Aug 3, 2021

Any node

    def test_get_bounds(self):
        class MyNode(Node):
            def find_coordinates(self):
                return [
                    podpac.Coordinates([[0, 1, 2], [0, 10, 20]], dims=["lat", "lon"], crs="EPSG:2193"),
                    podpac.Coordinates([[3, 4], [30, 40]], dims=["lat", "lon"], crs="EPSG:2193"),
                ]

        node = MyNode()

        with podpac.settings:
            podpac.settings["DEFAULT_CRS"] = "EPSG:4326"

            # specify crs
            bounds, crs = node.get_bounds(crs="EPSG:2193")
            assert bounds == {"lat": (0, 4), "lon": (0, 40)}
            assert crs == "EPSG:2193"

            # default crs
            bounds, crs = node.get_bounds()
            assert bounds == {
                "lat": (-75.81397534013118, -75.81362774074242),
                "lon": (82.92787904584206, 82.9280189659297),
            }
            assert crs == "EPSG:4326"

Special case for Datasources

    def test_get_bounds(self):
        node = podpac.data.Array(
            source=np.ones((3, 4)),
            coordinates=podpac.Coordinates([range(3), range(4)], ["lat", "lon"], crs="EPSG:2193"),
        )

        with podpac.settings:
            podpac.settings["DEFAULT_CRS"] = "EPSG:4326"

            # specify crs
            bounds, crs = node.get_bounds(crs="EPSG:3857")
            assert bounds == {
                "lat": (-13291827.558247399, -13291815.707967814),
                "lon": (9231489.26794932, 9231497.142754894),
            }
            assert crs == "EPSG:3857"

            # native/source crs
            bounds, crs = node.get_bounds(crs="source")
            assert bounds == {"lat": (0, 2), "lon": (0, 3)}
            assert crs == "EPSG:2193"

            # default crs
            bounds, crs = node.get_bounds()
            assert bounds == {
                "lat": (-75.81365382984804, -75.81362774074242),
                "lon": (82.92787904584206, 82.92794978642414),
            }
            assert crs == "EPSG:4326"

closes #467

@jmilloy jmilloy added the enhancement New feature or request label Aug 3, 2021
@jmilloy jmilloy requested a review from mpu-creare August 3, 2021 20:00
@jmilloy jmilloy self-assigned this Aug 3, 2021
Copy link
Contributor

@mpu-creare mpu-creare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just fix a few of the doc strings and you can go ahead and merge.

podpac/core/data/datasource.py Outdated Show resolved Hide resolved
podpac/core/data/datasource.py Outdated Show resolved Hide resolved
podpac/core/node.py Outdated Show resolved Hide resolved
jmilloy and others added 3 commits August 3, 2021 17:17
Co-authored-by: mpu-creare <mpu-creare@users.noreply.github.com>
Co-authored-by: mpu-creare <mpu-creare@users.noreply.github.com>
Co-authored-by: mpu-creare <mpu-creare@users.noreply.github.com>
@jmilloy jmilloy merged commit 7eec446 into develop Aug 3, 2021
@jmilloy jmilloy deleted the feature/get_bounds branch August 3, 2021 21:17
podpac/core/node.py Outdated Show resolved Hide resolved
@mpu-creare mpu-creare mentioned this pull request Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node bounds attribute
2 participants