Get LEXI Data (lexi.get_lexi_data)

lexi_xray.lexi.get_lexi_data(time_range=None, time_zone='UTC', time_pad=300, data_clip=True, verbose=True, spc_prams=False, return_data_type='merged', spc_prams_kwargs={})[source]

Function to get LEXI data from the CDAweb website (eventually). Currently the code is set up to download the data from the GitHub repository. This function will be updated to download the data from the CDAweb website once the data is available and hosted on the website.

Parameters

time_rangelist, required

Time range to consider. [start time, end time]. Times can be expressed in the following formats:

  1. A string in the format ‘YYYY-MM-DDTHH:MM:SS’ (e.g. ‘2022-01-01T00:00:00’)

  2. A datetime object

  3. A float in the format of a UNIX timestamp (e.g. 1640995200.0)

This time range defines the time range of the ephemeris data and the time range of he LEXI data.

Note

The endpoints are inclusive (the end time is a closed interval); this is because he time range slicing is done with pandas, and label slicing in pandas is inclusive.

time_zonestr, optional

The timezone of the time range of interest. Default is “UTC”

verbosebool, optional

If True, print messages. Default is True

time_padfloat, optional

Time padding in seconds to add to the time range value. Default is 300 seconds

data_clipbool, optional

If True, clip the data to the original time range specified, else, keep the entire dataframe. Default is True

spc_pramsbool, optional

If True, get the spacecraft parameters for the same time range as LEXI data. Default is False

return_data_typestr, optional

Type of data to return. This parameter is only used when spc_prams is True. This defines what kind of dataframes to return. Valid options are:

  • ‘merged’: Merged LEXI and spacecraft parameters dataframes using the ‘pd.merge_asof’ function with a tolerance of 1 minute and direction of ‘nearest’. Default option.

  • ‘lexi’: LEXI data only

  • ‘spc_prams’: Spacecraft parameters data only

  • ‘both’: Both LEXI and spacecraft parameters dataframes

  • ‘all’: All three dataframes

Default is ‘merged’

spc_prams_kwargsdict, optional

Keyword arguments to pass to the get_spc_prams function. Default is None. If None, then the default values of the get_spc_prams function are used.

Returns

dfpandas DataFrame

LEXI data

df_spc_pramspandas DataFrame

Spacecraft parameters data

df_mergedpandas DataFrame

Merged LEXI and spacecraft parameters data

Example Usage

The following example shows how to use the get_lexi_data function to get LEXI data for a specific time range:

>>> from lexi_xray.lexi import get_lexi_data
>>> df_lexi = get_lexi_data(
        time_range=["2025-03-04 08:50:00", "2025-03-04 09:23:00"],
        verbose=True
    )

Jupyter Notebook Usage:

from lexi_xray.lexi import get_lexi_data

df_lexi = get_lexi_data(
    time_range=["2025-03-04 08:50:00", "2025-03-04 09:23:00"],
    verbose=False
)

print(df_lexi.head())
Downloading files from data/level_1c/cdf/1.0.0 on branch stable:
A total of 1917 files found

Files to download: 9

Downloading lexi_payload_1741077968_26406_level_1c_1.0.0.cdf...

Saved lexi_payload_1741077968_26406_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741077968_26406_level_1c_1.0.0.cdf

Downloading lexi_payload_1741078268_29290_level_1c_1.0.0.cdf...

Saved lexi_payload_1741078268_29290_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741078268_29290_level_1c_1.0.0.cdf

Downloading lexi_payload_1741078869_2840_level_1c_1.0.0.cdf...

Saved lexi_payload_1741078869_2840_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741078869_2840_level_1c_1.0.0.cdf

Downloading lexi_payload_1741079169_5198_level_1c_1.0.0.cdf...

Saved lexi_payload_1741079169_5198_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741079169_5198_level_1c_1.0.0.cdf

Downloading lexi_payload_1741079469_9233_level_1c_1.0.0.cdf...

Saved lexi_payload_1741079469_9233_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741079469_9233_level_1c_1.0.0.cdf

Downloading lexi_payload_1741079769_20852_level_1c_1.0.0.cdf...

Saved lexi_payload_1741079769_20852_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741079769_20852_level_1c_1.0.0.cdf

Downloading lexi_payload_1741080069_25191_level_1c_1.0.0.cdf...

Saved lexi_payload_1741080069_25191_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741080069_25191_level_1c_1.0.0.cdf

Downloading lexi_payload_1741080369_31310_level_1c_1.0.0.cdf...

Saved lexi_payload_1741080369_31310_level_1c_1.0.0.cdf to downloaded_data/lexi_payload_1741080369_31310_level_1c_1.0.0.cdf

                           Epoch_unix  ra_J2000_deg  dec_J2000_deg
Epoch_utc                                                         
2025-03-04 08:50:00+00:00  1741078200    233.365814     -23.028013
2025-03-04 08:50:00+00:00  1741078200    233.247787     -22.549011
2025-03-04 08:50:00+00:00  1741078200    229.612396     -24.492270
2025-03-04 08:50:00+00:00  1741078200    232.682541     -24.332512
2025-03-04 08:50:00+00:00  1741078200    228.622574     -23.796873