swift_too moduleswiftools = 2.4from swifttools.swift_too import Swift_Resolve, Resolve, ObsQuery, VisQuery, TOO
"Name resolution" is the process of looking up a target by name to find out it's coordinates. the Swift TOO API provides (as of swifttools 2.3) a method for performing this task called Swift_Resolve, although for most cases you won't actually need to call this class by itself. Swift_Resolve essentially queries online name resolvers for a given name. We can demonstrate the usage as follows:
Swift_Resolve(name="LMC X-3")
| Name | RA (J2000) | Dec (J2000) | Resolver |
|---|---|---|---|
| LMC X-3 | 84.73597 | -64.08426 | Simbad |
So here we see that the RA / Dec value has been returned for RA/Dec based on the Simbad database (http://simbad.u-strasbg.fr/simbad/). We can also query more recent transients by querying transient brokers for coordinates such as TNS (https://www.wis-tns.org) and MARS (https://mars.lco.global). The choice of name resolver is automatic, so for example:
Resolve(name="AT2018cow")
| Name | RA (J2000) | Dec (J2000) | Resolver |
|---|---|---|---|
| AT2018cow | 244.00092 | 22.26803 | TNS |
Firstly, for swifttools 2.3 we have introduced shorthand names for these classes, no longer do you need to include the Swift_ prefix, so just Resolve works.
You can see that for "The Cow" the name has been resolved using TNS. This is because it recognizes that names starting with AT originate with TNS. This is useful for recent transients as Simbad often will not include them until results have been published. E.g.
Resolve(name="AT2022aaa")
| Name | RA (J2000) | Dec (J2000) | Resolver |
|---|---|---|---|
| AT2022aaa | 265.88051 | 36.31897 | TNS |
For ZTF sources, MARS, which is a broker for ZTF transients, is used.
res = Resolve(name="ZTF20aasoapr")
res
| Name | RA (J2000) | Dec (J2000) | Resolver |
|---|---|---|---|
| ZTF20aasoapr | 172.94754 | -25.72712 | MARS |
We can as well as ra and dec attributes, use the skycoord attribute to return a astropy SkyCoord for the location. Note this will only work if you have astropy installed, and if you don't the next line will cause an error.
res.skycoord
<SkyCoord (FK5: equinox=J2000.000): (ra, dec) in deg
(172.9475431, -25.727119)>
This is of course useful if you want to do things like convert to different formats, e.g.
res.skycoord.galactic
<SkyCoord (Galactic): (l, b) in deg
(281.27179256, 33.77254096)>
Note that in order to use the RA/Dec of a source in API queries, we can simply pass the ra, dec or skycoord to the API query, for example:
VisQuery(ra=res.ra, dec=res.dec, length=7)
| Begin Time | End Time | Window length |
|---|---|---|
| 2022-03-28 16:56:00 | 2022-04-04 16:56:00 | 7 days, 0:00:00 |
VisQuery(skycoord=res.skycoord, length=7)
| Begin Time | End Time | Window length |
|---|---|---|
| 2022-03-28 16:56:00 | 2022-04-04 16:56:00 | 7 days, 0:00:00 |
However, for most cases you will not want to have to generate a stand alone Swift_Resolve instance, as for API calls as of swifttools 2.3 you can simply pass the name parameter, and it will automatically look up the RA/Dec. Here is an example using Swift_ObsQuery:
obs = ObsQuery(name="AT2018ahz")
obs
| Begin Time | End Time | Target Name | Observation Number | Exposure (s) | Slewtime (s) |
|---|---|---|---|---|---|
| 2018-07-29 20:50:02 | 2018-07-29 21:07:57 | AT 2018ahz | 00010770001 | 995 | 80 |
| 2018-07-29 22:25:02 | 2018-07-29 22:42:58 | AT 2018ahz | 00010770001 | 900 | 176 |
In this case, the Swift_Resolve call was generated automatically, and the results passed into the Swift_ObsQuery class. You can get the results of that call by looking at the resolve attribute:
obs.resolve
| Name | RA (J2000) | Dec (J2000) | Resolver |
|---|---|---|---|
| AT2018ahz | 215.95934 | -9.38821 | TNS |
obs.skycoord
<SkyCoord (FK5: equinox=J2000.000): (ra, dec) in deg
(215.95934083, -9.38821417)>
Swift_TOOFor Swift_TOO requests, the source_name parameter does not autoresolve, so if you wish to resolve names for a TOO request, simply issue a Swift_Resolve (or Resolve using shorthand introduced in swifttools 2.3. The following shows the most compact form of doing this. Note that for Resolve, as name is the first argument, you can leave out the name= keyword in the arguments.
too = TOO(skycoord=Resolve("Crab").skycoord)
print(f"RA/Dec(J2000) = {too.skycoord.to_string(style='hmsdms')}")
RA/Dec(J2000) = 05h34m31.9474s +22d00m52.153s
Or course, you can still set the values of RA/Dec manually.
too.ra = 83.633
too.dec = 22.015
print(f"RA/Dec(J2000) = {too.skycoord.to_string(style='hmsdms')}")
RA/Dec(J2000) = 05h34m31.92s +22d00m54s