Ejemplo n.º 1
0
    def to_generic_alert(self, alert):
        """ Extract relevant parameters from the Fink alert to the TOM interface

        Parameters
        ----------
        alert: dict
            Dictionary containing alert data: {column name: value}. See
            `self.fetch_alerts` for more information.

        Returns
        ----------
        out: GenericAlert
            Alert columns to be displayed on the TOM interface
        """
        # This URL points to the objectId page in the Fink Science Portal
        url = '{}/{}'.format(FINK_URL, alert['i:objectId'])

        return GenericAlert(timestamp=alert['i:jd'],
                            id=alert['i:candid'],
                            url=url,
                            name=alert['i:objectId'],
                            ra=alert['i:ra'],
                            dec=alert['i:dec'],
                            mag=alert['i:magpsf'],
                            score=alert['d:rf_snia_vs_nonia'])
Ejemplo n.º 2
0
    def to_generic_alert(self, alert):
        if alert['lastmjd']:
            timestamp = Time(alert['lastmjd'], format='mjd',
                             scale='utc').to_datetime(timezone=TimezoneInfo())
        else:
            timestamp = ''
        url = '{0}/{1}/{2}'.format(ALERCE_URL, 'object', alert['oid'])

        exits = (alert['mean_magpsf_g'] is None
                 and alert['mean_magpsf_r'] is not None)
        both_exists = (alert['mean_magpsf_g'] is not None
                       and alert['mean_magpsf_r'] is not None)
        bigger = (
            both_exists
            and (alert['mean_magpsf_r'] < alert['mean_magpsf_g'] is not None))
        is_r = any([exits, bigger])

        max_mag = alert['mean_magpsf_r'] if is_r else alert['mean_magpsf_g']

        if alert['pclassrf']:
            score = alert["pclassrf"]
        elif alert['pclassearly']:
            score = alert['pclassearly']
        else:
            score = None

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['oid'],
                            name=alert['oid'],
                            ra=alert['meanra'],
                            dec=alert['meandec'],
                            mag=max_mag,
                            score=score)
Ejemplo n.º 3
0
    def to_generic_alert(self, alert):
        if alert['lastmjd']:
            timestamp = Time(alert['lastmjd'], format='mjd',
                             scale='utc').to_datetime(timezone=TimezoneInfo())
        else:
            timestamp = ''
        url = f'{ALERCE_URL}/object/{alert["oid"]}'

        # Use the smaller value between r and g if both are present, else use the value that is present
        mag = None
        if alert['mean_magpsf_r'] is not None and alert[
                'mean_magpsf_g'] is not None:
            mag = alert['mean_magpsf_g'] if alert['mean_magpsf_r'] > alert[
                'mean_magpsf_g'] else alert['mean_magpsf_r']
        elif alert['mean_magpsf_r'] is not None:
            mag = alert['mean_magpsf_r']
        elif alert['mean_magpsf_g'] is not None:
            mag = alert['mean_magpsf_g']

        if alert['pclassrf'] is not None:
            score = alert['pclassrf']
        elif alert['pclassearly'] is not None:
            score = alert['pclassearly']
        else:
            score = None

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['oid'],
                            name=alert['oid'],
                            ra=alert['meanra'],
                            dec=alert['meandec'],
                            mag=mag,
                            score=score)
Ejemplo n.º 4
0
 def to_generic_alert(cls, alert):
     return GenericAlert(timestamp=alert['discoverydate'],
                         url=f'{TNS_BASE_URL}object/' + alert['objname'],
                         id=alert['objname'],
                         name=alert['name_prefix'] + alert['objname'],
                         ra=alert['radeg'],
                         dec=alert['decdeg'],
                         mag=alert['discoverymag'],
                         score=alert['name_prefix'] == 'SN')
Ejemplo n.º 5
0
 def to_generic_alert(clazz, alert):
     return GenericAlert(timestamp=alert['timestamp'],
                         url=broker_url,
                         id=alert['id'],
                         name=alert['name'],
                         ra=alert['ra'],
                         dec=alert['dec'],
                         mag=alert['mag'],
                         score=alert['score'])
Ejemplo n.º 6
0
 def to_generic_alert(cls, alert):
     return GenericAlert(timestamp=alert['discoverydate'],
                         url='https://wis-tns.weizmann.ac.il/object/' +
                         alert['objname'],
                         id=alert['objname'],
                         name=alert['name_prefix'] + alert['objname'],
                         ra=alert['radeg'],
                         dec=alert['decdeg'],
                         mag=alert['discoverymag'],
                         score=alert['name_prefix'] == 'SN')
Ejemplo n.º 7
0
 def to_generic_alert(self, alert):
     return GenericAlert(
         url=LASAIR_URL + '/object/' + alert['alert_id'],
         id=alert['alert_id'],
         name=alert['alert_id'],
         ra=alert['ra'],
         dec=alert['dec'],
         timestamp=alert['timestamp'],
         mag=alert['mag'],
         score=1,  # dunno what this means ..?
     )
Ejemplo n.º 8
0
    def to_generic_alert(self, alert):
        timestamp = parse(alert['lastRun'])
        url = 'https://cneos.jpl.nasa.gov/scout/#/object/' + alert['objectName']

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['objectName'],
                            name=alert['objectName'],
                            ra=hours_min_to_decimal(alert['ra']),
                            dec=alert['dec'],
                            mag=alert['H'],
                            score=alert['neoScore'])
Ejemplo n.º 9
0
    def to_generic_alert(self, alert):
        timestamp = parse(alert['candidate']['wall_time'])
        url = '{0}/{1}/'.format(MARS_URL, alert['lco_id'])

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['lco_id'],
                            name=alert['objectId'],
                            ra=alert['candidate']['ra'],
                            dec=alert['candidate']['dec'],
                            mag=alert['candidate']['magpsf'],
                            score=alert['candidate']['rb'])
Ejemplo n.º 10
0
 def to_generic_alert(self, alert):
     """ We use this method to transform a remote alert (in this case an item
     from the `test_alerts` list) into a `GenericAlert` so they can be displayed in a
     consistent manner.
     """
     return GenericAlert(timestamp=alert['timestamp'],
                         url='https://tomtoolkit.github.io',
                         id=alert['id'],
                         name=alert['name'],
                         ra=alert['ra'],
                         dec=alert['dec'],
                         mag=alert['mag'],
                         score=alert['score'])
Ejemplo n.º 11
0
    def to_generic_alert(self, alert):
        timestamp = parse(alert['obstime'])
        alert_link = alert.get('per_alert', {})['link']
        url = f'{BASE_BROKER_URL}/{alert_link}'

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['name'],
                            name=alert['name'],
                            ra=alert['ra'],
                            dec=alert['dec'],
                            mag=alert['alertMag'],
                            score=1.0)
Ejemplo n.º 12
0
    def to_generic_alert(self, alert):
        timestamp = parse(alert['obstime'])
        url = BROKER_URL.replace('/alerts/alertsindex',
                                 alert['per_alert']['link'])

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['name'],
                            name=alert['name'],
                            ra=alert['ra'],
                            dec=alert['dec'],
                            mag=alert['alertMag'],
                            score=1.0)
Ejemplo n.º 13
0
 def to_generic_alert(self, alert):
     _, alert = alert
     url = 'https://antares.noao.edu/alerts/data/{}'.format(alert['new_alert']['alert_id'])
     timestamp = datetime.utcfromtimestamp(alert['timestamp_unix']).replace(tzinfo=timezone.utc)
     return GenericAlert(
         timestamp=timestamp,
         url=url,
         id=alert['new_alert']['properties']['ztf_candid'],
         name=alert['new_alert']['properties']['ztf_object_id'],
         ra=alert['new_alert']['ra'],
         dec=alert['new_alert']['dec'],
         mag=alert['new_alert']['properties']['ztf_magpsf'],
         score=alert['new_alert']['properties']['ztf_rb']
     )
Ejemplo n.º 14
0
 def to_generic_alert(self, alert):
     score = alert['message'].get('rank', 0) if alert['topic'] == 'lvc.lvc-counterpart' else ''
     return GenericAlert(
         url=f'{SCIMMA_API_URL}/alerts/{alert["id"]}',
         id=alert['id'],
         # This should be the object name if it is in the comments
         name=alert['alert_identifier'],
         ra=alert['right_ascension'],
         dec=alert['declination'],
         timestamp=alert['alert_timestamp'],
         # Well mag is not well defined for XRT sources...
         mag=0.0,
         score=score  # Not exactly what score means, but ish
     )
Ejemplo n.º 15
0
    def to_generic_alert(self, alert):
        if alert['lastmjd']:
            timestamp = Time(alert['lastmjd'], format='mjd',
                             scale='utc').to_datetime(timezone=TimezoneInfo())
        else:
            timestamp = ''
        url = '{0}/{1}/{2}'.format(ALERCE_URL, 'vue/object', alert['oid'])

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['oid'],
                            name=alert['oid'],
                            ra=alert['meanra'],
                            dec=alert['meandec'],
                            mag=alert['mean_magpsf_g'],
                            score=None)
Ejemplo n.º 16
0
    def to_generic_alert(self, alert):
        if alert['lastmjd']:
            timestamp = Time(alert['lastmjd'], format='mjd',
                             scale='utc').to_datetime(timezone=TimezoneInfo())
        else:
            timestamp = ''
        url = f'{ALERCE_URL}/object/{alert["oid"]}'

        mag = None  # mag is no longer returned in the object list

        score = alert['probability']

        return GenericAlert(timestamp=timestamp,
                            url=url,
                            id=alert['oid'],
                            name=alert['oid'],
                            ra=alert['meanra'],
                            dec=alert['meandec'],
                            mag=mag,
                            score=score)
Ejemplo n.º 17
0
 def to_generic_alert(self, alert):
     return GenericAlert()