Calculate Sky Backgrounds (lexi.calc_sky_backgrounds)
- lexi_xray.lexi.calc_sky_backgrounds(time_range=None, time_zone='UTC', interp_method='linear', time_step=1, time_integrate=None, ra_range=[0, 360], dec_range=[-90, 90], ra_res=0.5, dec_res=0.5, save_exposure_map_file=False, save_exposure_map_image=False, save_sky_backgrounds_file=False, save_sky_backgrounds_image=False, verbose=True, force_compute=False, array_to_image_kwargs={})[source]
Function to compute sky backgrounds for a given time range and RA/DEC range and resolution using ROSAT data and exposure maps
Parameters
- time_rangelist, required
Time range to consider. [start time, end time]. Times can be expressed in the following formats:
A string in the format ‘YYYY-MM-DDTHH:MM:SS’ (e.g. ‘2022-01-01T00:00:00’)
A datetime object
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”
- interp_methodstr, optional
Interpolation method used when upsampling/resampling ephemeris data, ROSAT data. Options:
‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’.
See pandas.DataFrame.interpolate documentation for more information. Default is ‘linear’.
- time_stepint or float, optional
Time step in seconds for time resolution of the look direction datum.
- time_integrateint or float, optional
Integration time in seconds. If no integration time is provided, the time span of the time_range is used.
- ra_rangelist, optional
Range of right ascension in degrees. If no range is provided, the range of the spacecraft ephemeris data is used.
- dec_rangelist, optional
Range of declination in degrees. If no range is provided, the range of the spacecraft ephemeris data is used.
- ra_resfloat, optional
Right ascension resolution in degrees. Default is 0.5 degrees.
- dec_resfloat, optional
Declination resolution in degrees. Default is 0.5 degrees.
- save_exposure_map_filebool, optional
If True, save the exposure maps to a binary file. Default is False.
- save_exposure_map_imagebool, optional
If True, save the exposure maps to a PNG image. Default is False.
- save_sky_backgrounds_filebool, optional
If True, save the sky backgrounds to a binary file. Default is False.
- save_sky_backgrounds_imagebool, optional
If True, save the sky backgrounds to a PNG image. Default is False.
- verbosebool, optional
If True, print messages. Default is True
- force_computebool, optional
If True, force the computation of the sky backgrounds. Default is False.
- force_computebool, optional
If True, force the computation of the sky backgrounds even if a skybackground data is present in the default folder. Default is False.
- array_to_image_kwargsdict, optional
Keyword arguments to pass to the array_to_image function. Default is None. If None, then the default values of the array_to_image function are used.
Returns
- sky_backgrounds_dictdict
- Dictionary containing the following keys:
- sky_backgroundsnumpy array
Sky backgrounds
- Exposure mapsnumpy array
Exposure maps
- ra_arrnumpy array
Right ascension array
- dec_arrnumpy array
Declination array
- time_rangelist
Time range of the sky backgrounds
- time_integrateint or float
Integration time in seconds of the sky backgrounds
- ra_rangelist
Right ascension range of the sky backgrounds in degrees
- dec_rangelist
Declination range of the sky backgrounds in degrees
- ra_resfloat
Right ascension resolution of the sky backgrounds in degrees
- dec_resfloat
Declination resolution of the sky backgrounds in degrees
- start_time_arrnumpy array
Start time of each sky background
- stop_time_arrnumpy array
Stop time of each sky background
Example Usage
The following example demonstrates how to get sky backgrounds for a given time range and RA/DEC range and resolution using ROSAT data and exposure maps:
>>> from lexi_xray.lexi import calc_sky_backgrounds
>>> sky_background_dict = calc_sky_backgrounds( time_range=["2025-03-04 08:50:00", "2025-03-04 09:23:00"], ra_range=[160, 230], dec_range=[-20, 5], ra_res=0.5, dec_res=0.5, time_integrate=500, save_exposure_map_file=True, save_sky_backgrounds_file=True, save_exposure_map_image=True, save_sky_backgrounds_image=True, verbose=True )
Jupyter Notebook Usage:
from lexi_xray.lexi import calc_sky_backgrounds sky_background_dict = calc_sky_backgrounds( time_range=["2025-03-04 08:50:00", "2025-03-04 09:23:00"], ra_range=[190, 310], dec_range=[-33, 3], ra_res=0.5, dec_res=0.5, save_exposure_map_file=False, save_sky_backgrounds_file=False, save_exposure_map_image=True, save_sky_backgrounds_image=False, verbose=False, array_to_image_kwargs={"display": True} ) print(sky_background_dict.keys())
Exposure map not found, computing now. This may take a while
Sky background not found, computing now. This may take a while dict_keys(['sky_backgrounds', 'exposure_maps', 'ra_arr', 'dec_arr', 'time_range', 'time_integrate', 'ra_range', 'dec_range', 'ra_res', 'dec_res', 'start_time_arr', 'stop_time_arr'])