petitRADTRANS.ccf.ccf

Useful functions to analyze data using cross-correlation. The most useful functions are cross_correlate_data_model, and more importantly ccf_analysis, they provide an easy way to calculate the CCF of data against models. Also useful is get_co_added_ccf_peak_properties to quickly analyze the CCF.

Module Contents

Functions

_check_spectrum_wavelengths_rules(wavelengths, spectrum)

Check if wavelengths and spectrum obey the ruling shape.

_check_data_model_rules(data, model)

Check if data and model obey the ruling shape.

calculate_co_added_ccf_snr(co_added_cross_correlation, ...)

Calculate the "signal" to "noise" ratio of each point of a co-added cross correlation map.

ccf_analysis(wavelengths_data, data, ...[, ...])

Calculate the co-added CCF map of the data against the provided models.

cross_correlate_data_model(wavelengths_data, data, ...)

Cross correlate a model with data.

get_ccf_models(data, wavelengths_data, model, ...)

Get the models that will be used for the CCF analysis using the wavelengths shifted according to the CCF rest

get_ccf_model_wavelengths(wavelengths_model, ...[, ...])

Get the CCF wavelengths for the models that will be used for the CCF analysis.

get_ccf_velocity_space(...[, ...])

Get a velocity space of for CCF calculations.

get_co_added_ccf_peak_properties(...)

Get the location of the co-added cross-correlation ("SNR") peak and the number of points around the peak.

get_co_added_ccf_velocity_space(...[, kp_factor, ...])

petitRADTRANS.ccf.ccf._check_spectrum_wavelengths_rules(wavelengths, spectrum, wavelength_name='wavelengths', spectra_name='spectra')

Check if wavelengths and spectrum obey the ruling shape. The spectrum must have at least 1 dimension, with the last 3 corresponding to: (CCD, exposure, wavelength). The wavelengths of the spectrum must have one of the following shapes:

  • 1 dimension (wavelength) but only if the data have 1 or 2 dimensions,

  • 2 dimensions (CCD, wavelength) but only if the data have at least 3 dimensions,

  • the same shape as data.

Args:

wavelengths: wavelengths of the spectrum spectrum: spectrum wavelength_name: variable name of wavelengths, for error message spectra_name: variable name of spectra, for error message

petitRADTRANS.ccf.ccf._check_data_model_rules(data, model)

Check if data and model obey the ruling shape. The model must have one of the following shapes:

  • 1 dimension (wavelength),

  • 2 dimensions (exposure, wavelength) but only if the data have at least 2 dimensions,

  • one dimension less (CCD) than the data (…, exposure, wavelength).

The model cannot have the CCD dimension, otherwise the re-binning will fail due to insufficient wavelength range, taking into account the Doppler shift from the CCF rest velocities.

Args:

data: wavelengths of the spectra model: variable name of wavelengths, for error message

petitRADTRANS.ccf.ccf.calculate_co_added_ccf_snr(co_added_cross_correlation, rest_velocities, vr_peak_width)

Calculate the “signal” to “noise” ratio of each point of a co-added cross correlation map. The “SNR” is calculated as the value of the point of the CCF map divided by the standard deviation around that point over rest velocities. The standard deviation calculation excludes points at a distance vr_peak_width of the evaluated point.

Args:

co_added_cross_correlation: co-added cross correlation map rest_velocities: 1D array containing the rest velocities of the co-added CCF map vr_peak_width: expected width of the peak, in rest velocities units

petitRADTRANS.ccf.ccf.ccf_analysis(wavelengths_data, data, wavelengths_model, model, velocities_ccf=None, model_velocities=None, normalize_ccf=True, calculate_ccf_snr=True, ccf_sum_axes=None, radial_velocity_semi_amplitude=None, system_observer_radial_velocities=None, orbital_longitudes=None, line_spread_function_fwhm=None, pixels_per_resolution_element=2, co_added_ccf_peak_width=None, velocity_interval_extension_factor=0.25, kp_factor=2.0, n_kp=None, n_vr=None, radial_velocity_function=None, **kwargs)

Calculate the co-added CCF map of the data against the provided models. If velocities_ccf is not provided, one will be calculated using planetary and instrumental parameters.

Args:

wavelengths_data: wavelengths of the data data: data wavelengths_model: wavelengths of the model model: model velocities_ccf: (cm.s-1) 1D array containing the values of the CCF rest velocities model_velocities: (cm.s-1) rest frame velocities of the model, one per model exposure normalize_ccf: if True, normalize the data and CCF models by subtracting their respective mean calculate_ccf_snr: if True, output the signal-to-noise of the CCF map, based on the standard deviation ccf_sum_axes: iterable listing the axes on which to sum the CCF before computing the co-added CCF system_observer_radial_velocities: (cm.s-1) array of velocities between the system and the observer orbital_longitudes: 1D array containing the orbital longitudes of the data radial_velocity_semi_amplitude: (cm.s-1) radial orbital velocity semi-amplitude of the planet (Kp) line_spread_function_fwhm: (cm.s-1) Full Width at Half-Maximum of the instrument line spread function (LSF) co_added_ccf_peak_width: (cm.s-1) width of the CCF peak, for the SNR, 3 times the LSF px size by default pixels_per_resolution_element: number of spectral pixels per resolution element for the instrument velocity_interval_extension_factor: extension to the calculated velocities_ccf interval, set to 0 for no

