The scripts in examples/ have accumulated duplication and don't do a good job of explaining what the example data actually is. Proposed clean-up:
Reduce duplication
Every example repeats the same preamble: get_sample_graph(...) on data/d8.tif, a second pd.read_csv of the same file for the chemistry, drop(columns=["Bi", "S"]), then build the problem. unmix_mwe.py, unmix_mwe2.py, unmix_montecarlo_mwe.py and unmix_BDL.py all carry near-identical copies. Factor the loading into a single shared helper so each example shows only the thing it is actually demonstrating.
Note the CSV is currently read twice per script — once inside get_sample_graph for the coordinates and once by the caller for the chemistry. Worth collapsing.
Better names
unmix_mwe.py / unmix_mwe2.py don't say what distinguishes them. Names should describe the demonstration, e.g. unmix_single_element.py, unmix_all_elements.py, unmix_with_uncertainties.py, unmix_below_detection_limit.py.
Scientific background
The examples should explain the dataset they use: a real drainage geochemistry survey of NE Scotland (the Cairngorms and the surrounding Spey, Dee, Don, Deveron and Tay catchments), sampled stream sediments, concentrations in mg/kg, D8 raster at 50 m resolution. A reader should be able to tell what question the inversion is answering, not just which functions to call.
Plot geospatially rather than imshow
get_upstream_concentration_map returns an array that is currently shown with a bare plt.imshow(upstream_map) — no coordinates, no north, arbitrary pixel axes. The rasters are georeferenced to OSGB36 / British National Grid (EPSG:27700), so the examples should at minimum pass a correct extent= in eastings/northings with labelled axes, and ideally overlay the sample sites and the drainage network. That makes the output directly comparable to the same data loaded in QGIS.
Related
plot_sweep_of_regularizer_strength returns None and discards its solutions, so an example can't do anything with the misfit-roughness curve programmatically; and its docstring claims it prints values, which it does not. Worth addressing at the same time.
The scripts in
examples/have accumulated duplication and don't do a good job of explaining what the example data actually is. Proposed clean-up:Reduce duplication
Every example repeats the same preamble:
get_sample_graph(...)ondata/d8.tif, a secondpd.read_csvof the same file for the chemistry,drop(columns=["Bi", "S"]), then build the problem.unmix_mwe.py,unmix_mwe2.py,unmix_montecarlo_mwe.pyandunmix_BDL.pyall carry near-identical copies. Factor the loading into a single shared helper so each example shows only the thing it is actually demonstrating.Note the CSV is currently read twice per script — once inside
get_sample_graphfor the coordinates and once by the caller for the chemistry. Worth collapsing.Better names
unmix_mwe.py/unmix_mwe2.pydon't say what distinguishes them. Names should describe the demonstration, e.g.unmix_single_element.py,unmix_all_elements.py,unmix_with_uncertainties.py,unmix_below_detection_limit.py.Scientific background
The examples should explain the dataset they use: a real drainage geochemistry survey of NE Scotland (the Cairngorms and the surrounding Spey, Dee, Don, Deveron and Tay catchments), sampled stream sediments, concentrations in mg/kg, D8 raster at 50 m resolution. A reader should be able to tell what question the inversion is answering, not just which functions to call.
Plot geospatially rather than
imshowget_upstream_concentration_mapreturns an array that is currently shown with a bareplt.imshow(upstream_map)— no coordinates, no north, arbitrary pixel axes. The rasters are georeferenced to OSGB36 / British National Grid (EPSG:27700), so the examples should at minimum pass a correctextent=in eastings/northings with labelled axes, and ideally overlay the sample sites and the drainage network. That makes the output directly comparable to the same data loaded in QGIS.Related
plot_sweep_of_regularizer_strengthreturnsNoneand discards its solutions, so an example can't do anything with the misfit-roughness curve programmatically; and its docstring claims it prints values, which it does not. Worth addressing at the same time.