Skip to content

Event search

Get event info from L4 database

Text Only
import chime_frb_api
BASE_URL = "http://frb-vsop.chime:8001"
master = chime_frb_api.frb_master.FRBMaster(base_url = BASE_URL)
master.API.authorize()
auth = {"Authorization": master.API.access_token}
master.events.get_event(<event ID>)  # Use full_header=True for full information

Get events classified

Text Only
def get_classifications(classification_type):
    classified = []
    for ev in all_events:
        try:
            url = BASE_URL + "/v1/verification/get-verification/{}".format(ev)
            status = requests.get(url, headers=auth)
            classification = [n['classification'] for n in status.json()['user_verification'] if n['classification'] != 'UNCLASSIFIED']
            rating = [n['rating'] for n in status.json()['user_verification'] if n['classification'] != 'UNCLASSIFIED']
            other_ratings = [n for n,m in zip(rating, classification) if m != classification_type]
            if classification_type in classification:
                if len(other_ratings) > 0 and max(other_ratings) > 3:
                    continue
                classified.append(ev)
        except:
            pass
    return classified

Classification types include

  • NEW CANDIDATE for FRBs
  • KNOWN CANDIDATE for repeating FRBs
  • KNOWN SOURCE for pulsars
  • FAINT
  • RFI

Get event types

Text Only
def get_type(event_type):
    ev_list = []
    for ev in all_events:
        if master.events.get_event(ev)['event_type'] == event_type:
            ev_list.append(ev)
    return ev_list

Event types include:

  • EXTRAGALACTIC
  • KNOWN-FRB
  • AMBIGUOUS
  • KNOWN-PULSAR
  • RFI

Disk checks

Known pulsars are listed in this folder. There is one spreadsheet per year. Each spreadsheet contains three sheets

  1. Events that have been requested through specific rules.
  2. Events that were wrongly collected as extragalactic and that were classified as known pulsars by tsars.
  3. Events in the other sheets that have already been deleted, for tracking purposes.

Get all baseband events

Text Only
start_event = 0
end_event = 1e10

from glob import glob
import os
import requests
from time import sleep
import chime_frb_api
from requests.exceptions import HTTPError

import logging
logging.getLogger("chime_frb_api").setLevel(logging.ERROR)

BASE_URL = "http://frb-vsop.chime:8001"
master = chime_frb_api.frb_master.FRBMaster(base_url = BASE_URL)
def auth_tokens():
    master.API.authorize()
    auth = {"Authorization": master.API.access_token}
    return auth
auth = auth_tokens()
url_del = BASE_URL + '/v1/code/rawdata/baseband/{}'

all_folders = glob("/data/chime/baseband/raw/20??/*/*/astro_*")
all_events = [int(os.path.basename(n)[6:]) for n in all_folders]

all_folders = [n for ev,n in zip(all_events, all_folders) if (ev > start_event) and (ev < end_event)]
all_events = [n for n in all_events if (n > start_event) and (n < end_event)]

# Code to remove events
def remove_events(ev_list):
    list_out = []
    for i,ev in enumerate(ev_list):
        print('{:04.1f}% - {}'.format(i/len(ev_list)*100, ev))
        r = requests.delete(url_del.format(ev), headers=auth)
        print(r.text)
        print()
        try: r.raise_for_status()
        except HTTPError: list_out.append(ev)
        sleep(2)
    return list_out

Remove empty folders

Text Only
empty = []
empty_folder = []
for folder in all_folders:
    n_files = len(glob(os.path.join(folder, "*.h5")))
    if n_files < 10:
        empty.append(int(os.path.basename(folder)[6:]))
        empty_folder.append(folder)

all_events = [n for n in all_events if n not in empty]
all_folders = [n for n in all_folders if n not in empty_folder]

empty = remove_events(empty)

Remove RFI

Text Only
rfi = []
for ev in all_events:
    try:
        url = BASE_URL + "/v1/verification/get-verification/{}".format(ev)
        status = requests.get(url, headers=auth)
        if int(status.json()['max_rating']) < 2:
            rfi.append(ev)
    except TypeError:
        pass
rfi_folder = [f for f in all_folders if int(f.split('_')[-1]) in rfi]

