Skip to content

FileSpaceWeatherProvider

Load space weather data from CSSI format files.

FileSpaceWeatherProvider

FileSpaceWeatherProvider()

File-based Space Weather provider.

Loads space weather data from CSSI format files and provides extrapolation capabilities.

Example
import brahe as bh

# Create from file
sw = bh.FileSpaceWeatherProvider.from_file(
    "./sw_data/sw19571001.txt",
    extrapolate="Hold"
)

# Use default packaged file
sw = bh.FileSpaceWeatherProvider.from_default_file()

# Set as global provider
bh.set_global_space_weather_provider(sw)

# Get data for a specific MJD
mjd = 60000.0
kp = sw.get_kp(mjd)
ap = sw.get_ap_daily(mjd)
f107 = sw.get_f107_observed(mjd)

Initialize instance.

extrapolation method descriptor

extrapolation() -> str

Get the extrapolation method.

Returns:

Name Type Description
str str

Extrapolation method string

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Extrapolation: {sw.extrapolation()}")  # "Hold"

from_default_file builtin

from_default_file() -> FileSpaceWeatherProvider

Create provider from the default packaged space weather file.

Returns:

Name Type Description
FileSpaceWeatherProvider FileSpaceWeatherProvider

Provider initialized with default file

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
bh.set_global_space_weather_provider(sw)

from_file builtin

from_file(filepath: str, extrapolate: str) -> FileSpaceWeatherProvider

Create provider from a CSSI space weather file.

Parameters:

Name Type Description Default
filepath str

Path to CSSI space weather file

required
extrapolate str

Extrapolation method ("Hold", "Zero", or "Error")

required

Returns:

Name Type Description
FileSpaceWeatherProvider FileSpaceWeatherProvider

Provider initialized with file data

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_file("./sw19571001.txt", "Hold")
bh.set_global_space_weather_provider(sw)

get_ap method descriptor

get_ap(mjd: float) -> float

Get Ap index for the specified MJD.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

Ap index

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ap = sw.get_ap(60000.0)
print(f"Ap: {ap}")

get_ap_all method descriptor

get_ap_all(mjd: float) -> list[float]

Get all eight 3-hourly Ap indices for the day.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Type Description
list[float]

list[float]: Array of 8 Ap indices

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ap_all = sw.get_ap_all(60000.0)
print(f"8 Ap indices: {ap_all}")

get_ap_daily method descriptor

get_ap_daily(mjd: float) -> float

Get daily average Ap index.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

Daily average Ap

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ap_daily = sw.get_ap_daily(60000.0)
print(f"Daily Ap: {ap_daily}")

get_f107_adj_avg81 method descriptor

get_f107_adj_avg81(mjd: float) -> float

Get 81-day centered average adjusted F10.7 flux.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

81-day average adjusted F10.7 flux in sfu

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
f107_adj_avg = sw.get_f107_adj_avg81(60000.0)
print(f"F10.7 adj 81-day avg: {f107_adj_avg} sfu")

get_f107_adjusted method descriptor

get_f107_adjusted(mjd: float) -> float

Get adjusted F10.7 solar flux.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

Adjusted F10.7 flux in sfu

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
f107_adj = sw.get_f107_adjusted(60000.0)
print(f"F10.7 adjusted: {f107_adj} sfu")

get_f107_obs_avg81 method descriptor

get_f107_obs_avg81(mjd: float) -> float

Get 81-day centered average observed F10.7 flux.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

81-day average F10.7 flux in sfu

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
f107_avg = sw.get_f107_obs_avg81(60000.0)
print(f"F10.7 81-day avg: {f107_avg} sfu")

get_f107_observed method descriptor

get_f107_observed(mjd: float) -> float

Get observed F10.7 solar flux.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

F10.7 flux in sfu

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
f107 = sw.get_f107_observed(60000.0)
print(f"F10.7: {f107} sfu")

get_kp method descriptor

get_kp(mjd: float) -> float

Get Kp index for the specified MJD.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

Kp index (0.0-9.0)

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
kp = sw.get_kp(60000.0)
print(f"Kp: {kp}")

get_kp_all method descriptor

get_kp_all(mjd: float) -> list[float]

Get all eight 3-hourly Kp indices for the day.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Type Description
list[float]

list[float]: Array of 8 Kp indices

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
kp_all = sw.get_kp_all(60000.0)
print(f"8 Kp indices: {kp_all}")

get_kp_daily method descriptor

get_kp_daily(mjd: float) -> float

Get daily average Kp index.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
float float

Daily average Kp

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
kp_daily = sw.get_kp_daily(60000.0)
print(f"Daily Kp: {kp_daily}")

get_last_ap method descriptor

get_last_ap(mjd: float, n: int) -> list[float]

Get the last N 3-hourly Ap values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of values to return

required

Returns:

Type Description
list[float]

