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
Usage
First generate a set of random triggers, sorten on time:
import random
N = 1000
# Generate random trigger data
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)]
# Reformat data into a list of tuples
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 improves the effiency
triggers.sort(key=lambda tup: (tup[0], -tup[2]))
Now filter the triggers:
from astrotf.radio_pulse import RadioPulseFilterGen
freq_lo_mhz = 1249.8
freq_hi_mhz = 1549.8
# Itialize the filter generator
gen = RadioPulseFilterGen(freq_lo_mhz, freq_hi_mhz)
# Apply the filter to the list of triggers and print results
for filtered_trigger in gen(triggers):
print(filtered_trigger)
print('Filtered {} triggers out of a set of {}'.format(gen.num_out, gen.num_in))
Usage with Pandas
import pandas as pd
import random
from astrotf.radio_pulse import RadioPulseFilterGen
N = 1000 # Number of random triggers
freq_lo_mhz = 1249.8
freq_hi_mhz = 1549.8
# Generate a Pandas Data Frame with random trigger data
# ..or read triggers from a file:
# triggers = pd.read_csv('triggers.txt', delim_whitespace=True)
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']
)
# sort time increasing, then DM descending, then width descending
triggers.sort_values(by=['t', 'DM', 'w'], ascending=[True, False, False], inplace=True)
# Initialize the filter generator
gen = RadioPulseFilterGen(freq_lo_mhz, freq_hi_mhz)
# Print just the filtered triggers
for filtered_trigger in gen((e.t, e.w, e.DM, e.SNR) for e in triggers.itertuples()):
print(filtered_trigger)
print('Filtered {} triggers out of a set of {}'.format(gen.num_out, gen.num_in))
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
Close
Hashes for astro-trigger-filter-0.1.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7114af3f0c9ce9b24c03a9b8312bafb60e810cf697231c79abac698664d9a335 |
|
MD5 | 1fe9d88a9de83dd7e0601e527e4b8912 |
|
BLAKE2b-256 | a287d23f0ab0c7202ed618faf198656813452d2e11eb5f8b960a2d88c2a63d05 |
Close
Hashes for astro_trigger_filter-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e046b6ea1e53ba853be601d307f2843aea9934a36db5f337c4dd636e51aa8fec |
|
MD5 | cfea9236040dfa49c0135815d895d2c0 |
|
BLAKE2b-256 | 185e05eca62685b5d9f59d021e4fd804c4145e12b70212f33f8d55a7fab4a63a |