specfem::io::seismogram_writer¶
-
class seismogram_writer : public specfem::io::writer, public specfem::io::impl::ChannelGenerator¶
Writer for outputting seismograms at receiver locations.
Records displacement, velocity, or acceleration at receiver stations and writes time series to disk. Supports multiple output formats and wave types, with configurable sampling intervals.
Public Functions
-
inline seismogram_writer(const specfem::enums::seismogram_format type, const specfem::enums::elastic_wave elastic_wave, const specfem::enums::electromagnetic_wave electromagnetic_wave, const std::string output_folder, const type_real dt, const type_real t0, const int nstep_between_samples, std::optional<specfem::datetime::type> starttime = std::nullopt, const std::optional<bool> write_from_main = std::nullopt)¶
Construct a new seismogram writer object.
- Parameters:
type – Format of the output file
output_folder – path to output folder where results will be stored
dt – Time interval between subsequent timesteps
t0 – Solver start time
nstep_between_samples – number of timesteps between seismogram sampling (seismogram sampling frequency)
-
inline virtual void write(specfem::assembly::assembly<specfem::element::dimension_tag::dim2> &assembly) override¶
Method to execute the write operation.
- Parameters:
assembly – 2D Assembly object
-
inline virtual void write(specfem::assembly::assembly<specfem::element::dimension_tag::dim3> &assembly) override¶
Method to execute the write operation.
- Parameters:
assembly – 3D Assembly object
-
inline type_real get_timestep() const¶
Returns the simulation timestep (dt) in seconds.
- Returns:
type_real Simulation time step used to construct this generator.
-
std::vector<std::string> get_station_filenames(const std::string &network_name, const std::string &station_name, const std::string &location_code, specfem::enums::wavefield seismogram_type, std::span<const char> elastic_components = {kDefaultElasticComponents})¶
Generates SEED-compliant seismogram filenames for a given station.
- Parameters:
network_name – SEED network code.
station_name – SEED station code.
location_code – SEED location ID (e.g. “S2”, “S3”).
seismogram_type – Wavefield type to output.
elastic_components – Component letters for elastic seismograms. Defaults to {‘X’,’Y’,’Z’} for 3-D. Pass {‘X’,’Z’} for 2-D. Ignored for pressure seismograms (always single ‘P’ component).
- Returns:
std::vector<std::string> Filenames, one per component.
-
template<specfem::element::dimension_tag DimensionTag, typename StationInfo>
inline std::vector<std::string> get_station_filenames(const StationInfo &station_info, specfem::enums::wavefield seismogram_type)¶ Generate output filenames for one station/seismogram-type pair.
Overload that accepts a StationInfo object directly and derives the SEED location code and component letters from the simulation dimension (“S3”/{X,Y,Z} for 3-D, “S2”/{X,Z} for 2-D).
- Template Parameters:
DimensionTag – Simulation dimension (dim2 or dim3).
StationInfo – Type with public network_name and station_name members.
- Parameters:
station_info – Station descriptor from StationIterator.
seismogram_type – Wavefield type to write.
-
inline std::string get_band_code() const¶
Returns the SEED band code for this generator.
The band code is determined from the simulation timestep and follows FDSN conventions for broad-band instruments. Valid codes are:
’L’: Long Period ( \( dt \geq 1.0 \) s, \( \approx 1 \) Hz)
’M’: Mid Period ( \( 0.1 < dt < 1.0 \) s, \( > 1 \) to \( < 10 \) Hz)
’B’: Broad Band ( \( 0.0125 < dt \leq 0.1 \) s, \( \geq 10 \) to \( < 80 \) Hz)
’H’: High Broad Band ( \( 0.004 < dt \leq 0.0125 \) s, \( \geq 80 \) to \( < 250 \) Hz)
’C’: Band C ( \( 0.001 < dt \leq 0.004 \) s, \( \geq 250 \) to \( < 1000 \) Hz)
’F’: Band F ( \( dt \leq 0.001 \) s, \( \geq 1000 \) Hz)
See also
compute_band_code() for the mapping algorithm
- Returns:
std::string Single-character band code
-
std::string get_channel_code(const char component_letter)¶
Generates a three-character SEED channel code for synthetic seismograms.
Constructs a SEED channel code following the format: [Band][Instrument][Orientation]
Band code: Determined from simulation timestep (L, M, B, H, C, or F)
Instrument code: ‘X’ indicating derived/synthetic data
Orientation code: Component direction (X, Y, Z, N, E, P, etc.)
The ‘X’ instrument code denotes “Derived or Generated Channel” per SEED standards, indicating this is synthetic data from numerical simulation rather than direct instrumental recording.
specfem::io::ChannelGenerator gen(0.05); // dt=0.05s → Band B std::string channel_z = gen.get_channel_code('Z'); // Returns "BXZ" std::string channel_n = gen.get_channel_code('N'); // Returns "BXN"
See also
https://ds.iris.edu/ds/nodes/dmc/data/formats/seed-channel-naming/#derived-or-generated-channel
- Parameters:
component_letter – Single character specifying component orientation (e.g., ‘X’, ‘Y’, ‘Z’, ‘P’)
- Returns:
std::string Three-character SEED channel code (e.g., “BXZ”, “HXN”, “LXP”)
-
std::string get_file_extension(specfem::enums::wavefield seismogram_type)¶
Returns the file extension for a given seismogram type.
Maps wavefield types to standardized SPECFEM++ file extensions:
displacement → “semd”
velocity → “semv”
acceleration → “sema”
pressure → “semp”
- Parameters:
seismogram_type – Type of wavefield output
- Throws:
std::runtime_error – If seismogram_type is not supported
- Returns:
std::string File extension without leading dot
-
inline seismogram_writer(const specfem::enums::seismogram_format type, const specfem::enums::elastic_wave elastic_wave, const specfem::enums::electromagnetic_wave electromagnetic_wave, const std::string output_folder, const type_real dt, const type_real t0, const int nstep_between_samples, std::optional<specfem::datetime::type> starttime = std::nullopt, const std::optional<bool> write_from_main = std::nullopt)¶