Skip to content

Thick Target (and thermal) Update - #291

Open
KriSun95 wants to merge 10 commits into
sunpy:mainfrom
KriSun95:tt-fix
Open

Thick Target (and thermal) Update#291
KriSun95 wants to merge 10 commits into
sunpy:mainfrom
KriSun95:tt-fix

Conversation

@KriSun95

@KriSun95 KriSun95 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This PR got a bit away from me but it was all in the investigation of trying to figure out why the Thick target model would return NaNs sometimes.

So, what I've done is:

  • Because the scaling of emission measure and electron fluxes was being a real pain in the neck trying to work out what was going on, I've defined new Astropy units for these parameters to work in. This means that our units can now actually make sense using norm_thick_target_eflux_units, norm_thin_target_eflux_units, and norm_thermal_emission_measure_units.
    • E.g., we can pass the real value of emission measure, say 5e49 cm^-3, if we like but internally the value will be converted to the scaled version of 5 new_units where new_untis is 1e49 cm^-3. This is unit aware and so conversions can easily happen that the code knows about rather than it being in some places in the doc string that 5 cm^-3 really means 5e49 cm^-3.
    • Tests were added tp make sure 5e49 cm^-3 and 5 new_units work the same and as intended.
  • I've added realistic bounds to the thick target and thermal model parameters. Particularly for the thick target, certain values would result in a division by zero somewhere in the internal calculations and sometimes cause NaNs.
    • Tests have been added to make sure these weird values that the new bounds try to prevent give RunTimeWarnings as they should.
  • Units for parameters are now assumed or converted with << when the model evaluates. This means we don't need to have if/else statements checking all the input units then assuming the units if they're not there.
    • Unit behaviour should now be consistent between the models. Before, the thermal and thick target would work differently. E.g., the thermal model would always return units when evaluated but the thick target wouldn't. Now both return them, always in the same way (@jajmitchell , would this affect fitting? I'm unsure how if the thermal and thick were behaving differently anyway but want to check).

The above were fixes I made to keep investigating the weird NaN behaviour I've seen before, removing cases where this has happened. I then ran a fit, producing the plot below (data=thermal+thick source, model=thermal+thick model, thick=just the thick target model contribution):

Screenshot 2026-07-28 at 3 45 46 pm

From here, the thick target is returning one bin around 20 keV with a NaN.

Investigating this further, I think there are two important points:

  • it's the bin with the low-energy cut-off energy in it. See the example code and output below.
  • Moreover, this only appears with finer energy binning. Running the Thick target model with energies like energy_edges = np.arange(2, 15, 0.1) << u.keV instead does not return a NaN in that bin.

Still to do:

  • create a changelog
  • Following the Astropy Parameter docs, add a getter/setter to the flux and emission measure parameters (those that are scaled) so that if the parameter is edited outside initialising the model or calling evaluate (e.g., just doing something like .emission_measure = 3e50<<u.cm**-3) the units will be converted to the new scaled units for use internally to the model.
    • Turns out this is complicated. There may also be a bug inAstropy stopping us doing this when the parameter has units but I give up just now.
  • Will this PR fix the weird NaN in the low-energy cut-off bin issue? This seems like another PR after the model updates already here.
    • I think, now, that this PR should just have these updates and general fixes to the models. Then, along with Issue Thick target model errors #292, we can dive into the deeper issue with the thick target model in another PR.

The code I used to make the plot is here:

import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
from astropy.modeling.functional_models import FLOAT_EPSILON
from sunkit_spex.models.physical.nonthermal import ThickTarget, ThinTarget
from sunkit_spex.models.physical.thermal import ThermalEmission
from scipy.optimize import minimize

  

energy_edges = np.arange(1.6, 60, 0.2) << u.keV
energy_mids = (energy_edges[:-1]+energy_edges[1:])/2

  

thick = model.evaluate(energy_edges,
						p=5.7,
						break_energy=1500<< u.keV,
						q=20,
						low_e_cutoff=21.5<<u.keV,
						high_e_cutoff=1500<< u.keV,
						total_eflux=2.2)
therm = ThermalEmission(temperature=23<<u.MK, 
						emission_measure=17e49<<u.cm**-3)(energy_edges)
