test_spaceWeatherData

test_spaceWeatherData.test_failed_reload_preserves_previous_table()[source]

A failed second loadSpaceWeatherFile call must not destroy the first table.

Test Description

A valid CSV is loaded first, giving a working weather table. A second call is then made with a file that has a missing required column. The second load must fail (emitting BSK_ERROR) while leaving the module still able to serve data from the first load.

Description of Variables Being Tested

swDataOutMsgs[0].dataValue equals the expected AP_AVG value from the first table after the failed reload.

test_spaceWeatherData.test_inf_in_f107_field_rejected()[source]

An Inf string in an F10.7 column must be rejected.

Test Description

A CSV row with inf in the F10.7_OBS column is loaded. The strict numeric parser must reject the non-finite value.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_april_31_rejected()[source]

April 31 does not exist — the row must be rejected.

Test Description

A CSV with a single row dated 2026-04-31 is loaded. April has only 30 days, so the parser must reject the row and emit BSK_ERROR with "No valid weather rows were loaded".

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_day_zero_rejected()[source]

Day 0 is never valid — the row must be rejected.

Test Description

A CSV with a single row dated 2026-03-00 is loaded. Day-of-month zero is out of range for every month.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_feb_29_century_non_leap_rejected()[source]

February 29 in a century year that is not a 400-multiple must be rejected.

Test Description

2100 is divisible by 4 but not by 400, so it is not a leap year and February has only 28 days.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_feb_29_non_leap_rejected()[source]

February 29 in a non-leap year must be rejected.

Test Description

A CSV with a single row dated 2025-02-29 is loaded. 2025 is not a leap year (not divisible by 4), so February has only 28 days.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_feb_30_rejected()[source]

February 30 never exists — the row must be rejected.

Test Description

A CSV with a single row dated 2024-02-30 is loaded. Even in the leap year 2024, February has only 29 days, so the parser must reject it.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_month_13_rejected()[source]

Month 13 is never valid — the row must be rejected.

Test Description

A CSV with a single row dated 2026-13-01 is loaded. Month 13 is out of the valid [1, 12] range.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_month_zero_rejected()[source]

Month 0 is never valid — the row must be rejected.

Test Description

A CSV with a single row dated 2026-00-15 is loaded. Month zero is out of the valid [1, 12] range.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_invalid_date_november_31_rejected()[source]

November 31 does not exist — the row must be rejected.

Test Description

A CSV with a single row dated 2026-11-31 is loaded. November has only 30 days, so the parser must reject the row and emit BSK_ERROR.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_nan_in_ap_field_rejected()[source]

A NaN string in an AP column must be rejected.

Test Description

A CSV row with nan in the AP1 column is loaded. The strict numeric parser must reject the non-finite value, leaving the table empty.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_neg_inf_in_ap_avg_field_rejected()[source]

-Inf in the AP_AVG column must be rejected.

Test Description

A CSV row with -inf in AP_AVG is loaded. Negative infinity is non-finite and must be rejected by the strict numeric parser.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile.

test_spaceWeatherData.test_reset_error_when_epoch_before_table()[source]

Validate that Reset emits BSK_ERROR when the epoch date is not in the table.

Test Description

The simulation epoch is set to 2026-02-27, one day before the first row of the loaded table (2026-02-28). The Reset probe calls computeSwState at initialisation time; the four-day look-back window cannot be assembled and a BSK_ERROR is emitted, which Basilisk converts to a BasiliskError.

Description of Variables Being Tested

BasiliskError raised during InitializeSimulation with the message "simulation start date is not covered".

test_spaceWeatherData.test_space_weather_data_celestrak_example_columns()[source]

Validate parsing against the provided CelesTrak-style rows.

Test Description

This test uses the provided CelesTrak CSV rows and validates output values against the supplied ground-truth weather channel values.

Description of Variables Being Tested

The test checks all 23 outputs in swDataOutMsgs against known values for the epoch 2026-03-04 21:48:00.

test_spaceWeatherData.test_space_weather_data_duplicate_date_rows()[source]

Validate duplicate DATE rows are rejected and zero-state output is published.

Test Description

This test provides duplicate DATE rows in the weather table. The module should reject the file and publish zero outputs.

Description of Variables Being Tested

