Example #1
0
def dmag_errors(t,band,sigma=3,mode='mag',mags=np.arange(13,24,0.1)):
    """Given an exposure time, give dmag error bars at a range of magnitudes."""
    cnts = gt.mag2counts(mags,band)
    ymin = (cnts*t/t)-sigma*np.sqrt(cnts*t)/t
    ymax = (cnts*t/t)+sigma*np.sqrt(cnts*t)/t
    if mode=='mag':
        ymin=mags-gt.counts2mag(ymin,band)
        ymax=mags-gt.counts2mag(ymax,band)
    return mags,ymin,ymax
Example #2
0
def error(data,band,radius,annulus):
    N_a = 1
    N_b0 = (mc.area(annulus[1])-mc.area(annulus[0]))/mc.area(radius)
    N_b = data[band]['bg_eff_area']/mc.area(radius)
    B0 = data[band]['bg']
    B = data[band]['bg_cheese']
    S = gt.mag2counts(data[band]['mag'],band)*data[band]['t_eff']
    s2 = {'bg_cheese_err':(S-B)+(N_a+(N_a**2.)/N_b),
          'bg_err':(S-B0)+(N_a+(N_a**2.)/N_b0)}
    return s2
Example #3
0
def data_errors(catmag,t,band,sigma=3,mode='mag'):
	if mode!='cps' and mode!='mag':
		print 'mode must be set to "cps" or "mag"'
		exit(0)
	cnt = gt.mag2counts(catmag,band)
	ymin = (cnt*t/t)-sigma*np.sqrt(cnt*t)/t
	ymax = (cnt*t/t)+sigma*np.sqrt(cnt*t)/t
	if mode=='mag':
#		y = gt.counts2mag(cnt*t/t,band)
		ymin = gt.counts2mag(ymin,band)
		ymax = gt.counts2mag(ymax,band)
	return ymin, ymax
Example #4
0
def model_errors(catmag,band,sigma=3,mode='mag',trange=[1,1600]):
	"""Give upper and lower expected bounds as a function of the nominal
	magnitude of a source. Super userful for identifying outliers.
	sigma = how many sigma out to set the bounds
	mode = ['cps','mag'] - units in which to report bounds
	"""
	if mode!='cps' and mode!='mag':
		print 'mode must be set to "cps" or "mag"'
		exit(0)
	x = np.arange(trange[0],trange[1])
	cnt = gt.mag2counts(catmag,band)
	ymin = (cnt*x/x)-sigma*np.sqrt(cnt*x)/x
	ymax = (cnt*x/x)+sigma*np.sqrt(cnt*x)/x
	if mode=='mag':
#		y = gt.counts2mag(cnt*x/x,band)
		ymin = gt.counts2mag(ymin,band)
		ymax = gt.counts2mag(ymax,band)
	return ymin, ymax
Example #5
0
for band in bands:
    data[band] = pd.read_csv('{base}{band}.csv'.format(
                                                        base=base,band=band))
    print '{band} sources: {cnt}'.format(
                                band=band,cnt=data[band]['objid'].shape[0])

"""dMag vs. Mag"""
for band in bands:
    dmag = {'gphot_cheese':(lambda band:
                        data[band]['aper4']-data[band]['mag_bgsub_cheese']),
                 'gphot_nomask':(lambda band:
                        data[band]['aper4']-data[band]['mag_bgsub']),
                 'gphot_sigma':(lambda band:
                        data[band]['aper4']-data[band]['mag_bgsub_sigmaclip']),
                 'mcat':lambda band: data[band]['aper4']-
                        gt.counts2mag(gt.mag2counts(data[band]['mag'],band)-
                        data[band]['skybg']*3600**2*mc.area(gt.aper2deg(4)),
                        band)}
bgmodekeys={'gphot_cheese':'mag_bgsub_cheese',
            'gphot_nomask':'mag_bgsub',
            'gphot_sigma':'mag_bgsub_sigmaclip',
            'mcat':'skybg'}
for bgmode in dmag.keys():
    for band in bands:
        fig = plt.figure(figsize=(8*scl,4*scl))
        fig.subplots_adjust(left=0.12,right=0.95,wspace=0.02,
                                                        bottom=0.15,top=0.9)
        dmag_err=gu.dmag_errors(100.,band,sigma=1.41)
        # Make a cut on crazy outliers in the MCAT. Also on det radius and expt.
        ix = ((data[band]['aper4']>0) & (data[band]['aper4']<30) &
              (data[band]['distance']<300) & (data[band]['t_eff']<300) &
Example #6
0
 def test_mag2counts_NUV(self):
     self.assertAlmostEqual(gt.mag2counts(16,'NUV'),10.**(-(16-20.08)/2.5))
Example #7
0
 def test_mag2counts_FUV(self):
     self.assertAlmostEqual(gt.mag2counts(16,'FUV'),10.**(-(16-18.82)/2.5))
Example #8
0
bands = ['NUV','FUV']
base = 'calrun_'
data = {}
for band in bands:
    data[band] = pd.read_csv('{base}{band}.csv'.format(
                                                        base=base,band=band))
    print '{band} sources: {cnt}'.format(
                                band=band,cnt=data[band]['objid'].shape[0])

"""dMag vs. Mag"""
dmag = {'gphot_cheese':(lambda band:
                        data[band]['aper4']-data[band]['mag_bgsub_cheese']),
        'gphot_nomask':(lambda band:
                        data[band]['aper4']-data[band]['mag_bgsub']),
        'mcat':lambda band: data[band]['aper4']-
            gt.counts2mag(gt.mag2counts(data[band]['mag'],band)-
            data[band]['skybg']*3600**2*mc.area(gt.aper2deg(4)),band)}
for bgmode in dmag.keys():
    for band in bands:
        fig = plt.figure(figsize=(8*scl,4*scl))
        fig.subplots_adjust(left=0.12,right=0.95,wspace=0.02,
                                                        bottom=0.15,top=0.9)
        dmag_err=gu.dmag_errors(100.,band,sigma=1.41)
        # Make a cut on crazy outliers in the MCAT. Also on det radius and expt.
        ix = ((data[band]['aper4']>0) & (data[band]['aper4']<30) &
              (data[band]['distance']<300) & (data[band]['t_eff']<300))
        plt.subplot(1,2,1)
        plt.title('{band} {d}Mag vs. AB Mag (n={n},{bg}_bg)'.format(
                            d=r'$\Delta$',band=band,n=ix.shape[0],bg=bgmode))
        plt.xlabel('AB Magnitude (MCAT)')
        plt.ylabel(r'{d}Magnitude (MCAT-gPhoton)'.format(d=r'$\Delta$'))