Calculating Lightcurve Statistics#

Intro

We can start by importing our favourite package: elk!

[1]:
import elk
import numpy as np

%config InlineBackend.figure_format = "retina" # Not required, only applicable for Jupyter Notebooks

Lightcurve Setup#

Now let’s do a simple integrated lightcurve fit to NGC 419

[2]:
c = elk.ensemble.EnsembleLC(output_path='.',
                            identifier='NGC 419',
                            location='23.58271, +61.1236',
                            radius=.046,
                            cluster_age=7.75,
                            cutout_size=25,
                            verbose=True,
                            minimize_memory=False)
[3]:
c.create_output_table()
NGC 419 has 4 observations
Starting Quality Tests for Observation: 0
100%|█████████████████████████| 625/625 [00:25<00:00, 24.94it/s]
  Passed Quality Tests 
Starting Quality Tests for Observation: 1
100%|█████████████████████████| 625/625 [00:28<00:00, 22.08it/s]
  Passed Quality Tests 
Starting Quality Tests for Observation: 2
100%|█████████████████████████| 625/625 [00:24<00:00, 25.56it/s]
  Failed Scattered Light Test 
Starting Quality Tests for Observation: 3
100%|█████████████████████████| 625/625 [02:31<00:00,  4.12it/s]
  Failed Scattered Light Test 

Accessing statistics#

Now that we’ve run that we can use the output to start analyzing some statistics about the lightcurves that we’ve created. Let’s pick one of them out.

[4]:
lc = c.lcs[1]

This lightcurve has access to the many functions within elk.stats and we can easily access them. For the statistics that don’t require inputs, you can simply access them as attributes.

[5]:
lc.rms, lc.von_neumann_ratio
[5]:
(1.0000015, 0.001523331499211464)

Similarly, for statistics that could get some input you can access them as class methods like this

[6]:
lc.J_stetson()
[6]:
1.1804093968245712

Some of the statistics also require input, like when you create a periodogram

[7]:
frequencies = np.logspace(-1, 1, 100)
_ = lc.to_periodogram(frequencies=frequencies, n_bootstrap=10)
lc.stats["n_peaks"]
[7]:
2

Summarising Statistics#

As you may have noticed in the last cell, each of the statistics has been tracks in a dictionary within the class to save you running them again. You can access this dictionary like this

[8]:
lc.stats
[8]:
{'rms': 1.0000015,
 'von_neumann_ratio': 0.001523331499211464,
 'J_Stetson': 1.1804093968245712,
 'max_power': 0.0814774476132879,
 'freq_at_max_power': 0.8111308307896873,
 'peak_freqs': array([0.40370173, 0.81113083, 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ]),
 'peak_left_edge': array([0.38535286, 0.77426368]),
 'peak_right_edge': array([0.42292429, 0.84975344]),
 'power_at_peaks': array([0.02901209, 0.07563559, 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ]),
 'n_peaks': 2,
 'ratio_of_power_at_high_v_low_freq': 7.542208008583611,
 'FAP': 6.84794212669881e-19}

You can also turn this into an Astropy table for aggregation with other lightcurves

[9]:
lc.get_stats_table(name=c.identifier)
[9]:
Table length=1
namermsvon_neumann_ratioJ_Stetsonmax_powerfreq_at_max_powerpeak_freqspeak_left_edgepeak_right_edgepower_at_peaksn_peaksratio_of_power_at_high_v_low_freqFAP
str7float32float64float64float64float64float64[25]float64[2]float64[2]float64[25]int64float64float64
NGC 4191.00000150.0015233314992114641.18040939682457120.08147744761328790.81113083078968730.40370172585965547 .. 0.00.38535285937105296 .. 0.77426368268112720.4229242874389499 .. 0.84975343590864450.0290120900038226 .. 0.027.5422080085836116.84794212669881e-19

The Kitchen Sink#

If you’re in an instance in which you want to get every statistic for the lightcurve quickly, you can run them all using default settings as follows

[10]:
lc.get_stats_using_defaults()
[10]:
{'rms': 0.11711626158441998,
 'von_neumann_ratio': 0.001523331499211464,
 'J_Stetson': 1.1804093968245712,
 'max_power': 0.08225337901935341,
 'freq_at_max_power': 0.8100000000000002,
 'peak_freqs': array([0.41, 0.59, 0.81, 1.  , 5.5 , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  , 0.  ,
        0.  , 0.  , 0.  ]),
 'peak_left_edge': array([0.38, 0.57, 0.78, 0.98, 5.48]),
 'peak_right_edge': array([0.43, 0.61, 0.83, 1.02, 5.52]),
 'power_at_peaks': array([0.02940489, 0.02169242, 0.07518853, 0.05233719, 0.02002039,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ,
        0.        , 0.        , 0.        , 0.        , 0.        ]),
 'n_peaks': 5,
 'ratio_of_power_at_high_v_low_freq': 3.7030709677085705,
 'FAP': 4.108941685757319e-19,
 'std': 0.00018255888,
 'MAD': 9.998679e-05,
 'sigmaG': 0.00014875981268744874,
 'skewness': 3928.4478,
 'max_autocorrelation': 0.22151919044721688,
 'time_of_max_autocorrelation': array([5.08331299])}

We recommend caution when using this function since the default settings may not be the best ones for you!

Now when converting back to a table we can see every statistic

[11]:
lc.get_stats_table(name=c.identifier)
[11]:
Table length=1
namermsvon_neumann_ratioJ_Stetsonmax_powerfreq_at_max_powerpeak_freqspeak_left_edgepeak_right_edgepower_at_peaksn_peaksratio_of_power_at_high_v_low_freqFAPstdMADsigmaGskewnessmax_autocorrelationtime_of_max_autocorrelation
str7float64float64float64float64float64float64[25]float64[5]float64[5]float64[25]int64float64float64float32float32float64float32float64float64[1]
NGC 4190.117116261584419980.0015233314992114641.18040939682457120.082253379019353410.81000000000000020.41000000000000003 .. 0.00.38000000000000006 .. 5.4800000000000010.43000000000000005 .. 5.5200000000000010.029404892116234253 .. 0.053.70307096770857054.108941685757319e-190.000182558889.998679e-050.000148759812687448743928.44780.221519190447216885.08331298828125

Note

This tutorial was generated from a Jupyter notebook that can be found here.