diff --git a/CHANGELOG.md b/CHANGELOG.md index 85ab46a..6801408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # CHANGELOG + +## v0.4.2 (#48) + +- Remove plot axis formatter which forced axis bounds [0,1] in some instances +- Bugfix synthetic waveform label was being incorrectly set +- Changed misfit label $\chi$ format from float to scientific notation as misfit can be << 1 +- Allow Manager.load() to work even without valid StationXML attribute in ASFDataSet + +## v0.4.1 + +- Bugfix: no window selection did not allow measure to be called due to some + incorrect referencing + ## v0.4.0 >__Note__: Mainly improvements to the Inspector class and its ability to diff --git a/pyatoa/core/manager.py b/pyatoa/core/manager.py index 9a0069b..6953d9d 100755 --- a/pyatoa/core/manager.py +++ b/pyatoa/core/manager.py @@ -492,11 +492,14 @@ def load(self, code=None, path=None, ds=None, synthetic_tag=None, net, sta = code.split('.') sta_tag = f"{net}.{sta}" if sta_tag in ds.waveforms.list(): - self.inv = ds.waveforms[sta_tag].StationXML self.st_syn = ds.waveforms[sta_tag][synthetic_tag or self.config.synthetic_tag] self.st_obs = ds.waveforms[sta_tag][observed_tag or self.config.observed_tag] + try: + self.inv = ds.waveforms[sta_tag].StationXML + except AttributeError: + logger.warning("no StationXML attribute found for station") if windows: self.windows = load_windows(ds, net, sta, iter_, step, return_previous=False) @@ -1239,7 +1242,8 @@ def _format_windows(self): else: logger.debug("no windows given, adjoint sources will be " "calculated on full trace") - for comp in self.config.component_list: + component_list = list(set(_.stats.component for _ in self.st_syn)) + for comp in component_list: dt = self.st_obs.select(component=comp)[0].stats.delta npts = self.st_obs.select(component=comp)[0].stats.npts # We offset the bounds of the entire trace by 1s to play nice diff --git a/pyatoa/tests/test_data/baseline_images/default_manager_plot_wav.png b/pyatoa/tests/test_data/baseline_images/default_manager_plot_wav.png index a3cfd00..65b3301 100644 Binary files a/pyatoa/tests/test_data/baseline_images/default_manager_plot_wav.png and b/pyatoa/tests/test_data/baseline_images/default_manager_plot_wav.png differ diff --git a/pyatoa/visuals/wave_maker.py b/pyatoa/visuals/wave_maker.py index d8ac74e..4ad029d 100644 --- a/pyatoa/visuals/wave_maker.py +++ b/pyatoa/visuals/wave_maker.py @@ -6,6 +6,7 @@ Flexible to allow for only waveform plots, or for the addition of objects based on inputs. """ +from re import I import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt @@ -227,7 +228,7 @@ def plot_waveforms(self, ax, obs, syn, normalize=False): label=f"{obs.id} ({self.config.st_obs_type.upper()})", linewidth=linewidth) a2, = ax.plot(self.time_axis, syn.data, syn_color, zorder=10, - label=f"{syn.id} ({self.config.st_obs_type.upper()})", + label=f"{syn.id} ({self.config.st_syn_type.upper()})", linewidth=linewidth) return [a1, a2] @@ -485,7 +486,7 @@ def plot_adjsrcs(self, ax, adjsrc): b1, = ax.plot(self.time_axis, adjsrc.adjoint_source[::-1], color, alpha=alpha, linewidth=linewidth, linestyle=linestyle, zorder=9, - label=fr"Adjoint Source ($\chi$={adjsrc.misfit:.2f})" + label=fr"Adjoint Source ($\chi$={adjsrc.misfit:.3E})" ) return [b1] @@ -773,13 +774,11 @@ def format_axis(input_ax, percent_over=0.125): :param percent_over: the percentage above the peak value that the bounds of the axis will be set """ - ymin, ymax = input_ax.get_ylim() maxvalue = max([abs(_) for _ in input_ax.get_ylim()]) percent_over = maxvalue * percent_over - if abs(round(ymin / ymax)) != 0: - # Set bounds to be the same positive and negative - bounds = (-1 * (maxvalue + percent_over), (maxvalue + percent_over)) - else: - bounds = (-0.05, 1.05) + + # Set bounds to be the same positive and negative + bounds = (-1 * (maxvalue + percent_over), (maxvalue + percent_over)) + input_ax.set_ylim(bounds) diff --git a/pyproject.toml b/pyproject.toml index 7568721..4536c68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pyatoa" -version = "0.4.0" +version = "0.4.2" description = "Python's Adjoint Tomography Operations Assistant" readme = "README.md" requires-python = ">=3.7"