Skip to content

Commit

Permalink
Pyatoa v0.4.2 (#49)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bch0w authored Nov 20, 2024
1 parent 69261bb commit 3605c7c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions pyatoa/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions pyatoa/visuals/wave_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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)

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3605c7c

Please sign in to comment.