Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

176 add malanchev feature docs to readthedoc #177

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 87 additions & 9 deletions docs/pre_processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ as input to the learning algorithm.
``resspect`` can handle FITS format data from the RESSPECT project, csv data from the Photometric LSST Astronomical Classification Challenge (`PLAsTiCC <https://zenodo.org/record/2539456#.Xrsk33UzZuQ>`_) and text-like data from the SuperNova Photometric Classification Challenge (`SNPCC <https://arxiv.org/abs/1008.1024>`_).


Before starting any analysis, you need to choose a feature extraction method, all light curves will then be handdled by this method. In the examples below we used the Bazin feature extraction method (`Bazin et al., 2009 <https://arxiv.org/abs/0904.1066>`_ ).
Before starting any analysis, you need to choose a feature extraction method, all light curves will then be handdled by this method. In the examples below we used the Bazin feature extraction method (`Bazin et al., 2009 <https://arxiv.org/abs/0904.1066>`_ ) or the Malanchev feature extraction method (`Malanchev et al., 2021 <https://arxiv.org/abs/2012.01419>`_ ).

Load 1 light curve:
-------------------


For SNPCC:
For SNPCC using Bazin features:
^^^^^^^^^^

The raw data looks like this:
Expand Down Expand Up @@ -48,11 +48,42 @@ This allows you to visually inspect the content of the light curve:
75 56317.051 i 173.200 7.661 22.60 21.904 0.049
76 56318.035 z 141.000 13.720 10.28 22.127 0.111

For SNPCC using Malanchev features:
^^^^^^^^^^

You can load the data using:

.. code-block:: python
:linenos:

>>> from resspect import MalanchevFeatureExtractor

>>> path_to_lc = 'data/SIMGEN_PUBLIC_DES/DES_SN729076.DAT'

>>> lc = MalanchevFeatureExtractor() # create light curve instance
>>> lc.load_snpcc_lc(path_to_lc) # read data

This allows you to visually inspect the content of the light curve:

.. code-block:: python
:linenos:

>>> lc.photometry # check structure of photometry
mjd band flux fluxerr SNR
0 56194.012 g 13.090 6.204 2.11 99.000 5.000
1 56194.016 r -4.680 3.585 -1.31 99.000 5.000
... ... ... ... ... ... ... ...
75 56317.051 i 173.200 7.661 22.60 21.904 0.049
76 56318.035 z 141.000 13.720 10.28 22.127 0.111


Fit 1 light curve:
------------------

For SNPCC using Bazin features:
^^^^^^^^^^


In order to feature extraction in one specific filter, you can do:

.. code-block:: python
Expand Down Expand Up @@ -115,7 +146,7 @@ Before deploying large batches for pre-processing, you might want to visualize
>>> max_mjd = max(lc.photometry['mjd']) - min(lc.photometry['mjd'])

>>> lc.plot_fit(save=False, show=True, extrapolate=True,
time_flux_pred=[max_mjd+3, max_mjd+5, max_mjd+10])
>>> time_flux_pred=[max_mjd+3, max_mjd+5, max_mjd+10])


.. figure:: images/SN729076_flux_extrap.png
Expand All @@ -127,6 +158,39 @@ Before deploying large batches for pre-processing, you might want to visualize
Example of extrapolated light from SNPCC data.


For SNPCC using Malanchev features:
^^^^^^^^^^

In order to feature extraction in one specific filter, you can do:

.. code-block:: python
:linenos:

>>> lc.fit('r')
[1.03403418e+00, 3.60823443e+02, 7.24896424e+02, 8.86255944e-01,
6.03107809e+01, 1.23027000e+02, 2.50709726e+02, 6.38344483e+01,
5.19719109e+01, 6.31578947e-01, 1.22756021e+00, 2.41334828e-02,
6.15343688e+02]

The designation for each parameter are stored in:

.. code-block:: python
:linenos:

>>> lc.features_names
['anderson_darling_normal', 'inter_percentile_range_5', 'chi2',
'stetson_K', 'weighted_mean', 'duration', 'otsu_mean_diff',
'otsu_std_lower', 'otsu_std_upper', 'otsu_lower_to_all_ratio',
'linear_fit_slope', 'linear_fit_slope_sigma', 'linear_fit_reduced_chi2']

It is possible to perform the fit in all filters at once:

.. code-block:: python
:linenos:

>>> lc.fit_all() # perform fit in all filters


For PLAsTiCC:
^^^^^^^^^^^^^

Expand Down Expand Up @@ -167,7 +231,7 @@ Processing all light curves in the data set

There are 2 way to perform the Bazin fits for all three data sets. Using a python interpreter,

For SNPCC:
For SNPCC using Bazin features:
^^^^^^^^^^

.. code-block:: python
Expand All @@ -176,11 +240,25 @@ For SNPCC:
>>> from resspect import fit_snpcc

>>> path_to_data_dir = 'data/SIMGEN_PUBLIC_DES/' # raw data directory
>>> features_file = 'results/Bazin.csv' # output file
>>> features_file = 'results/Bazin.csv' # output file
>>> feature_extractor = 'bazin'

>>> fit_snpcc(path_to_data_dir=path_to_data_dir, features_file=features_file)

For SNPCC using Malanchev features:
^^^^^^^^^^

.. code-block:: python
:linenos:

>>> from resspect import fit_snpcc

>>> path_to_data_dir = 'data/SIMGEN_PUBLIC_DES/' # raw data directory
>>> features_file = 'results/Malanchev.csv' # output file
>>> feature_extractor = 'malanchev'

>>> fit_snpcc(path_to_data_dir=path_to_data_dir, features_file=features_file)


For PLAsTiCC:
^^^^^^^^^^^^^
Expand All @@ -198,10 +276,10 @@ For PLAsTiCC:
>>> sample = 'train'

>>> fit_plasticc(path_photo_file=path_photo_file,
path_header_file=path_header_file,
output_file=output_file,
feature_extractor=feature_extractor,
sample=sample)
>>> path_header_file=path_header_file,
>>> output_file=output_file,
>>> feature_extractor=feature_extractor,
>>> sample=sample)


The same result can be achieved using the command line:
Expand Down
1 change: 1 addition & 0 deletions resspect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from .batch_functions import *
from .query_budget_strategies import *
from .bump import *
from .feature_extractors.malanchev import *

import importlib.metadata

Expand Down
Loading