Models

Model (interface)

class kemitter.model.model.Model

Abstract base class for all solver models.

This class defines the common interface used by each individual model. Individual model classes differ in how they implement their run() method, but users interface with them using the methods and attributes defined here.

Notes

Model should not be instantiated on its own. Only its children, which implement a run() method should be used directly.

solver_result

ndarray – 1D array containing the solved variable values returned by the solver in its raw form.

background

float – the solved constant background term.

rates

dict – contains 1D arrays with the solved wavelength-dependent emission rates for each basis type.

total_emission

ndarray – 1D array containing the solved total emission rates, i.e. the sum of each value in Model.rates.

percent_emission

dict – contains 1D arrays corresponding to the percent contribution of each basis type to the total emission at each wavelength.

counts

dict – contains 1D arrays representing the solved wavelength-dependent total counts for each basis type.

basis_names

list of str – names of the basis types, denoting the keys to access specific rates, counts, and percent_emission vectors.

is_empty

bool – Whether or not the model contains any polarized data to process.

polarization_angles

list of int or float – the various polarization angles contained in the model data sets.

bases

list of Basis – the various bases contained in the model data sets in their full object format.

observations

list of Observation – the various observations contained in the model data sets in their full object format.

basis_matrices

list of csc_matrix – list of the sparse basis matrices stored in the Basis objects of the model data sets.

n_polarizations

int – the number of polarized data sets contained in the model.

data_set(pol_angle)

Getter function for a particular polarized data set.

Parameters:pol_angle (int or float) – the polarization angle of the desired polarized data set, in degrees.
Returns (PolDataSet):
The polarized data set object, containing references to the corresponding observations and bases, and if solved the polarized image fits and counts.
remove_data_set(pol_angle)

Removes a polarized data set form the model.

Parameters:pol_angle (int or float) – the polarization angle of the polarized data set to remove, in degrees.
reset()

Clears all polarized data sets from the model, after confirmation.

Warning

This operation will clear any built bases or solver results contained in the model.

run(bases, observations)

Abstract method for all child run() methods

This method is called by each individual solver routine to handle data pre-processing and basis building.

Processing proceeds by first loading bases and observations into proper polarized data sets. In this step, arguments are checked to ensure polarization angles match in value and order. Any bases that have not been built already are built with their corresponding build() method. Then processing is returned to the individual run() implementation of the calling solver.

Parameters:
  • bases (list of Basis) – The basis objects (built or not), to be used for fitting.
  • observations (list of Observations) – The observation objects to be used for fitting.

Polarized Data Set (storage)

class kemitter.model.model.PolDataSet(pol_angle, obs, basis)

Utility class for storing and organizing polarized data (bases, observation, fits).

Used to keep data of the same polarization angle packaged together for batch processing and access.

Warning

Polarized data sets should only be accessed and modified through the parent model’s data_set() method.

pol_angle

int or float – the polarization angle shared by all of the various data set components.

observation

Observation – the experimental observation object

basis

Basis – the theoretically basis object

fit

ndarray – reconstructed fit to observation data once solved by the model solver

counts

ndarray – the wavelength-dependent counts at this particular polarization angle, across all basis types.