def __call__(self, T, metal, vsini=0.0, return_xypoint=True, **kwargs):
"""
Given parameters, return an interpolated spectrum
If return_xypoint is False, then it will only return
a numpy.ndarray with the spectrum
Before interpolating, we will do some error checking to make
sure the requested values fall within the grid
"""
# Scale the requested values
T = (T - self.T_scale[0]) / self.T_scale[1]
metal = (metal - self.metal_scale[0]) / self.metal_scale[1]
# Get the minimum and maximum values in the grid
T_min = min(self.grid[:, 0])
T_max = max(self.grid[:, 0])
metal_min = min(self.grid[:, 1])
metal_max = max(self.grid[:, 1])
input_list = (T, metal)
# Check to make sure the requested values fall within the grid
if (T_min <= T <= T_max and
metal_min <= metal <= metal_max):
y = self.interpolator(input_list)
else:
if self.debug:
warnings.warn("The requested parameters fall outside the model grid. Results may be unreliable!")
print(T, T_min, T_max)
print(metal, metal_min, metal_max)
y = self.NN_interpolator(input_list)
# Test to make sure the result is valid. If the requested point is
# outside the Delaunay triangulation, it will return NaN's
if np.any(np.isnan(y)):
if self.debug:
warnings.warn("Found NaNs in the interpolated spectrum! Falling back to Nearest Neighbor")
y = self.NN_interpolator(input_list)
model = DataStructures.xypoint(x=self.xaxis, y=y)
vsini *= units.km.to(units.cm)
model = Broaden.RotBroad(model, vsini, linear=self.rebin)
# Return the appropriate object
if return_xypoint:
return model
else:
return model.y
评论列表
文章目录