extension

kp_factor: used to set the boundaries of the Kp space relative to the planet Kp (2 -> boundaries at 2 times Kp) n_kp: length of the Kp space, same as the size of velocities_ccf by default n_vr: length of the rest velocity space, same as the size of velocities_ccf by default radial_velocity_function: function to calculate the planet radial velocity with respect to the observer,

must have at least the following arguments:
  • radial_velocity_semi_amplitude,

  • planet_orbital_inclination,

  • orbital_longitude=orbital_longitudes

the Planet.calculate_radial_velocity function is used by default

Returns:

co_added_cross_correlations_snr: only if calculate_ccf_snr is True, the SNR of the co-added CCF map co_added_cross_correlations: the co-added CCF map of the data against the models v_rest: the rest velocities of the co-added CCF map kps: the orbit radial velocity semi-amplitudes of the co-added CCF map ccf_sum: the sum of CCFs used to calculate the co-added CCF ccfs: the CCFs of the data against the models velocities_ccf: the rest velocities of the CCF ccf_model: the models used to calculate the CCFs ccf_model_wavelengths: the wavelengths of the models used to calculate the CCFs

petitRADTRANS.ccf.ccf.cross_correlate_data_model(wavelengths_data, data, wavelengths_model, model, velocities_ccf=None, model_velocities=None, normalize_ccf=True)

Cross correlate a model with data. The data must have at least 2 dimensions, with the last 3 corresponding to: (…, CCD, exposure, wavelength). The wavelengths of the data must have one of the following shapes:

  • 1 dimension (wavelength) but only if the data have 2 dimensions,

  • 2 dimensions (exposure, wavelength) but only if the data have 2 dimensions,

  • 2 dimensions (CCD, wavelength) but only if the data have at least 3 dimensions,

  • the same shape as data.

The model must have 1 (wavelength), 2 (exposure, wavelength), or one dimension less than the data (…, exposure, wavelength). The model must have no CCD axis. The wavelengths of the model must follow the same rules as for the wavelengths of the data.

Args:

wavelengths_data: wavelengths of the data data: data wavelengths_model: wavelengths of the model model: model velocities_ccf: (cm.s-1) 1D array containing the values of the CCF rest velocities model_velocities: (cm.s-1) rest frame velocities of the model, one per model exposure normalize_ccf: if True, normalize the data and CCF models by subtracting their respective mean

Returns:

The CCF (…, exposure, CCF rest velocities), the CCF models and CCF models wavelengths

petitRADTRANS.ccf.ccf.get_ccf_models(data, wavelengths_data, model, ccf_model_wavelengths)

Get the models that will be used for the CCF analysis using the wavelengths shifted according to the CCF rest velocity axis. The model is re-binned to the wavelengths of the data to obtain a matrix with the same shape as the data, plus one dimension for the velocity axis.

Args:

data: data wavelengths_data: wavelengths of the data model: variable name of wavelengths, for error message ccf_model_wavelengths: wavelengths of the model Doppler-shifted to the CCF rest velocities

petitRADTRANS.ccf.ccf.get_ccf_model_wavelengths(wavelengths_model, velocities_ccf, relative_velocities=None)

Get the CCF wavelengths for the models that will be used for the CCF analysis. The wavelengths are Doppler-shifted to the rest velocities values of the CCF.

Args:

wavelengths_model: wavelengths of the model velocities_ccf: rest velocities used for the CCF relative_velocities: velocities used to build the model

petitRADTRANS.ccf.ccf.get_ccf_velocity_space(system_observer_radial_velocities, radial_velocity_semi_amplitude, line_spread_function_fwhm, pixels_per_resolution_element, velocity_interval_extension_factor=0.25)

Get a velocity space of for CCF calculations.

petitRADTRANS.ccf.ccf.get_co_added_ccf_peak_properties(co_added_cross_correlation, kp_space, vr_space, peak_cutoff)

Get the location of the co-added cross-correlation (“SNR”) peak and the number of points around the peak.

Args:

co_added_cross_correlation: the co-added CCF map to get the peak from kp_space: 1D array containing the orbital radial velocity semi-amplitudes of the co-added CCF map vr_space: 1D array containing the rest velocities of the co-added CCF map peak_cutoff: all points below this factor of the maximum are not considered part of the peak

Returns:

The value of the CCF peak, the Kp and rest velocity of the peak, and the number of points of the peak

petitRADTRANS.ccf.ccf.get_co_added_ccf_velocity_space(radial_velocity_semi_amplitude, velocities_ccf, system_observer_radial_velocities, orbital_longitudes, kp_factor=2.0, n_kp=None, n_vr=None, radial_velocity_function=None, **kwargs)