Skip to content

Commit

Permalink
Write software name and version to HDF5 files
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Apr 4, 2024
1 parent 859403b commit b072065
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sourcespec/source_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from argparse import ArgumentParser
import matplotlib
import matplotlib.pyplot as plt
from sourcespec._version import get_versions
from sourcespec.spectrum import read_spectra
from sourcespec.ssp_util import moment_to_mag, mag_to_moment
from sourcespec.spectrum import SpectrumStream
Expand Down Expand Up @@ -131,7 +132,8 @@ def compute_mean_residuals(residual_dict, min_spectra=20):
norm_mean += norm
spec_mean.data_mag /= norm_mean
spec_mean.data = mag_to_moment(spec_mean.data_mag)

spec_mean.stats.software = 'SourceSpec'
spec_mean.stats.software_version = get_versions()['version']
residual_mean.append(spec_mean)
return residual_mean

Expand Down
3 changes: 3 additions & 0 deletions sourcespec/ssp_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,8 @@ def save_spectra(config, spec_st):
f'{config.event.event_id}.spectra.hdf5'
)
spec_st.sort()
for spec in spec_st:
spec.stats.software = 'SourceSpec'
spec.stats.software_version = get_versions()['version']
spec_st.write(outfile)
logger.info(f'Spectra saved to: {outfile}')
3 changes: 3 additions & 0 deletions sourcespec/ssp_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
import os
import logging
from sourcespec._version import get_versions
from sourcespec.spectrum import SpectrumStream
from sourcespec.ssp_spectral_model import spectral_model
from sourcespec.ssp_util import mag_to_moment
Expand Down Expand Up @@ -47,6 +48,8 @@ def spectral_residuals(config, spec_st, sspec_output):
res = spec.copy()
res.data_mag = spec.data_mag - synth_mean_mag
res.data = mag_to_moment(res.data_mag)
res.stats.software = 'SourceSpec'
res.stats.software_version = get_versions()['version']
residuals.append(res)
# Save residuals to HDF5 file
evid = config.event.event_id
Expand Down

0 comments on commit b072065

Please sign in to comment.