--add-colorbar option with --add-coastlines fails if multiple .tif files specified
Closed this issue · 2 comments
I did the following commands:
1. p2g_grid_helper.sh NewOrleans -89.0 31.0 1000 -1000 960 720 > $GEO2GRID_HOME/MSY.yaml
2. p2g_grid_helper.sh Madison -89.0 43.0 1000 -1000 960 720 > $GEO2GRID_HOME/MSN.yaml
3. geo2grid.sh -r abi_l1b -w geotiff -p C13 -g NewOrleans Madison --grid-configs $GEO2GRID_HOME/MSY.yaml $GEO2GRID_HOME/MSN.yaml -f /arcdata/goes_restricted/grb/goes16/2022/2022_12_08_342/abi/L1b/RadC/*M6C13*s20223420901*.nc
4. add_colormap.sh ../../../enhancements/IR13_AWIPSAPPROX.txt *.tif
5. add_coastlines.sh *.tif --add-coastlines --coastlines-resolution h --coastlines-level 5 --add-colorbar --colorbar-text-color="black" --colorbar-title="GOES-16 Band 13 Clean Window infrared Brightness Temperature" --colorbar-tick-marks 20 --colorbar-min 160 --colorbar-max 330 --colorbar-text-size 16 --colorbar-height 36 --colorbar-align bottom
The following error occurred:
Traceback (most recent call last):
File "/home/scottl/CSPPGeo/geo2grid_v_1_1/libexec/python_runtime/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/scottl/CSPPGeo/geo2grid_v_1_1/libexec/python_runtime/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/scottl/CSPPGeo/geo2grid_v_1_1/libexec/python_runtime/lib/python3.10/site-packages/polar2grid/add_coastlines.py", line 549, in
sys.exit(main())
File "/home/scottl/CSPPGeo/geo2grid_v_1_1/libexec/python_runtime/lib/python3.10/site-packages/polar2grid/add_coastlines.py", line 352, in main
_process_one_image(input_tiff, output_filename, pycoast_options, args.shapes_dir, colorbar_kwargs)
File "/home/scottl/CSPPGeo/geo2grid_v_1_1/libexec/python_runtime/lib/python3.10/site-packages/polar2grid/add_coastlines.py", line 506, in _process_one_image
cmin = colorbar_kwargs.pop("cmin")
KeyError: 'cmin'
If I specify Madison.tif, the add_coastlines command completes as expected.
Thanks for writing this up @ScottLindstrom. I was able to reproduce this.
This requires a pretty simple fix:
Subject: [PATCH] Fix multi-tiff colorbar failure
---
Index: polar2grid/add_coastlines.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/polar2grid/add_coastlines.py b/polar2grid/add_coastlines.py
--- a/polar2grid/add_coastlines.py (revision db6bb1b7db18fd4e0e8e8e8579f9e176d8238a73)
+++ b/polar2grid/add_coastlines.py (date 1670790909051)
@@ -503,6 +503,7 @@
cw.add_overlay_from_dict(pycoast_options, area_def, background=img)
if colorbar_kwargs:
+ colorbar_kwargs = colorbar_kwargs.copy()
cmin = colorbar_kwargs.pop("cmin")
cmax = colorbar_kwargs.pop("cmax")
cmap = _get_colormap_object(input_tiff, num_bands, cmin, cmax)
Just some bad coding. I'll need to add a test that does multiple tifs as input. @ScottLindstrom feel free to hack your installation to get this to work. Again, this probably won't be part of the G2G 1.1.0 official release, but we'll work towards including it in 1.1.1.