light-curve-feature
light-curve-feature is a part of light-curve family that
implements extraction of numerous light curve features used in astrophysics.
If you are looking for Python bindings for this package, please see https://github.com/light-curve/light-curve-python
All features are available in Feature enum, and the recommended way to extract multiple features at
once is FeatureExtractor struct built from a Vec<Feature>. Data is represented by
TimeSeries struct built from time, magnitude (or flux) and weight arrays, all having the same length. Note
that multiple features interpret weight array as inversed squared observation errors.
use *;
// Let's find amplitude and reduced Chi-squared of the light curve
let fe = from_features;
// Define light curve
let time = ;
let magn = ;
let weights = ; // inverse squared magnitude errors
let mut ts = new;
// Get results and print
let result = fe.eval?;
let names = fe.get_names;
println!;
# Ok::
There are a couple of meta-features, which transform a light curve before feature extraction. For example Bins feature accumulates data inside time-windows and extracts features from this new light curve.
use *;
use Array1;
// Define features, "raw" MaximumSlope and binned with zero offset and 1-day window
let max_slope: = default.into;
let bins: = ;
let fe = from_features;
// Define light curve
let time = ;
let magn = ;
// We don't need weight for MaximumSlope, this would assign unity weight
let mut ts = new_without_weight;
// Get results and print
let result = fe.eval?;
println!;
# Ok::
Cargo features
The crate is configured with the following Cargo features:
ceres-systemandceres-source- enable Ceres Solver support for non-linear fitting. The former uses system-wide installation of Ceres, the latter builds Ceres from source and links it statically. The latter overrides the former. Seeceres-solver-rscrate for detailsfftw-system,fftw-source(enabled by default) andfftw-mkl- enable FFTW support for Fourier transforms needed byPeriodogram. The first uses system-wide installation of FFTW, the second builds FFTW from source and links it statically, the last downloads and links statically Intel MKL instead of FFTW.gsl- enables GNU Scientific Library support for non-linear fitting.default- enablesfftw-sourcefeature only, has no side effects.
Development
Setting up
Install Rust toolchain, the preferred way is rustup.
Install the required system libraries. For main project you need Ceres Solver, FFTW and GSL, as well as C++ compiler and CMake. The example script plots some stuff so it requires fontconfig.
# On macOS:
# On Debian-like:
Clone the repository with submodules and run compiler checks:
Run tests with native libraries.
Note that Ceres could require manual CPATH specification on some systems, like CPATH=/opt/homebrew/include on ARM macOS:
You may also run benchmarks, but be patient
See examples, .github/workflows and tests for examples of the code usage.
Formatting and linting
We format and check the code with the standard Rust tools: cargo fmt and cargo clippy.
Please use clippy's #[allow] as precise as possible and leave code comments if it is not obvious why its usage is required.
We use pre-commit for running some linters locally before commiting.
Please consider installing it and initializing in the repo with pre-commit init.
However pre-commit.ci and GitHub Actions will varify cargo fmt and cargo clippy for PRs.
Generally, we are aimed to test all user-level code, add unit-tests to your non-trivial PRs.
Currently we have no unsafe code in this repo and we are aimed to avoid it in the future.
Implementing a new feature evaluator
Your new feature evaluator code should go to at least three files:
- New file inside
src/featuresdirectory - Publically import the new struct inside
src/features/mod.rs - Add it as a new variant of
Featureenum insidesrc/feature.rs
Citation
If you found this project useful for your research please cite Malanchev et al., 2021