def test_basic_query_FUV(self):
     """Regtest the simplest valid query. (FUV)"""
     out = ga.gAperture(band='FUV',skypos=self.skypos,radius=self.radius)
     self.assertEqual(len(out['exptime']),2)
     # Regtest the exposure times
     self.assertAlmostEqual(out['exptime'][0],1227.36996722)
     self.assertAlmostEqual(out['exptime'][1],406.73730805)
     # Regtest the magnitudes (no bg subtraction)
     self.assertAlmostEqual(out['mag'][0],13.54947823)
     self.assertAlmostEqual(out['mag'][1],19.03458803)
 def test_basic_query_NUV(self):
     """Regtest the simplest valid query. (NUV)"""
     out = ga.gAperture(band='NUV',skypos=self.skypos,radius=self.radius)
     self.assertEqual(len(out['exptime']),4)
     # Regtest the exposure times
     self.assertAlmostEqual(out['exptime'][0],634.2852623)
     self.assertAlmostEqual(out['exptime'][1],1099.98059419)
     self.assertAlmostEqual(out['exptime'][2],457.07447477)
     self.assertAlmostEqual(out['exptime'][3],370.61241714)
     # Regtest the source magnitudes (no bg subtraction)
     self.assertAlmostEqual(out['mag'][0],17.77856936)
     self.assertAlmostEqual(out['mag'][1],13.16626222)
     self.assertAlmostEqual(out['mag'][2],17.821252)
     self.assertAlmostEqual(out['mag'][3],17.76766803)
Beispiel #3
0
def datamaker(
    band, skypos, outfile, maglimit=20.0, margin=0.005, searchradius=0.1, radius=gt.aper2deg(4), annulus=[0.0083, 0.025]
):
    extant_objids = file_setup(outfile)
    if extant_objids == False:
        print "NOT RUNNING!!*!"
        return False
    uniques = dt.find_unique_sources(band, skypos[0], skypos[1], searchradius, maglimit=maglimit)
    if uniques is None:
        print "No sources at this position."
        return
    for pos in uniques:
        mcat = dt.get_mcat_data(pos, margin)
        if not mcat:
            print "Nothing at {pos}.".format(pos=pos)
            continue
        extant_objids = file_setup(outfile)
        for i, objid in enumerate(mcat["objid"]):
            if objid in extant_objids:
                print "Already processed."
                continue
            exp = dt.exp_from_objid(objid)
            if exp[band]["t0"] < 0:
                print "skip"
                continue
            data = gAperture(
                band,
                [mcat["ra"][i], mcat["dec"][i]],
                radius,
                annulus=annulus,
                verbose=0,
                coadd=True,
                trange=[exp[band]["t0"], exp[band]["t1"]],
            )
            if data["mag_bgsub_cheese"] and np.isfinite(data["mag_bgsub_cheese"]):
                csv_construct = construct_row(i, band, objid, mcat, data)
                print csv_construct
                with open(outfile, "ab") as csvfile:
                    spreadsheet = csv.writer(csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL)
                    spreadsheet.writerow(csv_construct)
            else:
                print "no exp"
    return
