A package for filtering triggers from radio astronomical matched template pulse searches.
Project description
astro-trigger-filter
A Python package for filtering radio astronomical pulse matched template searches.
Installation
pip install astro-trigger-filter
Basic Usage
Generate a set of random triggers, sorten on time:
import random
N = 1000
start_times = [random.uniform(0.0, 1.0) for _ in range(N)]
widths = [random.uniform(0.00, 0.01) for _ in range(N)]
DMs = [random.uniform(0.0, 100.0) for _ in range(N)]
SNRs = [random.uniform(5.0, 10.0) for _ in range(N)]
triggers = [t for t in zip(start_times, widths,DMs, SNRs)]
Make sure the list is sorted on start time. Aditional reverse sorting on DM will improve the effiency.
triggers.sort(key=lambda tup: (tup[0], -tup[2]))
Now filter the triggers:
from astrotf.radio_pulse import RadioPulseFilterGen
gen = RadioPulseFilterGen(freq_lo_mhz=1249.8, freq_hi_mhz=1549.8)
for filtered_trigger in gen(triggers):
print(filtered_trigger)
Print filtering statistics
print('Reduced the number of triggers from {} to {}'.format(
gen.num_in,
gen.num_out
))
Processing Pandas Dataframes
Generate a pandas dataframe with random triggers:
import pandas as pd
import random
triggers = pd.DataFrame(
[
[
random.uniform(0.0, 1.0),
random.uniform(0.0, 0.01),
random.uniform(0.0, 100.0),
random.uniform(5.0, 10.0)
]
for _ in range(N)
],
columns=['t', 'w', 'DM', 'SNR']
)
..or read a csv file from disk:
triggers = pd.read_csv('triggers.txt', delim_whitespace=True)
Sort time increasing, then DM descending, then pulse width descending
triggers.sort_values(
by=['t', 'DM', 'w'],
ascending=[True, False, False],
inplace=True
)
finally filter and print the triggers:
gen = RadioPulseFilterGen(freq_lo_mhz, freq_hi_mhz)
for filtered_trigger in gen(
(e.t, e.w, e.DM, e.SNR)
for e in triggers.itertuples()
):
print(filtered_trigger)
Storing extra data for each trigger
You can add extra data for each trigger, as lomng as the first 4 elements remain [time, width, dispersion measure, signal-to-noise ration]. In the example below we have added a beam_id and sample_id.
for filtered_trigger in gen(
(
e.time,
e.w,
e.DM,
e.SNR,
e.beam_id,
e.sample_id
)
for e in triggers.itertuples()
):
print(filtered_trigger)
More settings
buffersize=0 : Limit the buffer size. The default setting is 0 which means an unlimited buffer size. A buffer size of 25 speeds up filtering while only generating margiuamly more false triggers.
autoflush=True : Automatically flush buffer when finished processing the input trigger. Set this to false if you want to process triggers in chunks and not flush the buffers between each chunk.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for astro-trigger-filter-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d934a9f26a21f9703b82a39d76452da0613279f454f5693bf401e92c041427 |
|
MD5 | 97be78ef569c3afa53666d1d343f51be |
|
BLAKE2b-256 | 9f4b6ccefe582472ff4e1396cd96e8a6e386f315673d40c42a8e4efc51f7a80a |
Hashes for astro_trigger_filter-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da2941cbbab2852facc56c6deaba320d5bdd1724cb9a658c30cee408745eab53 |
|
MD5 | 21316cd8000889507dce7c5c09a953f9 |
|
BLAKE2b-256 | 4f9624002fbce5d30ebc53fe75baba89ef7990cb9398b174dbfa719ca6685583 |