Skip to content

Commit 3605c7c

Browse files
authored
Pyatoa v0.4.2 (#49)
* Bugfi: measure with no windows (#47) * bugfix: when component list does not match the internal streams (e.g., seisflows inversion that is processing one component at a time), and no windows are selected, measure fails to run and throws an IndexError because it's tries to index out of the Stream. fixed to remove dependence on component list * bump version and update changelog * Bugfix Incorrectly scaled waveform plots (#48) * allow Manager.load() to work without the need for a StationXML attribute, which happens for synthetic only cases * removed plotting axis formatter which was forcing axis bounds [0,1] when the fraction between min and max y lim values was <1, which will happen if only have positive or negative values, but we don't want this to happen because we will likely always want plots to straddle 0, especially when showing adjoint sources which will straddle 0 even if waveforms are all one value * bugfix label for synthetic waveforms was incorrect * change misfit label formatting on waveform plots from floating point to sci notation as misfit is usually << 1 * updating test figure * bump patch version and update changelog
1 parent 69261bb commit 3605c7c

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# CHANGELOG
22

3+
4+
## v0.4.2 (#48)
5+
6+
- Remove plot axis formatter which forced axis bounds [0,1] in some instances
7+
- Bugfix synthetic waveform label was being incorrectly set
8+
- Changed misfit label $\chi$ format from float to scientific notation as misfit can be << 1
9+
- Allow Manager.load() to work even without valid StationXML attribute in ASFDataSet
10+
11+
## v0.4.1
12+
13+
- Bugfix: no window selection did not allow measure to be called due to some
14+
incorrect referencing
15+
316
## v0.4.0
417

518
>__Note__: Mainly improvements to the Inspector class and its ability to

pyatoa/core/manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,14 @@ def load(self, code=None, path=None, ds=None, synthetic_tag=None,
492492
net, sta = code.split('.')
493493
sta_tag = f"{net}.{sta}"
494494
if sta_tag in ds.waveforms.list():
495-
self.inv = ds.waveforms[sta_tag].StationXML
496495
self.st_syn = ds.waveforms[sta_tag][synthetic_tag or
497496
self.config.synthetic_tag]
498497
self.st_obs = ds.waveforms[sta_tag][observed_tag or
499498
self.config.observed_tag]
499+
try:
500+
self.inv = ds.waveforms[sta_tag].StationXML
501+
except AttributeError:
502+
logger.warning("no StationXML attribute found for station")
500503
if windows:
501504
self.windows = load_windows(ds, net, sta, iter_, step,
502505
return_previous=False)
@@ -1239,7 +1242,8 @@ def _format_windows(self):
12391242
else:
12401243
logger.debug("no windows given, adjoint sources will be "
12411244
"calculated on full trace")
1242-
for comp in self.config.component_list:
1245+
component_list = list(set(_.stats.component for _ in self.st_syn))
1246+
for comp in component_list:
12431247
dt = self.st_obs.select(component=comp)[0].stats.delta
12441248
npts = self.st_obs.select(component=comp)[0].stats.npts
12451249
# We offset the bounds of the entire trace by 1s to play nice
3.29 KB
Loading

pyatoa/visuals/wave_maker.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Flexible to allow for only waveform plots, or for the addition of objects
77
based on inputs.
88
"""
9+
from re import I
910
import numpy as np
1011
import matplotlib as mpl
1112
import matplotlib.pyplot as plt
@@ -227,7 +228,7 @@ def plot_waveforms(self, ax, obs, syn, normalize=False):
227228
label=f"{obs.id} ({self.config.st_obs_type.upper()})",
228229
linewidth=linewidth)
229230
a2, = ax.plot(self.time_axis, syn.data, syn_color, zorder=10,
230-
label=f"{syn.id} ({self.config.st_obs_type.upper()})",
231+
label=f"{syn.id} ({self.config.st_syn_type.upper()})",
231232
linewidth=linewidth)
232233

233234
return [a1, a2]
@@ -485,7 +486,7 @@ def plot_adjsrcs(self, ax, adjsrc):
485486
b1, = ax.plot(self.time_axis, adjsrc.adjoint_source[::-1], color,
486487
alpha=alpha, linewidth=linewidth, linestyle=linestyle,
487488
zorder=9,
488-
label=fr"Adjoint Source ($\chi$={adjsrc.misfit:.2f})"
489+
label=fr"Adjoint Source ($\chi$={adjsrc.misfit:.3E})"
489490
)
490491
return [b1]
491492

@@ -773,13 +774,11 @@ def format_axis(input_ax, percent_over=0.125):
773774
:param percent_over: the percentage above the peak value that the bounds
774775
of the axis will be set
775776
"""
776-
ymin, ymax = input_ax.get_ylim()
777777
maxvalue = max([abs(_) for _ in input_ax.get_ylim()])
778778
percent_over = maxvalue * percent_over
779-
if abs(round(ymin / ymax)) != 0:
780-
# Set bounds to be the same positive and negative
781-
bounds = (-1 * (maxvalue + percent_over), (maxvalue + percent_over))
782-
else:
783-
bounds = (-0.05, 1.05)
779+
780+
# Set bounds to be the same positive and negative
781+
bounds = (-1 * (maxvalue + percent_over), (maxvalue + percent_over))
782+
784783
input_ax.set_ylim(bounds)
785784

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyatoa"
7-
version = "0.4.0"
7+
version = "0.4.2"
88
description = "Python's Adjoint Tomography Operations Assistant"
99
readme = "README.md"
1010
requires-python = ">=3.7"

0 commit comments

Comments
 (0)