Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# (c) Stefan Countryman, 2019 

2 

3""" 

4Utilities for working with GW searches that depend on ``SkymapInfo``. 

5""" 

6 

7GRACEDB_HUMAN_URL_FMT = "https://gracedb.ligo.org/apiweb/events/{}/files/{}" 

8GRACEDB_HUMAN_SUPER_URL_FMT = ("https://gracedb.ligo.org/api/" 

9 "superevents/{}/files/{}") 

10 

11 

12def gracedb_human_file_url(graceid, filename, version=None): 

13 """Get a human-viewable (i.e. browser-viewable) URL for a specific filename 

14 and event combination on GraceDB. You can either specify the version as an 

15 argument, omit the version, or pass the version straight in as part of the 

16 filename (though explicitly passing the version number as an argument will 

17 override a version provided as part of the filename argument). Will check 

18 whether the event is a superevent and return the appropriate URL in that 

19 case.""" 

20 if version is not None: 

21 splitname = filename.split(',') 

22 if len(splitname) == 2: 

23 # override the implicit version provided in the filename 

24 filename = splitname[0] 

25 filename += ',' + version 

26 if is_super(graceid): 

27 return GRACEDB_HUMAN_SUPER_URL_FMT.format(graceid, filename) 

28 return GRACEDB_HUMAN_URL_FMT.format(graceid, filename) 

29 

30 

31def is_super(graceid): 

32 """Check whether this GraceID corresponds to an event or a superevent.""" 

33 if graceid.startswith("S") or graceid.startswith("MS"): 

34 return True 

35 if graceid.startswith("G") or graceid.startswith("M"): 

36 return False 

37 raise ValueError(("Unexpected GraceID format {}, not sure if " 

38 "superevent.").format(graceid))