InverseSquareFluxScaling#

class sunkit_spex.models.scaling.InverseSquareFluxScaling(observer_distance=<Quantity 1. AU>, **kwargs)[source]#

Bases: FittableModel

InverseSqaureFluxScaling model converts luminosity output of physical models to a distance scaled flux.

Parameters:
  • energy_edges – Energy edges associated with input spectrum

  • observer_distance – Distance of the observer from the source.

Examples

import astropy.units as u
import numpy as np
import matplotlib.pyplot as plt

from sunkit_spex.models.scaling import InverseSquareFluxScaling
from sunkit_spex.models.models import StraightLineModel

y_units = u.ph*u.keV**-1*u.s**-1
x_units = u.keV

ph_energies = np.arange(4, 100, 0.5)*x_units
ph_energies_centers = ph_energies[:-1] + 0.5*np.diff(ph_energies)

sim_cont = {"slope": -2*y_units/x_units, "intercept": 100*y_units}
source = StraightLineModel(**sim_cont)

plt.figure()
for i, d in enumerate([0.25,0.5,1]):
    distance =  InverseSquareFluxScaling(observer_distance=d*u.AU)
    observed = source * distance
    plt.plot(ph_energies_centers ,  observed(ph_energies), label='D = '+str(d)+' AU')
plt.loglog()
plt.legend()
plt.show()

(Source code, png, hires.png, pdf)

../_images/sunkit_spex-models-scaling-InverseSquareFluxScaling-1.png

Attributes Summary

n_inputs

n_outputs

name

observer_distance

param_names

Names of the parameters that describe models of this type.

return_units

This property is used to indicate what units or sets of units the output of evaluate should be in, and returns a dictionary mapping outputs to units (or None if any units are accepted).

Methods Summary

__call__(*inputs[, model_set_axis, ...])

Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.

evaluate(x, observer_distance)

Evaluate the model on some input variables.

Attributes Documentation

n_inputs = 1#
n_outputs = 1#
name = 'InverseSquareFluxScaling'#
observer_distance = Parameter('observer_distance', value=1.0, unit=AU, fixed=True)#
param_names = ('observer_distance',)#

Names of the parameters that describe models of this type.

The parameters in this tuple are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.

When defining a custom model class the value of this attribute is automatically set by the Parameter attributes defined in the class body.

return_units#

Methods Documentation

__call__(
*inputs,
model_set_axis=None,
with_bounding_box=False,
fill_value=nan,
equivalencies=None,
inputs_map=None,
**new_inputs,
)#

Evaluate this model using the given input(s) and the parameter values that were specified when the model was instantiated.

evaluate(x, observer_distance)[source]#

Evaluate the model on some input variables.