Fetching object data in JSON

(from Roberto Nesci, INAF/IAPS-Roma, Italy)
Last year you sent me the instruction to download the Lasair
photometry of a given source.
(e.g. https://lasair.roe.ac.uk/object/ZTF18aabqhpp/json/)

The website has been rearranged recently, and I am no more able to
download the photometry file. I get a message “file not found”

Can you help me?

1 Like

Yes, we have changed things, because the system was being overloaded by abusive requests. We now have a proper API for Lasair, as written here:

https://lasair-ztf.lsst.ac.uk/api

You will need to obtain a token for your account, with the following command:

curl --data "username=u&password=p" https://lasair-ztf.lsst.ac.uk/api/auth-token/

note that you need to put in your Lasair username and password where it has u and p. The token is a 40-digit hex number.

Now you can fetch the object information that you want, like this

https://lasair-ztf.lsst.ac.uk/api/objects/?objectIds=ZTF22abckkru&format=json&token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

for the last argument you should substitute your API token.

(from Roberto Nesci, INAF/IAPS-Roma, Italy)
I have got the API and downloaded the photometry file for my source.
It is a bit different from the previous version, some fields have been
added, but the structure seems the same. Unfortunately the python script
which you sent me to read the photometry file, now crashes giving this
error:

Traceback (most recent call last):
File “/home/nesci/script/prove_python/read_json2.py”, line 5, in
for c in j[‘candidates’]:
TypeError: list indices must be integers or slices, not str

I am using the same version of python3.

The output is not quite the same.
Now you can put in a list of objects and it returns a list of the descriptions.
So instead of this

    for c in j['candidates']:

I think you should have this

    for c in j[0]['candidates']:

Dear Roy, I modified the script and it works perfectly.
Looking at the json data, I notice that there are several more fields
but the old dc_mag is no more present: it was the apparent magnitude of
the source, which could be directly compared with the photometry from
another telescopes.
I assume that the field magnr is the reference magnitude of the source,
and magpsf is the magnitude difference with respect to magnr, but how
can I compute the old dc_mag value from magpsf and magnr ?
By the way I have a nearly simultaneous photometry of my source
ZTFaauazqz on August 26, at r=14.96 in the PanSTARRS scale, while the
ZTF diff.mag value is r=16.31 and magnr=15.19 in the r band: I would
expect a diff.mag value brighter than magnr !
Thanks for your help in understanding the ZTF photometry.

Hi Roberto
In earlier versions of Lasair, we tried to compute an apparent magnitude from the reference + difference magnitudes, and it is not so simple. Unfortunately we found that computation unreliable and decided to remove it from the published attributes.

However, the code that computes apparent magnitude is still available here.

The function defined in that code uses 7 attributes (fid, magpsf,sigmapsf, magnr,sigmagnr, magzpsci, isdiffpos), and all of these are available from the lightcurves method of the API, as defined here.

So you can compute your own apparent magnitudes. I hope things will be easier with LSST than they are with ZTF.
Roy

Thank you very much for your suggestions Roy, I will try to do myself with the code indicated. Hope that with the Vera Rubin Telescope things will be better. Roberto