docs: def query_for_observations(mjd, observable, runid_list):
      """Do a QUERY on the TAP service for all observations that are part of runid, 
      where taken after mjd and have calibration 'observable'.
  
      Schema is at: http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/tap/tables
  
      mjd : float 
      observable: str ( 2 or 1 )
      runid: tuple eg. ('13AP05', '13AP06')
  
      """
  
      data = {"QUERY": ("SELECT Observation.target_name as TargetName, "
                        "COORD1(CENTROID(Plane.position_bounds)) AS RA,"
                        "COORD2(CENTROID(Plane.position_bounds)) AS DEC, "
                        "Plane.time_bounds_lower AS StartDate, "
                        "Plane.time_exposure AS ExposureTime, "
                        "Observation.instrument_name AS Instrument, "
                        "Plane.energy_bandpassName AS Filter, "
                        "Observation.observationID AS dataset_name, "
                        "Observation.proposal_id AS ProposalID, "
                        "Observation.proposal_pi AS PI "
                        "FROM caom2.Observation AS Observation "
                        "JOIN caom2.Plane AS Plane ON "
                        "Observation.obsID = Plane.obsID "
                        "WHERE  ( Observation.collection = 'CFHT' ) "
                        "AND Plane.time_bounds_lower > %d "
                        "AND Plane.calibrationLevel=%s "
                        "AND Observation.proposal_id IN %s ") % (mjd, observable, str(runid_list)),
              "REQUEST": "doQuery",
              "LANG": "ADQL",
              "FORMAT": "votable"}
  
      result = requests.get(storage.TAP_WEB_SERVICE, params=data, verify=False)
      assert isinstance(result, requests.Response)
      logging.debug("Doing TAP Query using url: %s" % (str(result.url)))
      temp_file = tempfile.NamedTemporaryFile()
      with open(temp_file.name, 'w') as outfile:
          outfile.write(result.text)
      try:
          vot = parse(temp_file.name).get_first_table()
      except Exception as ex:
          logging.error(str(ex))
          logging.error(result.text)
          raise ex
  
      vot.array.sort(order='StartDate')
      t = vot.array
      temp_file.close()
  
      logging.debug("Got {} lines from tap query".format(len(t)))
  
      return t