castor_etc.spectra.models.flare
Module Contents
Functions
Boilerplate for pulling from the default dictionary if a desired key isn’t present. |
|
Boilerplate for checking units of a variable. |
|
Integrate a spectrum defined in a table with ‘w0’, ‘w1’, and ‘Edensity’ columns. |
|
Dang, I should have cited where I got this. Now it is lost. |
|
Integral of blackbody surface flux at wavelengths from 0 to w. |
|
Quick computation of blackbody surface flux integrated within wbins. |
|
Compute the flux spectral density of the emission from a blackbody. |
|
Rebin some binned values. |
|
Random values drawn from a power-law distribution. |
|
Generate random times of events that when binned into even intervals would yield counts that are Poisson distributed. |
|
Compute the lightcurve from one or more boxcar-decay functions. |
|
Convenience function for converting the energy in a photometric filter to the Si IV energy of a flare. |
|
Return a lightcurve for a single flare normalized to quiescent flux. |
|
Rate of flares spanning the given energy range. |
|
Start times and equivalent durations for a randomly generated series of flares. |
|
Generate a series of random flares and return their lightcurve. |
|
Return the flare spectrum scaled to match the energy or equivalent duration specified by SiIV and binned according to wbins. |
|
Return a series of flare spectra averaged over each tbin for a flare starting at t0 with equivalent duration eqd in Si IV. |
|
Generate time-evolving spectra from a random series of flares. |
|
Calculates flux from input values, picks corresponding spectra for M0-M9. Adds corresponding correction factors for chosen MUSCLES model. Generate time-evolving spectra from a random series of flares. |
Data
API
- castor_etc.spectra.models.flare.FLARE_DATA_PATH = None
- castor_etc.spectra.models.flare.default_flarespec_path = None
- castor_etc.spectra.models.flare.default_flarespec = 'read(...)'
- castor_etc.spectra.models.flare.fuv = None
- castor_etc.spectra.models.flare.nuv = None
- castor_etc.spectra.models.flare.boxcar_height_function_default(eqd)
- castor_etc.spectra.models.flare.flare_defaults = 'dict(...)'
- castor_etc.spectra.models.flare._kw_or_default(kws, keys)
Boilerplate for pulling from the default dictionary if a desired key isn’t present.
- castor_etc.spectra.models.flare._check_unit(func, var, unit)
Boilerplate for checking units of a variable.
- castor_etc.spectra.models.flare._integrate_spec_table(spec_table)
Integrate a spectrum defined in a table with ‘w0’, ‘w1’, and ‘Edensity’ columns.
- castor_etc.spectra.models.flare._fd = None
- castor_etc.spectra.models.flare._flare_params_doc = <Multiline-String>
- castor_etc.spectra.models.flare._param_doc_dic = 'dict(...)'
- castor_etc.spectra.models.flare._tbins_doc = <Multiline-String>
- castor_etc.spectra.models.flare._wbins_doc = <Multiline-String>
- castor_etc.spectra.models.flare._t0_doc = <Multiline-String>
- castor_etc.spectra.models.flare._eqd_doc = <Multiline-String>
- castor_etc.spectra.models.flare.add_indent(txt)
- castor_etc.spectra.models.flare._get_param_string(*keys)
- castor_etc.spectra.models.flare._format_doc(func, **kws)
- castor_etc.spectra.models.flare._Li = None
- castor_etc.spectra.models.flare._P3(x)
Dang, I should have cited where I got this. Now it is lost.
- castor_etc.spectra.models.flare._blackbody_partial_integral(w, T)
Integral of blackbody surface flux at wavelengths from 0 to w.
Parameters
w : astropy quantity, units of length wavelength to which to integrate T : astropy quantity, units of temperature temperature of blackbody
Returns
I : astropy quantity
- castor_etc.spectra.models.flare.blackbody_binned(wbins, T, bolometric=None)
Quick computation of blackbody surface flux integrated within wbins.
This is especially helpful if there are large wavelength bins where taking the value of the Planck function at the midpoint might give inaccurate results.
Parameters
{wbins} T : astropy quantity, units of temperature temperature of blackbody bolometric : astropy quantity, units of energy time-1 length-2 value of the bolometric blackbody flux by which to normalize the output. A value of None gives the flux at the surface of the emitter.
Returns
flux_density : astropy quantity, units of energy time-1 length-3 The flux spectral density of the blackbody in each wbin, generally in units of erg s-1 cm-2 AA-1.
- castor_etc.spectra.models.flare.blackbody_points(w, T, bolometric=None)
Compute the flux spectral density of the emission from a blackbody.
Returns the value at each w, rather than the value averaged over wbins. For the latter, use blackbody_binned.
Parameters
w : astropy quantity array, units of length Wavelengths at which to compute flux density. T : astropy quantity, units of temperature temperature of blackbody bolometric : astropy quantity, units of energy time-1 length-2 value of the bolometric blackbody flux by which to normalize the output. A value of None gives the flux at the surface of the emitter.
Returns
flux_density : astropy quantity, units of energy time-1 length-3 The flux spectral density of the blackbody at each w, generally in units of erg s-1 cm-2 AA-1.
- castor_etc.spectra.models.flare.rebin(bins_new, bins_old, y)
Rebin some binned values.
Parameters
bins_new : array New bin edges. bins_old : array Old bin edges. y : array Binned values (average of some function like a spectrum across each bin).
Returns
y_new : array Rebinned values.
- castor_etc.spectra.models.flare.power_rv(min, max, cumulative_index, n)
Random values drawn from a power-law distribution.
Parameters
min : float Minimum value of the distribution. max : float Maximum value of the distribution. cumulative_index : float Index of the cumulative distribution. n : integer Number of values to draw.
Returns
values : array Array of random values.
- castor_etc.spectra.models.flare.shot_times(rate, time_span)
Generate random times of events that when binned into even intervals would yield counts that are Poisson distributed.
Parameters
rate : float Average rate of events. time_span : float Length of time over which to generate events.
Returns
times : array Times at which random events occurr.
- castor_etc.spectra.models.flare.boxcar_decay(tbins, t0, area_box, height_box, area_decay)
Compute the lightcurve from one or more boxcar-decay functions.
Parameters
tbins : array edges of the time bins used for the lightcurve t0 : float or array start times of the boxcar-decays area_box : float or array areas of the boxcar portion of the boxcar-decays height_box : float or array heights of the boxcar-decays area_decay : float or array areas of the decay portions of the boxcar-decays
Returns
y : array lightcurve values
Notes
This function is a bottleneck when creating a lightcurve from a long series of flares. If this code is to be adapted for quick simulation of years-long series of flares, this is where the speedup needs to happen.
- castor_etc.spectra.models.flare.filter_to_SiIV_energy(filter_wave, filter_response, energy, **flare_params)
Convenience function for converting the energy in a photometric filter to the Si IV energy of a flare.
Parameters
filter_wave : astropy quantity array, units of length Wavelengths of filter response curve. filter_response : array, unitless Filter response at filter_wave. energy : float or astropy quantity, units of energy Energy of the flare in the specified filter. {flare_params}
Returns
energy_SiIV : float or astropy quantity Energy of the flare in the Si IV 1393,1402 AA line.
- castor_etc.spectra.models.flare.flare_lightcurve(tbins, t0, eqd, **flare_params)
Return a lightcurve for a single flare normalized to quiescent flux.
Parameters
{tbins} {t0} {eqd} {flare_params}
Returns
y : array Quiescent-normalized lightcurve of the flare.
- castor_etc.spectra.models.flare.flare_rate(**flare_params)
Rate of flares spanning the given energy range.
Parameters
{flare_params}
Returns
rate : astropy quantity
- castor_etc.spectra.models.flare.flare_series(time_span, **flare_params)
Start times and equivalent durations for a randomly generated series of flares.
Parameters
time_span : astropy quantity, units of time {flare_params}
Returns
t_flare : astropy quantity array, units of time Start times of the random flares. eqd : astropy quantity array, units of time Equivalent durations of the random flares.
- castor_etc.spectra.models.flare.flare_series_lightcurve(tbins, return_flares=False, **flare_params)
Generate a series of random flares and return their lightcurve.
Parameters
{tbins} return_flares : bool If True, return the start times and equivalent durations of the flares. {flare_params}
Returns
y : array Quiescent-normalized ightcurve values in each tbin. tflares : astropy quantity array, units of time, optional Start time of random flares. eqd : astropy quantity array, units of time, optional Equivalent durations of the random flares.
- castor_etc.spectra.models.flare.flare_spectrum(wbins, SiIV, **flare_params)
Return the flare spectrum scaled to match the energy or equivalent duration specified by SiIV and binned according to wbins.
Parameters
{wbins} SiIV : float or astropy quantity Equivalent duration or energy of the flare in the Si IV 1393,1402 AA line. This could also be peak flux or some other quantity, but note that you should probably specificy your own ‘Edensity’ column of the SiIV_normed_flare_spec table to match if so. {flare_params}
Returns
spectrum : astropy quantity array, units variabile according to units of SiIV Energy spectral density or other spectral density of the flare spectrum in each wbin.
- castor_etc.spectra.models.flare.flare_spectra(wbins, tbins, t0, eqd, **flare_params)
Return a series of flare spectra averaged over each tbin for a flare starting at t0 with equivalent duration eqd in Si IV.
Parameters
{wbins} {tbins} {t0} {eqd} {flare_params}
Returns
spectra : astropy quantity array, variable units Array of spectra in each tbin, where the array has dimensions (len(tbins)-1, len(wbins)-1). Units will match the product of the eqd and SiIV_quiescent units, divided by time and length.
- castor_etc.spectra.models.flare.flare_series_spectra(wbins, tbins, **flare_params)
Generate time-evolving spectra from a random series of flares.
Parameters
{wbins} {tbins} {flare_params}
Returns
spectra : astropy quantity array Array of spectra in each tbin, where the array has dimensions (len(tbins)-1, len(wbins)-1). Units will match the product of the eqd and SiIV_quiescent units, divided by time and length.
- castor_etc.spectra.models.flare.compute_flux_wavelength(star_radius, star_eff_temp, dist_to_star, show_figure)
Calculates flux from input values, picks corresponding spectra for M0-M9. Adds corresponding correction factors for chosen MUSCLES model. Generate time-evolving spectra from a random series of flares.
Parameters
{Star_radius} in solar radius {star_eff_temp} in Kelvin {dist_to_star} in light-years {print_figure} prints the full spectrum, Returns
spectra : 2D array Array of spectra in each tbin, where the array has dimensions (len(tbins)-1, len(wbins)-1). Units will match the product of the eqd and SiIV_quiescent units, divided by time and length. Returns wavelength, flux