From 619cab367b6799c711f8ebfe63526214a9237a04 Mon Sep 17 00:00:00 2001 From: "Noah D. Brenowitz" Date: Fri, 31 May 2024 09:48:21 -0700 Subject: [PATCH 1/3] fix github links in docs --- docs/installation.md | 27 ++++----------------------- tests/test_latlon.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index d1eda9d..d2121ac 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,43 +1,24 @@ # Installation -## Stable release - -To install Earth2 Grid Utilities, run this command in your -terminal: - -``` console -$ pip install earth2-grid -``` - -This is the preferred method to install Earth2 Grid Utilities, as it will always install the most recent stable release. - -If you don't have [pip][] installed, this [Python installation guide][] -can guide you through the process. - -## From source - The source for Earth2 Grid Utilities can be downloaded from the [Github repo][]. You can either clone the public repository: ``` console -$ git clone git://github.com/waynerv/earth2-grid +$ git clone git@github.com:NVlabs/earth2grid.git ``` Or download the [tarball][]: ``` console -$ curl -OJL https://github.com/waynerv/earth2-grid/tarball/master +$ curl -OJL https://github.com/NVlabs/earth2-grid/tarball/master ``` Once you have a copy of the source, you can install it with: ``` console -$ pip install . +$ pip install --no-build-isolation . ``` - [pip]: https://pip.pypa.io - [Python installation guide]: http://docs.python-guide.org/en/latest/starting/installation/ - [Github repo]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D - [tarball]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D/tarball/master + [Github repo]: https://github.com/NVlabs/earth2grid diff --git a/tests/test_latlon.py b/tests/test_latlon.py index 2b20940..997e1d3 100644 --- a/tests/test_latlon.py +++ b/tests/test_latlon.py @@ -1,3 +1,17 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License.import torch import torch from earth2grid.latlon import equiangular_lat_lon_grid From 5277dd5b83481d36aafe810ce4318732078cebfa Mon Sep 17 00:00:00 2001 From: "Noah D. Brenowitz" Date: Fri, 31 May 2024 09:49:15 -0700 Subject: [PATCH 2/3] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 29ff5c1..bdbfee6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "earth2-grid" -version = "2024.5.1" +version = "2024.5.2" description = "Utilities for working with geographic data defined on various grids." readme = "README.md" license = { file="LICENSE.txt" } From 60ce89f8ebb825879d819bae0a17923878fd9874 Mon Sep 17 00:00:00 2001 From: "Noah D. Brenowitz" Date: Fri, 31 May 2024 09:55:07 -0700 Subject: [PATCH 3/3] fix the readme and doc examples --- README.md | 7 ++++--- docs/usage.md | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9dbea46..0023c94 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,13 @@ pip install --no-build-isolation earth2-grid ``` >>> import earth2grid +>>> import torch ... # level is the resolution ... level = 6 -... hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.PixelOrder.XY) +... hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.XY()) ... src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64) -... z_torch = torch.as_tensor(z) -... z_torch = torch.as_tensor(z) +... z_torch = torch.cos(torch.deg2rad(torch.tensor(src.lat))) +... z_torch = z_torch.broadcast_to(src.shape) >>> regrid = earth2grid.get_regridder(src, hpx) >>> z_hpx = regrid(z_torch) >>> z_hpx.shape diff --git a/docs/usage.md b/docs/usage.md index 27b3493..c31bbde 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -3,16 +3,22 @@ To use Earth2 Grid Utilities in a project ``` -import earth2grid -# level is the resolution -level = 6 -hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.PixelOrder.XY) -src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64) -z_torch = torch.as_tensor(z) -z_torch = torch.as_tensor(z) -regrid = earth2grid.get_regridder(src, hpx) -z_hpx = regrid(z_torch) -z_hpx.shape -nside = 2**level -reshaped = z_hpx.reshape(12, nside, nside) +>>> import earth2grid +>>> import torch +... # level is the resolution +... level = 6 +... hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.XY()) +... src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64) +... z_torch = torch.cos(torch.deg2rad(torch.tensor(src.lat))) +... z_torch = z_torch.broadcast_to(src.shape) +>>> regrid = earth2grid.get_regridder(src, hpx) +>>> z_hpx = regrid(z_torch) +>>> z_hpx.shape +torch.Size([49152]) +>>> nside = 2**level +... reshaped = z_hpx.reshape(12, nside, nside) +... lat_r = hpx.lat.reshape(12, nside, nside) +... lon_r = hpx.lon.reshape(12, nside, nside) +>>> reshaped.shape +torch.Size([12, 64, 64]) ```