pyedra API¶
Pyedra currently has three functions, each of which adjusts a different phase function model.
The input file must be a .csv file with three columns: id (mpc number), alpha (phase angle) and v (reduced magnitude in Johnson’s V filter).
The modules are:
HG_fit: adjusts the H-G biparametric function to the data set.
Shev_fit: adjusts the Shevchenko triparametric function to the data set.
HG1G2_fit: adjusts the triparametric function H-G1-G2 to the data set.
In addition, the data input can be plotted with the chosen fit.
Module pyedra.core
¶
Implementation of phase function for asteroids.
-
class
pyedra.core.
MetaData
(data=NOTHING)[source]¶ Bases:
collections.abc.Mapping
Implements an inmutable dict-like to store the metadata.
Also provides attribute like access to the keys.
Example
>>> metadata = MetaData({"a": 1, "b": 2}) >>> metadata.a 1
>>> metadata["a"] 1
-
class
pyedra.core.
PyedraFitDataFrame
(model, model_df, plot_cls, metadata=NOTHING)[source]¶ Bases:
object
Initialize a dataframe model_df to which we can apply function a.
-
class
pyedra.core.
BasePlot
(pdf)[source]¶ Bases:
abc.ABC
Plots for HG fit.
-
abstract property
default_plot_kind
¶ Return the default plot to be rendered.
-
abstract property
-
pyedra.core.
obs_counter
(df, obs, idc='id', alphac='alpha')[source]¶ Count the observations. A minimum is needed to the fits.
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.obs (
int
) – Minimum number of observations needed to perform the fit.
- Returns
out – Numpy array containing the asteroids whose number of observations is less than obs.
- Return type
ndarray
-
pyedra.core.
merge_obs
(obs_a, obs_b, idc_a='id', idc_b='id', alphac_a='alpha', alphac_b='alpha', magc_a='v', magc_b='v', **kwargs)[source]¶ Merge two dataframes with observations.
Sources whose id is not present in obs_a are discarded.
The function concantenates two dataframes (
obs_a
andobs_b
), and assumes that the columnsidc_a
,alphac_a
andmagc_a
fromobs_a
are equivalent toidc_b
,alphac_b
andmagc_b
from a dataframeobs_b
. The resulting dataframe uses the names ofobs_a
for those three columns and places them at the start, and all other columns of both dataframes combined with the same behavior ofpandas.concat
.- Parameters
obs_a (
pandas.DataFrame
) – The dataframe must with the observations.obs_b (
pandas.DataFrame
) – The dataframe must with the observations to be concatenated toobs_a
.idc_a (
str
, optional (default=id)) – Column with the mpc number of the asteroids of theobs_a
dataframe.idc_b (
str
, optional (default=id)) – Column with the mpc number of the asteroids of theobs_b
dataframe.alphac_a (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids of theobs_a
dataframe.alphac_b (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids of theobs_b
dataframe.magc_a (
str
, optional (default=v)) – Column with the magnitude of theobs_a
dataframe. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.magc_b (
str
, optional (default=v)) – Column with the magnitude of theobs_b
dataframe. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.kwargs (
dict
orNone
(optional)) – The parameters to send to the subjacentpandas.concat
function.
- Returns
Merged dataframes.
- Return type
pd.DataFrame
Module pyedra.hg1g2_model
¶
Implementation of phase function for asteroids.
-
class
pyedra.hg1g2_model.
HG1G2Plot
(pdf)[source]¶ Bases:
pyedra.core.BasePlot
Plots for HG1G2 fit.
-
curvefit
(df, idc='id', alphac='alpha', magc='v', ax=None, cmap=None, fit_kwargs=None, data_kwargs=None)[source]¶ Plot the phase function using the HG1G2 model.
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.ax (
matplotlib.pyplot.Axis
, (optional)) – Matplotlib axiscmap (
None
,str
or calable (optional)) – Name of the color map to be used (https://matplotlib.org/users/colormaps.html). If is None, the default colors of the matplotlib.pyplot.plot function is used, and if, and is a callable is used as colormap generator.fit_kwargs (
dict
orNone
(optional)) – The parameters to send to the fit curve plot. Onlylabel
andcolor
can’t be provided.data_kwargs (
dict
orNone
(optional)) – The parameters to send to the data plot. Onlylabel
andcolor
can’t be provided.
- Returns
The axis where the method draws.
- Return type
matplotlib.pyplot.Axis
-
-
pyedra.hg1g2_model.
HG1G2_fit
(df, idc='id', alphac='alpha', magc='v')[source]¶ Fit (H-G1-G2) system to data from table.
HG1G2_fit calculates the H,G1 and G2 parameters of the phase function following the procedure described in 5 .
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.
- Returns
The output contains eight columns: id (mpc number of the asteroid), H (absolute magnitude returned by the fit), H error (fit H parameter error), G1 (G1 parameter returned by the fit), G1 error (fit G1 parameter error), G2 (G2 parameter returned bythe fit), G2 error (fit G2 parameter error), and R (fit determination coefficient).
- Return type
PyedraFitDataFrame
References
- 5
Muinonen K., Belskaya I. N., Cellino A., Delbò M., Levasseur-Regourd A.-C.,Penttilä A., Tedesco E. F., 2010, Icarus, 209, 542.
Module pyedra.hg_model
¶
H,G model for Pyedra.
-
class
pyedra.hg_model.
HGPlot
(pdf)[source]¶ Bases:
pyedra.core.BasePlot
Plots for HG fit.
-
curvefit
(df, idc='id', alphac='alpha', magc='v', ax=None, cmap=None, fit_kwargs=None, data_kwargs=None)[source]¶ Plot the phase function using the HG model.
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.ax (
matplotlib.pyplot.Axis
, (optional)) – Matplotlib axiscmap (
None
,str
or calable (optional)) – Name of the color map to be used (https://matplotlib.org/users/colormaps.html). If is None, the default colors of the matplotlib.pyplot.plot function is used, and if, and is a callable is used as colormap generator.fit_kwargs (
dict
orNone
(optional)) – The parameters to send to the fit curve plot. Onlylabel
andcolor
can’t be provided.data_kwargs (
dict
orNone
(optional)) – The parameters to send to the data plot. Onlylabel
andcolor
can’t be provided.
- Returns
The axis where the method draws.
- Return type
matplotlib.pyplot.Axis
-
-
pyedra.hg_model.
HG_fit
(df, idc='id', alphac='alpha', magc='v')[source]¶ Fit (H-G) system to data from table.
HG_fit calculates the H and G parameters of the phase function following the procedure described in 1 .
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.
- Returns
The output contains 7 columns: id (mpc number of the asteroid), H (absolute magnitude returned by the fit), H error (fit H parameter error), G (slope parameter returned by the fit), G error (fit G parameter error), R (fit determination coefficient) and observations (number of observation of the given asteroid).
- Return type
PyedraFitDataFrame
References
- 1
Muinonen K., Belskaya I. N., Cellino A., Delbò M., Levasseur-Regourd A.-C.,Penttilä A., Tedesco E. F., 2010, Icarus, 209, 542.
Module pyedra.shevchenko_model
¶
Shevchenko model for Pyedra.
-
class
pyedra.shevchenko_model.
ShevPlot
(pdf)[source]¶ Bases:
pyedra.core.BasePlot
Plots for Shevchenko fit.
-
curvefit
(df, idc='id', alphac='alpha', magc='v', ax=None, cmap=None, fit_kwargs=None, data_kwargs=None)[source]¶ Plot the phase function using the Shev model.
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.ax (
matplotlib.pyplot.Axis
, (optional)) – Matplotlib axiscmap (
None
,str
or calable (optional)) – Name of the color map to be used (https://matplotlib.org/users/colormaps.html). If is None, the default colors of the matplotlib.pyplot.plot function is used, and if, and is a callable is used as colormap generator.fit_kwargs (
dict
orNone
(optional)) – The parameters to send to the fit curve plot. Onlylabel
andcolor
can’t be provided.data_kwargs (
dict
orNone
(optional)) – The parameters to send to the data plot. Onlylabel
andcolor
can’t be provided.
- Returns
The axis where the method draws.
- Return type
matplotlib.pyplot.Axis
-
-
pyedra.shevchenko_model.
Shev_fit
(df, idc='id', alphac='alpha', magc='v')[source]¶ Fit Shevchenko equation to data from table.
Shev_fit calculates parameters of the three-parameter empirical function proposed by Schevchenko 2, 3 .
- Parameters
df (
pandas.DataFrame
) – The dataframe must with the valuesidc (
str
, optional (default=id)) – Column with the mpc number of the asteroids.alphac (
str
, optional (default=alpha)) – Column with the phase angle of the asteroids.magc (
str
, optional (default=v)) – Column with the magnitude. The default ‘v’ value is reference to the reduced magnitude in Johnson’s V filter.
- Returns
The output contains six columns: id (mpc number of the asteroid), V_lin (magnitude calculated by linear extrapolation to zero), V_lin error (fit V_lin parameter error), b (fit parameter characterizing the opposition efect amplitude), b error (fit b parameter error), c (fit parameter describing the linear part of the magnitude phase dependence), c error (fit c parameter error) 4 and R (fit determination coefficient).
- Return type
PyedraFitDataFrame
References
- 2
Shevchenko, V. G. 1996. Analysis of the asteroid phase dependences of brightness. Lunar Planet Sci. XXVII, 1086.
- 3
Shevchenko, V. G. 1997. Analysis of asteroid brightness phase relations. Solar System Res. 31, 219-224.
- 4
Belskaya, I. N., Shevchenko, V. G., 2000. Opposition effect of asteroids. Icarus 147, 94-105.
Module pyedra.datasets
¶
The pyedra.datasets module includes utilities to load datasets.
It also features some artificial data generators.
-
pyedra.datasets.
load_carbognani2019
()[source]¶ Input for use with the phase functions.
This dataset contains the first and second columns of Table 2 of 6 . These columns correspond to: phase angle (°) and V_max (mag). V_max is the reduced magnitude of the lightcurve maximum.
References
- 6
Carbognani, A., Cellino, A., & Caminiti, S. (2019). New phase-magnitude curves for some main belt asteroids, fit of different photometric systems and calibration of the albedo-Photometry relation. Planetary and Space Science, 169, 15-34.
-
pyedra.datasets.
load_penttila2016
()[source]¶ Tabulated values of the base functions for H-G1-G2 system.
This dataset corresponds to Table B.4 of 7 .
References
- 7
A. Penttilä, V. G. Shevchenko, O. Wilkman, & K. Muinonen (2016). H,G1, G2 photometric phase function extended to low-accuracy data. 123:117–125.
-
pyedra.datasets.
load_gaia
()[source]¶ Gaia observations.
The data used to obtain these quantities were downloaded from the Gaia Archive (https://gea.esac.esa.int/archive/) 8 .
References
- 8
Gaia Collaboration et al., 2018, A&A, 616, A13