Getting Started with Filter Development

The devkit is designed to be used in NOAO’s DataLab Jupyter environment. Sign up for DataLab, then log in to the Jupyter server.

Once logged in to DataLab, create a new notebook using the “Python 3 (ANTARES)” kernel and paste in the following code:

import antares.dev_kit as dk

You’re now ready to create and test ANTARES filters.

Let’s make a simple filter:

class MyFilter(dk.Filter):
            'name': 'foo',
            'description': 'blah blah blah',
    ERROR_LOG_SLACK_CHANNEL = '<my_slack_member_id>'

    def run(self, locus_data):
        This filter does nothing except print the magpsf
        value of ZTF alerts.
        props = locus_data.get_properties()
        alert_id = props['alert_id']
        magpsf = props['ztf_magpsf']
        print(f'Alert {alert_id} magpsf: {magpsf}')

Note: See Structure of a Filter for complete description of how ANTARAES filters are structured.

Let’s run the example filter on an alert from the test dataset:

# Fetch 1 random alert ID from the test dataset
alert_id = dk.get_alert_ids(1)[0]

# Execute `MyFilter` on the alert
result = dk.run_filter(alert_id, MyFilter)

Note: Function-style filters are also supported, but will not be supported forever. All new ANTARES filters should be classes, like the above example.

Next Steps

Now that you’ve seen a simple example to get started, take a look at:

If your filter needs to load data files, see:

For examples of filters, check out the filters which are currently running in the ANTARES Pipeline.