flux_data = thick + therm
rng = np.random.default_rng(147)
flux_data *= rng.normal(1.0, 0.2, energy_mids.shape)

def _fun(fp, x, data):

	p, eelow, eflux, t, em = fp
	model = ThickTarget(p=p,
						break_energy=1500<< u.keV,
						q=20,
						low_e_cutoff=eelow<< u.keV,
						high_e_cutoff=1500<< u.keV,
						total_eflux=eflux) + \
						ThermalEmission(temperature=t<<u.MK,
										emission_measure=em)
	mod = model(x)
	
	if any(np.isnan(mod)):
	print(fp)
	print(mod)
	
	res = (data-mod)/data
	return np.sum(res**2)
fun = lambda fp: _fun(fp, *(energy_edges, flux_data))

  
result = minimize(
				fun,
				[5, 20, 1, 20, 20],
				bounds=tuple(zip((1+FLOAT_EPSILON*1e30, 0+FLOAT_EPSILON, 0, 2, 0), (np.inf, np.inf, np.inf, 30, np.inf))),
				method="Nelder-Mead",
				tol=1e-30,
				)

print(result)

model = ThickTarget(p=result.x[0],
					break_energy=1500<< u.keV,
					q=20,
					low_e_cutoff=result.x[1]<< u.keV,
					high_e_cutoff=1500<< u.keV,
					total_eflux=result.x[2]) + \
					ThermalEmission(temperature=result.x[3]<<u.MK,
									emission_measure=result.x[4])

plt.figure()
plt.plot(energy_mids, flux_data, marker="o", label="data")
plt.plot(energy_mids, model(energy_edges), marker="x", ls=":", label="model")
plt.plot(energy_mids, thick, marker="o", label="thick")
plt.legend()
plt.yscale("log")
plt.ylabel(f"[{flux_c.unit:latex}]")
plt.xlabel(f"Energy [{energy_mids.unit:latex}]")
plt.show()

With output (the arrays being printed are those that contain a NaN during the parameter search during fitting with the parameters producing the array printed on the line before):

/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/sunkit_spex/sunkit_spex/models/physical/nonthermal.py:545: RuntimeWarning: divide by zero encountered in divide
  a2 = alpha * z * e2 / p2
/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/sunkit_spex/sunkit_spex/models/physical/nonthermal.py:726: RuntimeWarning: invalid value encountered in subtract
  l1 = np.abs(intsum - lastsum)
/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/sunkit_spex/sunkit_spex/models/physical/thermal.py:1266: UserWarning: Some input energy values outside valid range of 1.0002920302956426--10.34753795157738 keV. Flux will be zero outside this range.
  warnings.warn(message)
/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/venvs/jf/.venv/lib/python3.14/site-packages/astropy/units/quantity.py:676: RuntimeWarning: invalid value encountered in divide
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/sunkit_spex/sunkit_spex/models/physical/nonthermal.py:550: RuntimeWarning: invalid value encountered in multiply
  return twoar02 * fe * crtmp
