Rejecting OBS#

Selecting Observations based on conditions#

When using SBART we can reject observations in two different ways:

  • globally - they are effectivelly discarded for all SBART operations

  • temporarily -Only disable them for the creation of the Stellar Templates

Even though the two rejection types have completely different effects, we always use the same format, as defined in spectral_conditions.

Based on Header values#

  • Allows to define bounds for the “valid” values that a given header value can take.

  • The bounds argument takes a list of list, with each entry defining a “region” that the value can take.

  • If we want to place no upper/lower limits, we can place a None

# Only use observations that can have AIRMASS smaller than 1.5 or larger than 1.6
valid_AIRM_condition = KEYWORD_condition(KW = "airmass",
                                      bounds=[[None, 1.5], [1.6, None]]
                                     )

# Only select observations that have a previous RV error (the one from the CCF) smaller than 50 meter_second
# Note1: the conditions for 'RV related' values (previousRV, drift, BERV) must be in meter_second OR kilometer_second
# Note2: the units will be converted later on, so either "unit" can be chosen

valid_error_condition = KEYWORD_condition(KW="previousRV_ERR",
                                          bounds = [0, 50*meter_second])

Rejection based on filenames#

Provide a list of bad filenames that will be rejected.

Note: Filename only, do NOT pass a path

bad_filename_condition = FNAME_condition(filename_list=["filename.fits"])

Rejecting based on the “subInstrument”#

# Reject all observations from ESPRESSO21

bad_subInst_condition = SubInstrument_condition("ESPRESSO21")

Rejecting based on Warning Flags when loading the Frames#

Reject observation if a given warning flag was set when loading the spectra

bad_subInst_condition = WarningFlag_Notset("HIERARCH ESO QC SCIRED DRIFT CHECK")

Combining conditions#

To combine multiple conditions, sum them together. The observations will be rejected if any Condition decides to reject it

full_conditions = valid_AIRM_condition + valid_error_condition + bad_filename_condition + bad_subInst_condition

Applying the conditions#

For a DataClass object, we can use its reject_observations method

data.reject_observations(full_conditions)
class ConditionModel

Bases: object

Defines the Base Condition Class, from which we can generate new conditions. The conditions represent a boolean check that is applied to a given spectra, which is then rejected or kept, depending on the result from the check.

The ConditionModel is implemented in such a way that summing two conditions together creates a new, independent, condition that combines them all. This new, merged, conditions works as a sequential application of all conditions.

__init__()
evaluate(frame)

Apply all boolean checks to a given frame, returning a boolean value and a list of Flags with the results.

Parameters:

frame – frame to be validated against the conditions

Return type:

Tuple[bool, List[Flag]]

Returns:

  • valid_OBS – Boolean result of the comparison

  • flags – List of flags, one for each condition that was applied

select_spectra(frame)
Return type:

Flag

property set_conditions
property cond_info
write_to_disk(file)
Return type:

None

class KEYWORD_condition

Bases: ConditionModel

Limit the KW to be inside the defined interval (edges included)

__init__(KW, bounds, include_edges=True)
select_spectra(frame)
property cond_info
class SubInstrument_condition

Bases: ConditionModel

Flag the observations that are from the defined subInstrument

__init__(subInst)
select_spectra(frame)
Return type:

Flag

property cond_info: str
Return type:

str

class Empty_condition

Bases: ConditionModel

Place no Condition

__init__()
select_spectra(frame)
Return type:

Flag

property cond_info: str
Return type:

str

class WarningFlag_Notset

Bases: ConditionModel

Reject the observation if the given warning flag is True

__init__(flag_name, full_flag=False)
select_spectra(frame)
Return type:

Flag

property cond_info: str
Return type:

str

class FNAME_condition

Bases: ConditionModel

Flag the observations that have filename inside the filename_list list

Parameters:
  • filename_list (list) – List of files to either be outright used or list of paths to .txt files from which we can select observations

  • only_keep_filenames (bool) – Only keep the filenames that were selected. Default: False

  • load_from_file (bool) – If True (default False), use the filename_list parameter to provide a list of files that will be selected

__init__(filename_list, only_keep_filenames=False, load_from_file=False)
select_spectra(frame)
Return type:

Flag

property cond_info: str
Return type:

str

class SNR_condition

Bases: ConditionModel

Reject observations based on the order-wise SNR. Compares the SNR of the valid orders against the minimum SNR that is provided to this object.

Mostly useful for the creation of the stellar template

__init__(minimum_SNR)
select_spectra(frame)
property cond_info