Beispiel #4
0
def datamaker(band,skypos,outfile,maglimit=20.,detsize=0.5,
                                radius=gt.aper2deg(4),annulus=[0.0083,0.025]):
    """Note: If you wanted to change the default annulus, then a good starting
    point would be [0.0083,0.025] (i.e. 30" to 90").
    """
    extant_objids = file_setup(outfile)
    if extant_objids==False:
        print 'NOT RUNNING!!*!'
        return False
    uniques = dt.find_unique_sources(band,skypos[0],skypos[1],
                                                    detsize,maglimit=maglimit)
    for pos in uniques:
        mcat = dt.get_mcat_data(pos,0.005)
        if not mcat:
            print 'Nothing at {pos}.'.format(pos=pos)
            continue
        extant_objids = file_setup(outfile)
        for i,objid in enumerate(mcat['objid']):
            if objid in extant_objids:
                print 'Already processed.'
                continue
            exp = dt.exp_from_objid(objid)
            if exp[band]['t0']<0:
                print 'skip'
                continue
            data = gAperture(band,[mcat['ra'][i],mcat['dec'][i]],radius,
                             annulus=annulus,verbose=0,coadd=True,
                             trange=[exp[band]['t0'],exp[band]['t1']])
            if (data['mag_bgsub_cheese'] and
                                        np.isfinite(data['mag_bgsub_cheese'])):
                csv_construct = construct_row(i,band,objid,mcat,data)
                print csv_construct
                with open(outfile,'ab') as csvfile:
                    spreadsheet = csv.writer(csvfile, delimiter=',',
                                    quotechar='|', quoting=csv.QUOTE_MINIMAL)
                    spreadsheet.writerow(csv_construct)
            else:
                print 'no exp'
    return
 def test_lcurve_query_FUV(self):
     """Regtest lightcurve over a specific time range. (FUV)"""
     out = ga.gAperture(band='FUV',skypos=self.skypos,radius=self.radius,
                        trange=self.tranges[1],stepsz=self.stepsz,
                        annulus=self.annulus)
     self.assertEqual(len(out['mag']),13)
     # Check that all of the bins have the right size (except the last one)
     for binsize in (out['t1']-out['t0'])[:-1]:
         self.assertAlmostEqual(binsize,self.stepsz)
     # Check the magnitudes (no bg subtraction)
     for i,mag in enumerate([ 18.87932679,  18.48008581,  18.55708448,
                              18.47418146,  18.07477455,  16.8611657 ,
                              13.17292039,  13.05277282,  13.06770171,
                              12.10430201,  12.65757588,  13.23356214,
                              13.55337665]):
         self.assertAlmostEqual(out['mag'][i],mag)
     # w/ background subtraction: What this might really be testing is the
     #  efficiency of the Monte Carlo annulus area estimate...
     for i,bgsubmag in enumerate([ 19.22893201,  18.70040929,  18.82504715,
                                   18.71041594,  18.24891483,  16.92506023,
                                   13.1785874 ,  13.05737169,  13.07264662,
                                   12.11070168,  12.66165582,  13.238224  ,
                                   13.55910122]):
         self.assertAlmostEqual(out['mag_bgsub_cheese'][i],bgsubmag)
 def test_lcurve_query_NUV(self):
     """Regtest lightcurve over a specific time range. (NUV)"""
     out = ga.gAperture(band='NUV',skypos=self.skypos,radius=self.radius,
                        trange=self.tranges[1],stepsz=self.stepsz,
                        annulus=self.annulus)
     self.assertEqual(len(out['mag']),13)
     # Check that all of the bins have the right size (except the last one)
     for binsize in (out['t1']-out['t0'])[:-1]:
         self.assertAlmostEqual(binsize,self.stepsz)
     # Check the magnitudes (no bg subtraction)
     for i,mag in enumerate([ 17.19836281,  17.09897678,  17.00228114,
                              16.86768186,  16.58436345,  15.63889791,
                              12.88250218,  12.61903232,  12.64400935,
                              11.96701482,  12.27271088,  12.56295656,
                              12.7914485 ]):
         self.assertAlmostEqual(out['mag'][i],mag)
     # w/ background subtraction: What this might really be testing is the
     #  efficiency of the Monte Carlo annulus area estimate...
     for i,bgsubmag in enumerate([ 17.58541851,  17.44183919,  17.30126593,
                                   17.12353785,  16.78258979,  15.71808383,
                                   12.88917149,  12.62460547,  12.64943953,
                                   11.9710767 ,  12.27723637,  12.56842635,
                                   12.79805813]):
         self.assertAlmostEqual(out['mag_bgsub_cheese'][i],bgsubmag)
 def test_coadd_query_FUV(self):
     """Regtest a coadded magnitude. (FUV)"""
     out = ga.gAperture(band='FUV',skypos=self.skypos,radius=self.radius,
                        tranges=self.tranges,coadd=True)
     self.assertAlmostEqual(out['mag'][0],13.855867417553458)
 def test_coadd_query_NUV(self):
     """Regtest a coadded magnitude. (NUV)"""
     out = ga.gAperture(band='NUV',skypos=self.skypos,radius=self.radius,
                        tranges=self.tranges,coadd=True)
     self.assertAlmostEqual(out['mag'][0],14.064324896330707)