cassis_lte_python.LTEmodel ========================== .. py:module:: cassis_lte_python.LTEmodel Classes ------- .. autoapisummary:: cassis_lte_python.LTEmodel.ModelSpectrum cassis_lte_python.LTEmodel.ModelCube Functions --------- .. autoapisummary:: cassis_lte_python.LTEmodel.generate_lte_model_func Module Contents --------------- .. py:function:: generate_lte_model_func(config: dict) Function to generate the model function using information provided in config. The generated function depends on the frequency in MHz and on a set of lmfit parameters. :param config: a dictionary containing : - the following frequency-dependent functions: - tc : continuum values ; no default - beam_sizes : 1-D equivalent beam size ; no default - tmb2ta : conversion factor from Tmb to Ta* scale ; default to 1 - jypb2k : conversion factor from Jy/beam to K ; default to 1 - noise : rms noise values ; default to 0 - line_list : list of transitions to be modeled - cpt_list : list of components :return: The model function to be minimized. .. py:class:: ModelSpectrum(configuration: (dict, str, cassis_lte_python.sim.model_setup.ModelConfiguration), **kwargs) Bases: :py:obj:`object` .. py:attribute:: LOGGER .. py:attribute:: model_config .. py:attribute:: log :value: False .. py:attribute:: normalize :value: False .. py:attribute:: model :value: None .. py:attribute:: model_fit :value: None .. py:attribute:: model_fit_cpt :value: [] .. py:attribute:: figure :value: None .. py:attribute:: tag_colors :value: None .. py:attribute:: tag_other_sp_colors :value: None .. py:attribute:: cpt_cols :value: None .. py:attribute:: thresholds_other :value: None .. py:method:: save_config_dict() .. py:method:: save_config(filename, dirname=None) .. py:method:: update_configuration(config) .. py:method:: model_info(cpt=None) .. py:method:: get_tc(x_mod) .. py:method:: get_rms_cal(fmhz) .. py:method:: param_names() .. py:method:: generate_lte_model(normalize=False) .. py:method:: do_modeling() .. py:method:: do_minimization(print_report: short | long | None = None, report_kws=None) .. py:method:: do_savings() .. py:method:: do_plots() .. py:method:: fit_model(max_nfev=None, fit_kws=None) Computes weights and perform the fit. :param max_nfev: maximum number of iterations (default value depends on the algorithm) :param fit_kws: keywords for the fit function :return: .. py:method:: fit_report(report_kws=None) .. py:method:: eval_uncertainties_components(fmhz, sigma=1) From lmfit.model .. py:method:: compute_model_intensities(params=None, x_values=None, line_list=None, line_center_only=False, cpt=None) .. py:method:: compute_model(params=None, x_values=None, line_list=None, line_center_only=False) For backward compatibility. :param params: :param x_values: :param line_list: :param line_center_only: :return: .. py:method:: integrated_intensities() .. py:method:: setup_plot_fus() Plot in full spectrum mode (self.bandwidth is None) :return: .. py:method:: setup_plot_la(win_list: list, verbose=True, other_species_dict: dict | None = None, **kwargs) Prepare all data to do the plots in line analysis mode :param win_list: the list of windows :param verbose: :param other_species_dict: a dictionary of other species and their thresholds :return: .. py:method:: get_lines_plot_params(line_list: pandas.DataFrame, vlsr: float, f_ref: float, tag_colors: dict) .. py:method:: select_windows(**kwargs) Determine windows to plot :param tag: tag selection if do not want all the tags :param display_all: if False, only display windows with fitted data :param windows: a dictionary of the windows to be plotted (keys=tags, vals=window numbers) :return: .. py:method:: select_windows_other_lines(other_species_win_selection: str) Select windows with other lines from this tag :param other_species_win_selection: desired tag :return: .. py:method:: setup_plot() Prepare all data to do the plot(s), using provided keywords. Possible keywords are : - tag: tag selection if do not want all the tags - basic: do not plot other species - other_species: list or dictionary or file with other species ; dictionary and file can contain their thresholds - other_species_plot: list of other species to plot ; if None, other_species is used ; if other_species is provided, only these species are kept - other_species_win_selection: select only windows with other lines from this tag. - display_all: if False, only display windows with fitted data :return: Notes : - other_species_selection is deprecated, use other_species_win_selection .. py:method:: make_plot(plot_type) Do the plot(s). :param plot_type: gui or file :return: .. py:method:: set_filepath(filename, dirname=None, ext=None) .. py:method:: use_ref_pixel(tag_list=None) :abstractmethod: .. py:method:: save_model(filename, dirname=None, ext='txt', full_spectrum=True) Save the model spectrum from self.model. :param filename: the name of the file :param dirname: the directory where to save the file :param ext: extension of the file : txt (default) or fits :param full_spectrum: save the model for the entire observed spectrum ; if false, only save the model spectrum for the windows in self.win_list :return: None .. py:method:: save_spectrum(filename, dirname=None, ext='txt', spec: None | tuple = None, spectrum_type: typing_extensions.Literal[observed, continuum, synthetic, ] = '', vlsr: None | float | int = None, yunit: None | str = None, comment: None | str = None) Write a spectrum (continuum, data or model, depending on the provided parameters) on a file. :param filename: :param dirname: :param ext: :param spec: tuple of x and y values to be written ; if not provided and continuum is false, stored model is written :param spectrum_type: 'continuum', 'observed', 'synthetic' or empty string '' (default) :param vlsr: :param yunit: :param comment: :return: the path to the file .. py:method:: save_stick_spectrum(filename, dirname=None, ext='fits') .. py:method:: save_line_list_cassis(filename, dirname=None, snr_threshold=None) Writes the list of lines for display in CASSIS. To be used when fitting the entire spectrum. :param filename: :param dirname: :return: .. py:method:: save_fit_results(filename, dirname=None) .. py:method:: write_cassis_file(filename, ext: str, dirname=None, datafile=None) .. py:method:: write_ltm(filename, dirname=None) Writes a LTE model configuration file for CASSIS :param filename: the name of the file :param dirname: the directory where to save the file :return: None .. py:method:: write_lam(filename, dirname=None) Writes a line analysis configuration file for CASSIS :param filename: the name of the file :param dirname: the directory where to save the file :return: None .. py:class:: ModelCube(configuration, verbose=False) Bases: :py:obj:`object` .. py:attribute:: LOGGER .. py:attribute:: output_dir .. py:attribute:: output_dir_spectra .. py:attribute:: output_dir_images .. py:attribute:: log_file_loop .. py:attribute:: cubeshape .. py:attribute:: hdr .. py:attribute:: wcs .. py:attribute:: fmhz_ranges :value: [] .. py:attribute:: ref_pixel_info :value: None .. py:attribute:: latest_valid_params .. py:attribute:: tags .. py:attribute:: param_names .. py:attribute:: user_params .. py:attribute:: parameters_array .. py:attribute:: array_dict .. py:attribute:: err_dict .. py:attribute:: cont_info .. py:method:: get_beams() .. py:method:: read_frequencies(fits_list=None) .. py:method:: pixels_line(xref, yref, xmax, xmin, step=1) .. py:method:: pixels_gradient_loop(xref, yref, xmax, ymax, xmin=0, ymin=0, step=1) .. py:method:: pixel_infos(mdl) .. py:method:: save_latest_valid_params(params: dict) .. py:method:: use_ref_pixel(mdl, tag_list=None) .. py:method:: parameters_at_pix(pix) .. py:method:: do_minimization(pix_list=None) .. py:method:: make_maps(keep_all_pix=True, png_all=False, ntot_scaling='sqrt') Creates the fits images for the varying parameters. :param keep_all_pix: if False, use NaNs for parameters that are at boundary. :return: .. py:method:: print_infos() .. py:property:: log_path .. py:property:: yunit