ESPRESSO

ESPRESSO#

class ESPRESSO#

Bases: ESO_PIPELINE

Interface to handle ESPRESSO observations (S2D and S1D).

With ESPRESSO data we are considering 3 sub-Instruments:

  • ESPRESSO18 - Before 2019-06-27

  • ESPRESSO19 - Before 2020-12-18

  • ESPRESSO21 - Until the ends of time (hopefully)

User parameters:

Parameter name

Mandatory

Default Value

Valid Values

Comment

Note

Also check the User parameters of the parent classes for further customization options of SBART

sub_instruments = {'ESPRESSO18': datetime.datetime(2019, 6, 27, 0, 0), 'ESPRESSO19': datetime.datetime(2020, 12, 18, 0, 0), 'ESPRESSO21': datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)}#
__init__(file_path, user_configs=None, reject_subInstruments=None, frameID=None, quiet_user_params=True)#
Parameters:
  • file_path – Path to the S2D (or S1D) file.

  • user_configs (Optional[Dict[str, Any]]) – Dictionary whose keys are the configurable options of ESPRESSO (check above)

  • reject_subInstruments (Optional[Iterable[str]]) – Iterable of subInstruments to fully reject

  • frameID (Optional[int]) – ID for this observation. Only used for organization purposes by DataClass

load_telemetry_info(header)#

Loads (at least) the following keywords:

  • relative humidity

  • ambient temperature, in Celsius

  • airmass

  • Detector

Parameters:

header

check_header_QC_ESO_DRS(header)#
build_mask(bypass_QualCheck=False)#

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

property N_orders: int#

returns: Number of orders in the array :rtype: int

property OrderStatus#

Return the Status of the entire Frame

Return type:

OrderStatus

property OrderWiseStatus: <property object at 0x7f95a9f4a270>#

Returns the OrderStatus of the entire observation

Return type:

OrderStatus

add_relative_path(path_name, relative_structure)#
add_to_status(new_flag)#
Return type:

NoReturn

apply_BERV_correction(BERV_value)#

If it hasn’t been done before, apply the BERV correction to the wavelength solution of this frame.

Parameters:

BERV_value (Quantity) –

Return type:

None

apply_telluric_correction(wavelengths, model, model_uncertainty)#

Divide the spectra by a telluric correction model, without really accounting for model uncertainties. This shouldn’t be used in the current “state” ….

Parameters:
  • wavelengths

  • model

  • model_uncertainty

assess_bad_orders()#

Evaluate the masked points to find those that can always be discarded!

Return type:

None

property bad_orders: Set[int]#
Return type:

Set[int]

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

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)) `

check_header_QC_old_DRS(header)#
check_if_data_correction_enabled(property_name)#

If we attempt to access the correction state from the outside (before opening the S2D arrays), we will get a wrong value (of False), as the corrections are yet to be applied. Thus, we check if the desired property is currently given as a input argument. If it is, return its value, otherwise default to the class property values!

Return type:

bool

close_arrays()#

Close the arrays that are currently open in memory. Next time we try to access them, the disk file will be re-opened. Saves RAM at the cost of more I/O operations

Return type:

NoReturn

classmethod config_help()#

Prints a message to terminal, showing all possible configurations and their constraints

classmethod control_parameters()#
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

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

find_instrument_type()#
property fname#
generate_root_path(storage_path, no_logs=True)#
Return type:

NoReturn

get_BLAZE_function()#

Return the blaze function. If it is not available, attempt to compute it!

get_KW_value(KW)#
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

get_data_from_full_spectrum()#

Retrieve the entire spectra. If we are working with S2D data: send the [N_orders, N_pixels] matrix If we are working with S1D data: send a single N_pixels 1-D array with the relevant information

Returns:

  • np.ndarray – wavelengths

  • np.ndarray – Spectra

  • np.ndarray – Uncertainties

  • np.ndarray – Spectral mask, a binary mask which is set to one on the pixels to be discarded and zero otherwise.

get_data_from_spectral_order(order, include_invalid=False)#

Retrieve a single order from the S2D matrix

Parameters:
  • order (int) – Order to retrive

  • include_invalid (bool) – If False, raise exception when attempting to access data from bad order

Returns:

  • np.ndarray – wavelengths

  • np.ndarray – flux

  • np.ndarray – uncertainties

  • np.ndarray – Binary mask of the pixels

get_spectral_type()#

Check the filename to see if we are using an S1D or S2D file

Return type:

str

property has_warnings#
import_KW_from_outside(KW, value, optional)#

Allow to manually override frame parameters from the outside

initialize_modelling_interface()#
initialize_normalization_interface()#

Initialize the normalization interface for the currently selected mode!

Return type:

NoReturn

property interpol_mode: str#
Return type:

str

interpolate_spectrum_to_wavelength(order, new_wavelengths, shift_RV_by, RV_shift_mode, include_invalid=False)#
property interpolation_interface#
is_Instrument(Instrument)#
Return type:

bool

property is_S1D#
property is_S2D#
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]

is_object_type(type_to_check)#

Check if this object is of a given type

Parameters:

type_to_check (str) –

Return type:

bool

property is_open: bool#

returns: True if it has the arrays loaded on memory :rtype: bool

property is_valid: bool#
Return type:

bool

json_ready()#

Concerts the current class into a json entry that can be easily saved/loaded to/from disk

Return type:

Dict[str, Any]

load_ESO_DRS_S1D_data()#
load_ESO_DRS_S2D_data(overload_SCIDATA_key=None)#
load_S1D_data()#

To be overriden by the children classes

load_S2D_data()#

To be overriden by the children classes

load_data()#
Return type:

None

load_from_file(root_path, loading_path)#
Return type:

None

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

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]

load_old_DRS_S1D()#
load_old_DRS_S2D()#
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

property min_pixel_in_order: int#
Return type:

int

property name: str#
Return type:

str

normalize_spectra()#

TODO: See if we need to parallelize this!

Launch the normalization of the spectra, using the selected algorithm

property pixels_per_order: int#

returns: Number of pixels in each order :rtype: int

property previous_RV_measurements#
regenerate_order_status()#
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

remove_BERV_correction(BERV_value)#

Remove the BERV correction from a given observation

Parameters:

BERV_value (Quantity) –

scale_spectra(factor)#
Return type:

NoReturn

select_wavelength_region(order, wavelength_blocks)#
set_frame_as_Zscore()#

Re-defining the frame as one with zero mean and unit-variance (z-score)

Return type:

NoReturn

set_interpolation_properties(new_properties)#
property spectrum_information#
property status: Status#

Return the Status of the entire Frame

Return type:

Status

property storage_name: str#
Return type:

str

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

trigger_data_storage(*args, **kwargs)#
Return type:

NoReturn

trigger_epochwise_method(norm_interface)#
trigger_orderwise_method(norm_interface)#
update_uncertainties(new_values)#

Allow to update the uncertainty values, which allows for manual SNR changes

Parameters:

new_values – Numpy array with the new uncertainties

Return type:

NoReturn

property valid_orders#
file_path: Path#
wavelengths_to_remove: Dict[Flag, List[List[int]]]#