Radial Velocity Init

class modules.radial_velocity.src.alg_rv_init.RadialVelocityAlgInit(config=None, logger=None, l1_data=None, bc_time=None, bc_period=380, bc_corr_path=None, bc_corr_output=None, test_data=None)[source]

Radial velocity Init.

This module defines class ‘RadialVelocityAlgInit’ and methods to do init work for making mask lines and velocity steps based on star and module associated configuration for further radial velocity computation.

Parameters:
test_data_dir

KPF test data directory defined in .env to be loaded by the use of load_dotenv.

Type:

str

rv_config

A dict instance containing the values defined in radial velocity configuration file or star configuration file if there is. The instance includes the following keys (these are constants defined in the source):

SPEC, STARNAME, RA, DEC, PMRA, PMDEC, EPOCH, PARALLAX, STAR_RV, OBSLON, OBSLAT, OBSALT, STEP, MASK_WID, STEP_RANGE.

Type:

dict

mask_path

Mask file path.

Type:

str

velocity_loop

Evenly spaced velocity steps.

Type:

numpy.ndarray

velocity_steps

Total steps in velocity_loop.

Type:

int

zb_range

Redshift at a single time or redshift range over a period of time. The list contains one number for a single time or two numbers representing the minimum and the maximum during a period of time.

Type:

list

mask_line

A dict instance containing mask line information. Please refer to Returns section in get_mask_line() for the information detail.

Type:

dict

reweighting_ccf_method

Method of reweighting ccf orders. The possible methods include ccf_max or ccf_mean which scales the ccf of each order based on the ratio of the maximum (or 95 percentile) or the mean ccf among selected orders from the template observation and ccf_steps which scales the ccf of each order based on the mean of the ratio between current ccf over all velocity steps and that of the same order from the template observation.

Type:

str

bc_jd

Observation time in Julian Date format. Defaults to None.

Type:

float

bc_corr_path

Path of csv file storing a list of redshift data from Barycentric correction over a period of time. Defaults to None.

Type:

str, optional

bc_corr_output

Path of csv file to contain the redshift results from Barycentric correction over a period of time. Defaults to None for no output.

Type:

str, optional

Raises:
  • AttributeError – The Raises section is a list of all exceptions that are relevant to the interface.

  • Exception – If there is no configuration.

  • Exception – If test data directory is not found.

static check_epoch(epoch_data, p_header)[source]

check epoch value from the primary header for kpf case

Parameters:
  • epoch_data (float) – Epoch value.

  • p_header (fits.header.Header) – header

Returns:

epoch value or None.

Return type:

float

collect_init_data()[source]

Collect init data for radial velocity analysis.

Returns:

Collected init data.

Return type:

dict

Note

This data set is passed to the instance of RadialVelocityAlg and used for radial velocity computation.

get_ccf_version(default_code='python')[source]

Get the ccf code language

Parameters:

default_code (str) – Default ccf code language, ‘python’ or ‘c’

Returns:

ccf code language

Return type:

str

get_mask_line()[source]

Get mask coverage per mask width and the mask centers read from the mask file.

Returns:

dict containing mask line info for entire observation or dict of dict containing mask line info for each fiber source, like:

dict: Mask line for entire observation
{
    'start' : numpy.ndarray            # start points of masks
    'end' : numpy.ndarray              # end points of masks
    'center': numpy.ndarray            # center of masks
    'weight': numpy.ndarray            # weight of masks
    'bc_corr_start': numpy.ndarray     # adjusted start points of masks
    'bc_corr_end': numpy.ndarray       # adjusted end points of masks
}

