stix2xspec.spectrogram_utils module
- stix2xspec.spectrogram_utils.date2elut_file(date, stx_conf=None)
Find the ELUT table to be applied, given the date of the observation. ELUT tables are available in STIX-CONF https://github.com/i4Ds/STIX-CONF
- Parameters
date (str, datetime.datetime) – Date for which to find ELUT file.
stx_conf (str, optional) – Path to ELUT files. Defaults to None. If not set, the program will look for an environment variable STX_CONF which points to the correct location of the files mentioned above.
- Returns
ELUT filename
- Return type
str
- stix2xspec.spectrogram_utils.edge_products(edges)
Functions like [sswidl’s edge_products](https://hesperia.gsfc.nasa.gov/ssw/gen/idl/spectra/edge_products.pro). Forms a vector of contiguous channel boundaries and returns the commonly used quantities for plotting and scaling: mean, geometric mean, width, array of n+1 edges of contiguous channels, 2xn array of edges
- Parameters
edges (np.array) – A 1- or 2-D array of the edges to use.
- Returns
mean of edges, geometric mean of edges, width of bins between edges, lower edges, 2-D array of all edges
- Return type
tuple
- stix2xspec.spectrogram_utils.get_header_corrections(fits_path)
Returns distance from the Sun and time shift from primary header information.
- Parameters
fits_path (str) – Full path to FITS file
- Returns
Distance from the Sun in AU, time shift in seconds between spacecraft and Earth time.
- Return type
tuple
- stix2xspec.spectrogram_utils.get_hstart_time(primary_header)
Return the observation start time in both string and datetime format
- Parameters
primary_header (astropy.header) – Header to get observation start time from.
- Returns
Observation start time as string, observation start time as datetime
- Return type
tuple
- stix2xspec.spectrogram_utils.get_use_detectors(det_ind=None)
Get a mask of detectors used in observation.
- Parameters
det_ind (list, optional) – Defaults to None, in which case all 32 detectors are used. List of detectors to use.
- Returns
A mask of the detectors in use.
- Return type
np.array
- stix2xspec.spectrogram_utils.get_use_pixels(pix_ind=None)
Get a mask of detector pixels used in observation.
- Parameters
pix_ind (list, optional) – Defaults to None, in which case all 12 pixels are used. List of pixels to use.
- Returns
A mask of the pixels in use.
- Return type
np.array
- stix2xspec.spectrogram_utils.open_spec_fits(fits_path)
Open a L1, L1A, or L4 FITS file and return the HDUs
- Parameters
fits_path (str) – Full path to FITS file
- Returns
astropy Primary HDU header, control HDU, data HDU, energy HDU
- Return type
tuple
- stix2xspec.spectrogram_utils.read_elut(elut_filename=None, scl=4.0, ekev_actual=True)
This function finds the most recent ELUT csv file, reads it, and returns the gain and offset used to make it along with the edges of the Edges in keV (Exact) and ADC 4096, rounded. Translation of _stx_read_elut.pro_.
- Parameters
elut_filname (str, optional) – Name of the ELUT file to use. Defaults to None, in which case the most recent ELUT file will be used.
scl (float, optional) – Default 4.0. Otherwise should be set to 1. Scale factor for offset.
ekev_actual (bool, optional) – Return channel edges with true energies based on full adc 4096 bins
- Returns
offset (np.array): adc_4096_dict (dict):
- Return type
gain (np.array)
- stix2xspec.spectrogram_utils.shift_one_timestep(arr_in, axis=0, shift_step=-1)
Shift an array along a given axis a given number of steps. Primarily used to shift time axis by one step.
- Parameters
arr_in (np.array) – Input array
axis (int, optional) – Axis to shift along. Defaults to 0.
shift_step (int, optional) – Step to roll the array by. Defaults to -1.
- Returns
Array shifted by _shift_step_ along _axis_.
- Return type
np.array
- stix2xspec.spectrogram_utils.write_cropped_srm(srm, keep_channels, fitsfilename=None, request_id=None)
Write a SRM FITS file with only the channels relevant to the observation retained. A shortcut to generating the full SRM, used because the STIX SRM is relatively stable.
- Parameters
srm (astropy.BinTableHDU) – Input spectral response matrix from FITS file.
keep_channels (list) – List of indices of energy channels to keep.
fitsfilename (str, optional) – Defaults to None. Name of output SRM FITS file.
request_id (int or str, optional) – Request ID associated with observation, to help in creating default filename.
- Returns
Full path and filename of written FITS file.
- Return type
str