aburgasser / splat

SpeX Prism Spectral Analysis Toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

modelParameters breaking with NaNs

daniellabardalezgagliuffi opened this issue · comments

I’m getting an error when calculating secondary masses in the simulation for the luminosity function. I wasn’t getting this problem earlier, but I just updated splat to use the Hawley relations. This problem only appears when there is a np.nan in the mass input, which I’ll inevitably find in a vector of 10^6 masses generated by temperatures and ages. I'm trying to go back to an older version of SPLAT. Also FYI, the version including the Hawley relations was still 07.29.18, but I think maybe this was done later than that?

simdf.loc[0:10,'mass2'].values
array([0.08837744, 0.08821295, 0.03704864, 0.04597689, 0.03199591,
nan, nan, 0.06537881, nan, 0.0903129 ,
0.06264247])

evolve.modelParameters('baraffe03',m=simdf.loc[:10,'mass2'].values,a=simdf.loc[:10,'age'].values)['temperature'].value

mass: nan
age: 0.5123342650818499
temperature: nan
gravity: nan
luminosity: nan
radius: nan
[]

ValueError Traceback (most recent call last)
in ()
----> 1 evolve.modelParameters('baraffe03',m=simdf.loc[:10,'mass2'].values,a=simdf.loc[:10,'age'].values)['temperature'].value

~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs)
972 for p in pkeys:
973 inparams[p] = mkwargs[p][i]
--> 974 par = _modelParametersSingle(model,**inparams)
975 for p in list(EVOLUTIONARY_MODEL_PARAMETERS.keys()):
976 outparams[p].append(par[p])

~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs)
473 print('{}: {}'.format(k,params[k]))
474 print(P)
--> 475 raise ValueError('\nProblem with one_param interpolation\n')
476
477

ValueError:
Problem with one_param interpolation

OK, this has been changed so that nan inputs (or more precisely, < 2 non-nan inputs) will give nan outputs without stopping. This is not ideal coding - bad variables should be pointed out, and you should "clean" the inputs ahead of time - but if you set verbose=True on the call to modelParameters you can see where there are errors