spectuner.identify

class spectuner.identify.ResultManager(dirname: str)[source]

Interface to load fitting and identification results.

Parameters:

dirname – Directory that stores the results.

list_fitting_results(target: Literal['single', 'combine', 'modified']) tuple[source]

List all fitting results.

Parameters:

target – Category name.

Returns:

List of fitting result names.

list_ident_results(target: Literal['single', 'combine', 'modified']) tuple[source]

List all identification results.

Parameters:

target – Category name.

Returns:

List of identification result names.

load_fitting_result(target: Literal['single', 'combine', 'modified'], name: str) dict[source]

Load a fitting result.

Parameters:
  • target – Category name.

  • name – Name of the fitting result.

Returns:

Fitting result.

load_ident_result(target: Literal['single', 'combine', 'modified'], name: str) IdentResult[source]

Load an identification result.

Parameters:
  • target – Category name.

  • name – Name of the identification result.

Returns:

Identification result.

derive_df_mol_master(target: Literal['single', 'combine'] = 'combine', max_order: int = 3) DataFrame[source]

Derive a dataframe that summarizes the identification results of all candidates.

Parameters:
  • target – Category name.

  • max_order – Number of the top-x scores to include.

Returns:

Identification result summary.

query_line(freq: float | ndarray, target: Literal['single', 'combine'] = 'combine') list[source]

Find possible candidcates for an observed line from the identification results.

Parameters:
  • freq – Frequency of the unidentified lines. The code finds the closest lines to this frequency. Use an array to query multiple lines.

  • target – Category name. Defaults to “combine”.

Returns:

List of identification result names. If freq is an array, multiple lists are returned.

class spectuner.identify.IdentResult(specie_data: dict, line_table: LineTable, line_table_fp: LineTable, T_single_dict: dict, freq_data: list, specie_list: list, x: ndarray)[source]

Data class to store properties related to identification.

specie_data

Dictionary containing information about species.

Type:

dict

line_table

Line table for peaks that have intersections between the observed and model spectra.

Type:

spectuner.identify.identify.LineTable

line_table_fp

Line table for peaks identified in the model spectrum but not in the observed spectrum.

Type:

spectuner.identify.identify.LineTable

T_single_dict

Dictionary that stores the predicted spectra for each species.

Type:

dict

specie_list

Species information.

Type:

list

x

Best fitting parameters.

Type:

numpy.ndarray

get_T_pred(key: int | None = None, name: str | None = None) list[source]

Load the predicted spectrum.

Parameters:
  • key – Molecular ID. If None, return the spectrum summed over all keys.

  • name – Molecular name. If None, return the spectrum summed over all names of the same key.

Returns:

The predicted spectrum.

get_unknown_lines() ndarray[source]

Load the frequencies of unidentified lines.

Returns:

Unidentified line frequencies.

get_identified_lines(include_fp: bool = False) ndarray[source]

Load the frequencies of identified lines.

Parameters:

include_fp – Whether to include peaks identified in the model spectrum but not in the observed spectrum.

Returns:

Identified line frequencies.

get_line_props(target: Literal['tp', 'fp'], key: str, name: str) dict[source]

Load properties of identified lines.

Parameters:
  • target

    Target peaks:

    • ’tp’: Peaks that have intersections between the observed and model spectra.

    • ’fp’: Peaks identified in the model spectrum but not in the observed spectrum.

  • key – Molecular ID.

  • name – Molecular name.

Returns:

A dict with the following fields:

  • ’freq’ (array): Frequencies of the peaks.

  • ’span’ (array): Frequency spans of the peaks.

  • ’score’ (array): Scores of the peaks.

  • ’frac’ (list): Fraction contributions of the scores of each molecule.

  • ’id’: Group IDs.

  • ’name’: Molecular names.

query_sl_dict(sl_db: SpectralLineDB, key: int, name: str) dict[source]

Query transitions properties.

This method provides frequencies corrected using the velocity offset.

Parameters:
  • sl_db – SpectralLineDB object.

  • key – Molecular ID.

  • name – Molecular name.

Returns:

A dict with the following keys:

  • freq: Corrected frequency in MHz.

  • freq_rest: Rest-frame frequency in MHz.

  • E_low: Enerygy of the lower state in K.

  • E_up: Enerygy of the upper state in K.

  • A_ul: Einstein A cofficient in s^-1.

  • g_u: Upper state degeneracy.

  • Q_T: Partition function.

  • x_T: Temperature of the partition function.

compute_tau_max(sl_db: SpectralLineDB, key: int, name: str) ndarray[source]

Compute the maximum optical depth for each transition.

Parameters:
  • sl_db – Spectral line database.

  • key – Molecular ID.

  • name – Molecular name.

Returns:

Maximum optical depth.

class spectuner.identify.LineTable(freq: ~numpy.ndarray = <factory>, span: ~numpy.ndarray = <factory>, loss: ~numpy.ndarray = <factory>, score: ~numpy.ndarray = <factory>, frac: list = <factory>, id: list = <factory>, name: list = <factory>, error: ~numpy.ndarray = <factory>, norm: ~numpy.ndarray = <factory>)[source]

Data class to store line properties.

freq

Frequencies in MHz.

Type:

np.ndarray

span

Peak spans in MHz.

Type:

np.ndarray

loss

Losses.

Type:

np.ndarray

score

scores.

Type:

np.ndarray

frac

Fraction contributions of the scores of each molecule.

Type:

np.ndarray

id

Corresponding molecular IDs.

Type:

list

name

Corresponding molecular names.

Type:

list

error

Difference of the intensities between the observed and model spectra.

Type:

np.ndarray

norm

Peak intensities.

Type:

np.ndarray