geopulse.sources.base
Abstract base class for magnetic-field data sources.
Every source adapter (SuperMAG, INTERMAGNET, synthetic, MHD) implements this
interface. Downstream modules (efield, network) never know or care which
source produced the B-field data — they only see
BFieldTimeSeries.
Design principle: load raw data → convert to SI (Tesla) at the boundary → return a standardised container.
Classes
Abstract base class for magnetic-field data sources. |
|
|
Standardised magnetic-field time-series container. |
- class geopulse.sources.base.BFieldSource[source]
Bases:
ABCAbstract base class for magnetic-field data sources.
Subclasses must implement
load()which returns aBFieldTimeSeries. All unit conversion (nT → T, local time → UTC epoch seconds) happens inside the subclass, never downstream.Examples
>>> source = SyntheticSource(waveform="gaussian_pulse", amplitude_nT=500) >>> b = source.load(start_s=0, end_s=3600, dt_s=1.0) >>> b.bx_T.shape (3600,)
- abstractmethod load(start_s, end_s, dt_s=1.0, station_id='SYN')[source]
Load or generate magnetic-field data for the given time window.
- Parameters:
- Return type:
- Returns:
BFieldTimeSeries – Validated, SI-unit magnetic-field data.
- to_frequency_domain(b_data)[source]
Compute the FFT of the horizontal B-field components.
Concrete helper — NOT abstract — because the FFT is identical regardless of source type.
- Parameters:
b_data (
BFieldTimeSeries) – Time-domain magnetic-field data.- Return type:
- Returns:
freqs_Hz (numpy.ndarray) – Frequency array in Hz. Shape:
(n_freqs,). Positive frequencies only, including DC and Nyquist.Bx_f (numpy.ndarray) – FFT of
bx_Tin Tesla. Shape:(n_freqs,), complex.By_f (numpy.ndarray) – FFT of
by_Tin Tesla. Shape:(n_freqs,), complex.
Notes
Uses
scipy.fft.rfft()for real-valued input.
- class geopulse.sources.base.BFieldTimeSeries(time_s, bx_T, by_T, bz_T, station_id, latitude_deg, longitude_deg, sampling_rate_Hz=0.0, metadata=<factory>)[source]
Bases:
objectStandardised magnetic-field time-series container.
All values are in SI units (Tesla for field, seconds for time). This is the ONLY object that crosses the source → efield boundary.
- Parameters:
- time_s
Time array in seconds since epoch. Shape:
(n_times,). Must be monotonically increasing with (approximately) uniform spacing.- Type:
- bx_T
North-south magnetic-field component in Tesla. Shape:
(n_times,). Geographic north positive.- Type:
- by_T
East-west magnetic-field component in Tesla. Shape:
(n_times,). Geographic east positive.- Type:
- bz_T
Vertical component in Tesla. Downward positive (geophysics convention).
- Type:
Notes
Frozen dataclass — immutable after construction. To modify, build a new instance.