#!/usr/bin/env python usage = \ """ This searches through a database file to find which entries overlap with the supplied MJD range. The indices listed correspond to those to be found on the summary page http://deneb.astro.warwick.ac.uk/phsaap/v404cyg/data/ The file is downloaded via http each time. If you are not sure of the appropriate time range, enter 0 0 the first time. """ import os import argparse import json import urllib2 if __name__ == '__main__': parser = argparse.ArgumentParser(description=usage) # positional parser.add_argument('mjd1', type=float, help='start of time range') parser.add_argument('mjd2', type=float, help='end of time range') # OK, done with arguments. args = parser.parse_args() # Download database file url = 'http://deneb.astro.warwick.ac.uk/phsaap/v404cyg/data/v404cyg.json' response = urllib2.urlopen(url) jstring = response.read() results = json.loads(jstring) print len(results),'entries read from',url print '\nEntry Contact name Telescope Instrument Waveband(s)\n' nover = 0 tmin = +1.e10 tmax = -1.e10 for entry in results: for start, end in entry['times']: tmin = min(tmin, start) tmax = max(tmax, end) if start < args.mjd2 and end > args.mjd1: print '{0:3d} {1:26s} {2:26s} {3:26s} {4:10s}'.format( entry['nentry'],entry['Name'][:26],entry['Telescope'][:26], entry['Instrument'][:26],entry['Wavebands']) nover += 1 break if nover == 0: print 'Time range found:',tmin,'to',tmax