desk.set_up package

Submodules

desk.set_up.config module

desk.set_up.create_output_files module

desk.set_up.create_output_files.make_output_files_dusty(fit_params)[source]

Creates results csv file.

Parameters:

fit_params (Class) – Single source class with models, data, and specified options.

Returns:

Csv file with the first row (header).

Return type:

csv

desk.set_up.create_output_files.remove_old_output_files()[source]

Removes results file from previous run.

desk.set_up.error_messages module

exception desk.set_up.error_messages.BadFilenameError[source]

Bases: ValueError

Specific error message for bad input source (filename)

exception desk.set_up.error_messages.BadSourceDirectoryError[source]

Bases: ValueError

Specific error message for bad input source (directory)

exception desk.set_up.error_messages.Fitting_Range_Error[source]

Bases: ValueError

Specific error message for bad input range

desk.set_up.full_grid module

desk.set_up.full_grid.generate_model_luminosities(n)[source]

Creates an array of n luminosities from the lum_min and lum_max specified in the cofig.py script.

Parameters:

n (int) – number of luminosities to scale grid by.

Returns:

luminosities – array of luminosity values.

Return type:

array

class desk.set_up.full_grid.instantiate(grid, grid_dusty, grid_outputs, distance, n)[source]

Bases: object

Creates class with parameters needed to scale to the full grids

desk.set_up.full_grid.retrieve(full_grid_params)[source]

Creates full scaled grid using data from full_grid_params Class.

Parameters:

full_grid_params (class) – Class using parameters from instantiate class.

Returns:

  • full_outputs (astropy table) – scaled model grid outputs similar to grid_outputs

  • full_model_grid (astropy table) – scaled models similar to grid_dusty

desk.set_up.get_data module

desk.set_up.get_data.compile_data(source: str)[source]

Returns array with csv filename or csv filenames in specified directory.

Parameters:

source (str) – user input source name

Returns:

data – array with 1 or multiple filenames

Return type:

array

desk.set_up.get_data.get_values(filename: str, min_wavelength: float = 0, max_wavelength: float = 1000, fitting: bool = False)[source]

Reads csv file, convets Jy to Wm2, sorts both by wavelength. Returns both as 1D arrays.

Parameters:
  • filename (str) – Name of csv file name. The file should have: Column 0: wavelength in um, Column 1: flux in Jy

  • max_wavelength (float) – The maximum wavelength in um to fit the data.

  • min_wavelength (float) – The maximum wavelength in um to fit the data

  • fitting (bool) – Whether fitting or displaying data. If fitting=True, function will trim data using min_wavelength and max_wavelength.

Returns:

  • x (1D array) – wavelength in um

  • y (1D array) – flux in w/m2

desk.set_up.get_inputs module

class desk.set_up.get_inputs.fitting_parameters(file_names: list, source: str, distance: float, grid: str, n: int, model_wavelength_grid: ndarray, full_model_grid, full_outputs, min_wavelength: float, max_wavelength: float, save_model_spectrum: bool, testing: bool)[source]

Bases: object

Initializes fitting paramters.

desk.set_up.get_models module

desk.set_up.get_models.check_models(model_grid: str, respond: bool)[source]

Checks if model grids are available and returns the full path to the model. If the model is not downloaded, it is downloaded via Box.

Parameters:
  • model_grid (str) – Name of model grid to use.

  • respond (Bool) – Whether to print if models were found.

Returns:

  • outputs_file (str) – The full path/name of the model outputs file.

  • models_file (str) – The full path/name of the model grid file.

desk.set_up.get_models.get_model_grid(grid: str, testing: bool = False, respond: bool = True)[source]

Gets the real model grid name if the defaults were chosen,and runs check_models.

Parameters:
  • grid (str) – Model grid name.

  • testing (str) – Flag for testing that returns small grid (3 rows)

  • respond (Bool) – Whether to print if models were found.