[ 5.025 20.1    1.005 20.1   20.5  ]
[3.30226195e+35 4.40410516e+35 3.12908775e+35 1.59622992e+35
 1.77661807e+35 1.07801633e+35 7.29047670e+34 7.32678743e+34
 5.27420023e+34 4.03291129e+34 3.57758010e+34 4.98587590e+34
 2.51616537e+34 2.00248446e+34 1.80645706e+34 1.53240271e+34
 1.28076938e+34 1.05163553e+34 9.02943697e+33 7.72370222e+33
 6.61641590e+33 5.67149701e+33 4.85987336e+33 4.21457204e+33
 1.58307819e+34 4.74932307e+34 2.69839599e+33 2.27356612e+33
 1.94531998e+33 1.68324506e+33 2.96837422e+33 3.12894847e+33
 1.43856267e+33 1.61985535e+33 1.00792327e+33 7.09580973e+32
 6.56082161e+32 5.96805081e+32 4.96939466e+32 4.29122420e+32
 3.75277785e+32 3.25859345e+32 2.83029402e+32 2.46910156e+32
 2.15348417e+32 1.87837894e+32 1.63902084e+32 1.43064551e+32
 1.24914100e+32 1.09115100e+32 9.53501319e+31 8.33412556e+31
 7.28585683e+31 6.37308734e+31 5.57561927e+31 4.87852207e+31
 4.27115030e+31 3.73950802e+31 3.27521745e+31 2.86933287e+31
 2.51407783e+31 2.20378431e+31 1.93177043e+31 1.69421774e+31
 1.48579996e+31 1.30366635e+31 1.14387310e+31 1.00401609e+31
 8.81428791e+30 7.73867026e+30 6.79770522e+30 5.97008761e+30
 5.24652308e+30 4.61065348e+30 4.05206868e+30 3.56325501e+30
 3.13298571e+30 2.75520982e+30 2.42372727e+30 2.13188224e+30
 1.87601843e+30 1.65183576e+30 1.45433051e+30 1.28064634e+30
 1.12842629e+30 9.94257164e+29 8.76008745e+29 7.72394585e+29
 6.81156644e+29 6.00700707e+29 5.29806215e+29 4.67693975e+29
            nan 3.64536095e+29 3.21904810e+29 2.84541496e+29
 2.51556162e+29 2.22436500e+29 1.96729937e+29 1.74159217e+29
 1.54263166e+29 1.36684144e+29 1.21151925e+29 1.07427721e+29
 9.53886384e+28 8.47423335e+28 7.53255271e+28 6.69954373e+28
 5.96258460e+28 5.31418705e+28 4.74084959e+28 4.23297600e+28
 3.78300357e+28 3.38424409e+28 3.03104620e+28 2.71981400e+28
 2.44354999e+28 2.19824206e+28 1.98034020e+28 1.78670332e+28
 1.61455217e+28 1.46229426e+28 1.32685273e+28 1.20614517e+28
 1.09850017e+28 1.00243784e+28 9.16647846e+27 8.39969942e+27
 7.71780694e+27 7.10726682e+27 6.55957668e+27 6.06774177e+27
 5.62556243e+27 5.22754328e+27 4.86881271e+27 4.54530225e+27
 4.25430207e+27 3.99068911e+27 3.75150974e+27 3.53414197e+27
 3.33625780e+27 3.15578984e+27 2.99090173e+27 2.83996191e+27
 2.70179360e+27 2.57507135e+27 2.45829793e+27 2.35047268e+27
 2.25070451e+27 2.15819957e+27 2.07225029e+27 1.99222575e+27
 1.91756308e+27 1.84775983e+27 1.78248284e+27 1.72124652e+27
 1.66362773e+27 1.60931101e+27 1.55801355e+27 1.50948164e+27
 1.46348747e+27 1.41982630e+27 1.37831391e+27 1.33878440e+27
 1.30108821e+27 1.26511423e+27 1.23073344e+27 1.19780932e+27
 1.16624335e+27 1.13594602e+27 1.10683594e+27 1.07883896e+27
 1.05188744e+27 1.02591956e+27 1.00087875e+27 9.76713122e+26
 9.53375046e+26 9.30820693e+26 9.09016185e+26 8.87918986e+26
 8.67491547e+26 8.47702197e+26 8.28521516e+26 8.09922124e+26
 7.91878495e+26 7.74366791e+26 7.57364708e+26 7.40851351e+26
 7.24807101e+26 7.09213518e+26 6.94053233e+26 6.79309870e+26
 6.64967958e+26 6.51014152e+26 6.37433266e+26 6.24211908e+26
 6.11337642e+26 5.98798641e+26 5.86583639e+26 5.74681897e+26
 5.63083165e+26 5.51777653e+26 5.40755999e+26 5.30009242e+26
 5.19528798e+26 5.09306441e+26 4.99334275e+26 4.89604722e+26
 4.80110500e+26 4.70844608e+26 4.61800393e+26 4.52971386e+26
 4.44351212e+26 4.35933861e+26 4.27713541e+26 4.19684663e+26
 4.11841834e+26 4.04179849e+26 3.96693680e+26 3.89378468e+26
 3.82229519e+26 3.75242295e+26 3.68412406e+26 3.61735605e+26
 3.55207784e+26 3.48824965e+26 3.42583299e+26 3.36479056e+26
 3.30508623e+26 3.24668503e+26 3.18955302e+26 3.13365744e+26
 3.07896635e+26 3.02544879e+26 2.97307478e+26 2.92181527e+26
 2.87164204e+26 2.82252773e+26 2.77444578e+26 2.72737040e+26
 2.68127655e+26 2.63613994e+26 2.59193695e+26 2.54864465e+26
 2.50624078e+26 2.46470369e+26 2.42401236e+26 2.38414635e+26
 2.34508581e+26 2.30681141e+26 2.26930441e+26 2.23254654e+26
 2.19652006e+26 2.16120771e+26 2.12659271e+26 2.09265873e+26
 2.05938987e+26 2.02677069e+26 1.99478614e+26 1.96342158e+26
 1.93266276e+26 1.90249581e+26 1.87290724e+26 1.84388389e+26
 1.81541298e+26 1.78748203e+26 1.76007891e+26 1.73319179e+26
 1.70680916e+26 1.68091980e+26 1.65551278e+26 1.63057744e+26
 1.60610341e+26 1.58208057e+26 1.55849907e+26 1.53534929e+26
 1.51262187e+26 1.49030767e+26 1.46839779e+26 1.44688355e+26
 1.42575649e+26 1.40500833e+26 1.38463103e+26 1.36461674e+26
 1.34495779e+26 1.32564669e+26 1.30667617e+26 1.28803909e+26
 1.26972852e+26 1.25173767e+26 1.23405993e+26] ph / (keV s)
