Exemplo n.º 1
0
def web_query_aspect(eclipse, retries=20):
    """Grabs the aspect data from MAST databases based on eclipse."""
    print "Attempting to query MAST database for aspect records."
    entries = gQuery.getArray(gQuery.aspect_ecl(eclipse), retries=retries)
    n = len(entries)
    print "		Located " + str(n) + " aspect entries."
    if not n:
        print "No aspect entries for eclipse " + str(eclipse)
        return
    ra, dec, twist, time, flags = [], [], [], [], []
    header = {"RA": [], "DEC": [], "ROLL": []}
    ra0, dec0, twist0 = [], [], []
    for i in xrange(n):
        # The times are *1000 in the database to integerify
        time.append(float(entries[i][2]) / 1000.0)
        ra.append(float(entries[i][3]))
        dec.append(float(entries[i][4]))
        twist.append(float(entries[i][5]))
        flags.append(float(entries[i][6]))
        ra0.append(float(entries[i][7]))
        dec0.append(float(entries[i][8]))
        twist0.append(float(entries[i][9]))

        # Need to sort the output so that it is time ordered before returning.
        # Although it should already be ordered by time because that is requested
        #  in the SQL query above. If this is time consuming, remove it.
    ix = np.argsort(np.array(time))
    header = {"RA": np.array(ra0)[ix], "DEC": np.array(dec0)[ix], "ROLL": np.array(twist0)[ix]}

    return np.array(ra)[ix], np.array(dec)[ix], np.array(twist)[ix], np.array(time)[ix], header, np.array(flags)[ix]
Exemplo n.º 2
0
 def test_aspect_ecl(self):
     self.assertEqual(gq.aspect_ecl(self.eclipse),'http://masttest.stsci.edu/portal/Mashup/MashupQuery.asmx/GalexPhotonListQueryTest?query=select eclipse, filename, time, ra, dec, twist, flag, ra0, dec0, twist0 from aspect where eclipse=23456 order by time&format=json&timeout={}')