spectuner.slm_factory

class spectuner.slm_factory.SpectralLineModelFactory(config: Config, sl_db: SpectralLineDB | None = None)[source]

Factory class to create objects related to spectral line models.

Parameters:
  • configConfig instance.

  • sl_db – Spectral line database. If this is provided, the code will use this database instead of the one defined in the config.

create_parameter_mgr(specie_list: list, obs_info: list)[source]

Create a parameter manager.

This uses param_info in the config.

Parameters:
  • specie_list – List of species.

  • obs_info – List of information of each spectral window.

create_sl_model(obs_info: list, specie_list: list, sl_dict_list: list | None = None) SpectralLineModel[source]

Create a callable for computing model spectra.

This uses param_info and sl_model in the config.

Parameters:
  • obs_info – List of information of each spectral window.

  • specie_list – List of species.

  • sl_dict_list – List of molecular transition properties. If this is provided, the code will use this list instead of querying the database.

create_peak_mgr(obs_info: list, T_base_data: list | None = None) PeakManager[source]

Create a peak manager.

This uses peak_manager in the config.

Parameters:

obs_info – List of information of each spectral window.

create_fitting_model(obs_info: list, specie_list: list, loss_fn: Literal['pm', 'chi2', 'chi2_ls'] = 'pm', sl_dict_list: list | None = None, T_base_data: list | None = None) FittingModel[source]

Create a callable for fitting.

This uses param_info, sl_model and peak_manager in the config.

Parameters:
  • obs_info – List of information of each spectral window.

  • specie_list – List of species.

  • loss_fn

    Loss function for fitting.

    • "pm": Peak matching.

    • "chi2": Chi-square.

    • "chi2_ls": This should be used for fitting with scipy.optimize.least_squares.

  • sl_dict_list – List of molecular transition properties. If this is provided, the code will use this list instead of querying the database.