Skip to content

Commit

Permalink
Make plots that require internet optional in cli
Browse files Browse the repository at this point in the history
Resolves #52.

- New add_basemap and plot_icesat boolean flags on asp_plot call
- Default plot them, optionally turn them off
- Bump version from 0.5.0 to 0.5.1
  • Loading branch information
bpurinton committed Oct 26, 2024
1 parent 03a740a commit cc5c273
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 29 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Options:
Default: EPSG:4326
--reference_dem TEXT Reference DEM used in ASP processing. No
default. Must be supplied.
--add_basemap BOOLEAN If True, add a contextily basemap to the
figure, which requires internet connection.
Default: True
--plot_icesat BOOLEAN If True, plot an ICESat-2 difference plot
with the DEM result. This requires internet
connection to pull ICESat data. Default:
True
--report_filename TEXT PDF file to write out for report into the
processing directory supplied by
--directory. Default: Directory name of ASP
Expand Down
72 changes: 45 additions & 27 deletions asp_plot/cli/asp_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
default="",
help="Reference DEM used in ASP processing. No default. Must be supplied.",
)
@click.option(
"--add_basemap",
prompt=False,
default=True,
help="If True, add a contextily basemap to the figure, which requires internet connection. Default: True",
)
@click.option(
"--plot_icesat",
prompt=False,
default=True,
help="If True, plot an ICESat-2 difference plot with the DEM result. This requires internet connection to pull ICESat data. Default: True",
)
@click.option(
"--report_filename",
prompt=False,
Expand All @@ -62,6 +74,8 @@ def main(
stereo_directory,
map_crs,
reference_dem,
add_basemap,
plot_icesat,
report_filename,
report_title,
):
Expand All @@ -78,12 +92,15 @@ def main(

figure_counter = count(0)

ctx_kwargs = {
"crs": map_crs,
"source": ctx.providers.Esri.WorldImagery,
"attribution_size": 0,
"alpha": 0.5,
}
if add_basemap:
ctx_kwargs = {
"crs": map_crs,
"source": ctx.providers.Esri.WorldImagery,
"attribution_size": 0,
"alpha": 0.5,
}
else:
ctx_kwargs = {}

# Detailed hillshade plot
plotter = StereoPlotter(
Expand All @@ -100,31 +117,32 @@ def main(
)

# ICESat-2 comparison
icesat = Altimetry(dem_fn=plotter.dem_fn)
if plot_icesat:
icesat = Altimetry(dem_fn=plotter.dem_fn)

icesat.pull_atl06sr(
esa_worldcover=True,
save_to_parquet=False,
)
icesat.pull_atl06sr(
esa_worldcover=True,
save_to_parquet=False,
)

icesat.filter_atl06sr(
mask_worldcover_water=True,
save_to_parquet=False,
save_to_csv=False,
)
icesat.filter_atl06sr(
mask_worldcover_water=True,
save_to_parquet=False,
save_to_csv=False,
)

icesat.mapview_plot_atl06sr_to_dem(
title=f"Filtered ICESat-2 minus DEM (n={icesat.atl06sr_filtered.shape[0]})",
save_dir=plots_directory,
fig_fn=f"{next(figure_counter):02}.png",
**ctx_kwargs,
)
icesat.mapview_plot_atl06sr_to_dem(
title=f"Filtered ICESat-2 minus DEM (n={icesat.atl06sr_filtered.shape[0]})",
save_dir=plots_directory,
fig_fn=f"{next(figure_counter):02}.png",
**ctx_kwargs,
)

icesat.histogram(
title=f"Filtered ICESat-2 minus DEM (n={icesat.atl06sr_filtered.shape[0]})",
save_dir=plots_directory,
fig_fn=f"{next(figure_counter):02}.png",
)
icesat.histogram(
title=f"Filtered ICESat-2 minus DEM (n={icesat.atl06sr_filtered.shape[0]})",
save_dir=plots_directory,
fig_fn=f"{next(figure_counter):02}.png",
)

# Geometry plot
plotter = SceneGeometryPlotter(directory)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "asp_plot"
version = "0.5.0"
version = "0.5.1"
authors = [
{ name="Ben Purinton", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="asp_plot",
version="0.5.0",
version="0.5.1",
description="Python library and client for plotting Ames Stereo Pipeline outputs",
author="Ben Purinton",
author_email="[email protected]",
Expand Down

0 comments on commit cc5c273

Please sign in to comment.