SBART.Base_Models.Frame#
Classes
Base Class for the different Instruments, providing a shared interface to spectral data and header information. |
- class Frame#
Bases:
Spectrum
,Spectral_Modelling
,Spectral_Normalization
Base Class for the different Instruments, providing a shared interface to spectral data and header information.
This class defines a set of Keywords, consistent for all s-BART supported Instruments, which can be accessed through the proper methods. The internal keywords are initialized to a default value, which the Frame will use if the instrument does not provide that metric/value. Furthermore, all RV-related metrics are returned as astropy.Quantity objects (or lists of such objects). For such cases, one can use
convert_data()
to convert data to different units and/or to floatsThe supported list of keywords, and the default initialization values is:
Internal KW name
Default intialization
BERV
np.nan * kilometer_second
MAX_BERV
np.nan * kilometer_second
previous_SBART_RV
np.nan * kilometer_second
previous_SBART_RV_ERR
np.nan * kilometer_second
DRS_RV_ERR
np.nan * kilometer_second
DRS_RV_ERR
np.nan * kilometer_second
drift
np.nan * kilometer_second
drift_ERR
np.nan * kilometer_second
relative_humidity
np.nan
ambient_temperature
np.nan
airmass
np.nan
orderwise_SNRs
[]
OBJECT
None
BJD
None
MJD
None
DRS-VERSION
None
MD5-CHECK
None
ISO-DATE
None
CONTRAST
0
FWHM
0
BIS SPAN
0
RA
None
DEC
None
SPEC_TYPE
“”
User parameters:
Parameter name
Mandatory
Default Value
Valid Values
Comment
bypass_QualCheck
False
False
boolean
If True, avoid checking the pixel-wise QC checks
reject_order_percentage
False
0.25
range [0 ,1]
Smallest percentage of “valid” pixels in a “valid” order
minimum_order_SNR
False
20
int/float >= 0
If the order’s SNR is below this value, reject the order
spectra_format
False
S2D
“S2D”
Indicates where we are using S2D or S1D data. Not all instruments support S1D
use_air_wavelengths
False
False
boolean
Use air wavelengths, instead of vacuum. Only used in S1D files!
open_without_BervCorr
False
False
boolean
If True, remove any BERV correction
Note
This class also uses the User parameters defined by the
Spectral_Modelling
class
Note
Also check the User parameters of the parent classes for further customization options of SBART
- sub_instruments = {}#
- __init__(inst_name, array_size, file_path, frameID, KW_map, available_indicators, user_configs=None, reject_subInstruments=None, need_external_data_load=False, init_log=True, quiet_user_params=True)#
The Frame object is initialized with the following set of Keywords:
- Parameters:
inst_name (
str
) – Name of the instrumentarray_size (
Dict
[str
,tuple
]) – Size of the data that will be loaded from disk. Follow the format [Number order, Number pixels]file_path (
Path
) – Path to the file that is going to be openedframeID (
int
) – Numerical value that represents the frame’s ID inside theDataClass
KW_map (
Dict
[str
,str
]) – Dictionary where the keys are names of internal Keywords and the values represent the keyword name on the header of the .fits filesavailable_indicators (
tuple
) – Names of available activity indicators for the instrumentuser_configs (
Optional
[Dict
[str
,Any
]]) – User configs information to be loaded in the parent classreject_subInstruments (
Optional
[Iterable
[str
]]) – List of subInstruments to completely rejectneed_external_data_load (
bool
) – True if the instrument must load data from a file that is not the one specified on the “file_path” argumentinit_log (
bool
) – If True create a log entry with the filenamequiet_user_params (
bool
) – If True, there are no logs for the generation of the user parameters of each Frame
- get_spectral_type()#
Check the filename to see if we are using an S1D or S2D file
- Return type:
str
- copy_into_S2D(new_S2D_size=None)#
Return a new object which contains the S1D that that has been converted into a S2D
- Parameters:
new_S2D_size (Optional[Tuple[int, int]]) – Size of the new S2D size, should be a tuple with two elements: (number orders, pixel in order). If it is None, then uses the standard size of S2D files of this instrument. Default: None
- import_KW_from_outside(KW, value, optional)#
Allow to manually override frame parameters from the outside
- reject_wavelength_region_from_order(order, region)#
Flag a wavelength region from an order to be marked as invalid during the creation of the stellar mask
- mark_wavelength_region(reason, wavelength_blocks)#
Add wavelength regions to be removed whenever the S2D file is opened
- Parameters:
reason (Flag) – Flag for the removal type
wavelength_blocks (List[list]) – List with lists of wavelength limits. [[lambda_0, lambda_1], [lambda_2, lambda_3]]
- Return type:
None
- select_wavelength_region(order, wavelength_blocks)#
- finalize_data_load(bad_flag=None)#
Called for all Instruments, even those that do not need an external data load. Checks if the non-fatal Flag “LOADING_EXTERNAL_DATA” exists in the Status. If so, add the fatal Flag “MISSING_EXTERNAL_DATA”. Otherwise, does nothing
- Return type:
NoReturn
- finalized_external_data_load()#
Tuns an invalid CARMENES::KOBE frame into a valid one (assuming that the only problem is missing the SHAQ loads)
If the status of the frame is different than MISSING_SHAQ_DATA (meaning that something went bad with the data load) :rtype: NoReturn
- add_to_status(new_flag)#
- Return type:
NoReturn
- property status: Status#
Return the Status of the entire Frame
- Return type:
Status
- build_mask(bypass_QualCheck=False, assess_bad_orders=True)#
Build a spectral mask based on the S2D data
- Parameters:
bypass_QualCheck (bool, optional) – Do not check the QUAL_DATA array for non-zero values, by default False
- Return type:
None
- assess_bad_orders()#
Evaluate the masked points to find those that can always be discarded!
- Return type:
None
- check_header_QC(header)#
Check if the header keywords are in accordance with their default value. Each instrument should do this check on its own
This function will check for two things: 1. Fatal keywords - will mark the Frame as invalid 2. Warning Keywords - the frame is still valid, but it has a warning issued in the logs
If any of those conditions is met, make sure that the flags meet the following naming conditions (so that we can filter by them later on):
For fatal flags
` msg = f"QC flag {flag} has taken the bad value of {bad_value}" self.add_to_status(FATAL_KW(msg)) `
For warnings:
` msg = f"QC flag {flag} meets the bad value" self._status.store_warning(KW_WARNING(msg)) `
- find_instrument_type()#
- get_S1D_name()#
Build the S1D name that should be associated with this Frame. If it is already a S1D, returns the actual name. If it is not, remove “blaze” from the filename and replaces “S2D” with “S1D”
- Return type:
str
- load_data()#
- Return type:
None
- load_S1D_data()#
To be overriden by the children classes
- load_S2D_data()#
To be overriden by the children classes
- load_instrument_specific_KWs(header)#
Load the KW values that can not be loaded in a general fashion (e.g. needs UT number or units) To be overriden by the different instruments :param header: [description] :type header: [type]
- store_previous_SBART_result(RV, RV_err)#
Store, from the outside, RV and uncertainty from a previous SBART application
- Parameters:
RV (
Quantity
) –RV_err (
Quantity
) –
- Return type:
NoReturn
- load_header_info()#
Open the header of the fits file and load the necessary keywords. To be overriden by the children classes
- Return type:
None
- get_KW_value(KW)#
- property is_S1D#
- property is_S2D#
- property has_warnings#
- is_Instrument(Instrument)#
- Return type:
bool
- is_SubInstrument(sub_instrument)#
Check if the current instrument is from the given time_block (e.g ESPRESSO18/ESPRESSO19)
- Parameters:
sub_instrument (str) – Name of the time block that is going to be checked
- Returns:
Results from the comparison
- Return type:
[type]
- property previous_RV_measurements#
- property bare_fname: str#
Returns the file name without the _S2D (and similar) parts
The children classes must overload this property. Otherwise, returns the full filename
- Return type:
str
- property fname#
- property min_pixel_in_order: int#
- Return type:
int
- property spectrum_information#