The test checks all 23 weather outputs and verifies every value is zero.

test_spaceWeatherData.test_space_weather_data_epoch_update()[source]

Validate internal epoch update against the provided CelesTrak-style rows.

Test Description

This test uses the provided CelesTrak CSV rows and validates output values at a future epoch against the supplied ground-truth weather channel values.

Description of Variables Being Tested

The test checks all 23 outputs in swDataOutMsgs against known values for the epoch 2026-03-04 21:48:00 starting the simulation at 2026-03-03 18:48:00 and propagating the simulation for 1 day and 3 hours.

test_spaceWeatherData.test_space_weather_data_missing_required_column()[source]

Validate missing required CSV columns lead to zero-state output publication.

Test Description

This test removes F10.7_OBS_CENTER81 from the CSV header and checks that the module cannot build a valid weather table and thus publishes zeros.

Description of Variables Being Tested

The test checks all 23 weather outputs and verifies every value is zero.

test_spaceWeatherData.test_space_weather_data_rejects_date_with_trailing_chars()[source]

Validate that a DATE token with trailing characters is rejected.

Test Description

This test writes a CSV whose only data row has 2026-03-04junk in the DATE column. The parser must reject the row; the table is left empty and loadSpaceWeatherFile emits BSK_ERROR.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile with the message "No valid weather rows were loaded".

test_spaceWeatherData.test_space_weather_data_rejects_numeric_with_trailing_chars()[source]

Validate that a numeric field with trailing characters is rejected.

Test Description

This test writes a CSV whose only data row has 9abc in the AP1 column. The strict numeric parser must reject the row; the table is left empty and loadSpaceWeatherFile emits BSK_ERROR.

Description of Variables Being Tested

BasiliskError raised during loadSpaceWeatherFile with the message "No valid weather rows were loaded".

test_spaceWeatherData.test_space_weather_data_stops_at_first_invalid_row()[source]

Validate reading stops at the first invalid row (e.g., PRM monthly line).

Test Description

This test appends invalid PRM-style rows with missing AP fields after valid daily rows and verifies that the valid section is still used correctly.

Description of Variables Being Tested

The test checks the 23 weather outputs against the same ground-truth values as the valid CelesTrak example set.

test_spaceWeatherData.test_space_weather_data_unsorted_rows()[source]

Validate unsorted DATE rows are rejected and zero-state output is published.

Test Description

This test provides weather rows out of chronological order. The loader should reject the table and the module should publish zero outputs.

Description of Variables Being Tested

The test checks all 23 weather outputs and verifies every value is zero.

test_spaceWeatherData.test_stale_output_retained_on_missing_day()[source]

Validate that outputs are not overwritten when a required day is missing.

Test Description

The simulation runs two stages with the same module instance. In stage 1 (t = 1 s, epoch 2026-03-04) the look-up succeeds and known values are written. In stage 2 (t = 25 h + 1 s) D0 advances to 2026-03-05 which is absent from the table; the module must log BSK_WARNING and return without writing, leaving the outputs at the stage-1 values.

Description of Variables Being Tested

  • swDataOutMsgs[0] (ap_24_0, AP_AVG): 6.0 after both stages.

  • swDataOutMsgs[21] (f107_1944_0, F10.7c81): 138.5 after both stages.

test_spaceWeatherData.test_valid_date_feb_29_leap_accepted()[source]

February 29 in a leap year must be accepted.

Test Description

A four-row CSV that includes 2024-02-29 (2024 is a leap year) is loaded and the simulation is run with the epoch on 2024-03-02 12:00:00 so that the look-back window covers 2024-02-29. The table must load successfully and produce a finite ap_24_0 output.

Description of Variables Being Tested

swDataOutMsgs[0].dataValue is non-zero after a successful look-up.

test_spaceWeatherData.test_valid_date_feb_29_quad_century_leap_accepted()[source]

February 29 in a 400-multiple year (true leap) must be accepted.

Test Description

2000 is divisible by 400 and therefore is a leap year. A single row dated 2000-02-29 must not be rejected by the date validator. The test loads a four-row table that includes this date and verifies loadSpaceWeatherFile succeeds (no exception raised).

Description of Variables Being Tested

No exception from loadSpaceWeatherFile.