glue.lal module

This module contains bits and pieces of use when interacting with LAL and LAL-derived code (eg. LALApps programs)

class glue.lal.Cache(iterable=(), /)[source]

Bases: list

An object representing a LAL cache file. Currently it is possible to add anything to a Cache. This method should check that the thing you are adding is a CacheEntry and throw an error if it is not.

checkfilesexist(on_missing='warn')[source]

Runs through the entries of the Cache() object and checks each entry if the file which it points to exists or not. If the file does exist then it adds the entry to the Cache() object containing found files, otherwise it adds the entry to the Cache() object containing all entries that are missing. It returns both in the follwing order: Cache_Found, Cache_Missed.

Pass on_missing to control how missing files are handled:
“warn”: print a warning message saying how many files

are missing out of the total checked.

“error”: raise an exception if any are missing “ignore”: do nothing

entry_class

alias of CacheEntry

classmethod from_urls(urllist, coltype=<class 'glue.lal.LIGOTimeGPS'>)[source]

Return a Cache whose entries are inferred from the URLs in urllist, if possible. PFN lists will also work; for PFNs, the path will be absolutized and “file://” and “localhost” will be assumed for the schemes and hosts.

The filenames must be in the format set forth by DASWG in T050017-00.

classmethod fromfile(fileobj, coltype=<class 'glue.lal.LIGOTimeGPS'>)[source]

Return a Cache object whose entries are read from an open file.

classmethod fromfilenames(filenames, coltype=<class 'glue.lal.LIGOTimeGPS'>)[source]

Read Cache objects from the files named and concatenate the results into a single Cache.

pfnlist()[source]

Return a list of physical file names.

sieve(ifos=None, description=None, segment=None, segmentlist=None, exact_match=False)[source]

Return a Cache object with those CacheEntries that contain the given patterns (or overlap, in the case of segment or segmentlist). If exact_match is True, then non-None ifos, description, and segment patterns must match exactly, and a non-None segmentlist must contain a segment which matches exactly).

It makes little sense to specify both segment and segmentlist arguments, but it is not prohibited.

Bash-style wildcards (*?) are allowed for ifos and description.

to_segmentlistdict()[source]

Return a segmentlistdict object describing the instruments and times spanned by the entries in this Cache. The return value is coalesced.

tofile(fileobj)[source]

write a cache object to the fileobj as a lal cache file

topfnfile(fileobj)[source]

write a cache object to filename as a plain text pfn file

unique()[source]

Return a Cache which has every element of self, but without duplication. Preserve order. Does not hash, so a bit slow.

class glue.lal.CacheEntry(*args, **kwargs)[source]

Bases: CacheEntry

class glue.lal.LIGOTimeGPS(seconds, nanoseconds=0)[source]

Bases: object

An object for storing times with nanosecond resolution. LAL defines an equivalent object which is used through-out the search algorithms to represent times. Many LALApps routines input and output times in a manner that meshes well with this object.

Internally the time is represented as a signed integer “seconds” part and an unsigned integer “nanoseconds” part. The actual time is always constructed by adding the nanoseconds to the seconds. So -0.5 s is represented by setting seconds = -1, and nanoseconds to 500000000. That’s the way LAL does it.

property gpsNanoSeconds
property gpsSeconds
property nanoseconds
ns()[source]

Convert a LIGOTimeGPS to a count of nanoseconds as a long.

Example:

>>> LIGOTimeGPS(100.5).ns()
100500000000
property seconds