示例#1
0
def create_ami_followup_notification(alert, stream_id,
                                request_status,
                                superseded_ivorns=None):

    orig_pkt = alert.voevent
    voevent = create_skeleton_4pisky_voevent(
        substream=alarrm_request_substream,
        stream_id=stream_id,
        role=vp.definitions.roles.utility)
    vp.add_how(voevent, descriptions="AMI Large Array, Cambridge",
               references=vp.Reference(
                   "http://www.mrao.cam.ac.uk/facilities/ami/ami-technical-information/"),
    )
    voevent.Why = copy(orig_pkt.Why)
    vp.add_citations(voevent, citations=vp.Citation(ivorn=orig_pkt.attrib['ivorn'],
                              cite_type=vp.definitions.cite_types.followup))
    voevent.What.Description = "A request for AMI-LA follow-up has been made."
    
    request_params = [vp.Param(key, val)
                      for key, val in request_status.iteritems()]
    g = vp.Group(request_params, name='request_status')
    voevent.What.append(g)
    
    # Also copy target location into WhereWhen
    voevent.WhereWhen = copy(orig_pkt.WhereWhen)
    # But the time marker should refer to the AMI observation:
    # (We are already citing the original Swift alert)
    ac = voevent.WhereWhen.ObsDataLocation.ObservationLocation.AstroCoords
    del ac.Time
    voevent.WhereWhen.Description = "Target co-ords from original Swift BAT alert"

    return voevent
示例#2
0
 def add_reference(self, packet, ref_ivorn):
     self.n_citations += 1
     # self.cited.add(ref_ivorn)
     self.cite_counts[ref_ivorn] = self.cite_counts[ref_ivorn] + 1
     self.followup_packets.append(packet.attrib['ivorn'])
     vp.add_citations(
         packet, vp.EventIvorn(ref_ivorn,
                               vp.definitions.cite_types.followup))
示例#3
0
 def add_reference(self, packet, ref_ivorn):
     self.n_citations += 1
     # self.cited.add(ref_ivorn)
     self.cite_counts[ref_ivorn] = self.cite_counts[ref_ivorn] + 1
     self.followup_packets.append(packet.attrib['ivorn'])
     vp.add_citations(packet,
                      vp.Citation(
                          ref_ivorn,
                          vp.definitions.cite_types.followup)
                      )
示例#4
0
    def generate_voevent(self, feed_id):
        event_data = self.event_id_data_map[feed_id]
        stream_id = self.feed_id_to_stream_id(feed_id)
        v = create_skeleton_4pisky_voevent(
            substream=self.substream,
            stream_id=stream_id,
            role=vp.definitions.roles.observation,
            date=datetime.datetime.utcnow())

        vp.add_how(v, references=[vp.Reference(uri=self.url)])
        v.How.Description = "Parsed from Swift burst-analysis listings by 4PiSky-Bot."

        # Simply copy the WhereWhen from the trigger event:
        v.WhereWhen = self.trigger_event.WhereWhen
        v.What.append(vp.Param("TrigID", value=self.trigger_id, ucd="meta.id"))
        vp.add_citations(v,
                         event_ivorns=[
                             vp.EventIvorn(
                                 ivorn=self.trigger_event.attrib['ivorn'],
                                 cite_type=vp.definitions.cite_types.followup)
                         ])
        if SwiftFeedKeys.duration in feed_id:
            duration_data = event_data[SwiftFeedKeys.duration]
            battblocks_failed = duration_data['battblocks_failed']
            battblocks_param = vp.Param('battblocks_failed',
                                        value=battblocks_failed,
                                        ucd='meta.code.error')
            battblocks_param.Description = """\
            If 'battblocks_failed' is 'True', the source-page contains the 'battblocks failed' warning.
            This means the duration analysis is bad, usually because the source
            is not actually a GRB burst.
            """
            duration_params = []
            if not battblocks_failed:
                duration_params.extend([
                    vp.Param(k,
                             value=duration_data.get(k),
                             unit='s',
                             ucd='time.duration')
                    for k in (SwiftFeedKeys.t90, SwiftFeedKeys.t50)
                ])
                duration_params.extend([
                    vp.Param(k,
                             value=duration_data.get(k),
                             unit='s',
                             ucd='meta.code.error;time.duration')
                    for k in (SwiftFeedKeys.t90_err, SwiftFeedKeys.t50_err)
                ])
            duration_params.append(battblocks_param)
            v.What.append(
                vp.Group(params=duration_params, name=SwiftFeedKeys.duration))

        return v
