Swift MOC

swift_too module

Swift Resolve example - conversion of name of object into coordinates

API version = 1.2 swiftools = 2.4

Author: Jamie A. Kennea (Penn State)

from swifttools.swift_too import Swift_Resolve, Resolve, ObsQuery, VisQuery, TOO

Name Resolution

"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:

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.

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")
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.

<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.

<SkyCoord (Galactic): (l, b) in deg
    (281.27179256, 33.77254096)>

Using Swift_Resolve in API queries

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

Using Swift_Resolve automatically

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")
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:

Name RA (J2000) Dec (J2000) Resolver
AT2018ahz 215.95934 -9.38821 TNS
<SkyCoord (FK5: equinox=J2000.000): (ra, dec) in deg
    (215.95934083, -9.38821417)>

Use in Swift_TOO

For 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

Swift Mission Operations Center

The Pennsylvania State University
301 Science Park Road,
Building 2 Suite 332,
State College, PA 16801
☎ +1 (814) 865-6834
📧 swiftods@swift.psu.edu

Swift MOC Team Leads

Mission Director: John Nousek
Science Operations: Jamie Kennea
Flight Operations: Mark Hilliard
UVOT: Michael Siegel
XRT: Jamie Kennea