Closed logan-pearce closed 1 year ago
Hi @logan-pearce,
Thanks for opening this issue! I think that the problem might be the 'feh' parameter that is included in your model_param
dictionary while this isn't a free parameter with the BT-Setll CIFIST grid.
That should have printed a warning and ignored the parameter when interpolating a spectrum, but I see now that the parameter is actually not ignored by species
so therefore it runs into the interpolation error. Thanks for pointing this out. I will fix that!
You can use methods such as get_parameters
, get_bounds
, and get_points
from the ReadModel
class to check which parameters are required.
I hope this solves the problem but let me know otherwise!
Parameters that are not mandatory are now ignored by ReadModel
. See commit fa82915c33117ac8c35a567c71d148cabba895a2 that will be part of a next release.
I am trying to use the BTSettl-CIFIST models because they go up to the higher temperatures I need for the stars, and I am encountering an error that seems to be deep within the API that I am not able to solve. It seems that when read_model.py interfaces with scipy interpolate.interpnd, there is an error on reshaping an array. This error has not been a problem with any other models I have tried. I installed species yesterday, version 0.5.3
I am following the "synthetic photometry" tutorial:
import species
species.SpeciesInit()
database = species.Database()
database.add_model(model='bt-settl-cifist', teff_range=(2000., 7000.))
database.add_filter('SLOAN/SDSS.g')
database.add_filter('SLOAN/SDSS.r')
database.add_filter('SLOAN/SDSS.i')
database.add_filter('SLOAN/SDSS.z')
model_param = {'teff':5400, 'logg':4.0, 'feh':0.5, 'distance': Adistance[0], 'radius':1000}
model_box = read_model.get_model(model_param=model_param, spec_res=200., smooth=True)
Produces the error: `--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [10], in <cell line: 1>() ----> 1 model_box = read_model.get_model(model_param=model_param, spec_res=200., smooth=True)
File ~/anaconda3/envs/py39/lib/python3.9/site-packages/typeguard/init.py:1033, in typechecked..wrapper(*args, *kwargs)
1031 memo = _CallMemo(python_func, _localns, args=args, kwargs=kwargs)
1032 check_argument_types(memo)
-> 1033 retval = func(args, **kwargs)
1034 try:
1035 check_return_type(retval, memo)
File ~/anaconda3/envs/py39/lib/python3.9/site-packages/species/read/read_model.py:747, in ReadModel.get_model(self, model_param, spec_res, wavel_resample, magnitude, smooth) 743 parameters.append(model_param["log_kzz"]) 745 # Interpolate the spectrum from the grid --> 747 flux = self.spectrum_interp(parameters)[0] 749 # Add the radius to the parameter dictionary if the mass if given 751 if "mass" in model_param and "radius" not in model_param:
File ~/anaconda3/envs/py39/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py:2515, in RegularGridInterpolator.call(self, xi, method) 2512 raise ValueError("Method '%s' is not defined" % method) 2514 ndim = len(self.grid) -> 2515 xi = _ndim_coords_from_arrays(xi, ndim=ndim) 2516 if xi.shape[-1] != len(self.grid): 2517 raise ValueError("The requested sample points xi have dimension " 2518 "%d, but this RegularGridInterpolator has " 2519 "dimension %d" % (xi.shape[1], ndim))
File interpnd.pyx:157, in scipy.interpolate.interpnd._ndim_coords_from_arrays()
File interpnd.pyx:182, in scipy.interpolate.interpnd._ndim_coords_from_arrays()
ValueError: cannot reshape array of size 3 into shape (2)`