Example #1
0
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=1)
    alert_id = alert_ids[0]

    alert = ConstructAlertFromID(alert_id, 'E')

    try:
        alert.CA.P.value = 'abc'
    except TypeError:
        print(
            'TypeError caught because we are assigning an incompatible type of value!'
        )

    ## Suppose we first compute P value with lower confidence.
    alert.CA.P.value = ComputeP()
    alert.CA.P.confidence = 0.4
    alert.CA.P.annotation = 'Computed with low confidence'

    ## Later we compute P value with higher confidence, this will
    ## be the most-recently computed value for P. But the previous one
    ## will still be kept with its timpstamp.
    alert.CA.P.value = ComputeP()
    alert.CA.P.confidence = 1.0
    alert.CA.P.annotation = 'Computed with high confidence'

    # This will show the most-recently computed value.
    print(alert)

    # This will print out all the computed values for P and their timestamps.
    print(alert.CA.P.history)
Example #2
0
def main():
    alerts = GenerateCameraAlertStream()
    for alert in alerts:
        alert.CA.GMinusR.value = alert.CA.G.value - alert.CA.R.value
        alert.CA.GMinusR.confidence = 1.0
        alert.CA.GMinusR.annotation = 'Computed with high confidence'
        print(alert)
def main():
    alert_ids = GenerateCameraAlertStream(2)
    for alert_id in alert_ids:
        alert = ConstructAlertFromID(alert_id, 'E')
        lightcurve = alert.LA.assembleTimeSeries_cameraAlerts(
            'CA', 'Magnitude')
        print(lightcurve)
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=5)
    for alert_id in alert_ids:
        alert = ConstructAlertFromID(alert_id, 'E')

        ## This is the recommended way of getting ra/dec for an alert:
        ## directly from alert.
        ra = alert.ra
        decl = alert.decl
        print('alert {0}: ra={1}, dec={2}'.format(alert.ID, ra, decl))

        ## This is not recommended: too verbose and multiple level of references.
        ra = alert.CA.RA.value
        decl = alert.CA.Decl.value
        print('alert {0}: ra={1}, dec={2}'.format(alert.ID, ra, decl))
Example #5
0
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=1)
    alert_id = alert_ids[0]

    alert = ConstructAlertFromID(alert_id, 'E')
    print(alert)

    ## Create a replica with an associated astro object.
    replica_id1 = alert.createReplica(astro_id=17249)
    print('Created replica {0}'.format(replica_id1))
    ## Construct replica object given ID
    replica1 = ConstructAlertFromID(replica_id1, 'R')
    print(replica1)

    ## Create another replica without an associated astro object.
    replica_id2 = alert.createReplica()
    print('Created replica {0}'.format(replica_id2))

    ## Construct replica object given ID
    replica2 = ConstructAlertFromID(replica_id2, 'R')
    replica2.commit()
    print(replica2)
Example #6
0
def main():
    alert_ids = GenerateCameraAlertStream( alert_num=1 )
    alert_id = alert_ids[ 0 ]

    alert = ConstructAlertFromID( alert_id, 'E' )
    print( alert )

    ## Create a replica with an associated astro object.
    replica_id1 = alert.createReplica( astro_id=17249 )
    print( 'Created replica {0}'.format(replica_id1) )
    ## Construct replica object given ID
    replica1 = ConstructAlertFromID( replica_id1, 'R', alert )
    replica1.mark_as_rare( 'Replica1 is rare' )

    ## Create another replica without an associated astro object.
    replica_id2 = alert.createReplica()
    print( 'Created replica {0}'.format(replica_id2) )

    ## Construct replica object given ID
    replica2 = ConstructAlertFromID( replica_id2, 'R', alert )
    replica2.mark_as_rare( 'Replica2 is rare' )

    #print( alert.get_annotation() )
    print( alert.annotation )
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=1)
    alert_id = alert_ids[0]

    alert = ConstructAlertFromID(alert_id, 'E')
    print(alert)

    ## Create a replica with an associated astro object.
    replica_id = alert.createReplica(astro_id=17249)
    print('Created replica {0}'.format(replica_id))
    ## Construct replica object given ID
    replica = ConstructAlertFromID(replica_id, 'R')
    #print( replica )

    # ## Create another replica from the current replica
    # replica_replica_id = replica.createReplica()
    # print( 'Created replica {0}'.format(replica_replica_id) )

    # ## Construct replica object given ID
    # replica = ConstructAlertFromID( replica_replica_id, 'R' )
    # print( replica )

    parents = []
    for i in range(0, 4):
        replica_replica_id = replica.createReplica()
        #print( replica.parent.__repr__() )
        parents.append(replica.parent)
        print('Replica ID: ', replica_replica_id)
        ## Construct replica object given ID
        replica = ConstructAlertFromID(replica_replica_id, 'R')
        #print( replica )

    if parents[0] == parents[1]:
        print('Same object')
    else:
        print('Different object')
import sys, os
import VPDF


def filterVPDF(alert, rarityThreshold=1E7):
    dmag = alert.CA.DeltaMagnitude.value
    ra = alert.ra
    decl = alert.decl

    rarityVPDF = VPDF.findRarity(ra, decl, dmag)

    if rarityVPDF < rarityThreshold:
        annotation = 'Alert variability less than VPDF threshold (%.2f <  %.2f)' % (
            rarityVPDF, rarityThreshold)
        print(alert.parent.ID, annotation)
        alert.divert(annotation)


if __name__ == '__main__':
    sys.path.append('../')
    from antares.model.helper import GenerateCameraAlertStream
    from antares.model.helper import ConstructAlertFromID

    alert_ids = GenerateCameraAlertStream(alert_num=2)
    for alert_id in alert_ids:
        alert = ConstructAlertFromID(alert_id, 'E')

        replica_id = alert.createReplica()
        replica = ConstructAlertFromID(replica_id, 'R')
        filterVPDF(replica)
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=5)
    for alert_id in alert_ids:
        print(alert_id)
        alert = ConstructAlertFromID(alert_id, 'E')
        print(alert)