Exemplo n.º 1
0
    def test_low_dec(self):
        with open(datapaths.swift_bat_grb_pos_v2) as f:
            good_src = voeventparse.load(f)
        with open(datapaths.swift_bat_grb_low_dec) as f:
            bad_src = voeventparse.load(f)

        good_fk5 = convert_voe_coords_to_eqposn(
                                     voeventparse.pull_astro_coords(good_src))
        bad_fk5 = convert_voe_coords_to_eqposn(
                                     voeventparse.pull_astro_coords(bad_src))
        self.assertIsNone(filters.ami.reject(good_fk5))
        self.assertIsNotNone(filters.ami.reject(bad_fk5))
Exemplo n.º 2
0
def handle_grb(v):
    ivorn = v.attrib['ivorn']
    TrigID = v.find(".//Param[@name='TrigID']").attrib['value']
    web_link = 'https://gcn.gsfc.nasa.gov/other/' + TrigID + '.swift'
    grb_length = is_short(v)  # Work out if it is short or long:
    if grb_length == 'short':
        coords = voeventparse.pull_astro_coords(v)
        c = voeventparse.get_event_position(v)
        if c.dec > 15.0:
            send_telegram("GRB above declination cutoff of +15 degrees  " +
                          web_link)
            #send_mail("GRB above declination cutoff of +15 degrees  "+web_link, "Short GRB above Dec cutoff")
        else:
            os.system('python schedule_atca.py ' + str(c.ra) + ' ' +
                      str(c.dec) + ' ' + web_link + ' ' + 'SHORT_GRB')
            n = Notifier()
            n.send_notification(title="SWIFT Short GRB >> TRIGGERING!",
                                text="Coords are {}".format(coords))
            send_telegram("SHORT GRB TRIGGERING  " + web_link)
    if grb_length == 'mid':
        coords = voeventparse.pull_astro_coords(v)
        c = voeventparse.get_event_position(v)
        if c.dec > 15.0:
            send_telegram("GRB above declination cutoff of +15 degrees  " +
                          web_link)
            #send_mail("GRB above declination cutoff of +15 degrees  "+web_link, "Mid GRB above Dec cutoff")
        else:
            n = Notifier()
            n.send_notification(title="SWIFT Mid GRB >> ON HOLD!",
                                text="Coords are {}".format(coords))
            #mid_grb_email('Please check:'+web_link, "Mid duration GRB", str(c.ra), str(c.dec))
            send_telegram('Please check:' + web_link +
                          " Mid duration GRB RA=" + str(c.ra) + ' DEC=' +
                          str(c.dec))
            # Send out SMS
            #send_SMS(c.ra, c.dec, web_link, subject='Mid GRB')
    if grb_length == 'long':
        #send_mail("Long GRB not triggering "+web_link, "Long GRB")
        send_telegram("Long GRB not triggering " + web_link)
    if grb_length == 'mag':
        coords = voeventparse.pull_astro_coords(v)
        c = voeventparse.get_event_position(v)
        if c.dec > 15.0:
            send_telegram(
                "GRB / Magnetar above declination cutoff of +15 degrees  " +
                web_link)
        else:
            n = Notifier()
            n.send_notification(title="SWIFT / Magnetar >> ON HOLD!",
                                text="Coords are {}".format(coords))
            send_telegram('Please check:' + web_link + " Magnetar RA=" +
                          str(c.ra) + ' DEC=' + str(c.dec))
Exemplo n.º 3
0
def handle_pointing(v):
    ivorn = v.attrib['ivorn']
    coords = voeventparse.pull_astro_coords(v)
    text = "Swift repointing, coords are {}".format(coords)
    n = Notifier()
    n.send_notification(title="Swift repointing!", text=text)
    handle_other(v)
Exemplo n.º 4
0
def handle_grb(v):
    ivorn = v.attrib['ivorn']
    coords = voeventparse.pull_astro_coords(v)
    text = "Swift packet received, coords are {}".format(coords)
    n = Notifier()
    n.send_notification(title="NEW SWIFT GRB!", text=text)
    handle_other(v)
Exemplo n.º 5
0
    def test_synopsis(self, simple_populated_db):
        """Check synopsis wrapper function, helper class."""
        dbinf = simple_populated_db

        # Try an packet with references
        ivorns_w_refs = apiv1.list_ivorn(filters={apiv1.FilterKeys.ref_any: True}, order=apiv1.OrderValues.id)
        s = Synopsis(apiv1.packet_synopsis(ivorns_w_refs[0]))
        assert s.references
        assert len(s.sky_events) == 0

        # Now try a non-existent ivorn:
        with pytest.raises(requests.HTTPError):
            apiv1.packet_synopsis("ivo://foo/bar")

        # Now try a packet with co-ords
        sb_ivorn = swift_bat_grb_655721.attrib["ivorn"]
        assert sb_ivorn in dbinf.inserted_ivorns
        s = Synopsis(apiv1.packet_synopsis(sb_ivorn))
        assert s.coords
        assert len(s.coords) == 1
        skyevent = s.sky_events[0]
        c_pkt = vp.pull_astro_coords(swift_bat_grb_655721)
        assert skyevent.position.ra.value == c_pkt.ra
        assert skyevent.position.dec.value == c_pkt.dec
        assert skyevent.position_error.value == c_pkt.err
def handle_grb(v):
    ivorn = v.attrib['ivorn']
    coords = voeventparse.pull_astro_coords(v)
    n = Notifier()
    n.send_notification(title="NEW SWIFT GRB!",
                        text=str(coords))
    handle_other(v)
Exemplo n.º 7
0
def handle_voevent(v):

	#Basic attribute access
	print("Ivorn:", v.attrib['ivorn'])
	print("Role:", v.attrib['role'])
	print( "AuthorIVORN:", v.Who.AuthorIVORN)
	print( "Short name:", v.Who.Author.shortName)
	print( "Contact:", v.Who.Author.contactEmail)

	#Copying by value, and validation:
	print( "Original valid as v2.0? ", voeventparse.valid_as_v2_0(v))
	v_copy = copy.copy(v)
	print( "Copy valid? ", voeventparse.valid_as_v2_0(v_copy))

	#Changing values:
	v_copy.Who.Author.shortName = 'BillyBob'
	v_copy.attrib['role'] = voeventparse.definitions.roles.test
	print( "Changes valid? ", voeventparse.valid_as_v2_0(v_copy))

	v_copy.attrib['role'] = 'flying circus'
	print( "How about now? ", voeventparse.valid_as_v2_0(v_copy))
	print( "But the original is ok, because we copied? ", voeventparse.valid_as_v2_0(v))

	v.Who.BadPath = "This new attribute certainly won't conform with the schema."
	assert voeventparse.valid_as_v2_0(v) == False
	del v.Who.BadPath
	assert voeventparse.valid_as_v2_0(v) == True
	#######################################################
	# And now, SCIENCE
	#######################################################
	c = voeventparse.pull_astro_coords(v)
	print( "Coords:", c)
