-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modelParameters is not working - interpolation issue #135
Comments
A simple example of how map works: list(map(lambda x,y: x+y,np.arange(3),np.arange(3))) [0, 2, 4] |
Actually, the problem is in modelParameters altogether... I can't run it in batch without the interpolation issue: ValueError Traceback (most recent call last) ~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs) ~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs) /anaconda/lib/python3.6/site-packages/scipy/interpolate/polyint.py in call(self, x) /anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _evaluate(self, x_new) /anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _check_bounds(self, x_new) ValueError: A value in x_new is above the interpolation range. |
Yup, I get this same error on the very first set of values: evolve.modelParameters('baraffe03',teff=2419.93, age=6.56767) |
I updated splat and now the error has changed to this for the line in the last comment:ValueError Traceback (most recent call last) ~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs) ~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs) /anaconda/lib/python3.6/site-packages/numpy/core/fromnumeric.py in amin(a, axis, out, keepdims) /anaconda/lib/python3.6/site-packages/numpy/core/_methods.py in _amin(a, axis, out, keepdims) ValueError: zero-size array to reduction operation minimum which has no identity |
hmm, I'm not able to reproduce this last problem, and I'm confused as to why it is throwing an error on a comment line. Have you modified the code? I suggest restarting your kernel and then just trying the last (single parameter) interpolation. What version of python are you running? For reference, here is what I get for these parameters: import splat {'mass': <Quantity 0.08328793877705343 solMass>, |
For the earlier part, I suspect you may have nan's and/or are out of range on some parameters. I could figure out a way to stop the error messages. |
Hey Adam,
Thanks for checking on this. The splat version I’m running is: '2018.05.21'
I did try inputting NaNs, and modelParameters returned NaN if I gave it a few values, but when I tried running it in batch (as in, the entire column) it wouldn’t work.
Should I download splat from scratch again?
Daniella
… On Jul 23, 2018, at 3:58 PM, Adam Burgasser ***@***.***> wrote:
For the earlier part, I suspect you may have nan's and/or are out of range on some parameters. I could figure out a way to stop the error messages.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Di6uQcinX-u9brGpcKOU896i6FMEks5uJirOgaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Hey Adam,
I’ve updated splat to ‘2018.07.11’. I get this message:
Imported spectral data folders:
/Users/daniella/Python/splat//resources/Spectra/SPEX-PRISM/../SPEX-PRISM
I hope the double slashes are not a problem.
And I still get the same error when running:
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=6.56767)
…---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-ecf663f6f86c> in <module>()
1 import splat
2 import splat.evolve as spev
----> 3 spev.modelParameters('baraffe03',teff=2419.93, age=6.56767)
~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs)
635 for p in pkeys:
636 inparams[p] = mkwargs[p][i]
--> 637 par = _modelParametersSingle(model,**inparams)
638 for p in list(EVOLUTIONARY_MODEL_PARAMETERS.keys()):
639 outparams[p].append(par[p])
~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs)
426 vals = [lmodel[P[0][0]][ai][i],lmodel[P[0][0]][ai+1][aj]]
427 f = interp1d(lmodel['age'][ai:ai+2],vals)
--> 428 Ge.append(f(numpy.log10(params['age'])))
429 try:
430 f = interp1d(Ge, Ma)
/anaconda/lib/python3.6/site-packages/scipy/interpolate/polyint.py in __call__(self, x)
77 """
78 x, x_shape = self._prepare_x(x)
---> 79 y = self._evaluate(x)
80 return self._finish_y(y, x_shape)
81
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _evaluate(self, x_new)
632 y_new = self._call(self, x_new)
633 if not self._extrapolate:
--> 634 below_bounds, above_bounds = self._check_bounds(x_new)
635 if len(y_new) > 0:
636 # Note fill_value must be broadcast up to the proper size
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _check_bounds(self, x_new)
664 "range.")
665 if self.bounds_error and above_bounds.any():
--> 666 raise ValueError("A value in x_new is above the interpolation "
667 "range.")
668
ValueError: A value in x_new is above the interpolation range.
Daniella
On Jul 23, 2018, at 4:00 PM, Daniella Bardalez Gagliuffi ***@***.***> wrote:
Hey Adam,
Thanks for checking on this. The splat version I’m running is: '2018.05.21'
I did try inputting NaNs, and modelParameters returned NaN if I gave it a few values, but when I tried running it in batch (as in, the entire column) it wouldn’t work.
Should I download splat from scratch again?
Daniella
> On Jul 23, 2018, at 3:58 PM, Adam Burgasser ***@***.*** ***@***.***>> wrote:
>
> For the earlier part, I suspect you may have nan's and/or are out of range on some parameters. I could figure out a way to stop the error messages.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Di6uQcinX-u9brGpcKOU896i6FMEks5uJirOgaJpZM4VbeRm>.
>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
***@***.*** ***@***.***>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Oddly enough, some values work but not all:
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=10)
{'mass': <Quantity 0.08324766607759568 solMass>,
'age': <Quantity 10.0 Gyr>,
'temperature': <Quantity 2419.93 K>,
'gravity': <Dex 5.3313773499982435 dex(cm / s2)>,
'luminosity': <Dex -3.4911839187409974 dex(solLum)>,
'radius': <Quantity 0.10352437580434747 solRad>}
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=5)
{'mass': <Quantity 0.08331405203017828 solMass>,
'age': <Quantity 5.0 Gyr>,
'temperature': <Quantity 2419.93 K>,
'gravity': <Dex 5.330944210041608 dex(cm / s2)>,
'luminosity': <Dex -3.48996407646324 dex(solLum)>,
'radius': <Quantity 0.10361708866382914 solRad>}
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=7)
ValueError: A value in x_new is above the interpolation range.
… On Jul 23, 2018, at 4:10 PM, Daniella Bardalez Gagliuffi ***@***.***> wrote:
Hey Adam,
I’ve updated splat to ‘2018.07.11’. I get this message:
Imported spectral data folders:
/Users/daniella/Python/splat//resources/Spectra/SPEX-PRISM/../SPEX-PRISM
I hope the double slashes are not a problem.
And I still get the same error when running:
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=6.56767)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-ecf663f6f86c> in <module>()
1 import splat
2 import splat.evolve as spev
----> 3 spev.modelParameters('baraffe03',teff=2419.93, age=6.56767)
~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs)
635 for p in pkeys:
636 inparams[p] = mkwargs[p][i]
--> 637 par = _modelParametersSingle(model,**inparams)
638 for p in list(EVOLUTIONARY_MODEL_PARAMETERS.keys()):
639 outparams[p].append(par[p])
~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs)
426 vals = [lmodel[P[0][0]][ai][i],lmodel[P[0][0]][ai+1][aj]]
427 f = interp1d(lmodel['age'][ai:ai+2],vals)
--> 428 Ge.append(f(numpy.log10(params['age'])))
429 try:
430 f = interp1d(Ge, Ma)
/anaconda/lib/python3.6/site-packages/scipy/interpolate/polyint.py in __call__(self, x)
77 """
78 x, x_shape = self._prepare_x(x)
---> 79 y = self._evaluate(x)
80 return self._finish_y(y, x_shape)
81
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _evaluate(self, x_new)
632 y_new = self._call(self, x_new)
633 if not self._extrapolate:
--> 634 below_bounds, above_bounds = self._check_bounds(x_new)
635 if len(y_new) > 0:
636 # Note fill_value must be broadcast up to the proper size
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _check_bounds(self, x_new)
664 "range.")
665 if self.bounds_error and above_bounds.any():
--> 666 raise ValueError("A value in x_new is above the interpolation "
667 "range.")
668
ValueError: A value in x_new is above the interpolation range.
Daniella
> On Jul 23, 2018, at 4:00 PM, Daniella Bardalez Gagliuffi ***@***.*** ***@***.***>> wrote:
>
> Hey Adam,
>
> Thanks for checking on this. The splat version I’m running is: '2018.05.21'
>
> I did try inputting NaNs, and modelParameters returned NaN if I gave it a few values, but when I tried running it in batch (as in, the entire column) it wouldn’t work.
>
> Should I download splat from scratch again?
>
> Daniella
>
>> On Jul 23, 2018, at 3:58 PM, Adam Burgasser ***@***.*** ***@***.***>> wrote:
>>
>> For the earlier part, I suspect you may have nan's and/or are out of range on some parameters. I could figure out a way to stop the error messages.
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Di6uQcinX-u9brGpcKOU896i6FMEks5uJirOgaJpZM4VbeRm>.
>>
>
> _______________________________
> Daniella C Bardalez Gagliuffi, PhD
> Kalbfleisch Postdoctoral Fellow
> American Museum of Natural History
> Central Park West & 79th Street
> New York, NY 10024
> Phone: 212-496-3444
> ***@***.*** ***@***.***>
>
>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
***@***.*** ***@***.***>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Given these inputs: After a lot of unsuccessful debugging, I've isolated the problem to _modelParametersSingle on line 372: where the interpolating function f cannot evaluate the x_new given: The interpolating function is defined as: where: which are defined from: Now, I'm not 100% sure I understand the contents of lmodel, nor the indices that can be used inside it, but I think the problem may be that the high limit of lmodel for the interpolation, aj, is too low, or rather that the range of possible x's for the interpolation function is too tight. If we're looking for the temperature 3.38 within the lmodel['temperature'] vector, that is defined between the y vals, this temperature will never be found. |
I'll have to spend some time on this; I would suggest not using map until I can replicate (since I can't see them) and resolve these problems. Since the code returns nans if a parameter range is outside the model range, it may be that map is choking on these. Sorry, you'll have to run a large set overnight. |
Hey Adam,
Map is not the issue. Neither Christian nor I can run this line:
import splat
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=6.5) #6.56767
For which you get a normal answer.
Daniella
… On Jul 24, 2018, at 8:35 PM, Adam Burgasser ***@***.***> wrote:
I'll have to spend some time on this; I would suggest not using map until I can replicate (since I can't see them) and resolve these problems. Since the code returns nans if a parameter range is outside the model range, it may be that map is choking on these. Sorry, you'll have to run a large set overnight.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0DrblwNzc3d7bMI8ZT7AeoRdOBAYbks5uJ701gaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
As I said, until I can replicate, I don't know what to fix |
what versions of: astropy are you running? |
Which versions of spicy, numpy, and python are you running on your computer?
And which version of splat?
… On Jul 24, 2018, at 8:40 PM, Adam Burgasser ***@***.***> wrote:
As I said, until I can replicate, I don't know what to fix
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0DsghB_tai2xtfmTBvTq-Vxvu2omcks5uJ753gaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
ha ha ha |
Have you not updated these since the Stone Age? Hahaha
… On Jul 24, 2018, at 8:42 PM, Adam Burgasser ***@***.***> wrote:
ha ha ha
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Djb5eP6HFduuOoDh7WJkz-AaaVavks5uJ77_gaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
??? what's with the ageism comment ??? |
I’m joking, you never used to update your OS not to mess up with IDL
… On Jul 24, 2018, at 8:43 PM, Adam Burgasser ***@***.***> wrote:
??? what's with the ageism comment ???
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0DgJahic-UlyuRoEZtac17cuGS2D4ks5uJ79CgaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
numpy 1.11.3 |
np.__version__
scipy.__version__
astropy.__version__
'1.12.1', '1.0.0', '3.0.1'
… On Jul 24, 2018, at 8:45 PM, Adam Burgasser ***@***.***> wrote:
numpy 1.11.3
scipy 0.18.1
astropy 3.0.3
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Dr1Tj5x8eH3RPpptEqvq2RX5ehyeks5uJ7-RgaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Is interp1d in the code coming from numpy or scipy?
… On Jul 24, 2018, at 8:48 PM, Daniella Bardalez Gagliuffi ***@***.***> wrote:
np.__version__
scipy.__version__
astropy.__version__
'1.12.1', '1.0.0', '3.0.1'
> On Jul 24, 2018, at 8:45 PM, Adam Burgasser ***@***.*** ***@***.***>> wrote:
>
> numpy 1.11.3
> scipy 0.18.1
> astropy 3.0.3
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Dr1Tj5x8eH3RPpptEqvq2RX5ehyeks5uJ7-RgaJpZM4VbeRm>.
>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
***@***.*** ***@***.***>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Hey Adam,
I can’t seem to be able to make scipy and numpy agree on the versions you have. I downgraded scipy but I can’t downgrade numpy below 1.14.3. With these versions:
numpy, scipy, astropy, splat
('1.14.3', '0.18.1', '3.0.3', '2018.07.24’)
I try this line:
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=6.5) #6.56767
And I still get the same error:
ValueError: A value in x_new is above the interpolation range.
So it’s not the versions :( I don’t know what’s going on.
Unless it's numpy.
Daniella
… On Jul 24, 2018, at 8:49 PM, Daniella Bardalez Gagliuffi ***@***.***> wrote:
Is interp1d in the code coming from numpy or scipy?
> On Jul 24, 2018, at 8:48 PM, Daniella Bardalez Gagliuffi ***@***.*** ***@***.***>> wrote:
>
> np.__version__
> scipy.__version__
> astropy.__version__
> '1.12.1', '1.0.0', '3.0.1'
>
>> On Jul 24, 2018, at 8:45 PM, Adam Burgasser ***@***.*** ***@***.***>> wrote:
>>
>> numpy 1.11.3
>> scipy 0.18.1
>> astropy 3.0.3
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Dr1Tj5x8eH3RPpptEqvq2RX5ehyeks5uJ7-RgaJpZM4VbeRm>.
>>
>
> _______________________________
> Daniella C Bardalez Gagliuffi, PhD
> Kalbfleisch Postdoctoral Fellow
> American Museum of Natural History
> Central Park West & 79th Street
> New York, NY 10024
> Phone: 212-496-3444
> ***@***.*** ***@***.***>
>
>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
***@***.*** ***@***.***>
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
just updated scipy & numpy and I can still run this line, so yup, it's not those packages. You're also running the same version of python3, so that's not it. hmmm. |
Hey Adam,
When I use age = 6.5:
import splat.evolve as spev
spev.modelParameters('baraffe03',teff=2419.93, age=6.5)
I get the error, but when I use age = 5, 10, I don’t.
The problem is here. Lines 418-428 from evolve.py.
adiff = [numpy.log10(params['age'])-a for a in lmodel['age']]
ai = numpy.argmin(numpy.abs(adiff))
print(lmodel['age'])
print(adiff)
print(ai)
if adiff[ai] < 0:
ai=ai-1
for i,m in enumerate(lmodel['mass'][ai]):
if m in lmodel['mass'][ai+1]:
Ma.append(m)
aj = numpy.argmin(numpy.abs([a-m for a in lmodel['mass'][ai+1]]))
vals = [lmodel[P[0][0]][ai][i],lmodel[P[0][0]][ai+1][aj]]
f = interp1d(lmodel['age'][ai:ai+2],vals)
Ge.append(f(numpy.log10(params['age'])))
The interpolating function f cannot be evaluated on the value numpy.log10(params['age’]). This is the log of 6.5 = 0.81. The interpolating function is defined between
x = [0.6989700043360189, -1.3010299956639813]
and y = [2.110589710299249, 2.6910814921229687]
So my log age of log(6.5) = 0.81 is definitely outside the x interpolating range. No surprise there.
The question is how these interpolating ranges are chosen. I see that you are trying to find where the input is closest to params[‘age’].
This is how lmodel[‘age’] looks like:
[-0.3010299956639812, -1.0, 1.0, -2.3010299956639813, -2.0, -3.0, 0.6989700043360189, -1.3010299956639813, 0.0, -0.9208187539523752]
The problem in this case is that instead of picking 0.69 for x[0], we should be picking 1, the next-closest in order to include 0.81 in the interpolating range.
It looks like you choose to pick ai closest to the input value, but if the value of ai closest to the input is less than the input, we are going to have this problem. Can we just solve this by extrapolating? Or choosing the ai value that is closest but larger than the input?
Daniella
… On Jul 24, 2018, at 9:45 PM, Adam Burgasser ***@***.***> wrote:
just updated scipy & numpy and I can still run this line, so yup, it's not those packages. You're also running the same version of python3, so that's not it. hmmm.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#135 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIP0Dj0TkB1NfwYCrduHbAnU2jlPjliAks5uJ82ogaJpZM4VbeRm>.
_______________________________
Daniella C Bardalez Gagliuffi, PhD
Kalbfleisch Postdoctoral Fellow
American Museum of Natural History
Central Park West & 79th Street
New York, NY 10024
Phone: 212-496-3444
[email protected]
|
Hey Adam,
I think we can run modelParameters way faster if we use map. The problem comes when I try to unpack the map object, as seen below.
nbin = int(nsamp*0.20) #200,000 rows
t0 = time.time()
bind = np.sort(np.random.choice(np.arange(len(simdf)),size=int(nbin)))
binpropsdf = pd.DataFrame(index=bind,columns=['mass1','mass2','q','age','teff1','teff2','spt2','spt1',
'MJ1','MJ2','MH1','MH2','MK1','MK2'])
binpropsdf['age'] = simulate.simulateAges(distribution='uniform',age_range=[0.5,10],num=nbin)
binpropsdf['q'] = simulate.simulateMassRatios(distribution='allen',num=nbin)
binpropsdf['teff1'] = simdf.loc[bind,'true_sptn'].map(lambda x: empirical.typeToTeff(x,'dupuy')[0])
binpropsdf['mass1'] = map(lambda x,y: evolve.modelParameters('baraffe03',teff=x, age=y), binpropsdf['teff1'],binpropsdf['age'])
print(time.time() - t0, ' seconds')
21.901501893997192 seconds
binpropsdf['mass1'].head()
4 <map object at 0x1c14e94c88>
10 <map object at 0x1c14e94c88>
30 <map object at 0x1c14e94c88>
35 <map object at 0x1c14e94c88>
40 <map object at 0x1c14e94c88>
Name: mass1, dtype: object
This returns a map object for mass1. the only way to unpack this is to put a list() around it, and that's where the problem comes:
binpropsdf['mass1'] = list(map(lambda x,y: evolve.modelParameters('baraffe03',teff=x, age=y), binpropsdf['teff1'],binpropsdf['age']))
ValueError Traceback (most recent call last)
in ()
11 binpropsdf['q'] = simulate.simulateMassRatios(distribution='allen',num=nbin)
12 binpropsdf['teff1'] = simdf.loc[bind,'true_sptn'].map(lambda x: empirical.typeToTeff(x,'dupuy')[0])
---> 13 binpropsdf['mass1'] = list(map(lambda x,y: evolve.modelParameters('baraffe03',teff=x, age=y), binpropsdf['teff1'],binpropsdf['age']))
14 print(time.time() - t0)
in (x, y)
11 binpropsdf['q'] = simulate.simulateMassRatios(distribution='allen',num=nbin)
12 binpropsdf['teff1'] = simdf.loc[bind,'true_sptn'].map(lambda x: empirical.typeToTeff(x,'dupuy')[0])
---> 13 binpropsdf['mass1'] = list(map(lambda x,y: evolve.modelParameters('baraffe03',teff=x, age=y), binpropsdf['teff1'],binpropsdf['age']))
14 print(time.time() - t0)
~/Python/splat/splat/evolve.py in modelParameters(*model, **kwargs)
631 for p in pkeys:
632 inparams[p] = mkwargs[p][i]
--> 633 par = _modelParametersSingle(model,**inparams)
634 for p in list(EVOLUTIONARY_MODEL_PARAMETERS.keys()):
635 outparams[p].append(par[p])
~/Python/splat/splat/evolve.py in _modelParametersSingle(*args, **kwargs)
424 vals = [lmodel[P[0][0]][ai][i],lmodel[P[0][0]][ai+1][aj]]
425 f = interp1d(lmodel['age'][ai:ai+2],vals)
--> 426 Ge.append(f(numpy.log10(params['age'])))
427 try:
428 f = interp1d(Ge, Ma)
/anaconda/lib/python3.6/site-packages/scipy/interpolate/polyint.py in call(self, x)
77 """
78 x, x_shape = self._prepare_x(x)
---> 79 y = self._evaluate(x)
80 return self._finish_y(y, x_shape)
81
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _evaluate(self, x_new)
632 y_new = self._call(self, x_new)
633 if not self._extrapolate:
--> 634 below_bounds, above_bounds = self._check_bounds(x_new)
635 if len(y_new) > 0:
636 # Note fill_value must be broadcast up to the proper size
/anaconda/lib/python3.6/site-packages/scipy/interpolate/interpolate.py in _check_bounds(self, x_new)
664 "range.")
665 if self.bounds_error and above_bounds.any():
--> 666 raise ValueError("A value in x_new is above the interpolation "
667 "range.")
668
ValueError: A value in x_new is above the interpolation range.
The text was updated successfully, but these errors were encountered: