Swift TOO API
Swift MOC

swift_too module

Swift_GUANO example - querying GUANO data, i.e. dumps of BAT event data

API version = 1.2, swifttools = 2.4

Author: Jamie A. Kennea (Penn State)

What is GUANO? It is the Gamma-ray Urgent Archive for Novel Opportunities. GUANO is fully explained in the paper by Tohuvavohu et al. (2020). Essentially it is this, the Swift Burst Alert Telescope (BAT) is a coded mask telesope, which records individual X-ray photons as events. These events are then processed onboard to look for GRB triggers. However, sometimes the onboard trigger algorithm fails to find a GRB that is present in the BAT field of view. In these cases, it would be best to look at the event data on the ground to do a more detailed analysis to look for GRB events, however, because of telemetery limitations, the event data is only held onboard for around 25-30 mins before it is deleted.

The GUANO program seeks to solve this problem, but proactively commanding Swift to keep and downlink BAT event data for times of interest. Right now this includes times at which other instruments trigger, such as Fermi/GBM, INTEGRAL, CALET and other GRB missions, as well as multi-messenger observatories such as IceCube and LIGO/Virgo/Kagra.

The Swift_GUANO API allows you to query when these dumps occurred and were successful, and where to look for the BAT event data that were dump. We're going to use the shorthand for this class, simply GUANO.

from swifttools.swift_too import GUANO

First a simple example, let's look for the most recent 10 successful GUANO dumps.

guano = GUANO(limit=10)

In a Jupyter Notebook, we can just type the object name now to see the results, like so:

guano
Trigger TypeTrigger TimeOffset (s)Window Duration (s)Observation ID
GECAM GRB2022-03-28 14:39:59.1000005020000010547014
CALET_GRB2022-03-28 11:24:04.59000009000015033007
GBM GRB2022-03-28 11:20:39.3300005020000015033007
CALET_GRB2022-03-28 08:07:47.42000009003104374002
GECAM GRB2022-03-27 19:42:36.5500005020000015023017
GECAM GRB2022-03-27 19:35:07.1000005020003104609001
INTEGRAL_GRB2022-03-27 09:50:56.19000009003104037003
GBM GRB2022-03-27 04:33:28.3900005020003104350007
INTEGRAL_GRB2022-03-27 02:57:33.30000009003103689001
INTEGRAL_GRB2022-03-26 23:46:17.15000009003104547013

Basic information given here is the source of the trigger, usually a GRB detector, but also FRB and GW detectors. The trigger time is given, along with an offset and window duration. The offset is how much the window start is biased towards the trigger time. So for offset zero, and window duration of 200s, the trigger will be in the center of the window, at 100s. For offset 50, the window is moved 50 later, so the trigger will be at 50s and the window ends at T+150s.

Note if the Window Duration has a number in brackets after it, this means that the actual length of the dump is different from that requested. This can happen due to either the dump skimming the South Atlantic Anomaly (where no data is collected), or sometimes if the dump is commanded too late, and some of the data have been lost. Alternatively this can be due to the fact that the data has not been fully processed yet, so if the dump is recent, this may resolve itself in a few hours.

In some cases where the number is larger than the requested duration, this can mean that other nearby trigger was merged to create a larger dump, or in extreme cases, that the dump time overlaps a BAT detected GRB. The latter case is rare as we try to filter these out on the ground.

Finally the Observation ID shows us where the BAT event data lives. If you go the Swift archive or quick-look site (recent data), e.g. here: https://swift.gsfc.nasa.gov/sdc/ql/

And look for the given observation ID, you should be able to find the BAT event data for that GUANO dump.

Looking at an individual GUANO dump

Let's look at an individual GUANO dump, to see what information we have.

guano[3]
ParameterValue
triggertime2022-03-28 08:07:47.420000
triggertypeCALET_GRB
offset0
duration90
quadsaway6233877
obsnum03104374002
data90.1s of BAT event data

So here we see more detail on the event itself. In addition to what we see in the summary table, there are a few more parameters. quadsaway is perhaps the most complicated to understand, but perhaps also not necessary. Essentially the BAT event data live in a ring buffer, this ring buffer overwrites itself, with events living around ~25 mins in the buffer before they are overwritten. quadsaway gives the number of quadbytes between the dump and the buffer pointer at the time of dump. If this value is positive, it means that no data was overwritten. If the value is negative, it means that some data will have been lost, this should be seen in the difference between the requested dump duration, and the number of seconds of BAT event data in data.

Also if the trigger associated with the GUANO dump had an RA/Dec, these are given.

Looking at the data

The final parameter, data has more detail, so lets look at that.

guano[3].data
ParameterValue
obsid03104374002
triggertime2022-03-28 08:07:47.420000
begin2022-03-28 08:07:03.139545
end2022-03-28 08:08:33.258645
exposure90.1191
filenamessw03104374002bevshpo_uf.evt
gti2022-03-28 08:07:03.139545 - 2022-03-28 08:08:33.258645 (0:01:30)
all_gtis2022-03-28 08:07:03.139545 - 2022-03-28 08:08:33.258645 (0:01:30)
acspointing
utcf-28.860559463500977

So this is essentially metadata from a simple processing the BAT event data. Important information here, begin and end give the start and end of the event data. exposure is the amount of event data in seconds. filenames is the names of the BAT event files processed for this trigger. The different filenames represent the state of swift while the data was being taken, which is encoded into the final characters of the filename.

A simple breakdown of the filename:

  • "sw" for Swift
  • The 10 character long obsid in SDC format
  • "bev" = BAT event data
  • "sl"/"po" or sometimes "sp", this indicates if Swift was slewing ("sl"), pointing ("po") or in some rare cases, both ("sp") for the data in that file.
  • "_uf.evt" = this is unfiltered event data

If you see more than one filename, then this means that the event data for this GUANO dump is spread across multiple files, typically because Swift was slewing at some point during the dump. Note that the parameter acs shows if the data is slewing, pointed or mixed.

Next gti is an object that defines the Good Time Interval (GTI) of the GUANO dump. In this table, it is show and begin and end times of the GTI with exposure in brackets.

gti is a merged GTI, merging all the different GTIs given in all_gtis if they overlap. Typically all_gtis shows 2 GTIs if there are two filenames. However if there are gaps in the data, all_gtis can show more GTIs.

gti importantly only covers the continuous GTI that includes triggertime. Let's take a look at that.

guano[0].data.gti
ParameterValue
begin2022-03-28 14:39:10.138045
end2022-03-28 14:42:30.257445
exposure0:03:20
utcf-28.862159729003906
acspointing
filenamesw00010547014bevshpo_uf.evt

So here we see the usual information, begin, end and exposure. In addition acs for this GTI is reported, along with the filename(s) associated with the BAT event data processed.

Note on UT Correction Factor

Also you'll note utcf, which is a negative number of seconds. This is the Univeral Time Correction Factor (UTCF), which corrects time that Swift reports to actual UT. This includes both correction for drift in the Swift clock, and leap seconds. GUANO trigger times and begin and end times are corrected using this utcf value, as it is important that the reported times match a common time system when comparing with other missions.

Other times, such as those reported by Swift_ObsQuery for when Swift observations occur, are not at this time corrected to UTC, as the absolute timing for these is are not critical. UTCF corrections are typically performed during data analysis, for example when performing barycentric correction using the standard HEAsoft barycorr tool.

Swift times can also be corrected to UT using the HEAsoft swifttime analysis tool. If you use this, make sure that your Swift calibration files are upto date as the clock correction is updated regularly.

Update for swifttools 2.4

As noted elsewhere, clock correction can now be performed on results from a class using the clock_correct method.

As of swifttools 2.4, all recorded dates in the GUANO class and its subclasses are automatically clock corrected. By default, all dates are UTC, not Swift time, and dates are stored in the swiftdatetime format, which is an extended version of Python's datetime, which supports clock correction, and MET conversion. So as an example, the trigger time for the above trigger:

guano[0].triggertime
MET (s)Swift TimeUTC Time (default)UTCF (s)
670171227.9621192022-03-28 14:40:27.9621192022-03-28 14:39:59.100000-28.862119

So this time is record in datetime by default, but you can access the time as MET by using the met attribute, or the time as recorded by the Swift clock using the swifttime attribute. E.g.

print(f"Trigger MET        = {guano[0].triggertime.met}")
print(f"Trigger Swift Time = {guano[0].triggertime.swifttime}")
print(f"Trigger UTC Time   = {guano[0].triggertime.utctime}")
Trigger MET        = 670171227.962119
Trigger Swift Time = 2022-03-28 14:40:27.962119
Trigger UTC Time   = 2022-03-28 14:39:59.100000

Fetching GUANO data for a specific triggers or date ranges

The above example show fetching recent triggers, what about for date ranges, or specific times. Here we'll give a few examples of how to search for GUANO triggers using time searches. Firstly, let's see what GUANO dumps occrred during Jan 1st, 2022:

guano = GUANO(begin="2022-01-01", end="2022-01-02", limit=100)
guano
Trigger TypeTrigger TimeOffset (s)Window Duration (s)Observation ID
GBM GRB2022-01-01 08:57:395020000014979001
GBM GRB2022-01-01 07:16:205020000031306080
INTEGRAL_GRB2022-01-01 05:11:22090 (1202)01091527000

So on Jan 1st, 2022 there were three GUANO dumps, 2 Fermi/GBM detected GRBs and one INTEGRAL GRB. By default, GBM GRBs are dumped for 200s and INTEGRAL GRBs are dumped for 90s. However, in this case you can see that the actual amount of event data for the INTEGRAL GRB was 1202s. Let's look into why, by taking a look at the Swift_GUANO_Data object associated with that trigger.

guano[-1].data
ParameterValue
obsid01091527000
triggertime2022-01-01 05:11:22
begin2022-01-01 05:06:11.642365
end2022-01-01 05:26:13.749165
exposure1202.1068
filenamessw01091527000bevshsp_uf.evt
gti2022-01-01 05:06:11.642365 - 2022-01-01 05:26:13.749165 (0:20:02)
all_gtis2022-01-01 05:06:11.642365 - 2022-01-01 05:26:13.749165 (0:20:02)
acsmixed
utcf-28.357940673828125

So it looks like around 20 minutes of event data were dumped during starting more than 5 minutes before the trigger time. Why did this happen? Well, if you notice the filename, the slew type here is "sp" which means "slewing and pointing". Why not two files like we see in others - the reason is that this event data was dumped not due to a GUANO request, but because there was a BAT triggered GRB at the same time.

In this case, GRB 220101A. Looking at GCN #31347 this GRB triggered BAT at 05:09:55UT, over a minute before the INTEGRAL trigger. However, it's likely that the INTEGRAL trigger was the same GRB.

Fetching the data

OK, so what if we want to process these data? Well, a full BAT analysis tutorial isn't the aim here, but a good start is to download the data associated with this trigger. We can do this with the Swift_Data class. We'll set bat = True, the auxil data will come down, and we'll download it our Downloads directory.

from swifttools.swift_too import Data

data = Data(obsid=guano[-2].obsid, bat=True, outdir="~/Downloads/", clobber=True)
Downloading 29 files...

Let's look to see what we got. As this was the data for a GRB, it will be quite a lot as this was a BAT triggered GRB.

data
PathFilenameDescription
00031306080/auxilSWIFT_TLE_ARCHIVE.txt.22010.15512555.gzAuxillary file
''sw00031306080pat.fits.gzAuxillary attitude file
''sw00031306080pjb.par.gzAuxillary file
''sw00031306080pob.cat.gzAuxillary catalog
''sw00031306080ppr.par.gzAuxillary file
''sw00031306080s.mkf.gzAuxillary file
''sw00031306080sao.fits.gzAuxillary file
''sw00031306080sat.fits.gzAuxillary attitude file
''sw00031306080sen.hk.gzAuxillary housekeeping
''sw00031306080sti.fits.gzAuxillary file
''sw00031306080uat.fits.gzAuxillary attitude file
''sw00031306080x.mkf.gzAuxillary file
00031306080/bat/eventsw00031306080bevshpo_uf.evt.gzBAT pointed unfiltered event file
00031306080/bat/hksw00031306080bdecb.hk.gzBAT housekeeping file
''sw00031306080bdp.hk.gzBAT housekeeping file
''sw00031306080bdqcb.hk.gzBAT housekeeping file
''sw00031306080ben.hk.gzBAT housekeeping file
''sw00031306080bevtlsp.hk.gzBAT housekeeping file
''sw00031306080bevtssp.hk.gzBAT housekeeping file
''sw00031306080bgocb.hk.gzBAT housekeeping file
''sw00031306080bhd.hk.gzBAT housekeeping file
00031306080/bat/masktagsw00031306080bmt00010005.lc.gzBAT mask tagged lightcurve
''sw00031306080bmt00010005_rw.lc.gzBAT raw mask tagged lightcurve
00031306080/bat/ratesw00031306080brt1s.lc.gzBAT rate lightcurve
''sw00031306080brtmc.lc.gzBAT rate lightcurve
''sw00031306080brtms.lc.gzBAT rate lightcurve
''sw00031306080brtqd.lc.gzBAT rate lightcurve
00031306080/bat/surveysw00031306080bsvpbo2a52g08e5.dph.gzBAT survey DPH
''sw00031306080bsvpbo2a54g08e5.dph.gzBAT survey DPH

You can see that the all important file sw00031306080bevshpo_uf.evt.gz is up there in the bat/event directory. Here is the file details for the event files:

data[12]
ParameterValue
filenamesw00031306080bevshpo_uf.evt.gz
path00031306080/bat/event
urlhttps://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2022_01/00031306080/b
at/event/sw00031306080bevshpo_uf.evt.gz
quicklookFalse
typeBAT pointed unfiltered event file
size14008411
localpath/Users/myuser/Downloads/00031306080/bat/event/sw00031306080bevshpo_uf.e
vt.gz

You can see that now the file is downloaded, localpath gives the full path to where the data lives.

Swift Mission Operations Center

The Pennsylvania State University
301 Science Park Road,
Building 2 Suite 332,
State College, PA 16801
USA
☎ +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