This post is about how to make cleaner, better Lasair filters.
Sometimes tables can get very wide. This is why there is a horizontal scroll bar for filter results to see the whole width. But there are easy ways to control the width of columns in the resulting output, which is the maximum of the width of the header and the width of the column data. If your SELECT clause includes, for example, physical_separation_kpc from the Sherlock table, then you will have a wide column! The simple solution is the AS keyword of SQL, so you can SELECT physical_separation_kpc as Kpc, and the column header will be just the three-letter Kpc.
Here is example SQL and its result with wide columns; note that there is a horizontal scrollbar that is needed to allow you to see the whole table.

And here is example SQL that shortens the column names, with the result where eveything fits and the scrollbar is not needed.


-
The width of the column data can also be reduced with the SQL
ROUND()function, so that for example ifpi=3.141592653589793thenROUND(pi,2)will be just 3.14. -
Lasair provides some functions that may be useful. If you find yourself using the SQL function
UNIX_TIMESTAMP, you might alternatively use the Lasair functionmjdnow(), which is the current modified Julian Day, so to ask if an object was detected in the last week, you can use this clause in the WHERE section of the filter:mjdnow() - object.lastDiaSourceMjdTai < 7. -
Rubin difference fluxes are expressed in nanoJanskies rather than magnitudes – because a difference flux can be negative. The Lasair documentation has a conversion table and formula that converts positive difference fluxes to magnitudes. There is also an SQL function for this: if you want objects brighter than magnitude 19, you can put write
flux2mag(objects.latest_psfFlux) < 19. -
Many of the lightcurve features have a
NULLvalue to mean not present. If you are using the BazinBlackBody parametric fit, the parameters are all NULL if the algorithm didn’t converge, so you can useobjects.BBBRiseRate is not NULLin the filter to remove these. -
Finally, the active filters, watchlists, and watchmaps all use precious CPU resources in the ingestion pipeline, that may be handling millions of alerts. Therefore, Lasair has a policy that these resources must be renewed every 6 months. So you will get a few warning emails every Sunday night, and if you do nothing the resource will become inactive. All you have to do to refresh it is to go to the Lasair web page – the URL provided in the email – and click on “save”.
