heyoka.sw_data#

class heyoka.sw_data#

Space weather data class.

Added in version 7.3.0.

This class is used to manage and access space weather (SW) data.

Note

A tutorial illustrating the use of this class is available.

Methods

__init__(self, *[, data, timestamp, identifier])

Constructor.

fetch_latest_celestrak([long_term])

Fetch the latest SW data from celestrak.

Attributes

identifier

SW data identifier.

table

SW data table.

timestamp

SW data timestamp.

__init__(self, *, data: numpy.ndarray | None = None, timestamp: str | None = None, identifier: str | None = None)#

Constructor.

If no arguments are provided, the data is initialised with a builtin copy of the SW-All.csv data file from celestrak.

Note that the builtin SW data is likely to be outdated. You can use functions such as fetch_latest_celestrak() to fetch up-to-date data from the internet.

Alternatively, a custom dataset can be built by providing all three of the data, timestamp and identifier arguments.

Added in version 7.12.0: The ability to construct custom datasets.

Parameters:
  • data – the SW data table. If provided, it must be a one-dimensional structured NumPy array whose dtype is sw_data_row.

  • timestamp – a string used to disambiguate between different versions of the same dataset (see timestamp).

  • identifier – a string uniquely identifying the source of the data (see identifier).

Raises:
  • TypeError – if only some (but not all) of data, timestamp and identifier are provided, or if the input array has the wrong dtype.

  • ValueError – in case of invalid input arguments.

static fetch_latest_celestrak(long_term: bool = False) sw_data#

Fetch the latest SW data from celestrak.

This function will download from celestrak one the latest SW data files, from which it will construct and return an sw_data instance.

The long_term argument indicates which SW data file will be donwloaded:

  • if True, then the full historical dataset from 1957 up to the present time will be downloaded, otherwise

  • the dataset for the last 5 years will be downloaded.

Both datasets contain predictions for the near future.

Please refer to the documentation on the celestrak website for more information about the content of these files.

Note

This function will release the global interpreter lock (GIL) while downloading.

Parameters:

long_term – flag selecting which file to be downloaded.

Returns:

an sw_data instance constructed from the remote file.

property identifier#

SW data identifier.

A string uniquely identifying the source of SW data.

Type:

str

property table#

SW data table.

This is a structured NumPy array containing the raw SW data. The dtype of the returned array is sw_data_row.

Type:

numpy.ndarray

property timestamp#

SW data timestamp.

A timestamp in string format which can be used to disambiguate between different versions of the same dataset.

Type:

str