list[float]: Ap values, oldest first

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ap_last = sw.get_last_ap(60000.0, 8)
print(f"Last 8 Ap values: {ap_last}")

get_last_daily_ap method descriptor

get_last_daily_ap(mjd: float, n: int) -> list[float]

Get the last N daily average Ap values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of values to return

required

Returns:

Type Description
list[float]

list[float]: Daily Ap values, oldest first

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ap_daily_last = sw.get_last_daily_ap(60000.0, 7)
print(f"Last 7 daily Ap: {ap_daily_last}")

get_last_daily_epochs method descriptor

get_last_daily_epochs(mjd: float, n: int) -> list[Epoch]

Get epochs for the last N daily values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of epochs to return

required

Returns:

Type Description
list[Epoch]

list[Epoch]: Epoch objects, oldest first

Example
1
2
3
4
5
6
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
epochs = sw.get_last_daily_epochs(60000.0, 7)
for epoch in epochs:
    print(f"Epoch: {epoch}")

get_last_daily_kp method descriptor

get_last_daily_kp(mjd: float, n: int) -> list[float]

Get the last N daily average Kp values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of values to return

required

Returns:

Type Description
list[float]

list[float]: Daily Kp values, oldest first

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
kp_daily_last = sw.get_last_daily_kp(60000.0, 7)
print(f"Last 7 daily Kp: {kp_daily_last}")

get_last_f107 method descriptor

get_last_f107(mjd: float, n: int) -> list[float]

Get the last N daily F10.7 values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of values to return

required

Returns:

Type Description
list[float]

list[float]: F10.7 values in sfu, oldest first

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
f107_last = sw.get_last_f107(60000.0, 7)
print(f"Last 7 F10.7 values: {f107_last}")

get_last_kp method descriptor

get_last_kp(mjd: float, n: int) -> list[float]

Get the last N 3-hourly Kp values.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of values to return

required

Returns:

Type Description
list[float]

list[float]: Kp values, oldest first

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
kp_last = sw.get_last_kp(60000.0, 8)
print(f"Last 8 Kp values: {kp_last}")

get_last_kpap_epochs method descriptor

get_last_kpap_epochs(mjd: float, n: int) -> list[Epoch]

Get epochs for the last N 3-hourly Kp/Ap intervals.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date (end point)

required
n int

Number of epochs to return

required

Returns:

Type Description
list[Epoch]

list[Epoch]: Epoch objects, oldest first

Example
1
2
3
4
5
6
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
epochs = sw.get_last_kpap_epochs(60000.0, 8)
for epoch in epochs:
    print(f"Epoch: {epoch}")

get_sunspot_number method descriptor

get_sunspot_number(mjd: float) -> int

Get International Sunspot Number.

Parameters:

Name Type Description Default
mjd float

Modified Julian Date

required

Returns:

Name Type Description
int int

Sunspot number

Example
1
2
3
4
5
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
ssn = sw.get_sunspot_number(60000.0)
print(f"Sunspot number: {ssn}")

is_initialized method descriptor

is_initialized() -> bool

Check if the provider is initialized.

Returns:

Name Type Description
bool bool

True if initialized

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Initialized: {sw.is_initialized()}")  # True

len method descriptor

len() -> int

Get the number of space weather data points.

Returns:

Name Type Description
int int

Number of data points

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Data points: {sw.len()}")

mjd_last_daily_predicted method descriptor

mjd_last_daily_predicted() -> float

Get the last MJD with daily predicted data.

Returns:

Name Type Description
float float

Last MJD with daily predicted data

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Last daily predicted MJD: {sw.mjd_last_daily_predicted()}")

mjd_last_monthly_predicted method descriptor

mjd_last_monthly_predicted() -> float

Get the last MJD with monthly predicted data.

Returns:

Name Type Description
float float

Last MJD with monthly predicted data

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Last monthly predicted MJD: {sw.mjd_last_monthly_predicted()}")

mjd_last_observed method descriptor

mjd_last_observed() -> float

Get the last MJD with observed data.

Returns:

Name Type Description
float float

Last MJD with observed data

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Last observed MJD: {sw.mjd_last_observed()}")

mjd_max method descriptor

mjd_max() -> float

Get the maximum Modified Julian Date in the dataset.

Returns:

Name Type Description
float float

Maximum MJD

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Max MJD: {sw.mjd_max()}")

mjd_min method descriptor

mjd_min() -> float

Get the minimum Modified Julian Date in the dataset.

Returns:

Name Type Description
float float

Minimum MJD

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Min MJD: {sw.mjd_min()}")

sw_type method descriptor

sw_type() -> str

Get the space weather data type.

Returns:

Name Type Description
str str

Space weather type string

Example
1
2
3
4
import brahe as bh

sw = bh.FileSpaceWeatherProvider.from_default_file()
print(f"Type: {sw.sw_type()}")  # "CssiSpaceWeather"

See Also