Register functions to automatically generate columns in the atlas¶
Provide a registry of functions to analyse lightcurves.
YSOVAR.atlas.YSOVAR_atlas
objects can autogenerate a certain number of
columns in the data table. This module provides the mechanism for defining the
functions that are required for this autogeneration to work.
For each function a certain number of metadata information is required, so
that YSOVAR.atlas.YSOVAR_atlas
can find them and call them with the
right parameters.
Example¶
This is probably best explained by an example:
import numpy as np
from YSOVAR import registry
from YSOVAR import atlas
registry.register(np.mean, n_bands=1, error = False,
time = False, name = "mean", default_colnames = ["mean"],
description = "mean of lightcurve")
The modules uses sensible defaults, e.g. the name of the function is used as default for the autogenerated column name, so, the following would also work:
registry.register(np.mean, n_bands=1, error = False, time = False)
After this function is registered, you can now automatically generate columns for the mean values:
<read your datafile>
my_cloud = atlas.YSOVAR_atlas(lclist = your_data_here)
temp = my_cloud['mean_36']
temp = my_cloud['mean_45']
Note
In practice, you do not need to register np.mean
because a selection of
common functions is automatically registered when the module is imported.
The following command will list the available functions:
registry.list_lcfuncs()
Call signatures for functions¶
The string in the colname is split in the name that will be used to look up the
function in the function registry ('mean'
) and the name of the band ('36'
).
For this reason, registered function names cannot contain underscores.
Registered functions have to follow a convention on which inputs they accept:
def func([time],band1, band2, ..., [band1_err, band2_err ...])
All inputs will be numpy arrays. time = True / False
controls if the
time array is present, error = True / False
if the uncertainties
for each band are passed in. n_bands
says how many bands are expected
on input.
-
class
YSOVAR.registry.
LightcurveFunc
(func, n_bands, error, time, name='', default_colnames=[], default_colunits=[None], default_coldescriptions=None, other_cols={}, description='', kwargs={})¶ Wrap function for the lightcurve analysis function registry
This wrapper is to be used for fucntions that operate on individual lightcurves.
Functions in the registry of analysis function for lightcurves need some metadata for make sure that they can be called correctly, when
atlas.YSOVAR_atlas
autogenerated columns in the table.This class warps a function and provides some metadata. This metadata includes:
- The number of bands the function requires as input.
- Does the function require the uncertainty of the mags?
- Does the function require the time of the observations?
- What is the name of the function, so that it can be found?
- Some short description of the function.
- Default names for the columns that are autogenerated.
Use the following command to read the full docstring of the function that is wrapped in this object:
help(my_object.func)
Note
This class is usually not called directly. Use
YSOVAR.registry.register()
.-
kwargs
= {}¶
-
YSOVAR.registry.
list_lcfuncs
()¶ List all function currently registered with a one-line summary
-
YSOVAR.registry.
register
(func, n_bands=1, error=False, time=False, force=False, **kwargs)¶ Register a new function for lightcurve analysis
Parameters: func : function or callable object
This function will be called.
n_bands : int
Number of spectral bands required by this function.
error : bool
If
True
the uncertainties in each lightcurve band will be passed to the function.time : bool
If
True
the observations times will be passed as first argument.force : bool
If
True
a function of same name that was previously registered will be over written.All remaining keywords will be passed to :func:`LightcurveFunc.__init__`. :
See that function for description and default values of other :
accepted keywords. :