Difference: AmpelCommissioning (1 vs. 9)

Revision 92018-03-06 - SjoertVanVelzen

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Line: 19 to 19
 This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package (https://github.com/MatteoGiomi/extcats), developed as part of the AMPEL project.
Added:
>
>
from extcats import CatalogQuery #see https://github.com/MatteoGiomi/extcats
  class AGNFilter(AbstractTransientFilter): """

Revision 82018-02-26 - RobertStein

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

AMPEL is processing alerts as they are made available at the UW Kafka server. Work so far has focused on implementing a set of sample T0 filters that will work as templates for specific science channels. A key feature of AMPEL is the ability to take user-defined actions for each transient, depending on the outcome of the filters. For this test, two such actions are implemented: relaying information on the accepted alerts to a Slack channel and uploading candidates to the TNS sandbox area.

Changed:
<
<
In the following, a few templates filters are briefly described. For the sake of clarity, only the relevant parts of the code are shown. Complete and in depth description and explanation of the AMPEL filtering stage (the T0 pipeline tier) can be found at: https://github.com/AmpelProject/Ampel-T0-ref.
>
>
In the following, a few templates filters are briefly described. For the sake of clarity, only the relevant parts of the code are shown. Complete and in depth description and explanation of the AMPEL filtering stage (the T0 pipeline tier) can be found at: https://github.com/AmpelProject/Ampel-T0-ref. A list of variables that AMPEL can call is given on the AMPEL Variables Page.
 NOTE: as with any commissioning activity, this is still work in progress. More careful study is needed to tune the performance and science output of each of these filters.

If anyone is interested in contributing to AMPEL, please get in touch! We need help developing filters, as well as modules for calculating science values. People to contact:

Revision 72018-02-23 - MatteoGiomi

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Line: 16 to 16
 

Finding/rejecting AGNs:

Changed:
<
<
This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package (https://github.com/AmpelProject/extcats), developed as part of the AMPEL project.
>
>
This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package (https://github.com/MatteoGiomi/extcats), developed as part of the AMPEL project.
 

Revision 62018-02-21 - RobertStein

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Line: 261 to 261
 

TDE Filter:

Changed:
<
<
This filter combines photometry calculations with catalogue matching to search for TDE-like nuclear transients, similar to the TDE SEDm proposal. To minimise computational time, photometry cuts are firstly appplied to search for bright, strongly-varying blue flares. We then check to make sure the flare is not coincident with a known AGN, (i.e the location is not listed in MQC).
>
>
This filter combines photometry calculations with catalogue matching to search for TDE-like nuclear transients, similar to the TDE SEDm proposal (from Tiara Hung). To minimise computational time, photometry cuts are firstly appplied to search for bright, strongly-varying blue flares. We then check to make sure the flare is not coincident with a known AGN, (i.e the location is not listed in MQC).
 

Revision 52018-02-16 - RobertStein

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Line: 7 to 7
 In the following, a few templates filters are briefly described. For the sake of clarity, only the relevant parts of the code are shown. Complete and in depth description and explanation of the AMPEL filtering stage (the T0 pipeline tier) can be found at: https://github.com/AmpelProject/Ampel-T0-ref. NOTE: as with any commissioning activity, this is still work in progress. More careful study is needed to tune the performance and science output of each of these filters.
Added:
>
>
If anyone is interested in contributing to AMPEL, please get in touch! We need help developing filters, as well as modules for calculating science values. People to contact:

 

Finding/rejecting AGNs:

This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package (https://github.com/AmpelProject/extcats), developed as part of the AMPEL project.

Line: 254 to 261
 

TDE Filter:

Changed:
<
<
This filter combines photometry calculations with catalogue matching to search for TDE-like nuclear transients, similar to the TDE SEDm proposal. To minimise computational time, photometry cuts are firstly appplied to search for bright, highly-varying blue flares. We then check to make sure the flare is not coincident with a known AGN, (i.e the location is not listed in MQC).
>
>
This filter combines photometry calculations with catalogue matching to search for TDE-like nuclear transients, similar to the TDE SEDm proposal. To minimise computational time, photometry cuts are firstly appplied to search for bright, strongly-varying blue flares. We then check to make sure the flare is not coincident with a known AGN, (i.e the location is not listed in MQC).
 
Line: 330 to 337
  -- MatteoGiomi - 16 Feb 2018 -- JakobNordin - 16 Feb 2018 \ No newline at end of file
Added:
>
>
-- RobertStein - 16 Feb 2018

Revision 42018-02-16 - RobertStein

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Revision 32018-02-16 - MatteoGiomi

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Line: 9 to 9
 

Finding/rejecting AGNs:

Changed:
<
<
This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package, developed as part of the AMPEL project.
>
>
This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package (https://github.com/AmpelProject/extcats), developed as part of the AMPEL project.
 

class AGNFilter(AbstractTransientFilter):
    """
Changed:
<
<
Requires match with the million quasar catalog.
>
>
Accept a transient if coincident with an AGN.
  """

....

def __init__(self):

Changed:
<
<
self.logger.info("Initiliazing AGN filter")
>
>
self.logger.info("Initiliazing AGNFilter")
  self.mqc_query = CatalogQuery('milliquas', ra_key = 'ra', dec_key = 'dec') # connect to the MQC database

.....

Line: 49 to 48
  mean_ra, mean_dec = np.mean(ras), np.mean(decs)

# check the MQC

Changed:
<
<
if not self.mqc_query.binaryserach( #this method return True if at least one counterpart is found around target
>
>
if self.mqc_query.binaryserach( #this method return True if at least one counterpart is found around target
  mean_ra, mean_dec, self.search_radius_arcsec, method = self.search_method): return self.on_match_default_flags else:
Line: 57 to 56
 
Changed:
<
<
The parameters (search radius and search method) are assigned to the filter by the mandatory set_filter_parameters method. The apply method process the alert and it is where the logic of the filter is specified. In this case, an alert is rejected if a counterpart in the MQC is found within the search radius.
>
>
The parameters (search radius and search method) are assigned to the filter by the mandatory set_filter_parameters method. Parameter values can either be assigned through a dictionary, or via a config file. The apply method process the alert and it is where the logic of the filter is specified. In this case, an alert is accepted if a counterpart in the MQC is found within the search radius.
 

New transient sources

Changed:
<
<
This filters looks for transient which have been detected twice in a short period of time. The
>
>
This filters looks for transient which have been detected twice in a short period of time. A preliminary cut on realbogus value, minimum number of detections, and star/galaxy score is applied.
 

Changed:
<
<
class AtLeast2withinNightFilter(AbstractTransientFilter):
>
>
class NewTransients(AbstractTransientFilter):
  """
Changed:
<
<
Requires no bogus no star, two alerts for the same transient within a short time range. Push stuff to TNS and message to Slack.
>
>
Requires no bogus, no star, two alerts for the same transient within a short time range. Push to TNS and message to Slack.
  """

...

def __init__(self):

Changed:
<
<
self.logger.info("Initiliazing AtLeast2withinNightFilter filter")
>
>
self.logger.info("Initiliazing NewTransients filter")
  ...

Line: 89 to 88
  self.rb_cut_latest = d['rb_cut'] self.sgscore_cut = d['sgscore_cut']

Changed:
<
<
# youngness th
>
>
# minimum time difference between most recent alerts
  self.latest_2pt_within = d['latest_2pt_within']

Changed:
<
<
# min det above RB
>
>
# min number of detection above RB
  self.min_ndet = d['min_det']

Changed:
<
<
# how to comunicate with slak / TNS
>
>
# communicate with slack / TNS
  if not d['slackchannel'] is None: self.sc = SlackClient(botapi_ztfmsip)
Changed:
<
<
self.slackchannel = d['slackchannel'] # should be "#bottest"
>
>
self.slackchannel = d['slackchannel']
  else: self.slackchannel = None self.atreport = d['send_atreport']
Line: 119 to 118
  if (latest_pp['sgscore'] is None) or latest_pp['sgscore'] > self.sgscore_cut: return None

Changed:
<
<
# get JD of all the points above rb cut
>
>
# get JD of all the points passing RB cut
  jds = sorted( ampel_alert.get_values( 'jd', filters={'rb': self.rb_cut, 'op': '>'}) )

Line: 140 to 139
 

Using WISE vs. PanSTARRS photometry to reject Brown dwarfs

Changed:
<
<
This filter implements a more complex logic, and relies on both PS1 photometry (provided in the alert by the ML working group) and WISE infrared colors to further reduce the number of stars by eliminating alerts associated with flares from M-dwarfs. Such objects can in fact produce rapid transients that could be misinterpreted as extragalactic transients. In http://adsabs.harvard.edu/abs/2017arXiv171200949H it is shown that these M-dwarfs can be efficiently filtered out based on their red W1-i(PS1) color. The infrared color of the transient are obtained by matching with the allWISE catalog,
>
>
This filter implements a more complex logic, and relies on both PS1 photometry (provided in the alert by the ML working group) and WISE infrared colors to further reduce the number of stars by eliminating alerts associated with flares from M-dwarfs. Such objects can in fact produce rapid transients that could be misinterpreted as extragalactic. In http://adsabs.harvard.edu/abs/2017arXiv171200949H it is shown that these M-dwarfs can be efficiently filtered out based on their red W1-i(PS1) color. The infrared color of the transient are obtained by matching with the allWISE catalog,
  see: http://irsa.ipac.caltech.edu/data/download/wise-allwise/.

Beside a first cut on the real bogus and star-galaxy score, the strategy of the filter is the following:

  • accept the candidate if there are at least 2 point in its detection history.
  • If there is no PS1 photometric information the alert is accepted: it is unlikely that the steady emission of variable star is not detected by PanStarrs, but its flares are seen with ZTF.
Changed:
<
<
  • the alert is rejected if an AGN counterpart (from the MQC) is found within a few arcseconds from its average position. As the MQC is smaller than the allWISE one, it is queried before to improve filtering speed.
>
>
  • the alert is rejected if an AGN counterpart (from the MQC) is found within a few arcseconds from its average position. As the MQC is smaller than the allWISE one, it is queried first to improve filtering speed.
 
  • the allWISE catalog is searched for counterparts of the alert:
Changed:
<
<
* if none is found we have no information to reject the alert and it is therefore accepted. * else, its M-dwarf-likeness is computed and the alert is accepted accordingly.
>
>
* if none is found, we have no reason to reject the alert so it is therefore accepted. * else, its M-dwarf-likeness (based on the IR/optical colors) is computed and a cut is applied.
 
Changed:
<
<
class MasterFilter(AbstractTransientFilter):
>
>
class MdwarfFilter(AbstractTransientFilter):
  """ Requires 2 detections, no bogus, no star, reject AGNs, and M-dwarfs comparing the PS1 and WISE colors.
Line: 163 to 162
  def __init__(self):

Added:
>
>
self.logger.info("Initiliazing MdwarfFilter")
  # connect to the databases of the external catalogs self.mqc_query = CatalogQuery( 'milliquas', ra_key = 'ra', dec_key = 'dec')
Line: 186 to 186
  self.allwise_rs_arcsec = d['allwise_rs_arcsec'] self.allwise_search_method = d['allwise_search_method']

Changed:
<
<
# infrared-optical color cut for M-dwarfs (pseudo code here!! TODO)
>
>
# infrared-optical color cut for M-dwarfs
  self.w1_minus_PS1i_cut = d['w1_minus_PS1i_cut']

Line: 217 to 217
  if all( [ (ps1c is None) for ps1c in ps1_mags] ): pass # if you don't return None, the candidate will be accepted at a certain point.

Changed:
<
<
else: # here we have PS1 info

# if the ML say it's a galaxy there are three options:

>
>
else: # if the sg_score say it's a galaxy there are three options:
  # a) it is a misclassified star # b) it is an AGN
Changed:
<
<
# c) none of the above, it's interesting for us. # we first check with the AGN catalog which is smaller and hence faster
>
>
# c) none of the above, this filter thinks it's interesting.
  # compute average ra/dec for the alert ras, decs = np.array(ampel_alert.get_values('ra')), np.array(ampel_alert.get_values('dec'))
Line: 249 to 247
  # congratulations, you made it! return self.on_match_default_flags
Added:
>
>


TDE Filter:

This filter combines photometry calculations with catalogue matching to search for TDE-like nuclear transients, similar to the TDE SEDm proposal. To minimise computational time, photometry cuts are firstly appplied to search for bright, highly-varying blue flares. We then check to make sure the flare is not coincident with a known AGN, (i.e the location is not listed in MQC).


class TDEFilter(AbstractTransientFilter):
    """
    """
    
    ...

    def __init__(self):
        self.logger.info("Initiliazing TDEFilter")
        self.mqc_query = mqc_query = CatalogQuery(
            'milliquas', ra_key = 'ra', dec_key = 'dec')


    def set_filter_parameters(self, d):
       
        # realbogus and star galaxy cut
        self.rb_cut = d['rb_cut']
        self.sgscore_cut = d['sgscore_cut']
        
        # cuts on photometry
        self.mag_threshold = d['mag_threshold']
        self.delta_mag_threshold = d['delta_mag_threshold']
        self.color_gr_threshold = d['color_gr_threshold']
        
        # cuts on AGN matching
        self.search_radius_arcsec = d['rs_arcsec']
        self.search_method = d['search_method']

    def apply(self, ampel_alert):
        """
        To exclude the alert, return *None*
        To accept it, either 
            * return self.on_match_default_flags
            * return a custom combination of T2RunnableIds
        """

        # get lightcurve points and stats
        lc = np.array(ampel_alert.get_values("mag"))
        max_mag, min_mag = lc.min(), lc.max()
        delta_mag = min_mag - max_mag

        # skim out faint sources
        if max_mag > self.mag_threshold:
            return None
        
        # retain strongly varying sources
        if delta_mag < self.delta_mag_threshold:
            return None
        
        # now check the color
        r_lc = np.array(ampel_alert.get_values("mag", filters={'filter_id': 1, 'op': '='})) 
        g_lc = np.array(ampel_alert.get_values("mag", filters={'filter_id': 0, 'op': '='})) 
        if len(g_lc)==0 or len(r_lc)==0:
            return None
        else:
            max_mag_r, max_mag_g = np.min(r_lc), np.min(g_lc)
            if max_mag_g - max_mag_r < self.color_gr_threshold:
                return None
        
        # finally query catalog for CP in the million quasar catalog
        ras, decs =  np.array(ampel_alert.get_values('ra')), np.array(ampel_alert.get_values('dec'))
        mean_ra, mean_dec = np.mean(ras), np.mean(decs)
        if self.mqc_query.binaryserach(mean_ra, mean_dec, self.search_radius_arcsec, 
            method = self.search_method):
            return None
        
        # congratulations you made it!
        return self.on_match_default_flags
 

Revision 22018-02-16 - MatteoGiomi

Line: 1 to 1
 
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

Changed:
<
<
AMPEL is ingesting alerts as they are made available at the UW Kafka server. Work so far has focused on implementing a set of sample T0 filters that will work as templates for specific science channels.
>
>
AMPEL is processing alerts as they are made available at the UW Kafka server. Work so far has focused on implementing a set of sample T0 filters that will work as templates for specific science channels. A key feature of AMPEL is the ability to take user-defined actions for each transient, depending on the outcome of the filters. For this test, two such actions are implemented: relaying information on the accepted alerts to a Slack channel and uploading candidates to the TNS sandbox area.
 
Changed:
<
<

Using WISE photometry to reject Brown dwarfs

>
>
In the following, a few templates filters are briefly described. For the sake of clarity, only the relevant parts of the code are shown. Complete and in depth description and explanation of the AMPEL filtering stage (the T0 pipeline tier) can be found at: https://github.com/AmpelProject/Ampel-T0-ref. NOTE: as with any commissioning activity, this is still work in progress. More careful study is needed to tune the performance and science output of each of these filters.
 
Added:
>
>

Finding/rejecting AGNs:

 
Changed:
<
<

Finding/rejecting AGNs through the XXX catalog

>
>
This very simple filter checks for possible AGN counterparts around the average position of the alert. For this preliminary implementation, only the Million Quasar Catalog (MQC, http://quasars.org/milliquas.htm) is used. In the near future we plan to support also (some of) the many AGN catalogs suggested by the AGN & TDE group (http://noir.caltech.edu/twiki_ptf/bin/view/ZTF/AGNTDEWorkingGroup). The catalog matching is provided by the extcats package, developed as part of the AMPEL project.
 
Added:
>
>
 
Changed:
<
<
New transient sources
>
>
class AGNFilter(AbstractTransientFilter): """ Requires match with the million quasar catalog. """
 
Added:
>
>
....
 
Added:
>
>
def __init__(self):
 
Added:
>
>
self.logger.info("Initiliazing AGN filter") self.mqc_query = CatalogQuery('milliquas', ra_key = 'ra', dec_key = 'dec') # connect to the MQC database
 
Added:
>
>
.....
 
Added:
>
>
def set_filter_parameters(self, d): """ set parameters for the filter """

self.search_radius_arcsec = d['rs_arcsec'] self.search_method = d['search_method']

def apply(self, ampel_alert): """ To exclude the alert, return None To accept it, either

        • return self.on_match_default_flags
        • return a custom combination of T2RunnableIds """

# compute average RA/Dec of the alert ras, decs = np.array(ampel_alert.get_values('ra')), np.array(ampel_alert.get_values('dec')) mean_ra, mean_dec = np.mean(ras), np.mean(decs)

# check the MQC if not self.mqc_query.binaryserach( #this method return True if at least one counterpart is found around target mean_ra, mean_dec, self.search_radius_arcsec, method = self.search_method): return self.on_match_default_flags else: return None

The parameters (search radius and search method) are assigned to the filter by the mandatory set_filter_parameters method. The apply method process the alert and it is where the logic of the filter is specified. In this case, an alert is rejected if a counterpart in the MQC is found within the search radius.

New transient sources

This filters looks for transient which have been detected twice in a short period of time. The


class AtLeast2withinNightFilter(AbstractTransientFilter):
    """
    Requires no bogus no star, two alerts for the same transient
    within a short time range. Push stuff to TNS and message to Slack.
    """
    
    ...
    
    def __init__(self):
        self.logger.info("Initiliazing AtLeast2withinNightFilter filter")
    
    ...
    
    def set_filter_parameters(self, d):
        """
        set parameters for the filter
        """
        
        # realbogus and star galaxy cut
        self.rb_cut_latest = d['rb_cut']
        self.sgscore_cut = d['sgscore_cut']
        
        # youngness th
        self.latest_2pt_within = d['latest_2pt_within']
        
        # min det above RB
        self.min_ndet = d['min_det']
        
        # how to comunicate with slak / TNS
        if not d['slackchannel'] is None:
            self.sc = SlackClient(botapi_ztfmsip)
            self.slackchannel = d['slackchannel']   # should be "#bottest"
        else:
            self.slackchannel = None
        self.atreport = d['send_atreport']


    def apply(self, ampel_alert):
        """
        To exclude the alert, return *None*
        To accept it, either 
            * return self.on_match_default_flags
            * return a custom combination of T2RunnableIds
        """
        
        # apply SG and RB cut on latest detection
        latest_pp = ampel_alert.get_photopoints()[0]
        if latest_pp['rb'] < self.rb_cut:
            return None
        if (latest_pp['sgscore'] is None) or latest_pp['sgscore'] > self.sgscore_cut:
            return None
               
        # get JD of all the points above rb cut
        jds = sorted( ampel_alert.get_values(
            'jd', filters={'rb': self.rb_cut, 'op': '>'}) )
        
        # check for minimum number of detections
        if len(jds) < self.min_ndet:
            return None
            
        # now check time difference between last and previous detection
        latest_jd, previous_jd = jds[-1], jds[-2]
        if ( latest_jd - previous_jd ) > self.latest_2pt_within:
            return None
        
        # congratulations you made it!
        return self.on_match_default_flags

Using WISE vs. PanSTARRS photometry to reject Brown dwarfs

This filter implements a more complex logic, and relies on both PS1 photometry (provided in the alert by the ML working group) and WISE infrared colors to further reduce the number of stars by eliminating alerts associated with flares from M-dwarfs. Such objects can in fact produce rapid transients that could be misinterpreted as extragalactic transients. In http://adsabs.harvard.edu/abs/2017arXiv171200949H it is shown that these M-dwarfs can be efficiently filtered out based on their red W1-i(PS1) color. The infrared color of the transient are obtained by matching with the allWISE catalog, see: http://irsa.ipac.caltech.edu/data/download/wise-allwise/.

Beside a first cut on the real bogus and star-galaxy score, the strategy of the filter is the following:

  • accept the candidate if there are at least 2 point in its detection history.
  • If there is no PS1 photometric information the alert is accepted: it is unlikely that the steady emission of variable star is not detected by PanStarrs, but its flares are seen with ZTF.
  • the alert is rejected if an AGN counterpart (from the MQC) is found within a few arcseconds from its average position. As the MQC is smaller than the allWISE one, it is queried before to improve filtering speed.
  • the allWISE catalog is searched for counterparts of the alert: * if none is found we have no information to reject the alert and it is therefore accepted. * else, its M-dwarf-likeness is computed and the alert is accepted accordingly.


class MasterFilter(AbstractTransientFilter):
    """
    Requires 2 detections, no bogus, no star, reject AGNs, and 
    M-dwarfs comparing the PS1 and WISE colors.
    """
    
    ...

    def __init__(self):
        
        # connect to the databases of the external catalogs
        self.mqc_query = CatalogQuery.CatalogQuery(
            'milliquas', ra_key = 'ra', dec_key = 'dec')        
        self.wise_query = CatalogQuery.CatalogQuery(
            'wise', ra_key = 'ra', dec_key = 'dec')
    
    ...
    
    def set_filter_parameters(self, d):

        # realbogus and star galaxy cut
        self.rb_cut = d['rb_cut']
        self.sgscore_cut = d['sgscore_cut']

        # min det above RB
        self.min_ndet = d['min_det']
        
        # catalog query parameters
        self.milliquas_rs_arcsec = d['milliquas_rs_arcsec']
        self.milliquas_search_method = d['milliquas_search_method']
        self.allwise_rs_arcsec = d['allwise_rs_arcsec']
        self.allwise_search_method = d['allwise_search_method']
        
        # infrared-optical color cut for M-dwarfs (pseudo code here!! TODO)
        self.w1_minus_PS1i_cut = d['w1_minus_PS1i_cut']
        
        
    def apply(self, ampel_alert):
        """
        To exclude the alert, return *None*
        To accept it, either 
            * return self.on_match_default_flags
            * return a custom combination of T2RunnableIds
        """
        
        # apply SG and RB cut on latest detection
        latest_pp = ampel_alert.get_photopoints()[0]
        if latest_pp['rb'] < self.rb_cut:
            return None
        if (latest_pp['sgscore'] is None) or latest_pp['sgscore'] > self.sgscore_cut:
            return None        

        # minimum number of detections
        lc = np.array(ampel_alert.get_values("mag"))
        if len(lc) < self.min_ndet:
            return None
        
        # check for PS1 colors. 
        ps1_mags = [latest_pp['s%smag'%ps1_band] for ps1_band in ['r', 'g', 'z', 'i']]
        
        # if there are no PS1 counterparts it can not to be a star, so we take it
        if all( [ (ps1c is None) for ps1c in ps1_mags] ):
            pass # if you don't return None, the candidate will be accepted at a certain point.
            
        else: # here we have PS1 info
        
            # if the ML say it's a galaxy there are three options:
            #   a) it is a misclassified star
            #   b) it is an AGN
            #   c) none of the above, it's interesting for us.
            # we first check with the AGN catalog which is smaller and hence faster
            
            # compute average ra/dec for the alert
            ras, decs =  np.array(ampel_alert.get_values('ra')), np.array(ampel_alert.get_values('dec'))
            mean_ra, mean_dec = np.mean(ras), np.mean(decs)
            
            # match with AGN
            if self.mqc_query.binaryserach(
                mean_ra, mean_dec, self.milliquas_rs_arcsec, method = self.milliquas_search_method):
                return None
            
            # check if you find wise cp
            wise_cp, wise_cp_dist = self.wise_query.findclosest(
                mean_ra, mean_dec, self.allwise_rs_arcsec, method = self.allwise_search_method)
            
            # if there aren't take the alert. There are no reason why not.
            if wise_cp is None:
                return self.on_match_default_flags
            
            # if there is, check infrared-optical colors
            if (wise_cp['w1mpro']-latest_pp['simag']) > self.w1_minus_PS1i_cut:
                return None
      
            # congratulations, you made it!
            return self.on_match_default_flags


-- MatteoGiomi - 16 Feb 2018

 -- JakobNordin - 16 Feb 2018 \ No newline at end of file

Revision 12018-02-16 - JakobNordin

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CosmoAMPEL"

AMPEL operating on ZTF commissioning observations.

AMPEL is ingesting alerts as they are made available at the UW Kafka server. Work so far has focused on implementing a set of sample T0 filters that will work as templates for specific science channels.

Using WISE photometry to reject Brown dwarfs

Finding/rejecting AGNs through the XXX catalog

New transient sources

-- JakobNordin - 16 Feb 2018

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback