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 )
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)
Example #3
0
def main():
    alert_ids = GenerateFakeAlerts()
    for alert_id in alert_ids:
        print(alert_id)
        alert = ConstructAlertFromID(alert_id, 'E')
        print(alert)
        lightcurve = alert.LA.assembleTimeSeries_cameraAlerts(
            'CA', 'Magnitude')
        print(lightcurve)
        print('P=', alert.CA.P.value)
Example #4
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)
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' )
Example #6
0
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 #7
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)
Example #8
0
def main():
    alert_ids = GenerateCameraAlertStream(alert_num=1)
    alert_id = alert_ids[0]

    alert = ConstructAlertFromID(alert_id, 'E')

    ## 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'

    #print( alert )

    alert.commit()
    # Second commit won't write DB since everything is synced now.
    alert.commit()
Example #9
0
def main():
    alert_ids = GenerateCameraAlertStream( alert_num=5 )
    for alert_id in alert_ids:
        print( alert_id )
        alert = ConstructAlertFromID( alert_id, 'E' )
        print( alert )
        lightcurve = alert.LA.assembleTimeSeries_cameraAlerts( "CA", "Magnitude" )
        vals       = lightcurve.values # ndarray
        stdev      = np.std( vals )

    return stdev


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

    ## Construct a camera alert.
    alert_ids = GenerateFakeAlerts()
    alert_id = alert_ids[ 1 ]
    alert = ConstructAlertFromID( alert_id, 'E' )

    replica_id = alert.createReplica()
    print( 'Created replica {0}'.format(replica_id) )

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

    replica.CA.P.value = derivePeriod( replica )
    replica.CA.A.value = deriveAmplitude( replica )
    replica.CA.mmed.value = deriveMmed( replica )
    replica.CA.kurt.value = deriveKurt( replica )
    replica.CA.stdev.value = deriveStdev( replica )

    print( 'Replica {0} of camera alert {1}'.format(replica.ID, replica.parent.ID) )
    print( replica.CA.P.value, replica.CA.A.value, replica.CA.mmed.value, replica.CA.stdev.value, replica.CA.kurt.value )