/Users/kris/Documents/umnPostdoc/projects/code/sunxspexMaster/sunkit_spex/sunkit_spex/legacy/integrate.py:94: RuntimeWarning: invalid value encountered in multiply
  return np.sum(wi * func(xi, *args, **func_kwargs), axis=1)
[ 5.  20.5  1.  20.  20. ]
[3.22675962e+35 4.31824509e+35 3.05791101e+35 1.55793520e+35
 1.73469269e+35 1.04826212e+35 7.09335250e+34 7.12507095e+34
 5.12043003e+34 3.91460758e+34 3.47156742e+34 4.83565835e+34
 2.43589653e+34 1.93958280e+34 1.74892502e+34 1.48266785e+34
 1.23832639e+34 1.01628554e+34 8.72126396e+33 7.45598431e+33
 6.38354576e+33 5.46890617e+33 4.68381477e+33 4.06076167e+33
 1.52832643e+34 4.55518431e+34 2.59311245e+33 2.18497535e+33
 1.86907125e+33 1.61633812e+33 2.83978948e+33 2.98741680e+33
 1.37884241e+33 1.54887373e+33 9.64017422e+32 6.79087556e+32
 6.27094196e+32 5.69755137e+32 4.74387735e+32 4.09483858e+32
 3.57858691e+32 3.10578069e+32 2.69622399e+32 2.35074724e+32
 2.04907627e+32 1.78629162e+32 1.55778118e+32 1.35896106e+32
 1.18587698e+32 1.03530050e+32 9.04183348e+31 7.89858302e+31
 6.90119143e+31 6.03320286e+31 5.27528866e+31 4.61314345e+31
 4.03654295e+31 3.53212346e+31 3.09185328e+31 2.70718383e+31
 2.37068835e+31 2.07694335e+31 1.81958345e+31 1.59495219e+31
 1.39798376e+31 1.22595039e+31 1.07510411e+31 9.43151170e+30
 8.27556658e+30 7.26187672e+30 6.37557146e+30 5.59647365e+30
 4.91569578e+30 4.31776252e+30 3.79276401e+30 3.33349432e+30
 2.92946956e+30 2.57501382e+30 2.26424845e+30 1.99078820e+30
 1.75115166e+30 1.54127921e+30 1.35647891e+30 1.19404598e+30
 1.05174403e+30 9.26382566e+29 8.15953828e+29 7.19237921e+29
 6.34116246e+29 5.59090603e+29 4.93012479e+29 4.35144770e+29
 3.84107839e+29 3.39097023e+29            nan 2.64667320e+29
 2.33994900e+29 2.06928020e+29 1.83042893e+29 1.62079292e+29
 1.43606329e+29 1.27289931e+29 1.12877648e+29 1.00146518e+29
 8.89798850e+28 7.91073133e+28 7.03765897e+28 6.26546500e+28
 5.58239293e+28 4.98141821e+28 4.45002567e+28 3.97930405e+28
 3.56222328e+28 3.19256940e+28 2.86509066e+28 2.57642521e+28
 2.32011338e+28 2.09243461e+28 1.89009843e+28 1.71019480e+28
 1.55015008e+28 1.40847833e+28 1.28234401e+28 1.16982361e+28
 1.06937192e+28 9.79621354e+27 8.99361469e+27 8.27520876e+27
 7.63518205e+27 7.06110473e+27 6.54514080e+27 6.08083879e+27
 5.66248207e+27 5.28500463e+27 4.94391647e+27 4.63546286e+27
 4.35712114e+27 4.10420966e+27 3.87400675e+27 3.66409646e+27
 3.47233368e+27 3.29681337e+27 3.13584316e+27 2.98791923e+27
 2.85195028e+27 2.72671448e+27 2.61083909e+27 2.50340035e+27
 2.40357522e+27 2.31063005e+27 2.22391050e+27 2.14283269e+27
 2.06687526e+27 1.99557238e+27 1.92861108e+27 1.86554288e+27
 1.80597639e+27 1.74961754e+27 1.69620232e+27 1.64549348e+27
 1.59727760e+27 1.55136249e+27 1.50757490e+27 1.46575844e+27
 1.42577178e+27 1.38750821e+27 1.35084560e+27 1.31565567e+27
 1.28184421e+27 1.24932539e+27 1.21802088e+27 1.18785911e+27
 1.15877456e+27 1.13070713e+27 1.10360164e+27 1.07740728e+27
 1.05207724e+27 1.02756827e+27 1.00384610e+27 9.80869018e+26
 9.58599913e+26 9.37007008e+26 9.16060675e+26 8.95733233e+26
 8.75998780e+26 8.56833035e+26 8.38213198e+26 8.20117830e+26
 8.02526735e+26 7.85420860e+26 7.68782205e+26 7.52593742e+26
 7.36839335e+26 7.21504805e+26 7.06574449e+26 6.92034227e+26
 6.77871014e+26 6.64072298e+26 6.50626135e+26 6.37521114e+26
 6.24746321e+26 6.12291311e+26 6.00146077e+26 5.88301025e+26
 5.76746949e+26 5.65475012e+26 5.54476722e+26 5.43743914e+26
 5.33268736e+26 5.23043628e+26 5.13061378e+26 5.03314984e+26
 4.93797568e+26 4.84502614e+26 4.75423834e+26 4.66555156e+26
 4.57890720e+26 4.49424860e+26 4.41152105e+26 4.33067163e+26
 4.25164918e+26 4.17440420e+26 4.09888881e+26 4.02505666e+26
 3.95286288e+26 3.88226403e+26 3.81321802e+26 3.74568410e+26
 3.67962275e+26 3.61499569e+26 3.55176582e+26 3.48989722e+26
 3.42935495e+26 3.37010511e+26 3.31211486e+26 3.25535236e+26
 3.19978669e+26 3.14538785e+26 3.09212671e+26 3.03997500e+26
 2.98890524e+26 2.93889078e+26 2.88990571e+26 2.84192487e+26
 2.79492381e+26 2.74887877e+26 2.70376666e+26 2.65956505e+26
 2.61625212e+26 2.57380666e+26 2.53220805e+26 2.49143624e+26
 2.45147173e+26 2.41229555e+26 2.37388925e+26 2.33623487e+26
 2.29931496e+26 2.26311251e+26 2.22761099e+26 2.19279428e+26
 2.15864672e+26 2.12515306e+26 2.09229843e+26 2.06006839e+26
 2.02844883e+26 1.99742605e+26 1.96698668e+26 1.93711772e+26
 1.90780648e+26 1.87904061e+26 1.85080807e+26 1.82309714e+26
 1.79589638e+26 1.76919466e+26 1.74298111e+26 1.71724516e+26
 1.69197647e+26 1.66716499e+26 1.64280091e+26 1.61887465e+26
 1.59537689e+26 1.57229853e+26 1.54963067e+26 1.52736468e+26
 1.50549208e+26 1.48400465e+26 1.46289434e+26 1.44215329e+26
 1.42177385e+26 1.40174854e+26 1.38207005e+26] ph / (keV s)
