sora.extra
ChiSquare Class
- class sora.extra.ChiSquare(chi2, npts, **kwargs)[source]
Store chi-square values and associated fitted parameters.
- Parameters:
chi2 (numpy.array) – Array with all the chi-square values.
npts (int) – Number of points used in the fit.
**kwargs – Additional inputs. Each value must be an array with the same size as chi2. Each keyword is used as the parameter name in data.
Examples
>>> chisquare = ChiSquare(chi2, npts=4, immersion=t1, emersion=t2)
t1andt2must be arrays with the same size aschi2.The data can be accessed as
>>> chisquare.data['immersion']
- get_nsigma(sigma=1, key=None)[source]
Return intervals for values within the requested sigma level.
- Parameters:
sigma (float, int) – Sigma level used to select values with
chi2 < chi2_min + sigma**2.key (str, default=None) – Parameter name for which to return the interval. If None, intervals for all parameters are returned.
- Returns:
result – If key is None, a dictionary with the minimum chi-square, sigma level, number of selected points, and intervals for all parameters. If key is given, a list with the central value and half-width for that parameter.
- Return type:
dict, list
- Raises:
ValueError – If key is not one of the available parameter names.
Notes
Parameter intervals are computed from the minimum and maximum values selected within the requested sigma level.
- get_values(sigma=0.0, key=None)[source]
Return values where chi-square is within the requested sigma level.
- Parameters:
sigma (float, int) – Sigma level used to select values with
chi2 < chi2_min + sigma**2. If 0, only values at the minimum chi-square are returned.key (str, optional) – Parameter name for which to return values. If None, values for all parameters are returned.
- Returns:
values – If key is None, a dictionary with selected values for all parameters. If key is given, the selected values for that parameter.
- Return type:
dict, numpy.array
Notes
If
sigma=0, this returns the parameter values at the minimum chi-square instead of arrays selected by a sigma threshold.
- plot_chi2(key=None, ax=None)[source]
Plot chi-square values as a function of fitted parameters.
- Parameters:
key (str, optional) – Parameter name for which to plot the chi-square values. If None, a plot is generated for each parameter.
ax (matplotlib.pyplot.Axes, optional) – Matplotlib axes where the plot is drawn. If None, the current axes are used.
- Raises:
ValueError – If key is not one of the available parameter names.
Plot ellipse
- sora.extra.plots.draw_ellipse(equatorial_radius, oblateness=0.0, center_f=0.0, center_g=0.0, position_angle=0.0, center_dot=False, ax=None, **kwargs)[source]
Plot an ellipse with the given input parameters.
- Parameters:
equatorial_radius (float, int, array-like) – Semi-major axis of the ellipse, in km.
oblateness (float, int, array-like, optional) – Oblateness of the ellipse.
center_f (float, int, array-like, optional) – Coordinate of the ellipse center in the f direction, in km.
center_g (float, int, array-like, optional) – Coordinate of the ellipse center in the g direction, in km.
position_angle (float, int, array-like, optional) – Pole position angle of the ellipse, in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.
center_dot (bool, optional) – If True, plots a dot at the center of the ellipse.
ax (matplotlib.pyplot.Axes, optional) – Axes where the ellipse is plotted. If None, the current axes are used.
**kwargs – Additional keyword arguments passed directly to matplotlib.
Complementary functions
- sora.extra.utils.get_ellipse_points(theta, equatorial_radius, oblateness=0.0, center_f=0.0, center_g=0.0, position_angle=0.0)[source]
Calculate points on an ellipse for the given input parameters.
- Parameters:
theta (float, array-like) – Angular coordinate, in radians, where the ellipse points are calculated.
equatorial_radius (float, int) – Semi-major axis of the ellipse, in km.
oblateness (float, int, optional) – Oblateness of the ellipse.
center_f (float, int, optional) – Coordinate of the ellipse center in the f direction, in km.
center_g (float, int, optional) – Coordinate of the ellipse center in the g direction, in km.
position_angle (float, int, optional) – The pole position angle of the ellipse in degrees. Zero is in the North direction (‘g-positive’). Positive clockwise.
- Returns:
x_model (float, numpy.array) – Cartesian x-component, in km.
y_model (float, numpy.array) – Cartesian y-component, in km.
r_model (float, numpy.array) – Radial distance, in km.
theta (float, array-like) – Input angular coordinate, in radians.