# How to annotate Lasair and why

**URL:** <https://www.rubin.community/t/how-to-annotate-lasair-and-why/11069>\
**Category:** Lasair Blog\
**Created:** [October 6, 2025, 4:13pm UTC](https://www.rubin.community/t/how-to-annotate-lasair-and-why/11069 "2025-10-06T16:13:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roy](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/roy/32/1254_2.png) [@roy](https://www.rubin.community/u/roy)\
**Post date:** [October 6, 2025, 4:13pm UTC](https://www.rubin.community/t/how-to-annotate-lasair-and-why/11069/1 "2025-10-06T16:13:45Z")

</div>

Suppose you have built a classifier for the Rubin data about astrophysical objects: the six-band lightcurve, and perhaps also the crossmatches and association with known objects. The annotation capability allows you to run the classifier in near real time as alerts come in, and if you wish share the results with others. First you make a Lasair “pre-filter” to winnow down the millions of alerts per night to something reasonable: it could use host galaxy association from [Sherlock](https://lasair-lsst.readthedocs.io/en/main/core_functions/sherlock.html), or the Alerce stamp classifier (another annotator), or perhaps a watchlist of [where TDE events are likely](https://lasair-lsst.lsst.ac.uk/watchlists/8/). You will make a program that can receive the identity of the alerts from the pre-filter, and fetch the full lightcurve from Lasair. The result of your classification will be encoded into some simple JSON and other attributes, then pushed back into Lasair.

It’s quite a sophisticated workflow, but not bad if done in these five stages:

1. The first thing is to [get a Lasair account](https://lasair-lsst.lsst.ac.uk/register), and note down the corresponding [API key](https://lasair-lsst.readthedocs.io/en/develop/core_functions/client.html#authorisation-token). Next, write a short description of your annotator and sent it to the Lasair team; we will set it up and connect it to your account. You can have a private annotator so only you can see it, or a public annotator for everyone. Full instructions [here](https://lasair-lsst.readthedocs.io/en/develop/core_functions/make_annotator.html). Note that your API key will needed in the program that posts to it.

2. Next, [make the pre-filter](https://lasair-lsst.readthedocs.io/en/develop/core_functions/make_filter.html) and [set it to active](https://lasair-lsst.readthedocs.io/en/develop/core_functions/alert-streams.html#kafka-streams). Then wait a few days for alerts to flow into it. [Make your receiving code](https://lasair-lsst.readthedocs.io/en/develop/core_functions/make_annotator.html#make-the-code) with the Lasair client and your API key, and check that alerts are being received. You can change the `group_id` to get the results again from the start. There is a [video about `group_id`](https://lasair-lsst.readthedocs.io/en/develop/videos.html#topic-and-groupid-for-a-lasair-kafka-stream).

3. For each alert received, use the client to [fetch the lightcurve and other data](https://github.com/lsst-uk/lasair-examples/blob/main/notebooks/API_lsst/ObjectAPI.ipynb), then run it through your classifier. Choose how to represent the results as `classdict`, `classification`, and `explanations`, for example this toy annotation:

```auto
classdict = {'fruit': 'apple'. 'radius': 6}
classification = 'ripe'
explanation = 'another nice apple'

```

1. Finally, change the annotation code to push the annotation back into Lasair, with code like this:

```auto
L.annotate(
    topic_out, 
    objectId, 
    classification,
    version='0.1', 
    explanation=explanation, 
    classdict=classdict, 
    url='')

```

Full instructions [here](https://lasair-lsst.readthedocs.io/en/develop/core_functions/make_annotator.html).

1. Then run your annotation code continuously or regularly, as you prefer, to fetch all the alerts since last time you ran it, analyse them, and annotate the associated objects. When you build a filter, you can [filter on your classification results](https://lasair-lsst.readthedocs.io/en/develop/core_functions/make_filter.html#filtering-on-an-annotator). If the annotator is public, anyone can use the results.