Exemplo n.º 8
0
def handle_flare_star(v):
    n = Notifier()
    ivorn = v.attrib['ivorn']
    name_not_used, tel = get_name(v)
    name = get_flare_name(v)
    if tel == "SWIFT":
        TrigID = v.find(".//Param[@name='TrigID']").attrib['value']
        web_link = 'https://gcn.gsfc.nasa.gov/other/' + TrigID + '.swift'
    if tel == "MAXI":
        TrigID = v.find(".//Param[@name='TrigID']").attrib['value']
        web_link = 'https://gcn.gsfc.nasa.gov/other/8' + TrigID + '.maxi'
        #web_link = 'http://gcn.gsfc.nasa.gov/maxi.html'
    coords = voeventparse.pull_astro_coords(v)
    c = voeventparse.get_event_position(v)
    sub = vp.prettystr(v.What.Description)
    if "The sub-sub-threshold Swift-BAT trigger position notice" in sub:
        #send_mail("Flare Star "+name+" sub-sub threshold trigger", "Not triggering")
        send_telegram("Flare Star " + name + " sub-sub threshold trigger",
                      "Not triggering")
        n.send_notification(title="Flare Star " + name +
                            " sub-sub threshold burst ",
                            text="Coords are {}".format(coords))
    else:
        ra = get_flare_RA(name)
        dec = get_flare_DEC(name)
        n.send_notification(title="Flare Star " + name +
                            " Detected >> TRIGGERING!",
                            text="Coords are {}".format(coords))
        os.system('python schedule_atca.py ' + str(ra) + ' ' + str(dec) + ' ' +
                  web_link + ' ' + tel)
def handle_pointing(v):
    ivorn = v.attrib['ivorn']
    coords = voeventparse.pull_astro_coords(v)
    text = "Swift repointing, coords are {}".format(coords)
    n = Notifier()
    n.send_notification(title="Swift repointing!",
                        text=text)
    handle_other(v)
def handle_grb(v):
    ivorn = v.attrib['ivorn']
    coords = voeventparse.pull_astro_coords(v)
    text = "Swift packet received, coords are {}".format(coords)
    n = Notifier()
    n.send_notification(title="NEW SWIFT GRB!",
                        text=text)
    handle_other(v)
Exemplo n.º 11
0
 def test_swift_grb_v2_fk5(self):
     with open(datapaths.swift_bat_grb_pos_v2) as f:
         swift_grb_v2 = voeventparse.load(f)
     known_swift_grb_posn = ephem.Equatorial(74.741200 / DEG_PER_RADIAN,
                                             25.313700 / DEG_PER_RADIAN,
                                             epoch=ephem.J2000)
     voe_coords = voeventparse.pull_astro_coords(swift_grb_v2)
     extracted_posn = convert_voe_coords_to_eqposn(voe_coords)
     self.assertEqual(extracted_posn.ra, known_swift_grb_posn.ra)
     self.assertEqual(extracted_posn.dec, known_swift_grb_posn.dec)
Exemplo n.º 12
0
 def test_swift_grb_v2_fk5(self):
     with open(datapaths.swift_bat_grb_pos_v2) as f:
         swift_grb_v2 = voeventparse.load(f)
     known_swift_grb_posn = ephem.Equatorial(
         74.741200/DEG_PER_RADIAN, 25.313700/DEG_PER_RADIAN,
         epoch=ephem.J2000)
     voe_coords = voeventparse.pull_astro_coords(swift_grb_v2)
     extracted_posn = convert_voe_coords_to_eqposn(voe_coords)
     self.assertEqual(extracted_posn.ra, known_swift_grb_posn.ra)
     self.assertEqual(extracted_posn.dec, known_swift_grb_posn.dec)
Exemplo n.º 13
0
    def __init__(self, voevent):
        self.voevent = voevent
        if not filters.is_bat_grb_pkt(voevent):
            raise ValueError("Cannot instantiate BatGrb; packet header mismatch.")

        self.description = "Swift BAT GRB - initial position"
        id_long_short = BatGrb._pull_swift_bat_id(self.voevent)
        self.id_long = 'SWIFT' + id_long_short[0]
        self.id = 'SWIFT_' + id_long_short[1]
        #Assigned name according to the 'why' section of voevent packet:
        self.inferred_name = self.voevent.Why.Inference.Name
        self.isotime = voeventparse.pull_isotime(self.voevent)
        self.params = voeventparse.pull_params(self.voevent)
        self.position = convert_voe_coords_to_eqposn(
                                       voeventparse.pull_astro_coords(self.voevent))