dict of dict: mask line information for different fiber source,
{ 'fiber1': {                          # mask line info. for fiber source 1
    {
        'start' : numpy.ndarray            # start points of masks
        'end' : numpy.ndarray              # end points of masks
        'center': numpy.ndarray            # center of masks
        'weight': numpy.ndarray            # weight of masks
        'bc_corr_start': numpy.ndarray     # adjusted start points of masks
        'bc_corr_end': numpy.ndarray       # adjusted end points of masks
    }
    :
}

get_redshift_range(bc_path=None, jd_time=None, period=None, bc_output=None)[source]

Get redshift range by using Barycentric velocity correction over a period of time.

Parameters:
  • bc_path (str) – The path of barycentric correction data over a period. Defaults to None.

  • jd_time (float, optional) – Starting time for the period in Julian Date format. Defaults to None. For example, 2458591.5 is for Apr-18-2019.

  • period (int, optional) – Period of days. Defaults to 380 (days).

  • bc_output (str) – The path of the output for Barycentric correction results.

Returns:

Minimum and maximum redshift over a period of time. The first number in the array is the minimum and the second one is the maximum. Attributes zb_range is updated.

Return type:

numpy.ndarray

get_reweighting_ccf_method(default_method='ccf_max')[source]

Get the ccf reweighting method.

Parameters:

default_method (str) – Default ccf reweighting method.

Returns:

ccf reweighting method.

Return type:

str

get_rv_config_value(prop, star_config=None, default=None)[source]

Get value of specific parameter from the config file or star config file.

Check the value from the configuration file first, then from the star configuration file if it is available. The default is set if it is not defined in any configuration file.

Parameters:
  • prop (str) – Name of the parameter to be searched.

  • star_config (ConfigHandler) – Section of designated star in star configuration file.

  • default (Union[int, float, str, bool], optional) – Default value for the searched parameter. Defaults to None.

Returns:

Value for the searched parameter.

Return type:

Union[int, float, str, bool]

get_step_range(default='[-80, 81]')[source]

Get the step range for the velocity.

Parameters:

default (list) – Default step range in string format. Defaults to ‘[-80, 81]’.

Returns:

Step range. step_range in attribute rv_config is updated.

Return type:

list

get_value_from_config(prop, default='', config=None)[source]

Get value of specific parameter from the configuration file.

Get defined value from the specific section of a configuration file. The configuration file is either defined with the module or some other configuration associated with the observation.

Parameters:
  • prop (str) – Name of the parameter to be searched.

  • default (Union[int, float, str, bool], optional) – Default value for the searched parameter.

  • config (ConfigHandler) – External config, such as star config for NEID.

Returns:

Value for the searched parameter.

Return type:

Union[int, float, str, bool]

get_velocity_loop()[source]

Get array of velocities based on step range, step interval, and estimated star radial velocity.

Returns:

Array of evenly spaced velocities. Attribute velocity_loop is updated.

Return type:

numpy.ndarray

get_velocity_steps()[source]

Total velocity steps.

Returns:

Total velocity steps based on attribute velocity_steps of the class. Attribute velocity_steps is updated.

Return type:

int

get_velocity_width_per_pixel(default=None)[source]

Get velocity span per ccd pixel :param default: default velocity span per pixel. :type default: float

Returns:

velocity width per pixel

Return type:

float

init_calculation()[source]

Initial data setup for radial velocity computation based on the setting in PARAM section of the configuration file.

Returns:

status of data initialization, like:

{
    'status': True|False,
    'msg': <error message> # if status is False
}

The following attributes and values are updated,

  • rv_config: values of SPEC, STARNAME, RA, DEC, PMRA, PMDEC, PARALLAX, EPOCH, STAR_RV, OBSLON, OBSLAT, OBSALT, STEP, MASK_WID, STEP_RANGE.

  • velocity_steps

  • velocity_loop

  • zb_range

  • ccf_engine

  • vel_span_pixel

  • mask_line

  • mask_path

  • reweighting_ccf_method

Return type:

dict

init_star_config()[source]

Data initialization from star related configuration, including ra, dec, pmra, pmdec, parallax and the mask file.

Returns:

status of getting data from star related configuration, like:

{
    'status': True|False,
    'msg': <error message> # if status is False
}

Attribute mask_path is updated and the values of the following keys in rv_config, SPEC, STARNAME, RA, DEC, PMRA, PMDEC, EPOCH, and PARALLAX, are updated.

Return type:

dict

start(print_debug=None)[source]

Start the data initialization for radial velocity computation.

Parameters:

print_debug (str, optional) – Print debug information to stdout if it is provided as empty string or to a file path, print_debug, if it is non empty string, or no print is made if it is None. Defaults to None.

Returns:

Result of init data, like:

{
    'status': True|False
    'msg': <error message if status is False>
    'data': <init data>     # Please see Returns of collect_init_data
}

Return type:

dict