def main(): props = [] props.append((3111, 'WD_Kilic')) props.append((3116, 'WD_Redfield')) props.append((3096, 'EXO_Heller')) props.append((3095, 'EXO_vanGrootel')) props.append((3086, 'EB_Southworth')) props.append((3067, 'EB_Peters')) props.append((3049, 'EB_Prsa')) props.append((3005, 'EB_Shporer')) # combined = [] qm = QueryK2ByTgtId() for p in props: print "Getting %s" % (p[1]) text = qm.queryProposal(p[0]) data = qm.parseResults(text) data = appendCol(data[1:, :], 'Proposal') data[:, 'Proposal'] = p[1] combined.append(data) cat = np.concatenate(combined) idx = np.unique(cat[:, 0], return_index=True)[1] cat = cat[idx] cat = nca.Nca(cat) cat.setLookup(1, data.lookup[1]) return cat
def regularSpaceKeplerDataByCadence(data, missingValue=0, cCol=FluxColDef['CADENCENO']): """Take Kepler multi quarter data and insert zeros where no data is present. This results in regularly spaced data. Inputs: data Numpy array as returned by kplrfits.loadMultiQuarter() Optional Inputs: missingValue (float) What value to enter for cadences where there is no data """ nR,nCol = data.shape cin = data[:, cCol].astype(np.int32) nCadence = cin[-1] reg = np.zeros( (nCadence+1, nCol) ) + missingValue for i in range(nCol): reg[cin, i] = data[:,i] #Insert all the cadence values, even where data was missing reg[:, cCol] = np.arange(cin[0], cin[0]+nCadence+1) #Fix the infinities idx = np.isfinite(reg) reg[~idx] = missingValue reg = nca.Nca(reg, data.lookup) return reg
def appendCol(data, name): nr, nc = data.shape nc += 1 newCol = np.atleast_2d(data[:, 0].asarray()).transpose() newData = np.hstack((data.asarray(), newCol)) lookup = data.lookup lookup[1].append(name) return nca.Nca(newData, lookup)
dataList.append(data) if len(dataList) == 0: raise IOError("Failed to find data in any listed quarter for %i" %(int(kepid))) out = np.concatenate( tuple(dataList)) lookup = """ TIME TIMECORR CADENCENO SAP_FLUX SAP_FLUX_ERR SAP_BKG SAP_BKG_ERR PDCSAP_FLUX PDCSAP_FLUX_ERR SAP_QUALITY PSF_CENTR1 PSF_CENTR1_ERR PSF_CENTR2 PSF_CENTR2_ERR MOM_CENTR1 MOM_CENTR1_ERR MOM_CENTR2 MOM_CENTR2_ERR POS_CORR1 POS_CORR2""".split() out = nca.Nca(out) out.setLookup(1, lookup) return out def getNumpyArrayFromFitsRec(rec, cols=None): #If not defined, try to get all columns if cols is None: cols = range(len(rec.names)) nRow = len(rec) nCol = len(cols) data = np.empty( (nRow, nCol) )