[ 5.025 20.1    1.005 20.1   19.75 ]
[3.18144809e+35 4.24297989e+35 3.01460939e+35 1.53783166e+35
 1.71162020e+35 1.03857703e+35 7.02375481e+34 7.05873684e+34
 5.08124406e+34 3.88536793e+34 3.44669502e+34 4.80346764e+34
 2.42411224e+34 1.92922442e+34 1.74036864e+34 1.47634056e+34
 1.23391325e+34 1.01316226e+34 8.69910298e+33 7.44113833e+33
 6.37436186e+33 5.46401260e+33 4.68208198e+33 4.06038875e+33
 1.52516149e+34 4.57556810e+34 2.59968130e+33 2.19039363e+33
 1.87415615e+33 1.62166902e+33 2.85978097e+33 3.01448026e+33
 1.38593759e+33 1.56059736e+33 9.71052817e+32 6.83625262e+32
 6.32083518e+32 5.74974918e+32 4.78762740e+32 4.13426632e+32
 3.61551757e+32 3.13941153e+32 2.72678011e+32 2.37880061e+32
 2.07472885e+32 1.80968718e+32 1.57908487e+32 1.37833187e+32
 1.20346668e+32 1.05125575e+32 9.18641027e+31 8.02944797e+31
 7.01952139e+31 6.14013715e+31 5.37183637e+31 4.70023472e+31
 4.11507619e+31 3.60287689e+31 3.15556551e+31 2.76452362e+31
 2.42225923e+31 2.12331170e+31 1.86124357e+31 1.63237610e+31
 1.43157785e+31 1.25610237e+31 1.10215013e+31 9.67404960e+30
 8.49297860e+30 7.45666760e+30 6.55008462e+30 5.75270385e+30
 5.05557091e+30 4.44292607e+30 3.90473999e+30 3.43377381e+30
 3.01921147e+30 2.65522333e+30 2.33583609e+30 2.05463741e+30
 1.80810470e+30 1.59209517e+30 1.40178812e+30 1.23443166e+30
 1.08775504e+30 9.58469894e+29 8.44523916e+29 7.44677693e+29
 6.56755768e+29 5.79222230e+29 5.10901150e+29 4.51041827e+29
            nan 3.51621486e+29 3.10532931e+29 2.74520451e+29
 2.42726567e+29 2.14657667e+29 1.89877696e+29 1.68119500e+29
 1.48938742e+29 1.31990831e+29 1.17015394e+29 1.03782351e+29
 9.21732746e+28 8.19064905e+28 7.28246679e+28 6.47902254e+28
 5.76815407e+28 5.14264498e+28 4.58948580e+28 4.09942956e+28
 3.66518851e+28 3.28031751e+28 2.93937044e+28 2.63888149e+28
 2.37210783e+28 2.13518285e+28 1.92468519e+28 1.73758755e+28
 1.57121127e+28 1.42402111e+28 1.29305180e+28 1.17629621e+28
 1.07214321e+28 9.79166233e+27 8.96102114e+27 8.21832312e+27
 7.55755509e+27 6.96567136e+27 6.43447434e+27 5.95721924e+27
 5.52792756e+27 5.14129958e+27 4.79263684e+27 4.47801484e+27
 4.19481828e+27 3.93810715e+27 3.70503169e+27 3.49306187e+27
 3.29995107e+27 3.12370393e+27 2.96254782e+27 2.81490762e+27
 2.67964647e+27 2.55548444e+27 2.44097622e+27 2.33515505e+27
 2.23715987e+27 2.14622338e+27 2.06166154e+27 1.98286427e+27
 1.90928711e+27 1.84044395e+27 1.77601184e+27 1.71552107e+27
 1.65856219e+27 1.60482953e+27 1.55404898e+27 1.50597455e+27
 1.46038522e+27 1.41708230e+27 1.37588692e+27 1.33663792e+27
 1.29918991e+27 1.26343464e+27 1.22924662e+27 1.19649320e+27
 1.16507838e+27 1.13491489e+27 1.10592331e+27 1.07803125e+27
 1.05117262e+27 1.02528698e+27 1.00031896e+27 9.76217778e+26
 9.52936749e+26 9.30432890e+26 9.08672838e+26 8.87614913e+26
 8.67222264e+26 8.47463733e+26 8.28310352e+26 8.09735141e+26
 7.91712931e+26 7.74220197e+26 7.57234917e+26 7.40736440e+26
 7.24705369e+26 7.09123456e+26 6.93973507e+26 6.79239296e+26
 6.64905488e+26 6.50958812e+26 6.37384233e+26 6.24168466e+26
 6.11299155e+26 5.98764544e+26 5.86553432e+26 5.74655137e+26
 5.63059461e+26 5.51756655e+26 5.40737399e+26 5.29992767e+26
 5.19514206e+26 5.09293517e+26 4.99322829e+26 4.89594585e+26
 4.80101523e+26 4.70836658e+26 4.61793350e+26 4.52965143e+26
 4.44345678e+26 4.35928956e+26 4.27709193e+26 4.19680809e+26
 4.11838418e+26 4.04176822e+26 3.96690996e+26 3.89376090e+26
 3.82227412e+26 3.75240427e+26 3.68410750e+26 3.61734138e+26
 3.55206484e+26 3.48823814e+26 3.42582278e+26 3.36478151e+26
 3.30507822e+26 3.24667793e+26 3.18954673e+26 3.13365186e+26
 3.07896140e+26 3.02544440e+26 2.97307089e+26 2.92181182e+26
 2.87163898e+26 2.82252502e+26 2.77444338e+26 2.72736827e+26
 2.68127466e+26 2.63613826e+26 2.59193546e+26 2.54864333e+26
 2.50623961e+26 2.46470266e+26 2.42401144e+26 2.38414554e+26
 2.34508508e+26 2.30681077e+26 2.26930384e+26 2.23254604e+26
 2.19651961e+26 2.16120732e+26 2.12659236e+26 2.09265841e+26
 2.05938960e+26 2.02677045e+26 1.99478592e+26 1.96342138e+26
 1.93266259e+26 1.90249566e+26 1.87290710e+26 1.84388377e+26
 1.81541287e+26 1.78748194e+26 1.76007883e+26 1.73319172e+26
 1.70680910e+26 1.68091974e+26 1.65551273e+26 1.63057739e+26
 1.60610337e+26 1.58208053e+26 1.55849904e+26 1.53534926e+26
 1.51262184e+26 1.49030765e+26 1.46839777e+26 1.44688354e+26
 1.42575647e+26 1.40500832e+26 1.38463102e+26 1.36461673e+26
 1.34495778e+26 1.32564668e+26 1.30667616e+26 1.28803909e+26
 1.26972851e+26 1.25173766e+26 1.23405992e+26] ph / (keV s)
       message: Maximum number of function evaluations has been exceeded.
       success: False
        status: 1
           fun: nan
             x: [ 5.000e+00  2.000e+01  1.000e+00  2.000e+01  2.000e+01]
           nit: 143
          nfev: 1000
 final_simplex: (array([[ 5.000e+00,  2.000e+01, ...,  2.000e+01,
                         2.000e+01],
                       [ 5.000e+00,  2.000e+01, ...,  2.000e+01,
                         2.000e+01],
                       ...,
                       [ 5.000e+00,  2.000e+01, ...,  2.000e+01,
                         2.000e+01],
                       [ 5.000e+00,  2.000e+01, ...,  2.000e+01,
                         2.000e+01]], shape=(6, 5)), array([       nan,        nan,        nan,        nan,
                              nan,        nan]))


__all__ = ["ThickTarget", "ThinTarget"]

FLOAT_EPSILON_FOR_POWER_LAW = 1 + FLOAT_EPSILON * 1e30

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the FLOAT_EPSILON * 1e30 come from, trail and error or something else?

Comment on lines +16 to +18
scaled_thick_eflux_units = u.def_unit("scaled_thick_eflux_units", 1e35 * (u.electron * u.s**-1))
scaled_thin_eflux_units = u.def_unit("scaled_thin_eflux_units", 1e55 * (u.electron * u.cm ** (-2) * u.s**-1))
scaled_em_units = u.def_unit("scaled_em_units", 1e49 * (u.cm ** (-3)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the naming these aren't scaled they are the thick_eflux units etc, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants