astra.contrib.ferre.utils¶
Module Contents¶
Functions¶
sanitise_parameter_names(parameter_name) |
|
line_count(filename) |
|
wavelength_array_from_ferre_header(header) |
|
write_data_file(data, path, fmt=’%.4e’, footer=’\n’, **kwargs) |
|
safe_read_header(headers, keys) |
|
read_ferre_header(fp) |
Read a FERRE library header into a dictionary. |
read_ferre_headers(path) |
Read a full FERRE library header with multi-extensions. |
parse_grid_information(header_paths) |
Parse the parameter limits of a pre-computed grid (e.g., in effective temperature) from grid header paths provided, |
yield_suitable_grids(grid_info, mean_fiber, teff, logg, fe_h, telescope) |
Yield suitable FERRE grids given header information from an observation and a dictionary of grid limits. |
get_lsf_grid_name(fibre_number) |
Return the appropriate LSF name (a, b, c, or d) to use, given a mean fiber number. |
parse_header_path(header_path) |
Parse the path of a header file and return a dictionary of relevant parameters. |
approximate_log10_microturbulence(log_g) |
Approximate the log10(microturbulent velocity) given the surface gravity. |
read_output_parameter_file(path, n_dimensions) |
Three more columns follow, giving the fraction of photometric data |
format_ferre_control_keywords(ferre_kwds) |
Format control keywords for FERRE to digest. |
__format_ferre_input_parameters(*p, star_name=’dummy’) |
Format input parameters for FERRE to digest. |
format_ferre_input_parameters(*p, star_name=’dummy’) |
Format input parameters for FERRE to digest. |
prepare_ferre_input_keywords(grid_header_path, n_parameters, parameter_search_indices, n_dimensions, input_parameter_path=’parameters.input’, input_wavelength_path=’wavelengths.input’, input_flux_path=’flux.input’, input_lsf_path=’lsf.input’, input_weights_path=’weights.input’, input_uncertainties_path=’uncertainties.input’, output_parameter_path=’parameters.output’, output_flux_path=’flux.output’, output_normalized_input_flux_path=’normalized_flux.output’, continuum_flag=None, continuum_order=None, continuum_reject=None, continuum_observations_flag=None, n_spectra=None, n_pixels=None, interpolation_order=3, n_runs=1, init_flag=1, init_algorithm_flag=1, optimization_algorithm_flag=1, error_algorithm_flag=0, wavelength_interpolation_flag=0, lsf_shape_flag=0, n_threads=1, synthfile_format_flag=1, full_covariance=False, pca_project=False, pca_chi=False, use_direct_access=True, ferre_kwds=None) |
-
astra.contrib.ferre.utils.sanitise_parameter_names(parameter_name)¶
-
astra.contrib.ferre.utils.line_count(filename)¶
-
astra.contrib.ferre.utils.wavelength_array_from_ferre_header(header)¶
-
astra.contrib.ferre.utils.write_data_file(data, path, fmt='%.4e', footer='n', **kwargs)¶
-
astra.contrib.ferre.utils.safe_read_header(headers, keys)¶
-
astra.contrib.ferre.utils.read_ferre_header(fp)¶ Read a FERRE library header into a dictionary.
This functionality was originally written by Jon Holtzmann.
Parameters: fp – A file pointer to a FERRE header file.
-
astra.contrib.ferre.utils.read_ferre_headers(path)¶ Read a full FERRE library header with multi-extensions. :param path:
The path of a FERRE header file.Returns: libstr0, libstr – first header, then list of extension headers; headers returned as dictionaries
-
astra.contrib.ferre.utils.parse_grid_information(header_paths)¶ Parse the parameter limits of a pre-computed grid (e.g., in effective temperature) from grid header paths provided, and other possibly relevant information (e.g., telescope of the LSF model).
Parameters: header_paths – A list of paths that store information about pre-computed grids. Returns: A dictionary with paths as keys, and the value of the dictionary is a three-length tuple containing (1) metadata, (2) lower limits in parameters, (2) upper limits in parameters.
-
astra.contrib.ferre.utils.yield_suitable_grids(grid_info, mean_fiber, teff, logg, fe_h, telescope)¶ Yield suitable FERRE grids given header information from an observation and a dictionary of grid limits.
Parameters: - grid_info – A dictionary containing header paths as keys, and a three-length tuple as values: (1) metadata, (2) lower limits, (3) upper limits.
This is the expected output from
parse_grid_information. - mean_fiber – The mean fiber number of observations.
- teff – An initial guess of the effective temperature.
- logg – An initial guess of the surface gravity.
- fe_h – An initial guess of the metallicity.
Returns: A generator that yields two-length tuples containing header path, and metadata..
- grid_info – A dictionary containing header paths as keys, and a three-length tuple as values: (1) metadata, (2) lower limits, (3) upper limits.
This is the expected output from
-
astra.contrib.ferre.utils.get_lsf_grid_name(fibre_number)¶ Return the appropriate LSF name (a, b, c, or d) to use, given a mean fiber number.
Parameters: fiber_number – The mean fiber number of observations. Returns: A one-length string describing which LSF grid to use (‘a’, ‘b’, ‘c’, or ‘d’).
-
astra.contrib.ferre.utils.parse_header_path(header_path)¶ Parse the path of a header file and return a dictionary of relevant parameters.
Parameters: header_path – The path of a grid header file. Returns: A dictionary of keywords that are relevant to running FERRE tasks.
-
astra.contrib.ferre.utils.approximate_log10_microturbulence(log_g)¶ Approximate the log10(microturbulent velocity) given the surface gravity.
Parameters: log_g – The surface gravity. Returns: The log base-10 of the microturbulent velocity, vt: log_10(vt).
-
astra.contrib.ferre.utils.read_output_parameter_file(path, n_dimensions)¶ Three more columns follow, giving the fraction of photometric data points (useful when multiple grids combining spectroscopy and photometry are used), the average log(S/N)2 for the spectrum, and the logarithm of the reduced χ^2 for the fit.
Additional columns with the covariance matrix of the errors can be output setting to 1 the keyword COVPRINT.
-
astra.contrib.ferre.utils.format_ferre_control_keywords(ferre_kwds)¶ Format control keywords for FERRE to digest.
Parameters: ferre_kwds – A dictionary of FERRE-recognized keywords, in a suitable order. Returns: String contents for a FERRE input file.
-
astra.contrib.ferre.utils.__format_ferre_input_parameters(*p, star_name='dummy')¶ Format input parameters for FERRE to digest.
Returns: String contents for a FERRE input parameter file.
-
astra.contrib.ferre.utils.format_ferre_input_parameters(*p, star_name='dummy')¶ Format input parameters for FERRE to digest.
Returns: String contents for a FERRE input parameter file.
-
astra.contrib.ferre.utils._translate_keyword¶
-
astra.contrib.ferre.utils.prepare_ferre_input_keywords(grid_header_path, n_parameters, parameter_search_indices, n_dimensions, input_parameter_path='parameters.input', input_wavelength_path='wavelengths.input', input_flux_path='flux.input', input_lsf_path='lsf.input', input_weights_path='weights.input', input_uncertainties_path='uncertainties.input', output_parameter_path='parameters.output', output_flux_path='flux.output', output_normalized_input_flux_path='normalized_flux.output', continuum_flag=None, continuum_order=None, continuum_reject=None, continuum_observations_flag=None, n_spectra=None, n_pixels=None, interpolation_order=3, n_runs=1, init_flag=1, init_algorithm_flag=1, optimization_algorithm_flag=1, error_algorithm_flag=0, wavelength_interpolation_flag=0, lsf_shape_flag=0, n_threads=1, synthfile_format_flag=1, full_covariance=False, pca_project=False, pca_chi=False, use_direct_access=True, ferre_kwds=None)¶