all_events = [n for n in all_events if n not in rfi]
all_folders = [n for n in all_folders if n not in rfi_folder]

rfi = remove_events(rfi)

Get manual pulsar dumps

Text Only
# Get pulsars manually triggered
ev = all_events[0]
ev_list = all_events[all_events.index(ev):]
pulsars_manually_triggered = []
for i,ev in enumerate(ev_list):
    print('{:04.1f}% - {}'.format(i/len(ev_list)*100, ev))
    if i == 100: auth = auth_tokens()
    try:
        if master.events.get_event(ev)['event_type'] == 'KNOWN-PULSAR':
            pulsars_manually_triggered.append(ev)
    except TypeError:
        print(f'Event {ev} not found')
        pulsars_manually_triggered.append(ev)
pulsars_manually_triggered = sorted(pulsars_manually_triggered)

# Get list of pulsar names
pulsar_name = []
for i,ev in enumerate(pulsars_manually_triggered):
    print('{:04.1f}% - {}'.format(i/len(pulsars_manually_triggered)*100, ev))
    if i == 100: auth = auth_tokens()
    try:
        header = master.events.get_event(ev, full_header=True)
        pulsar_name.append(header['event_best_data']['source_category_name'])
    except (TypeError, HTTPError):
        print(f'Event {ev} not found')
        pulsar_name.append('')

# Get list of dump dates
pulsar_date = []
for i,ev in enumerate(pulsars_manually_triggered):
    print('{:04.1f}% - {}'.format(i/len(pulsars_manually_triggered)*100, ev))
    if i == 100: auth = auth_tokens()
    try:
        header = master.events.get_event(ev, full_header=False)
        pulsar_date.append(header['measured_parameters'][0]['datetime'])
    except (TypeError, HTTPError):
        print(f'Event {ev} not found')
        pulsar_date.append('')

Get accidental pulsar dump

Text Only
classification_type = "KNOWN SOURCE"
classified = []
for i,ev in enumerate(all_events):
    print('{:04.1f}% - {}'.format(i/len(all_events)*100, ev))
    if i == 100: auth = auth_tokens()
    try:
        url = BASE_URL + "/v1/verification/get-verification/{}".format(ev)
        status = requests.get(url, headers=auth)
        classification = [n['classification'] for n in status.json()['user_verification'] if n['classification'] != 'UNCLASSIFIED']
        rating = [n['rating'] for n in status.json()['user_verification'] if n['classification'] != 'UNCLASSIFIED']
        other_ratings = [n for n,m in zip(rating, classification) if m != classification_type]
        if classification_type in classification:
            if len(other_ratings) > 0 and max(other_ratings) > 3:
                continue
            classified.append(ev)
    except:
        pass
classified = sorted(classified)

# Get list of dump dates
pulsar_date = []
pulsar_dm = []
for i,ev in enumerate(classified):
    print('{:04.1f}% - {}'.format(i/len(classified)*100, ev))
    if i == 100: auth = auth_tokens()
    try:
        header = master.events.get_event(ev, full_header=False)
        pulsar_date.append(header['measured_parameters'][0]['datetime'])
        pulsar_dm.append(header['measured_parameters'][0]['dm'])
    except (TypeError, HTTPError):
        print(f'Event {ev} not found')
        pulsar_date.append('')

Delete an event folder and database entry (CAUTION!)

Text Only
import chime_frb_api
import requests
from time import sleep

# Code to remove events
def remove_events(ev_list):
    list_out = []
    for i,ev in enumerate(ev_list):
        print('{:04.1f}% - {}'.format(i/len(ev_list)*100, ev))
        r = requests.delete(url_del.format(ev), headers=auth)
        print(r.text)
        print()
        try: r.raise_for_status()
        except HTTPError: list_out.append(ev)
        sleep(2)
    return list_out

BASE_URL = "http://frb-vsop.chime:8001"
master = chime_frb_api.frb_master.FRBMaster(base_url = BASE_URL)
master.API.authorize()
auth = {"Authorization": master.API.access_token}
url_del = BASE_URL + '/v1/code/rawdata/baseband/{}'

ev_list = [
...
]

ev_list = remove_events(ev_list)