Returns:

  • grid_dusty (2 column astropy table with array of wavelengths (um) and array of)

  • fluxes (Wm^2) in each column of each row. The (intial) model grid wavelengths and fluxes.

  • This is not the full model grid with appended scaled models.

  • grid_outputs (astropy table) – The model grid parameters corresponding to the grid_dusty model grids

desk.set_up.get_models.get_model_index_using_number(grid_name: str, grid_outputs, requested_grid_number: int, requested_grid_index: int = 0)[source]

Returns the model_outputs index of a grid or external grid given.

Parameters:
  • grid_name (str) – Name of the desk grid for which you want a model.

  • grid_outputs (astropy table) – outputs table read from the *model*_outfits.hdf5 file.

  • requested_grid_number (int) – number which is a column in the model_outputs. Number is unique for external grids but not for regular grids.

  • requested_grid_index (int) – grid_idx which is a column in the model_outputs. For grids, number and grid_idx create unique identifier.

Returns:

correct_index – grid outputs index of correct model.

Return type:

int

desk.set_up.get_models.get_remote_models(model_grid_name: str)[source]

Downloads models and model results files (HDF5) from BOX.

Parameters:

model_grid_name (str) – Name of model grid to download.

desk.set_up.get_models.read_hdf5(filename: str, testing: bool | str)[source]

Reads HDF5 file.

Parameters:
  • filename (str) – name of the file to be read including the full path.

  • testing (str) – If testing flag enabled, the function will only return the first couple columns of the table.

Returns:

out – contents of table at filename.

Return type:

astropy table

desk.set_up.scale_dusty module

desk.set_up.scale_dusty.scale(_outputs, _models, luminosities: ndarray, scaling_factor: float)[source]

Scale DUSTY models and outputs.

Parameters:
  • _outputs (astropy table) – grid outputs.

  • _models (astropy table) – grid models.

  • luminosities (array) – 1-D array of luminosities

  • scaling_factor (float) – Scaling factor to scale grids to distance.

Returns:

  • full_outputs (astropy table) – Updated astropy table with scaled vexp, and mdot.

  • full_model_grid (astropy table) – astropy table with sclaed fluxes

desk.set_up.scale_dusty.scale_mdot(mass_loss_rates: ndarray, luminosities: ndarray) ndarray[source]

Scales mass loss rates by the luminosity and gas-to-dust ratio see: Elitzur & Ivezić 2001, MNRAS, 327, 403 (https://ui.adsabs.harvard.edu/abs/2001MNRAS.327..403E/abstract)

Parameters:
  • mass_loss_rates (array) – mass-loss rates from original model grid.

  • luminosities (array) – unique luminosity values created by generate_model_luminosities.

Returns:

scaled_mdot – scaled mass loss rates.

Return type:

array

desk.set_up.scale_dusty.scale_vexp(expansion_velocities: ndarray, luminosities: ndarray) ndarray[source]

Scales expansion velocity by the luminosity and gas-to-dust ratio see: Elitzur & Ivezić 2001, MNRAS, 327, 403 (https://ui.adsabs.harvard.edu/abs/2001MNRAS.327..403E/abstract)

Parameters:
  • expansion_velocities (array) – expansion velocities from original model grid.

  • luminosities (array) – unique luminosity values created by generate_model_luminosities.

Returns:

scaled_expansion_velocities – scaled expansion velocities.

Return type:

array

desk.set_up.scale_external module

desk.set_up.scale_external.scale_by_distance(_grid_name: str, _outputs, _models, scaling_factor: float, distance: float)[source]

Scale external model fluxes and normalization value.

Parameters:
  • _grid_name (str) – name of grid specified

  • _outputs (astropy table) – grid outputs.

  • _models (astropy table) – grid models.

  • scaling_factor (float) – Scaling factor to scale grids to distance.

  • distance (float) – distance in kpc

Returns:

  • _outputs (astropy table) – Updated astropy table with scaled vexp, and mdot.

  • scaled_models (astropy table) – astropy table with sclaed fluxes

Module contents