示例#5
0
 def test_followup_citation(self):
     ref = 'ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-729'
     vp.add_citations(
         self.v,
         vp.EventIvorn('ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-729',
                       cite_type=vp.definitions.cite_types.followup))
     vp.assert_valid_as_v2_0(self.v)
     self.assertEqual(len(self.v.Citations.getchildren()), 1)
     # print
     # print vp.prettystr(self.v.Citations)
     vp.add_citations(
         self.v,
         vp.EventIvorn('ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-730',
                       cite_type=vp.definitions.cite_types.followup))
     self.assertTrue(vp.valid_as_v2_0(self.v))
     #         print voe.prettystr(self.v.Citations)
     self.assertEqual(len(self.v.Citations.getchildren()), 2)
示例#6
0
 def test_followup_citation(self):
     ref = 'ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-729'
     vp.add_citations(self.v,
                      vp.EventIvorn(
                          'ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-729',
                          cite_type=vp.definitions.cite_types.followup)
                      )
     vp.assert_valid_as_v2_0(self.v)
     self.assertEqual(len(self.v.Citations.getchildren()), 1)
     # print
     # print vp.prettystr(self.v.Citations)
     vp.add_citations(self.v,
                      vp.EventIvorn(
                          'ivo://nasa.gsfc.gcn/SWIFT#BAT_GRB_Pos_532871-730',
                          cite_type=vp.definitions.cite_types.followup)
                      )
     self.assertTrue(vp.valid_as_v2_0(self.v))
     #         print voe.prettystr(self.v.Citations)
     self.assertEqual(len(self.v.Citations.getchildren()), 2)
print("\n***And your What:***\n")
print(vp.prettystr(v.What))

# You would normally describe or reference your telescope / instrument here:
vp.add_how(v, descriptions='Discovered via 4PiSky',
           references=vp.Reference('http://4pisky.org'))

# The 'Why' section is optional, allows for speculation on probable
# astrophysical cause
vp.add_why(v, importance=0.5,
           inferences=vp.Inference(probability=0.1,
                                   relation='identified',
                                   name='GRB121212A',
                                   concept='process.variation.burst;em.radio')
           )

# We can also cite earlier VOEvents:
vp.add_citations(v,
                 vp.EventIvorn(
                     ivorn='ivo://astronomy.physics.science.org/super_exciting_events#101',
                     cite_type=vp.definitions.cite_types.followup))

# Check everything is schema compliant:
vp.assert_valid_as_v2_0(v)

output_filename = 'new_voevent_example.xml'
with open(output_filename, 'wb') as f:
    vp.dump(v, f)

print("Wrote your voevent to ", os.path.abspath(output_filename))
# You would normally describe or reference your telescope / instrument here:
vp.add_how(v,
           descriptions='Discovered via 4PiSky',
           references=vp.Reference('http://4pisky.org'))

# The 'Why' section is optional, allows for speculation on probable
# astrophysical cause
vp.add_why(v,
           importance=0.5,
           inferences=vp.Inference(probability=0.1,
                                   relation='identified',
                                   name='GRB121212A',
                                   concept='process.variation.burst;em.radio'))

# We can also cite earlier VOEvents:
vp.add_citations(
    v,
    vp.EventIvorn(
        ivorn='ivo://astronomy.physics.science.org/super_exciting_events#101',
        cite_type=vp.definitions.cite_types.followup))

# Check everything is schema compliant:
vp.assert_valid_as_v2_0(v)

output_filename = 'new_voevent_example.xml'
with open(output_filename, 'wb') as f:
    vp.dump(v, f)

print("Wrote your voevent to ", os.path.abspath(output_filename))