Skip to content

Commit

Permalink
chore: update from antarctic-plots to polartoolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Feb 22, 2024
1 parent 8d30cda commit 16bf313
Show file tree
Hide file tree
Showing 20 changed files with 165 additions and 192 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PROJECT=invert4geom
STYLE_CHECK_FILES=.

create:
mamba create --name $(PROJECT) --yes --force antarctic-plots python=3.11
mamba create --name $(PROJECT) --yes --force polartoolkit python=3.11

create_test_env:
mamba create --name test --yes python=3.11
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- SPHINX-START1 -->

<!-- <p align="center">
<a href="https://mybinder.org/v2/gh/mdtanker/antarctic_plots/main">
<a href="https://mybinder.org/v2/gh/mdtanker/polartoolkit/main">
<img src="https://mybinder.org/badge_logo.svg" alt="Binder link"></a>
</p> -->

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# pykdtree
"xrft": ("https://xrft.readthedocs.io/en/stable/", None),
"harmonica": ("https://www.fatiando.org/harmonica/latest/", None),
"antarctic_plots": ("https://antarctic-plots.readthedocs.io/en/latest/", None),
"polartoolkit": ("https://polartoolkit.readthedocs.io/en/latest/", None),
"numba": ("https://numba.pydata.org/numba-doc/latest/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
# nptyping
Expand Down
8 changes: 4 additions & 4 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ First create a `conda` environment and install the necessary packages into that:
```

```
mamba create --name invert4geom antarctic-plots python=3.11
mamba create --name invert4geom polartoolkit python=3.11
```

The package `antarctic-plots` provides several useful functions used in
`invert4geom`. Since `antarctic-plots` has several dependencies that can't be
The package `polartoolkit` provides several useful functions used in
`invert4geom`. Since `polartoolkit` has several dependencies that can't be
install with `pip` (mostly `pygmt`), it is easiest to install with `conda`.

activate the environment and use `pip` to install `invert4geom`:
Expand Down Expand Up @@ -66,7 +66,7 @@ If you don't have or want `make` or `mamba` installed, you can accomplish the
same with the following:

```
conda create --name invert4geom --yes --force antarctic-plots python=3.11
conda create --name invert4geom --yes --force polartoolkit python=3.11
conda activate invert4geom
pip install -e .[all]
```
6 changes: 3 additions & 3 deletions docs/user_guide/adhering_to_constraints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"import pandas as pd\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import inversion, plotting, synthetic, utils"
]
Expand Down Expand Up @@ -150,7 +150,7 @@
}
],
"source": [
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" starting_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down Expand Up @@ -1329,7 +1329,7 @@
"source": [
"final_topography = topo_results.set_index([\"northing\", \"easting\"]).to_xarray().topo\n",
"\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" final_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down
238 changes: 110 additions & 128 deletions docs/user_guide/combining_it_all.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/user_guide/damping_cross_validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"import numpy as np\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import cross_validation, inversion, plotting, synthetic, utils"
]
Expand Down Expand Up @@ -1053,7 +1053,7 @@
"source": [
"final_topography = topo_results.set_index([\"northing\", \"easting\"]).to_xarray().topo\n",
"\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" final_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/user_guide/density_cross_validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"import pandas as pd\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import maps\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import maps\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import cross_validation, inversion, plotting, synthetic, utils"
]
Expand Down Expand Up @@ -872,7 +872,7 @@
"source": [
"final_topography = topo_results.set_index([\"northing\", \"easting\"]).to_xarray().topo\n",
"\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" final_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down
12 changes: 6 additions & 6 deletions docs/user_guide/estimating_regional_field.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"import pandas as pd\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import maps\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import maps\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import plotting, regional, synthetic, utils"
]
Expand Down Expand Up @@ -683,7 +683,7 @@
"grav_grid = grav_df.set_index([\"northing\", \"easting\"]).to_xarray()\n",
"\n",
"# compare with true regional\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" grav_grid.lower_surface_grav,\n",
" grav_grid.filter_reg,\n",
" plot_type=\"xarray\",\n",
Expand Down Expand Up @@ -744,7 +744,7 @@
"grav_grid = grav_df.set_index([\"northing\", \"easting\"]).to_xarray()\n",
"\n",
"# compare with true regional\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" grav_grid.lower_surface_grav,\n",
" grav_grid.trend_reg,\n",
" plot_type=\"xarray\",\n",
Expand Down Expand Up @@ -806,7 +806,7 @@
"grav_grid = grav_df.set_index([\"northing\", \"easting\"]).to_xarray()\n",
"\n",
"# compare with true regional\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" grav_grid.lower_surface_grav,\n",
" grav_grid.eq_sources_reg,\n",
" plot_type=\"xarray\",\n",
Expand Down Expand Up @@ -870,7 +870,7 @@
"grav_grid = grav_df.set_index([\"northing\", \"easting\"]).to_xarray()\n",
"\n",
"# compare with true regional\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" grav_grid.lower_surface_grav,\n",
" grav_grid.constraints_reg,\n",
" plot_type=\"xarray\",\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/user_guide/including_starting_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"import pandas as pd\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import inversion, plotting, synthetic, utils"
]
Expand Down Expand Up @@ -128,7 +128,7 @@
}
],
"source": [
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" starting_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down Expand Up @@ -994,7 +994,7 @@
"source": [
"final_topography = topo_results.set_index([\"northing\", \"easting\"]).to_xarray().topo\n",
"\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" final_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down
31 changes: 11 additions & 20 deletions docs/user_guide/reference_level_cross_validation.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/user_guide/simple_inversion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"\n",
"import verde as vd\n",
"import xarray as xr\n",
"from antarctic_plots import maps\n",
"from antarctic_plots import utils as ap_utils\n",
"from polartoolkit import maps\n",
"from polartoolkit import utils as polar_utils\n",
"\n",
"from invert4geom import inversion, plotting, synthetic, utils"
]
Expand Down Expand Up @@ -1393,7 +1393,7 @@
"source": [
"final_topography = topo_results.set_index([\"northing\", \"easting\"]).to_xarray().topo\n",
"\n",
"_ = ap_utils.grd_compare(\n",
"_ = polar_utils.grd_compare(\n",
" true_topography,\n",
" final_topography,\n",
" plot_type=\"xarray\",\n",
Expand Down
2 changes: 1 addition & 1 deletion env/RTD_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- pykdtree
- xrft>=1.0
- harmonica>=0.6.0
- antarctic-plots>=0.0.6
- polartoolkit
- numba
- scipy
- nptyping
Expand Down
2 changes: 1 addition & 1 deletion env/test_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- pykdtree
- xrft>=1.0
- harmonica>=0.6.0
- antarctic-plots>=0.0.6
- polartoolkit
- numba
- scipy
- nptyping
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def tests(session: nox.Session) -> None:
"""
Run the unit and regular tests.
"""
session.conda_install("antarctic-plots")
session.conda_install("polartoolkit")
session.install(".[test]")

# run tests with numba jit disabled to get real coverage
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"pykdtree",
"xrft>=1.0",
"harmonica>=0.6.0",
"antarctic_plots>=0.0.6",
"polartoolkit",
"numba",
"scipy",
"nptyping",
Expand Down
4 changes: 2 additions & 2 deletions src/invert4geom/cross_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pandas as pd
import verde as vd
import xarray as xr
from antarctic_plots import utils as ap_utils
from polartoolkit import utils as polar_utils
from tqdm.autonotebook import tqdm

from invert4geom import inversion, plotting, utils
Expand Down Expand Up @@ -194,7 +194,7 @@ def grav_cv_score(
obs = test_grid[kwargs.get("input_grav_column")] - test_grid.reg
pred = test_grid.test_point_grav.rename("")

ap_utils.grd_compare(
polar_utils.grd_compare(
pred,
obs,
grid1_name="Predicted gravity",
Expand Down
12 changes: 6 additions & 6 deletions src/invert4geom/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
pyvista = None
import verde as vd
import xarray as xr
from antarctic_plots import utils as ap_utils
from polartoolkit import utils as polar_utils

from invert4geom import utils

Expand Down Expand Up @@ -342,7 +342,7 @@ def plot_inversion_topo_results(

topo_lims = []
for g in [initial_topo, final_topo]:
topo_lims.append(ap_utils.get_min_max(g))
topo_lims.append(polar_utils.get_min_max(g))

topo_min = min([i[0] for i in topo_lims]) * topo_cmap_perc # pylint: disable=consider-using-generator
topo_max = max([i[1] for i in topo_lims]) * topo_cmap_perc # pylint: disable=consider-using-generator
Expand Down Expand Up @@ -455,7 +455,7 @@ def plot_inversion_grav_results(
initial_rmse = utils.rmse(grav_results["iter_1_initial_misfit"])
final_rmse = utils.rmse(grav_results[f"iter_{max(iterations)}_final_misfit"])

_ = ap_utils.grd_compare(
_ = polar_utils.grd_compare(
initial_misfit,
final_misfit,
plot=True,
Expand Down Expand Up @@ -530,11 +530,11 @@ def plot_inversion_iteration_results(
corrections_lims = []

for g in misfit_grids:
misfit_lims.append(ap_utils.get_min_max(g))
misfit_lims.append(polar_utils.get_min_max(g))
for g in topo_grids:
topo_lims.append(ap_utils.get_min_max(g))
topo_lims.append(polar_utils.get_min_max(g))
for g in corrections_grids:
corrections_lims.append(ap_utils.get_min_max(g))
corrections_lims.append(polar_utils.get_min_max(g))

misfit_min = min([i[0] for i in misfit_lims]) # pylint: disable=consider-using-generator
misfit_max = max([i[1] for i in misfit_lims]) # pylint: disable=consider-using-generator
Expand Down
6 changes: 3 additions & 3 deletions tests/test_regional.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_regional_trend(fill_method, trend):
)

# grid = df.set_index(["northing", "easting"]).to_xarray()
# ap_utils.grd_compare(grid.reg, grid.misfit, plot=True, plot_type="xarray")
# polar_utils.grd_compare(grid.reg, grid.misfit, plot=True, plot_type="xarray")

assert len(df.misfit) == len(df.reg)

Expand Down Expand Up @@ -96,7 +96,7 @@ def test_regional_filter():
)

# grid = df.set_index(["northing", "easting"]).to_xarray()
# ap_utils.grd_compare(grid.reg, grid.misfit, plot=True, plot_type="xarray")
# polar_utils.grd_compare(grid.reg, grid.misfit, plot=True, plot_type="xarray")

assert len(df.misfit) == len(df.reg)

Expand Down Expand Up @@ -172,7 +172,7 @@ def test_regional_constraints(test_input):
)

# grid = df.set_index(["northing", "easting"]).to_xarray()
# ap_utils.grd_compare(
# polar_utils.grd_compare(
# grid.reg, grid.misfit, plot=True, plot_type="xarray",
# points=points.rename(columns={"easting":"x", "northing":"y"}),
# )
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def test_filter_grid_nans():
# # filter the grid
# filtered = utils.filter_grid(grid, filter_width=500, change_spacing=True)
# # get grid spacings
# original_spacing = float(ap_utils.get_grid_info(grid)[0])
# new_spacing = float(ap_utils.get_grid_info(filtered)[0])
# original_spacing = float(polar_utils.get_grid_info(grid)[0])
# new_spacing = float(polar_utils.get_grid_info(filtered)[0])
# print(original_spacing)
# print(new_spacing)
# # check that the gridspacing has been changed
Expand Down

0 comments on commit 16bf313

Please sign in to comment.