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

        good_fk5 = convert_voe_coords_to_fk5(
                                     voeparse.pull_astro_coords(good_src))
        bad_fk5 = convert_voe_coords_to_fk5(
                                     voeparse.pull_astro_coords(bad_src))
        self.assertIsNone(filters.ami.reject(good_fk5))
        self.assertIsNotNone(filters.ami.reject(bad_fk5))
Esempio n. 2
0
def swift_bat_grb_logic(v):
    now = datetime.datetime.now(pytz.utc)
    posn = ps.utils.convert_voe_coords_to_fk5(voeparse.pull_astro_coords(v))
    actions_taken = []
    alert_id, alert_id_short = ps.utils.pull_swift_bat_id(v)
    target_name = 'SWIFT_' + alert_id_short
    comment = 'Automated SWIFT ID ' + alert_id

    if posn.dec.degrees > -10.0:
        duration = datetime.timedelta(hours=1)

        ami_request = ami.request_email(posn, target_name, duration,
                      timing='ASAP',
                      action='QUEUE',
                      requester=contacts['ami']['requester'],
                      comment=comment)
        ps.comms.email.send_email(account=default_email_account,
                                recipient_addresses=contacts['ami']['email'],
                                subject=ami.request_email_subject,
                                body_text=ami_request)

        actions_taken.append('Observation requested from AMI.')

    notify_msg = generate_report_text(
                                {'position': posn, 'description': 'Swift GRB'},
                                active_sites,
                                now,
                                actions_taken)
    ps.comms.email.send_email(default_email_account,
                        [p['email'] for p in notify_contacts],
                        notification_email_prefix + target_name,
                        notify_msg)
Esempio n. 3
0
 def test_swift_grb_v2_fk5(self):
     with open(datapaths.swift_bat_grb_pos_v2) as f:
         swift_grb_v2 = voeparse.load(f)
     known_swift_grb_posn = FK5Coordinates(ra=74.741200, dec=25.313700,
                                          raerr=0.05, decerr=0.05)
     voe_coords = voeparse.pull_astro_coords(swift_grb_v2)
     fk5 = convert_voe_coords_to_fk5(voe_coords)
     self.assertEqual(fk5, known_swift_grb_posn)
Esempio n. 4
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 = voeparse.pull_isotime(self.voevent)
        self.params = voeparse.pull_params(self.voevent)
        self.position = convert_voe_coords_to_fk5(
                                       voeparse.pull_astro_coords(self.voevent))
#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? ", voeparse.valid_as_v2_0(v)
v_copy = copy.copy(v)
print "Copy valid? ", voeparse.valid_as_v2_0(v_copy)

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

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

# v.Who.BadPath = "This new child certainly won't conform with the schema."
# assert voeparse.valid_as_v2_0(v) == False
# del v.Who.BadPath
# assert voeparse.valid_as_v2_0(v) == True
#######################################################
# And now, SCIENCE
#######################################################
c = voeparse.pull_astro_coords(v)
print "Coords:", c