def test_PPMatchPointingsAndColours(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPMatchPointing import PPMatchPointing from surveySimPP.modules.PPMatchPointingsAndColours import PPMatchPointingsAndColours padafr = PPReadOif('./data/test/oiftestoutput.txt', 'whitespace') padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, 'whitespace') resdf = PPJoinPhysicalParametersPointing(padafr, padacl) # DRY COMMENT OUT BELOW - PPhookBrightnessWithColour NO LONGER EXISTS # resdf1=PPhookBrightnessWithColour(resdf, 'r', 'i-r', 'i') # resdf3=PPhookBrightnessWithColour(resdf1, 'r', 'g-r', 'g') dbq = 'SELECT observationId, observationStartMJD, filter, seeingFwhmGeom, seeingFwhmEff, fiveSigmaDepth, fieldRA, fieldDec, rotSkyPos FROM SummaryAllProps order by observationId' pada5 = PPMatchPointing('./data/test/baseline_10yrs_10klines.db', ['g', 'r', 'i'], dbq) # pada6=PPMatchPointingsAndColours(resdf3,pada5) # ncols=38 # ncolsre=len(pada6.columns) # assert ncols==ncolsre return
def test_PPOutWriteSqlite3(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPMatchPointing import PPMatchPointing from surveySimPP.modules.PPMatchPointingsAndColours import PPMatchPointingsAndColours from surveySimPP.modules.PPOutput import PPOutWriteSqlite3 padafr = PPReadOif('./data/test/oiftestoutput.txt', "whitespace") padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, "whitespace") resdf = PPJoinPhysicalParametersPointing(padafr, padacl) dbq = 'SELECT observationId, observationStartMJD, filter, seeingFwhmGeom, seeingFwhmEff, fiveSigmaDepth, fieldRA, fieldDec, rotSkyPos FROM SummaryAllProps order by observationId' pada5 = PPMatchPointing('./data/test/baseline_10yrs_10klines.db', ['g', 'r', 'i'], dbq) # DRY COMMENT OUT BELOW - resdf3 NOT CREATED # pada6 = PPMatchPointingsAndColours(resdf3, pada5) # pada7 = PPOutWriteSqlite3(pada6, './outtest.db') # nrows = 5 # con = sqlite3.connect('./outtest.db') # cur = con.cursor() # cur.execute("SELECT COUNT(*) FROM pp_results") # i = cur.fetchone()[0] # cmp = int(i) # os.system("rm ./outtest.db") # assert nrows == cmp return
def test_PPCalculateSimpleCometaryMagnitude(): from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPReadCometaryInput import PPReadCometaryInput from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPJoinOrbitalData import PPJoinOrbitalData from surveySimPP.modules.PPReadOrbitFile import PPReadOrbitFile from surveySimPP.modules.PPCalculateSimpleCometaryMagnitude import PPCalculateSimpleCometaryMagnitude padafr = PPReadOif('./data/test/67P.out', 'whitespace') padacl = PPReadPhysicalParameters('./data/test/testcometcolour.txt', 0, 3, 'whitespace') padaco = PPReadCometaryInput('./data/test/testcomet.txt', 0, 3, 'whitespace') padaor = PPReadOrbitFile('./data/test/67P.orb.des', 0, 3, 'whitespace') resdf1 = PPJoinPhysicalParametersPointing(padafr, padacl) resdf2 = PPJoinPhysicalParametersPointing(resdf1, padaco) resdf3 = PPJoinOrbitalData(resdf2, padaor) #resdf3['r'] = resdf3['V'] ncols1 = len(resdf3.columns) + 3 resdf = PPCalculateSimpleCometaryMagnitude(resdf3, 'r') ncols = len(resdf.columns) assert ncols == ncols1 return
def test_PPBrightLimit(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPMatchPointing import PPMatchPointing from surveySimPP.modules.PPMatchPointingsAndColours import PPMatchPointingsAndColours from surveySimPP.modules.PPBrightLimit import PPBrightLimit padafr = PPReadOif('./data/test/oiftestoutput.txt', 'whitespace') padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, 'whitespace') resdf = PPJoinPhysicalParametersPointing(padafr, padacl) dbq = 'SELECT observationId, observationStartMJD, filter, seeingFwhmGeom, seeingFwhmEff, fiveSigmaDepth, fieldRA, fieldDec, rotSkyPos FROM SummaryAllProps order by observationId' pada5 = PPMatchPointing('./data/test/baseline_10yrs_10klines.db', ['r', 'g', 'i'], dbq) # DRY COMMENT OUT BELOW - resdf3 NOT CREATED # pada6=PPMatchPointingsAndColours(resdf3,pada5) # print(pada6) # pada7=PPBrightLimit(pada6,18.2) # nros=5 # nrosre=len(pada7.index) # assert nros==nrosre return
def test_PPCheckOrbitAndPhysicalParametersMatching(): from surveySimPP.modules.PPReadOrbitFile import PPReadOrbitFile from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPCheckOrbitAndPhysicalParametersMatching import PPCheckOrbitAndPhysicalParametersMatching from surveySimPP.modules.PPReadOif import PPReadOif compval = 1 padaor = PPReadOrbitFile('./data/test/testorb.des', 0, 10, 'whitespace') padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 10, 'whitespace') padapo = PPReadOif('./data/test/oiftestoutput.txt', 'whitespace') print(padaor) print(padacl) print(padapo) try: PPCheckOrbitAndPhysicalParametersMatching(padaor, padacl, padapo) ret = 1 except: ret = 0 assert ret == compval return
def test_PPReadPhysicalParameters(): from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters rescol = 0.3 padafr = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 3, "whitespace") val = padafr.at[0, 'g-r'] assert rescol == val return
def test_PPJoinPhysicalParametersPointing(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters padafr = PPReadOif('./data/test/oiftestoutput.txt', 'whitespace') padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, 'whitespace') padare = PPJoinPhysicalParametersPointing(padafr, padacl) ncol = 27 ncolre = len(padare.columns) assert ncol == ncolre return
def test_PPOutWriteHDF5(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPMatchPointing import PPMatchPointing from surveySimPP.modules.PPMatchPointingsAndColours import PPMatchPointingsAndColours from surveySimPP.modules.PPOutput import PPOutWriteHDF5 padafr = PPReadOif('./data/test/oiftestoutput.txt', "whitespace") padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 20, "whitespace") resdf = PPJoinPhysicalParametersPointing(padafr, padacl) dbq = 'SELECT observationId, observationStartMJD, filter, seeingFwhmGeom, seeingFwhmEff, fiveSigmaDepth, fieldRA, fieldDec, rotSkyPos FROM SummaryAllProps order by observationId' pada5 = PPMatchPointing('./data/test/baseline_10yrs_10klines.db', ['r', 'g', 'i'], dbq) # DRY COMMENT OUT BELOW - resdf3 NOT CREATED # pada6 = PPMatchPointingsAndColours(resdf3, pada5) # pada7 = PPOutWriteHDF5(pada6, 'outtest.h5', str(1)) # pd.read_hdf('outtest.h5', str(1)).dtypes # ncols = 5 # print(pada6) # rer = pd.read_hdf('outtest.h5') # nrs = len(rer.index) # os.system("rm outtest.h5") # # ncolsre=len(pada6.columns) # assert ncols == nrs return
def test_PPJoinCOrbitalData(): from surveySimPP.modules.PPJoinOrbitalData import PPJoinOrbitalData from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPReadOrbitFile import PPReadOrbitFile padafr = PPReadOif('./data/test/oiftestoutput.txt', "whitespace") padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, "whitespace") padaor = PPReadOrbitFile('./data/test/testorb.des', 0, 5, "whitespace") padain = PPJoinPhysicalParametersPointing(padafr, padacl) padare = PPJoinOrbitalData(padain, padaor) ncol = 36 ncolre = len(padare.columns) assert ncol == ncolre return
def test_PPReadIntermDatabase(): from surveySimPP.modules.PPMakeIntermediatePointingDatabase import PPMakeIntermediatePointingDatabase from surveySimPP.modules.PPReadIntermDatabase import PPReadIntermDatabase from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, 'whitespace') print(padacl) objid_list = padacl['ObjID'].unique().tolist() daba = PPMakeIntermediatePointingDatabase( './data/test/oiftestoutput.txt', './data/test/testdb_PPIntermDB.db', 10) padafr = PPReadIntermDatabase('./data/test/testdb_PPIntermDB.db', objid_list) nlines = 9 nlinesdb = len(padafr.index) assert nlines == nlinesdb return
def test_PPOutWriteCSV(): from surveySimPP.modules.PPJoinPhysicalParametersPointing import PPJoinPhysicalParametersPointing from surveySimPP.modules.PPReadOif import PPReadOif from surveySimPP.modules.PPReadPhysicalParameters import PPReadPhysicalParameters from surveySimPP.modules.PPMatchPointing import PPMatchPointing from surveySimPP.modules.PPMatchPointingsAndColours import PPMatchPointingsAndColours from surveySimPP.modules.PPOutput import PPOutWriteCSV padafr = PPReadOif('./data/test/oiftestoutput.txt', "whitespace") padacl = PPReadPhysicalParameters('./data/test/testcolour.txt', 0, 5, "whitespace") resdf = PPJoinPhysicalParametersPointing(padafr, padacl) dbq = 'SELECT observationId, observationStartMJD, filter, seeingFwhmGeom, seeingFwhmEff, fiveSigmaDepth, fieldRA, fieldDec, rotSkyPos FROM SummaryAllProps order by observationId' pada5 = PPMatchPointing('./data/test/baseline_10yrs_10klines.db', ['g', 'r', 'i'], dbq) # DRY COMMENT OUT BELOW - resdf3 NOT CREATED # pada6 = PPMatchPointingsAndColours(resdf3, pada5) # pada7 = PPOutWriteCSV(pada6, './outtest.csv') # ncols = 6 # tpt = os.popen("wc -l ./outtest.csv | awk '{print $1}'") # cmp = tpt.read() # cmp.strip() # cmp1 = int(cmp) # os.system("rm ./outtest.csv") # # ncolsre=len(pada6.columns) # assert ncols == cmp1 return