Mercurial > repos > muon-spectroscopy-computational-project > larch_plot
annotate larch_plot.py @ 0:886949a03377 draft
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
| author | muon-spectroscopy-computational-project | 
|---|---|
| date | Tue, 14 Nov 2023 15:35:36 +0000 | 
| parents | |
| children | 002c18a3e642 | 
| rev | line source | 
|---|---|
| 0 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 1 import json | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 2 import sys | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 3 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 4 from common import read_groups | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 5 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 6 import matplotlib | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 7 import matplotlib.pyplot as plt | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 8 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 9 import numpy as np | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 10 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 11 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 12 Y_LABELS = { | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 13 "norm": r"x$\mu$(E), normalised", | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 14 "dmude": r"d(x$\mu$(E))/dE, normalised", | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 15 "chir_mag": r"|$\chi$(r)|", | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 16 } | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 17 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 18 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 19 def main(dat_files: "list[str]", plot_settings: "list[dict]"): | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 20 groups = list(read_groups(dat_files)) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 21 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 22 for i, settings in enumerate(plot_settings): | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 23 data_list = [] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 24 e0_min = None | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 25 e0_max = None | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 26 variable = settings["variable"]["variable"] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 27 x_min = settings["variable"]["energy_min"] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 28 x_max = settings["variable"]["energy_max"] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 29 plot_path = f"plots/{i}_{variable}.png" | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 30 plt.figure() | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 31 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 32 for group in groups: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 33 label = group.athena_params.annotation or group.athena_params.id | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 34 if variable == "chir_mag": | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 35 x = group.r | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 36 energy_format = None | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 37 else: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 38 x = group.energy | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 39 energy_format = settings["variable"]["energy_format"] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 40 if energy_format == "relative": | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 41 e0 = group.athena_params.bkg.e0 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 42 e0_min = find_relative_limit(e0_min, e0, min) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 43 e0_max = find_relative_limit(e0_max, e0, max) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 44 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 45 y = getattr(group, variable) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 46 if x_min is None and x_max is None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 47 plt.plot(x, y, label=label) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 48 else: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 49 data_list.append({"x": x, "y": y, "label": label}) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 50 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 51 if variable != "chir_mag" and energy_format == "relative": | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 52 if x_min is not None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 53 x_min += e0_min | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 54 if x_max is not None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 55 x_max += e0_max | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 56 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 57 if x_min is not None or x_max is not None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 58 for data in data_list: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 59 index_min = None | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 60 index_max = None | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 61 x = data["x"] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 62 if x_min is not None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 63 index_min = max(np.searchsorted(x, x_min) - 1, 0) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 64 if x_max is not None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 65 index_max = min(np.searchsorted(x, x_max) + 1, len(x)) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 66 plt.plot( | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 67 x[index_min:index_max], | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 68 data["y"][index_min:index_max], | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 69 label=data["label"], | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 70 ) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 71 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 72 plt.xlim(x_min, x_max) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 73 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 74 save_plot(variable, plot_path) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 75 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 76 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 77 def find_relative_limit(e0_min: "float|None", e0: float, function: callable): | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 78 if e0_min is None: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 79 e0_min = e0 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 80 else: | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 81 e0_min = function(e0_min, e0) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 82 return e0_min | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 83 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 84 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 85 def save_plot(y_type: str, plot_path: str): | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 86 plt.grid(color="r", linestyle=":", linewidth=1) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 87 plt.xlabel("Energy (eV)") | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 88 plt.ylabel(Y_LABELS[y_type]) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 89 plt.legend() | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 90 plt.savefig(plot_path, format="png") | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 91 plt.close("all") | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 92 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 93 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 94 if __name__ == "__main__": | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 95 # larch imports set this to an interactive backend, so need to change it | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 96 matplotlib.use("Agg") | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 97 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 98 dat_files = sys.argv[1] | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 99 input_values = json.load(open(sys.argv[2], "r", encoding="utf-8")) | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 100 | 
| 
886949a03377
planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 5be486890442dedfb327289d597e1c8110240735
 muon-spectroscopy-computational-project parents: diff
changeset | 101 main(dat_files.split(","), input_values["plots"]) | 
