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]:
| name | rms | von_neumann_ratio | J_Stetson | max_power | freq_at_max_power | peak_freqs | peak_left_edge | peak_right_edge | power_at_peaks | n_peaks | ratio_of_power_at_high_v_low_freq | FAP |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| str7 | float32 | float64 | float64 | float64 | float64 | float64[25] | float64[2] | float64[2] | float64[25] | int64 | float64 | float64 |
| NGC 419 | 1.0000015 | 0.001523331499211464 | 1.1804093968245712 | 0.0814774476132879 | 0.8111308307896873 | 0.40370172585965547 .. 0.0 | 0.38535285937105296 .. 0.7742636826811272 | 0.4229242874389499 .. 0.8497534359086445 | 0.0290120900038226 .. 0.0 | 2 | 7.542208008583611 | 6.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]:
| name | rms | von_neumann_ratio | J_Stetson | max_power | freq_at_max_power | peak_freqs | peak_left_edge | peak_right_edge | power_at_peaks | n_peaks | ratio_of_power_at_high_v_low_freq | FAP | std | MAD | sigmaG | skewness | max_autocorrelation | time_of_max_autocorrelation |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| str7 | float64 | float64 | float64 | float64 | float64 | float64[25] | float64[5] | float64[5] | float64[25] | int64 | float64 | float64 | float32 | float32 | float64 | float32 | float64 | float64[1] |
| NGC 419 | 0.11711626158441998 | 0.001523331499211464 | 1.1804093968245712 | 0.08225337901935341 | 0.8100000000000002 | 0.41000000000000003 .. 0.0 | 0.38000000000000006 .. 5.480000000000001 | 0.43000000000000005 .. 5.520000000000001 | 0.029404892116234253 .. 0.0 | 5 | 3.7030709677085705 | 4.108941685757319e-19 | 0.00018255888 | 9.998679e-05 | 0.00014875981268744874 | 3928.4478 | 0.22151919044721688 | 5.08331298828125 |
Note
This tutorial was generated from a Jupyter notebook that can be found here.