def plotBrightLimitInV(gBright, pdf=False, png=False): """ Plot the bright limit of Gaia in V as a function of (V-I). Parameters ---------- gBright - The bright limit of Gaia in G """ vmini = np.linspace(0.0, 6.0, 1001) gminv = gminvFromVmini(vmini) vBright = gBright - gminv fig = plt.figure(figsize=(10, 6.5)) plt.plot(vmini, vBright, 'b-') plt.xlabel('$(V-I)$') plt.ylabel('Bright limit of Gaia in $V$') plt.xlim(0, 6) plt.ylim(5, 11) plt.grid(which='both') plt.title("Bright limit in $G$: {0}".format(gBright)) if (pdf): plt.savefig('VBandBrightLimit.pdf') elif (png): plt.savefig('VBandBrightLimit.png') else: plt.show()
def plotBrightLimitInV(gBright, pdf=False, png=False): """ Plot the bright limit of Gaia in V as a function of (V-I). Parameters ---------- gBright - The bright limit of Gaia in G """ vmini=np.linspace(0.0,6.0,1001) gminv=gminvFromVmini(vmini) vBright=gBright-gminv fig=plt.figure(figsize=(10,6.5)) plt.plot(vmini,vBright,'b-') plt.xlabel('$(V-I)$') plt.ylabel('Bright limit of Gaia in $V$') plt.xlim(0,6) plt.ylim(5,11) plt.grid(which='both') plt.title("Bright limit in $G$: {0}".format(gBright)) if (pdf): plt.savefig('VBandBrightLimit.pdf') elif (png): plt.savefig('VBandBrightLimit.png') else: plt.show()
def get_gaia_bp_and_rp(v, v_minus_i): gminusv = transformations.gminvFromVmini(v_minus_i) g = gminusv + v gminusbp = vminusi_to_gminusbp(v_minus_i) gminusrp = vminusi_to_gminusrp(v_minus_i) bp = g - gminusbp rp = g - gminusrp return bp, rp
def makePlot(pdf=False, png=False): """ Plot relative parallax errors as a function of distance for stars of a given spectral type. Parameters ---------- args - command line arguments """ logdistancekpc = np.linspace(-1, np.log10(20.0), 100) sptVabsAndVmini = OrderedDict([ ('K0V', (5.58, 0.87)), ('G5V', (4.78, 0.74)), ('G0V', (4.24, 0.67)), ('F5V', (3.50, 0.50)), ('F0V', (2.98, 0.38)), ('RC', (0.8, 1.0)) ]) lines = {} fig = plt.figure(figsize=(10, 6.5)) currentAxis = plt.gca() for spt in sptVabsAndVmini.keys(): vmag = sptVabsAndVmini[spt][0] + 5.0 * logdistancekpc + 10.0 indices = (vmag > 14) & (vmag < 16) gmag = vmag + gminvFromVmini(sptVabsAndVmini[spt][1]) parerrors = parallaxErrorSkyAvg(gmag, sptVabsAndVmini[spt][1]) relparerrors = parerrors * 10**logdistancekpc / 1000.0 plt.loglog(10**logdistancekpc, relparerrors, '--k', lw=1) plt.loglog(10**logdistancekpc[indices], relparerrors[indices], '-', label=spt) plt.xlim(0.1, 20.0) plt.ylim(0.001, 0.5) plt.text(0.9, 0.05, 'Colours indicate $14<V<16$', horizontalalignment='right', verticalalignment='bottom', transform=currentAxis.transAxes) plt.legend(loc=2) plt.xlabel('distance [kpc]') plt.ylabel('$\\sigma_\\varpi/\\varpi$') plt.grid(which='both') if (args['pdfOutput']): plt.savefig('RelativeParallaxErrorsVsDist.pdf') elif (args['pngOutput']): plt.savefig('RelativeParallaxErrorsVsDist.png') else: plt.show()
def calcParallaxError(args): """ Calculate the parallax error for the given input source magnitude and colour. :argument args: command line arguments """ gmag = float(args['gmag']) vmini = float(args['vmini']) sigmaPar = parallaxErrorSkyAvg(gmag, vmini) gminv = gminvFromVmini(vmini) print(("G = {0}".format(gmag))) print(("V = {0}".format(gmag - gminv))) print(("(V-I) = {0}".format(vmini))) print(("(G-V) = {0}".format(gminv))) print(("standard error = {0} muas".format(sigmaPar)))
def calcParallaxError(args): """ Calculate the parallax error for the given input source magnitude and colour. :argument args: command line arguments """ gmag=float(args['gmag']) vmini=float(args['vmini']) sigmaPar=parallaxErrorSkyAvg(gmag, vmini) gminv=gminvFromVmini(vmini) print("G = {0}".format(gmag)) print("V = {0}".format(gmag-gminv)) print("(V-I) = {0}".format(vmini)) print("(G-V) = {0}".format(gminv)) print("standard error = {0} muas".format(sigmaPar))
def makePlot(pdf=False, png=False): """ Plot relative parallax errors as a function of distance for stars of a given spectral type. Parameters ---------- args - command line arguments """ logdistancekpc = np.linspace(-1,np.log10(20.0),100) sptVabsAndVmini=OrderedDict([('K0V',(5.58,0.87)), ('G5V',(4.78,0.74)), ('G0V',(4.24,0.67)), ('F5V',(3.50,0.50)), ('F0V',(2.98,0.38)), ('RC',(0.8,1.0))]) lines={} fig=plt.figure(figsize=(10,6.5)) currentAxis=plt.gca() for spt in sptVabsAndVmini.keys(): vmag=sptVabsAndVmini[spt][0]+5.0*logdistancekpc+10.0 indices=(vmag>14) & (vmag<16) gmag=vmag+gminvFromVmini(sptVabsAndVmini[spt][1]) parerrors=parallaxErrorSkyAvg(gmag,sptVabsAndVmini[spt][1]) relparerrors=parerrors*10**logdistancekpc/1000.0 plt.loglog(10**logdistancekpc, relparerrors,'--k',lw=1) plt.loglog(10**logdistancekpc[indices], relparerrors[indices],'-',label=spt) plt.xlim(0.1,20.0) plt.ylim(0.001,0.5) plt.text(0.9, 0.05,'Colours indicate $14<V<16$', horizontalalignment='right', verticalalignment='bottom', transform = currentAxis.transAxes) plt.legend(loc=2) plt.xlabel('distance [kpc]') plt.ylabel('$\\sigma_\\varpi/\\varpi$') plt.grid(which='both') if (args['pdfOutput']): plt.savefig('RelativeParallaxErrorsVsDist.pdf') elif (args['pngOutput']): plt.savefig('RelativeParallaxErrorsVsDist.png') else: plt.show()
def makePlot(gmag, pdf=False, png=False, rvs=False): """ Make a plot of a Mv vs (V-I) colour magnitude diagram containing lines of constant distance for stars at G=20. This will give an idea of the reach of Gaia. Parameters ---------- args - command line arguments """ vmini = np.linspace(-0.5,4.0,100) if (rvs): gminv = -vminGrvsFromVmini(vmini) else: gminv = gminvFromVmini(vmini) mvlimit100pc = gmag-5.0*np.log10(100.0)+5.0-gminv mvlimit1kpc = gmag-5.0*np.log10(1000.0)+5.0-gminv mvlimit10kpc = gmag-5.0*np.log10(10000.0)+5.0-gminv fig=plt.figure(figsize=(8,8)) plt.plot(vmini,mvlimit100pc,'b') plt.text(vmini[50]-0.4,mvlimit100pc[50],"$d=100$ pc", horizontalalignment='right', va='top') plt.plot(vmini,mvlimit1kpc,'r') plt.text(vmini[50]-0.4,mvlimit1kpc[50],"$d=1000$ pc", horizontalalignment='right', va='top') plt.plot(vmini,mvlimit10kpc,'g') plt.text(vmini[50]-0.4,mvlimit10kpc[50],"$d=10000$ pc", horizontalalignment='right', va='top') ax=plt.gca() ax.set_ylim(ax.get_ylim()[::-1]) plt.xlabel("$(V-I)$") plt.ylabel("$M_V$") if (rvs): plt.title("Distance limits for $G_\\mathrm{RVS}"+"={0}$".format(gmag)) else: plt.title("Distance limits for $G={0}$".format(gmag)) if (args['pdfOutput']): plt.savefig('GaiaSurveyLimits.pdf') elif (args['pngOutput']): plt.savefig('GaiaSurveyLimits.png') else: plt.show()
def gabsFromSpt(spt): """ Obtain M_G (absolute magnitude in G-band) for the input spectral type. Parameters ---------- spt - String representing the spectral type of the star. Returns ------- The value of M_G. """ if spt in _sptToVminiVabsDictionary: return vabsFromSpt(spt) + gminvFromVmini(vminiFromSpt(spt)) else: message = "Unknown spectral type. Allowed values are: " for key in list(_sptToVminiVabsDictionary.keys()): message += key + " " raise Exception(message)
def gabsFromSpt(spt): """ Obtain M_G (absolute magnitude in G-band) for the input spectral type. Parameters ---------- spt - String representing the spectral type of the star. Returns ------- The value of M_G. """ if spt in _sptToVminiVabsDictionary: return vabsFromSpt(spt) + gminvFromVmini(vminiFromSpt(spt)) else: message="Unknown spectral type. Allowed values are: " for key in _sptToVminiVabsDictionary.keys(): message += key+" " raise Exception(message)
def make_gaia_observables(desi_table, dust='galaxia'): """ """ import pygaia import pygaia.errors.astrometric as gaia_astro import pygaia.errors.spectroscopic as gaia_spectro import pygaia.errors.photometric as gaia_photo np.random.seed(2019) gaia_table = Table() # Intrinsic heliocentric distance in parsecs d_parsecs = desi_table['d_helio'] * 1000.0 # Heliocentric RV in km/s v_helio_kms = desi_table['v_helio'] # Intrinsic photometry (using values without extinction) g = desi_table['SDSSg_true_nodust'] r = desi_table['SDSSr_true_nodust'] i = desi_table['SDSSi_true_nodust'] # Lupton conversions magV_nodust = g - 0.5784 * (g - r) - 0.0038 magI_nodust = r - 1.2444 * (r - i) - 0.3820 gaia_table.add_column( Column( magV_nodust, name='V_Lupton_nodust', unit=1.0, description= 'J-C V-band magnitude converted from SDSS g, gmr following Lupton 2005' )) gaia_table.add_column( Column( magI_nodust, name='I_Lupton_nodust', unit=1.0, description= 'J-C I-band magnitude converted from SDSS r, rmi following Lupton 2005' )) # Add extinction back (currently in a poor way!). If we care in detail we # should know exactly which V and I pygaia wants! if dust == 'galaxia': # Galaxia dust equations use E(B-V) and coefficients Am/E(B-V). # # E_schelgel is seletive absorption to star in fiducial bands (V and B in this case). # # Am = E_schlegel * A_over_EBV[band] # mag_true = mag_nodust + Am # # Hence: # mag_nodust = mag_true - E_schelgel*A_over_EBV[band] # Extinction coefficients for SDSS from galaxia documentation # These are Am/E(B-V) for Rv = 3.1 according to the Finkbeiner 99 law. # These give the coefficients to use with E(B-V)_Schelgel get reddenings # consistent with S&F 2011 and Schlafly 2010. ext_coeffs_ctio = {'V': 3.240, 'I': 1.962} magV = magV_nodust + desi_table['ABV'] * ext_coeffs_ctio['V'] magI = magI_nodust + desi_table['ABV'] * ext_coeffs_ctio['I'] elif dust == 'galfast': # GalFast dust equations use Ar and coefficients Am/Ar. # Am0 is total absorption to star in fiducial band (r, in this case). # # Am = Am0 * reddening[band] # mag_true = mag_nodust + Am # # Hence: # mag_nodust = mag_true - Am0*reddening[band] Ar_coeffs_ctio = {'V': 1.1800, 'I': 0.5066} magV = magV_nodust + desi_table['Ar'] * Ar_coeffs_ctio['V'] magI = magI_nodust + desi_table['Ar'] * Ar_coeffs_ctio['I'] gaia_table.add_column( Column( magV, name='V_Lupton', unit=1.0, description= 'J-C V-band magnitude converted from SDSS g, gmr following Lupton 2005, with extinction' )) gaia_table.add_column( Column( magI, name='I_Lupton', unit=1.0, description= 'J-C I-band magnitude converted from SDSS r, rmi following Lupton 2005, with extinction' )) # Gaia routines need this colour as observed (something to do with PSF size) VminI = magV - magI from pygaia.photometry.transformations import gminvFromVmini, vminGrvsFromVmini # Calculate the value of (G-V) from (V-I) # Should this be the true or extincted V-I? GmV = gminvFromVmini(VminI) GmVrvs = vminGrvsFromVmini(VminI) magG = GmV + magV magGrvs = GmVrvs + magV gaia_table.add_column( Column(magV, name='G_gaia', unit=1.0, description='Gaia G apparent magnitude (pygaia)')) gaia_table.add_column( Column(magI, name='G_gaia_rvs', unit=1.0, description='Gaia G apparent magnitude for RVS (pygaia)')) # Sky coordinates and intrinsic PMs ra = desi_table['RA'] # Degrees dec = desi_table['DEC'] # Degrees pm_ra = desi_table['pm_RA'] # mas/yr pm_dec = desi_table['pm_DEC'] # mas/yr import pygaia.astrometry.coordinates as gaia_coordinates matrix_equ_to_ecl = gaia_coordinates.Transformations.ICRS2ECL equ_to_ecl = gaia_coordinates.CoordinateTransformation(matrix_equ_to_ecl) # Note input in radians and output in radians. This is only used for input # into the proper motion error routine. ecl_lambda, ecl_beta = equ_to_ecl.transformSkyCoordinates( ra * np.pi / 180.0, dec * np.pi / 180.0) # The error in mu_alpha* and the error in mu_delta, in that order, in # micro-arcsecond/year. The * on mu_alpha* indicates # mu_alpha*=mu_alpha*cos(delta). These are in MICRO arcsec/yr so convert # to MILLI arcsec/yr. mu_alpha_star_err, mu_delta_err = gaia_astro.properMotionError( magG, VminI, ecl_beta) mu_alpha_star_err = mu_alpha_star_err / 1000.0 mu_delta_err = mu_delta_err / 1000.0 gaia_table.add_column( Column( mu_alpha_star_err, name='pm_RA_gaia_error', unit=1.0, description= 'Gaia error on proper motion in RA (mu_alpha_star; pygaia) [mas/yr]' )) gaia_table.add_column( Column( mu_delta_err, name='pm_DEC_gaia_error', unit=1.0, description= 'Gaia error on proper motion in DEC (mu_delta; pygaia) [mas/yr]')) # Error-convolved proper motions. Question here whether pm_ra from Galfast # is mu_alpha or mu_alpha_star. Give Mario the benefit of the doubt and # assume it is mu_alpha_star. GALFAST_PMRA_IS_MU_ALPHA_STAR = True if GALFAST_PMRA_IS_MU_ALPHA_STAR: RA_FIX_FACTOR = 1.0 else: RA_FIX_FACTOR = np.cos(dec * np.pi / 180.0) gaia_mu_alpha_star = np.random.normal(pm_ra * RA_FIX_FACTOR, mu_alpha_star_err) gaia_mu_delta = np.random.normal(pm_dec, mu_delta_err) gaia_table.add_column( Column( gaia_mu_alpha_star, name='pm_RA_star_gaia', unit=1.0, description= 'Proper motion in RA convolved with Gaia error (mu_alpha_star; pygaia) [mas/yr]' )) gaia_table.add_column( Column( gaia_mu_delta, name='pm_DEC_gaia', unit=1.0, description= 'Proper motion in DEC convolved with Gaia error (mu_delta; pygaia) [mas/yr]' )) # True parallax in **milli-arcsec** true_parallax_arcsec = 1.0 / d_parsecs true_parallax_milliarcsec = true_parallax_arcsec * 1e3 # Pygaia error on parallax is returned in micro-arcsec # Convert to **milli-arcsec** MICRO_TO_MILLI = 1.0 / 1e3 gaia_parallax_err_milliarcsec = gaia_astro.parallaxError( magG, VminI, ecl_beta) * MICRO_TO_MILLI # Error convolved parallax gaia_parallax_milliarcsec = np.random.normal( true_parallax_milliarcsec, gaia_parallax_err_milliarcsec) gaia_table.add_column( Column(gaia_parallax_err_milliarcsec, name='parallax_gaia_error', unit=1.0, description='Gaia error on parallax (pygaia) [mas]')) gaia_table.add_column( Column( gaia_parallax_milliarcsec, name='parallax_gaia', unit=1.0, description='Parallax convolved with Gaia error (pygaia) [mas]')) # Error convolved RV for spectype in ['G0V', 'F0V', 'K1III', 'K1IIIMP']: gaia_rv_error_kms = gaia_spectro.vradErrorSkyAvg(magV, spectype) gaia_rv_kms = np.random.normal(v_helio_kms, gaia_rv_error_kms) gaia_table.add_column( Column( gaia_rv_error_kms, name='v_helio_gaia_error_%s' % (spectype), unit=1.0, description= 'Gaia error on heliocentric radial velocity assuming star is type %s (pygaia) [km/s]' % (spectype))) gaia_table.add_column( Column( gaia_rv_kms, name='v_helio_gaia_%s' % (spectype), unit=1.0, description= 'Heliocentric radial velocity convolved with Gaia error assuming star is type %s (pygaia) [km/s]' % (spectype))) return gaia_table
def makePlot(args): """ Make the plot with parallax horizons. The plot shows V-band magnitude vs distance for a number of spectral types and over the range 5.7<G<20. In addition a set of crudely drawn contours show the points where 0.1, 1, and 10 per cent relative parallax accracy are reached. Parameters ---------- args - Command line arguments. """ distances = 10.0**np.linspace(1,6,10001) av = args['extinction'] ai = 0.479*av #Cardelli et al R=3.1 spts = ['B0I', 'B1V', 'G2V', 'K4V', 'M0V', 'M6V', 'K1III', 'M0III'] pointOnePercD = [] pointOnePercV = [] onePercD = [] onePercV = [] tenPercD = [] tenPercV = [] vabsPointOnePerc = [] vabsOnePerc = [] vabsTenPerc = [] fig=plt.figure(figsize=(11,7.8)) deltaHue = 240.0/(len(spts)-1) hues = (240.0-np.arange(len(spts))*deltaHue)/360.0 hsv=np.zeros((1,1,3)) hsv[0,0,1]=1.0 hsv[0,0,2]=0.9 for hue,spt in zip(hues, spts): hsv[0,0,0]=hue vmags = vabsFromSpt(spt)+5.0*np.log10(distances)-5.0+av vmini=vminiFromSpt(spt)+av-ai #gmags = gabsFromSpt(spt)+5.0*np.log10(distances)-5.0 gmags = vmags + gminvFromVmini(vmini) relParErr = parallaxErrorSkyAvg(gmags,vmini)*distances/1.0e6 observed = (gmags>=5.7) & (gmags<=20.0) relParErrObs = relParErr[observed] # Identify the points where the relative parallax accuracy is 0.1, 1, or 10 per cent. if (relParErrObs.min()<0.001): index = len(relParErrObs[relParErrObs<=0.001])-1 pointOnePercD.append(distances[observed][index]) pointOnePercV.append(vmags[observed][index]) vabsPointOnePerc.append(vabsFromSpt(spt)) if (relParErrObs.min()<0.01): index = len(relParErrObs[relParErrObs<=0.01])-1 onePercD.append(distances[observed][index]) onePercV.append(vmags[observed][index]) vabsOnePerc.append(vabsFromSpt(spt)) if (relParErrObs.min()<0.1): index = len(relParErrObs[relParErrObs<=0.1])-1 tenPercD.append(distances[observed][index]) tenPercV.append(vmags[observed][index]) vabsTenPerc.append(vabsFromSpt(spt)) plt.semilogx(distances[observed], vmags[observed], '-', label=spt, color=hsv_to_rgb(hsv)[0,0,:]) if (spt=='B0I'): plt.text(distances[observed][-1]-1.0e5, vmags[observed][-1], spt, horizontalalignment='right', verticalalignment='bottom', fontsize=14) else: plt.text(distances[observed][-1], vmags[observed][-1], spt, horizontalalignment='center', verticalalignment='bottom', fontsize=14) # Draw the "contours" of constant relative parallax accuracy. pointOnePercD = np.array(pointOnePercD) pointOnePercV = np.array(pointOnePercV) indices = np.argsort(vabsPointOnePerc) plt.semilogx(pointOnePercD[indices],pointOnePercV[indices],'k--') plt.text(pointOnePercD[indices][-1]*1.2,pointOnePercV[indices][-1]-2.5,"$0.1$\\%", ha='right', size=16, bbox=dict(boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0),)) onePercD = np.array(onePercD) onePercV = np.array(onePercV) indices = np.argsort(vabsOnePerc) plt.semilogx(onePercD[indices],onePercV[indices],'k--') plt.text(onePercD[indices][-1]*1.2,onePercV[indices][-1]-2.5,"$1$\\%", ha='right', size=16, bbox=dict(boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0),)) tenPercD = np.array(tenPercD) tenPercV = np.array(tenPercV) indices = np.argsort(vabsTenPerc) plt.semilogx(tenPercD[indices],tenPercV[indices],'k--') plt.text(tenPercD[indices][-1]*1.5,tenPercV[indices][-1]-2.5,"$10$\\%", ha='right', size=16, bbox=dict(boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0),)) plt.title('Parallax relative accuracy horizons ($A_V={0}$)'.format(av)) plt.xlabel('Distance [pc]') plt.ylabel('V') plt.grid() #leg=plt.legend(loc=4, fontsize=14, labelspacing=0.5) plt.ylim(5,26) basename='ParallaxHorizons' if (args['pdfOutput']): plt.savefig(basename+'.pdf') elif (args['pngOutput']): plt.savefig(basename+'.png') else: plt.show()
def makePlot(args): """ Make the plot with proper motion performance predictions. The predictions are for the TOTAL proper motion under the assumption of equal components mu_alpha* and mu_delta. :argument args: command line arguments """ gmag=np.linspace(5.7,20.0,101) vminiB1V=vminiFromSpt('B1V') vminiG2V=vminiFromSpt('G2V') vminiM6V=vminiFromSpt('M6V') vmagB1V=gmag-gminvFromVmini(vminiB1V) vmagG2V=gmag-gminvFromVmini(vminiG2V) vmagM6V=gmag-gminvFromVmini(vminiM6V) sigmualphaB1V, sigmudeltaB1V = properMotionErrorSkyAvg(gmag,vminiB1V) sigmuB1V = np.sqrt(0.5*sigmualphaB1V**2+0.5*sigmudeltaB1V**2) sigmualphaB1V, sigmudeltaB1V = properMotionMinError(gmag,vminiB1V) sigmuB1Vmin = np.sqrt(0.5*sigmualphaB1V**2+0.5*sigmudeltaB1V**2) sigmualphaB1V, sigmudeltaB1V = properMotionMaxError(gmag,vminiB1V) sigmuB1Vmax = np.sqrt(0.5*sigmualphaB1V**2+0.5*sigmudeltaB1V**2) sigmualphaG2V, sigmudeltaG2V = properMotionErrorSkyAvg(gmag,vminiG2V) sigmuG2V = np.sqrt(0.5*sigmualphaG2V**2+0.5*sigmudeltaG2V**2) sigmualphaG2V, sigmudeltaG2V = properMotionMinError(gmag,vminiG2V) sigmuG2Vmin = np.sqrt(0.5*sigmualphaG2V**2+0.5*sigmudeltaG2V**2) sigmualphaG2V, sigmudeltaG2V = properMotionMaxError(gmag,vminiG2V) sigmuG2Vmax = np.sqrt(0.5*sigmualphaG2V**2+0.5*sigmudeltaG2V**2) sigmualphaM6V, sigmudeltaM6V = properMotionErrorSkyAvg(gmag,vminiM6V) sigmuM6V = np.sqrt(0.5*sigmualphaM6V**2+0.5*sigmudeltaM6V**2) sigmualphaM6V, sigmudeltaM6V = properMotionMinError(gmag,vminiM6V) sigmuM6Vmin = np.sqrt(0.5*sigmualphaM6V**2+0.5*sigmudeltaM6V**2) sigmualphaM6V, sigmudeltaM6V = properMotionMaxError(gmag,vminiM6V) sigmuM6Vmax = np.sqrt(0.5*sigmualphaM6V**2+0.5*sigmudeltaM6V**2) fig=plt.figure(figsize=(10,6.5)) if (args['gmagAbscissa']): plt.semilogy(gmag, sigmuB1V, 'b', label='B1V') plt.semilogy(gmag, sigmuG2V, 'g', label='G2V') plt.semilogy(gmag, sigmuM6V, 'r', label='M6V') plt.xlim((5,20)) plt.ylim((1,500)) plt.legend(loc=4) else: ax=fig.add_subplot(111) plt.semilogy(vmagB1V, sigmuB1V, 'b', label='B1V') #plt.semilogy(vmagG2V, sigmuG2V, 'g', label='G2V') plt.semilogy(vmagM6V, sigmuM6V, 'r', label='M6V') plt.fill_between(vmagB1V, sigmuB1Vmin, sigmuB1Vmax, color='b', alpha=0.3) plt.fill_between(vmagM6V, sigmuM6Vmin, sigmuM6Vmax, color='r', alpha=0.3) plt.xlim((5,22.5)) plt.ylim((1,500)) plt.text(17.5,100,'B1V',color='b') plt.text(18,10,'M6V',color='r') plt.text(7,11,'calibration noise floor', size=12, bbox=dict(boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) plt.text(14.75,50,'photon noise', rotation=45, size=12, bbox=dict(boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) ax.annotate('non-uniformity\nover the sky', xy=(21.5, 80), xycoords='data', xytext=(21.5,30), textcoords='data', ha='center', size='12', bbox=dict(boxstyle="round,pad=0.3",ec=(0,0,0),fc=(1,1,1)), arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='top', ) ax.annotate('', xy=(21.5, 170), xycoords='data', xytext=(21.5,380), textcoords='data', ha='center', size='12', arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='bottom', ) plt.xticks(np.arange(6,24,2)) ax = plt.gca().yaxis ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) plt.ticklabel_format(axis='y',style='plain') plt.grid(which='both') plt.xlabel('$V$ [mag]') plt.ylabel('End-of-mission $\\sigma_\\mu$ [$\mu$as/yr]') basename = 'ProperMotionErrors' if (args['pdfOutput']): plt.savefig(basename+'.pdf') elif (args['pngOutput']): plt.savefig(basename+'.png') else: plt.show()
def makePlot(args): """ Make the plot with parallax performance predictions. :argument args: command line arguments """ gmag = np.linspace(5.7, 20.0, 101) vminiB1V = vminiFromSpt('B1V') vminiG2V = vminiFromSpt('G2V') vminiM6V = vminiFromSpt('M6V') vmagB1V = gmag - gminvFromVmini(vminiB1V) vmagG2V = gmag - gminvFromVmini(vminiG2V) vmagM6V = gmag - gminvFromVmini(vminiM6V) sigparB1V = parallaxErrorSkyAvg(gmag, vminiB1V) sigparB1Vmin = parallaxMinError(gmag, vminiB1V) sigparB1Vmax = parallaxMaxError(gmag, vminiB1V) sigparG2V = parallaxErrorSkyAvg(gmag, vminiG2V) sigparG2Vmin = parallaxMinError(gmag, vminiG2V) sigparG2Vmax = parallaxMaxError(gmag, vminiG2V) sigparM6V = parallaxErrorSkyAvg(gmag, vminiM6V) sigparM6Vmin = parallaxMinError(gmag, vminiM6V) sigparM6Vmax = parallaxMaxError(gmag, vminiM6V) fig = plt.figure(figsize=(10, 6.5)) if (args['gmagAbscissa']): plt.semilogy(gmag, sigparB1V, 'b', label='B1V') plt.semilogy(gmag, sigparG2V, 'g', label='G2V') plt.semilogy(gmag, sigparM6V, 'r', label='M6V') plt.xlim((5, 20)) plt.ylim((4, 1000)) plt.legend(loc=4) plt.xlabel('$G$ [mag]') else: ax = fig.add_subplot(111) plt.semilogy(vmagB1V, sigparB1V, 'b', label='B1V') #plt.semilogy(vmagG2V, sigparG2V, 'g', label='G2V') plt.semilogy(vmagM6V, sigparM6V, 'r', label='M6V') plt.fill_between(vmagB1V, sigparB1Vmin, sigparB1Vmax, color='b', alpha=0.3) plt.fill_between(vmagM6V, sigparM6Vmin, sigparM6Vmax, color='r', alpha=0.3) plt.xlim((5, 22.5)) plt.ylim((4, 1000)) plt.text(17.2, 190, 'B1V', color='b') plt.text(18, 20, 'M6V', color='r') plt.xlabel('$V$ [mag]') plt.text(7, 17, 'calibration noise floor', size=12, bbox=dict( boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) plt.text(14.75, 80, 'photon noise', rotation=45, size=12, bbox=dict( boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) ax.annotate( 'non-uniformity\nover the sky', xy=(21.5, 320), xycoords='data', xytext=(21.5, 80), textcoords='data', ha='center', size='12', bbox=dict(boxstyle="round,pad=0.3", ec=(0, 0, 0), fc=(1, 1, 1)), arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='top', ) ax.annotate( '', xy=(21.5, 500), xycoords='data', xytext=(21.5, 950), textcoords='data', ha='center', size='12', arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='bottom', ) plt.xticks(np.arange(6, 24, 2)) ax = plt.gca().yaxis ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) plt.ticklabel_format(axis='y', style='plain') plt.grid(which='both') plt.ylabel('End-of-mission parallax standard error [$\mu$as]') if (args['pdfOutput']): plt.savefig('ParallaxErrors.pdf') elif (args['pngOutput']): plt.savefig('ParallaxErrors.png') else: plt.show()
def makePlot(args): """ Make the plot with proper motion performance predictions. The predictions are for the TOTAL proper motion under the assumption of equal components mu_alpha* and mu_delta. :argument args: command line arguments """ gmag = np.linspace(5.7, 20.0, 101) vminiB1V = vminiFromSpt('B1V') vminiG2V = vminiFromSpt('G2V') vminiM6V = vminiFromSpt('M6V') vmagB1V = gmag - gminvFromVmini(vminiB1V) vmagG2V = gmag - gminvFromVmini(vminiG2V) vmagM6V = gmag - gminvFromVmini(vminiM6V) sigmualphaB1V, sigmudeltaB1V = properMotionErrorSkyAvg(gmag, vminiB1V) sigmuB1V = np.sqrt(0.5 * sigmualphaB1V**2 + 0.5 * sigmudeltaB1V**2) sigmualphaB1V, sigmudeltaB1V = properMotionMinError(gmag, vminiB1V) sigmuB1Vmin = np.sqrt(0.5 * sigmualphaB1V**2 + 0.5 * sigmudeltaB1V**2) sigmualphaB1V, sigmudeltaB1V = properMotionMaxError(gmag, vminiB1V) sigmuB1Vmax = np.sqrt(0.5 * sigmualphaB1V**2 + 0.5 * sigmudeltaB1V**2) sigmualphaG2V, sigmudeltaG2V = properMotionErrorSkyAvg(gmag, vminiG2V) sigmuG2V = np.sqrt(0.5 * sigmualphaG2V**2 + 0.5 * sigmudeltaG2V**2) sigmualphaG2V, sigmudeltaG2V = properMotionMinError(gmag, vminiG2V) sigmuG2Vmin = np.sqrt(0.5 * sigmualphaG2V**2 + 0.5 * sigmudeltaG2V**2) sigmualphaG2V, sigmudeltaG2V = properMotionMaxError(gmag, vminiG2V) sigmuG2Vmax = np.sqrt(0.5 * sigmualphaG2V**2 + 0.5 * sigmudeltaG2V**2) sigmualphaM6V, sigmudeltaM6V = properMotionErrorSkyAvg(gmag, vminiM6V) sigmuM6V = np.sqrt(0.5 * sigmualphaM6V**2 + 0.5 * sigmudeltaM6V**2) sigmualphaM6V, sigmudeltaM6V = properMotionMinError(gmag, vminiM6V) sigmuM6Vmin = np.sqrt(0.5 * sigmualphaM6V**2 + 0.5 * sigmudeltaM6V**2) sigmualphaM6V, sigmudeltaM6V = properMotionMaxError(gmag, vminiM6V) sigmuM6Vmax = np.sqrt(0.5 * sigmualphaM6V**2 + 0.5 * sigmudeltaM6V**2) fig = plt.figure(figsize=(10, 6.5)) if (args['gmagAbscissa']): plt.semilogy(gmag, sigmuB1V, 'b', label='B1V') plt.semilogy(gmag, sigmuG2V, 'g', label='G2V') plt.semilogy(gmag, sigmuM6V, 'r', label='M6V') plt.xlim((5, 20)) plt.ylim((1, 500)) plt.legend(loc=4) else: ax = fig.add_subplot(111) plt.semilogy(vmagB1V, sigmuB1V, 'b', label='B1V') #plt.semilogy(vmagG2V, sigmuG2V, 'g', label='G2V') plt.semilogy(vmagM6V, sigmuM6V, 'r', label='M6V') plt.fill_between(vmagB1V, sigmuB1Vmin, sigmuB1Vmax, color='b', alpha=0.3) plt.fill_between(vmagM6V, sigmuM6Vmin, sigmuM6Vmax, color='r', alpha=0.3) plt.xlim((5, 22.5)) plt.ylim((1, 500)) plt.text(17.5, 100, 'B1V', color='b') plt.text(18, 10, 'M6V', color='r') plt.text(7, 11, 'calibration noise floor', size=12, bbox=dict( boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) plt.text(14.75, 50, 'photon noise', rotation=45, size=12, bbox=dict( boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) ax.annotate( 'non-uniformity\nover the sky', xy=(21.5, 80), xycoords='data', xytext=(21.5, 30), textcoords='data', ha='center', size='12', bbox=dict(boxstyle="round,pad=0.3", ec=(0, 0, 0), fc=(1, 1, 1)), arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='top', ) ax.annotate( '', xy=(21.5, 170), xycoords='data', xytext=(21.5, 380), textcoords='data', ha='center', size='12', arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='bottom', ) plt.xticks(np.arange(6, 24, 2)) ax = plt.gca().yaxis ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) plt.ticklabel_format(axis='y', style='plain') plt.grid(which='both') plt.xlabel('$V$ [mag]') plt.ylabel('End-of-mission $\\sigma_\\mu$ [$\mu$as/yr]') basename = 'ProperMotionErrors' if (args['pdfOutput']): plt.savefig(basename + '.pdf') elif (args['pngOutput']): plt.savefig(basename + '.png') else: plt.show()
def main(argv): parser = argparse.ArgumentParser( description= "This Script downloads a besancon model including include_kinematics using the astroquery interface. Gaia DR2 parallax and proper motion sky-averaged uncertainties are derived using pygaia. Random errors corresponding to Gaia DR2 expectations can be added to the parallaxes and distances of the model output." ) parser.add_argument('email', help='Your valid email address.') parser.add_argument('--ra_deg', type=float, default=10., help='RA in degrees') parser.add_argument('--dec_deg', type=float, default=0., help='Dec in degrees') parser.add_argument('--field_size_squaredegree', type=float, default=0.05, help='Field size in squaredegrees.') parser.add_argument('--data_dir', type=str, default='', help='Path to directory for table saving') parser.add_argument('--overwrite', type=bool, default=False, help='Overwrite download from besancon server.') parser.add_argument( '--add_random_gaia_errors', type=bool, default=False, help= 'Add random errors to parallax and PM assuming Gaia DR2 performances.') parser.add_argument( '--random_seed', type=int, default=None, help='numpy random seed for error simulation. Allows for repeatability.' ) # parser.add_argument('--argument_dict', type=, default=None, # help='Dictionary of arguments passed to Besancon.query. See Besancon.query documentation for allowed values and format.') parser.add_argument( '--vmag_upper_limit', type=float, default=None, help='V mag upper limit passed to Besancon.query. Default is 18') args = parser.parse_args(argv) email = args.email # central pointing and field size ra_deg = args.ra_deg dec_deg = args.dec_deg field_size_squaredegree = args.field_size_squaredegree data_dir = args.data_dir overwrite = args.overwrite random_seed = args.random_seed add_random_gaia_errors = args.add_random_gaia_errors # argument_dict = args.argument_dict # vmag_limits = args.vmag_limits vmag_upper_limit = args.vmag_upper_limit galactic_latitude_deg = None galactic_longitude_deg = None if (galactic_latitude_deg is None) and (galactic_longitude_deg is None): equatorial_coordinates = SkyCoord(ra=ra_deg * u.deg, dec=dec_deg * u.deg) galactic_longitude_deg = equatorial_coordinates.galactic.l.value galactic_latitude_deg = equatorial_coordinates.galactic.b.value include_kinematics = True pm_in_lb = False # flag to obtain proper motions in galactic coordinates instead of equatorial # include_kinematics options kwd = {} if (include_kinematics): kwd['cinem'] = 1 kwd['sc'] = [ [0, 0, 0] ] * 15 # changed default *9 to *15 to allow for kinematics to be downloaded # note: if you leave klee at zero you get no kinematics if (pm_in_lb): kwd['klee'] = 2 #l/b else: kwd['klee'] = 1 #ra/dec # merge two dictionaries of arguments # if argument_dict is not None: # kwd = {**kwd, **argument_dict} # if vmag_limits is not None: # kwd['mag_limits'] = {'V': vmag_limits} # execute the query and save into astropy table on disk table_file = os.path.join( data_dir, 'besancon_table_{:3.2f}_{:3.2f}_{:3.2f}.csv'.format( galactic_longitude_deg, galactic_latitude_deg, field_size_squaredegree)) if (not os.path.isfile(table_file)) | (overwrite): if vmag_upper_limit is not None: # print(vmag_upper_limit) mag_limits = {'V': (10, vmag_upper_limit)} besancon_model = Besancon.query(glon=galactic_longitude_deg, glat=galactic_latitude_deg, email=email, retrieve_file=False, area=field_size_squaredegree, mag_limits=mag_limits, **kwd) # print('Faintest V magnitude = {}'.format(np.max(besancon_model['V']))) else: besancon_model = Besancon.query(glon=galactic_longitude_deg, glat=galactic_latitude_deg, email=email, retrieve_file=False, area=field_size_squaredegree, **kwd) besancon_model.write(table_file, format='ascii.fixed_width', delimiter=',', bookend=False) else: besancon_model = Table.read(table_file, format='ascii.basic', delimiter=',') dr2_table_file = table_file.replace('besancon_', 'besancon_gaia_dr2_') # compute Gaia magnitude and color besancon_model['G-V'] = transformations.gminvFromVmini( besancon_model['V-I']) besancon_model['Gmag'] = besancon_model['G-V'] + besancon_model['V'] besancon_model['BP-RP'] = vminusi_to_gaiacolor(besancon_model['V-I']) besancon_model['BP'], besancon_model['RP'] = get_gaia_bp_and_rp( besancon_model['V'], besancon_model['V-I']) # print(besancon_model['BP']-besancon_model['RP'] - besancon_model['BP-RP']) # compute expected DR2 errors, parallaxErrorSkyAvg is in microarcsec dr2_offset = -(60. - 22.) / 12. besancon_model['properMotionErrorSkyAvg_dr2_ra_maspyr'], besancon_model[ 'properMotionErrorSkyAvg_dr2_dec_maspyr'] = np.array( properMotionErrorSkyAvg(besancon_model['Gmag'].data, besancon_model['V-I'].data, extension=dr2_offset)) / 1000. besancon_model['parallaxErrorSkyAvg_dr2_mas'] = np.array( parallaxErrorSkyAvg(besancon_model['Gmag'], besancon_model['V-I'], extension=dr2_offset)) / 1000. besancon_model['parallax_mas'] = 1. / besancon_model[ 'Dist'] # 'Dist' is in kpc # coordinates are constant and equal to the central pointing in the standard output galactic_coords = SkyCoord('galactic', l=besancon_model['l'], b=besancon_model['b'], unit='deg') besancon_model['ra_deg'] = galactic_coords.icrs.ra.value besancon_model['dec_deg'] = galactic_coords.icrs.dec.value if pm_in_lb is False: # mux,muy are in arcsec/century besancon_model['pm_ra*_maspyr'] = besancon_model['mux'] * 1000 / 100. besancon_model['pm_dec_maspyr'] = besancon_model['muy'] * 1000 / 100. if add_random_gaia_errors: # add random errors to parallax and PM assuming Gaia DR2 performances if random_seed is not None: np.random.seed(random_seed) besancon_model['parallax_mas'] += ( np.random.normal(0., 1, len(besancon_model)) * besancon_model['parallaxErrorSkyAvg_dr2_mas']) if random_seed is not None: np.random.seed(random_seed + 1) besancon_model['pm_ra*_maspyr'] += ( np.random.normal(0., 1, len(besancon_model)) * besancon_model['properMotionErrorSkyAvg_dr2_ra_maspyr']) if random_seed is not None: np.random.seed(random_seed + 2) besancon_model['pm_dec_maspyr'] += ( np.random.normal(0., 1, len(besancon_model)) * besancon_model['properMotionErrorSkyAvg_dr2_dec_maspyr']) besancon_model.meta = {} besancon_model.write(dr2_table_file, format='ascii.fixed_width', delimiter=',', bookend=False) print('Besancon model and Gaia DR2 performance simulation written to {}'. format(dr2_table_file))
def makePlot(args): """ Make the plot with parallax performance predictions. :argument args: command line arguments """ gmag=np.linspace(5.7,20.0,101) vminiB1V=vminiFromSpt('B1V') vminiG2V=vminiFromSpt('G2V') vminiM6V=vminiFromSpt('M6V') vmagB1V=gmag-gminvFromVmini(vminiB1V) vmagG2V=gmag-gminvFromVmini(vminiG2V) vmagM6V=gmag-gminvFromVmini(vminiM6V) sigparB1V=parallaxErrorSkyAvg(gmag,vminiB1V) sigparB1Vmin=parallaxMinError(gmag,vminiB1V) sigparB1Vmax=parallaxMaxError(gmag,vminiB1V) sigparG2V=parallaxErrorSkyAvg(gmag,vminiG2V) sigparG2Vmin=parallaxMinError(gmag,vminiG2V) sigparG2Vmax=parallaxMaxError(gmag,vminiG2V) sigparM6V=parallaxErrorSkyAvg(gmag,vminiM6V) sigparM6Vmin=parallaxMinError(gmag,vminiM6V) sigparM6Vmax=parallaxMaxError(gmag,vminiM6V) fig=plt.figure(figsize=(10,6.5)) if (args['gmagAbscissa']): plt.semilogy(gmag, sigparB1V, 'b', label='B1V') plt.semilogy(gmag, sigparG2V, 'g', label='G2V') plt.semilogy(gmag, sigparM6V, 'r', label='M6V') plt.xlim((5,20)) plt.ylim((4,1000)) plt.legend(loc=4) plt.xlabel('$G$ [mag]') else: ax=fig.add_subplot(111) plt.semilogy(vmagB1V, sigparB1V, 'b', label='B1V') #plt.semilogy(vmagG2V, sigparG2V, 'g', label='G2V') plt.semilogy(vmagM6V, sigparM6V, 'r', label='M6V') plt.fill_between(vmagB1V, sigparB1Vmin, sigparB1Vmax, color='b', alpha=0.3) plt.fill_between(vmagM6V, sigparM6Vmin, sigparM6Vmax, color='r', alpha=0.3) plt.xlim((5,22.5)) plt.ylim((4,1000)) plt.text(17.2,190,'B1V',color='b') plt.text(18,20,'M6V',color='r') plt.xlabel('$V$ [mag]') plt.text(7,17,'calibration noise floor', size=12, bbox=dict(boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) plt.text(14.75,80,'photon noise', rotation=45, size=12, bbox=dict(boxstyle="round,pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) ax.annotate('non-uniformity\nover the sky', xy=(21.5, 320), xycoords='data', xytext=(21.5,80), textcoords='data', ha='center', size='12', bbox=dict(boxstyle="round,pad=0.3",ec=(0,0,0),fc=(1,1,1)), arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='top', ) ax.annotate('', xy=(21.5, 500), xycoords='data', xytext=(21.5,950), textcoords='data', ha='center', size='12', arrowprops=dict(facecolor='black', shrink=0.15, width=1, headwidth=6), horizontalalignment='right', verticalalignment='bottom', ) plt.xticks(np.arange(6,24,2)) ax = plt.gca().yaxis ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) plt.ticklabel_format(axis='y',style='plain') plt.grid(which='both') plt.ylabel('End-of-mission parallax standard error [$\mu$as]') if (args['pdfOutput']): plt.savefig('ParallaxErrors.pdf') elif (args['pngOutput']): plt.savefig('ParallaxErrors.png') else: plt.show()
def makePlot(args): """ Make the plot with photometry performance predictions. :argument args: command line arguments """ gmag = np.linspace(3.0, 20.0, 171) vmini = args['vmini'] vmag = gmag - gminvFromVmini(vmini) if args['eom']: sigmaG = gMagnitudeErrorEoM(gmag) sigmaGBp = bpMagnitudeErrorEoM(gmag, vmini) sigmaGRp = rpMagnitudeErrorEoM(gmag, vmini) yminmax = (1.0 - 4, 0.1) else: sigmaG = gMagnitudeError(gmag) sigmaGBp = bpMagnitudeError(gmag, vmini) sigmaGRp = rpMagnitudeError(gmag, vmini) yminmax = (1.0 - 4, 1) fig = plt.figure(figsize=(10, 6.5)) if (args['vmagAbscissa']): plt.semilogy(vmag, sigmaG, 'k', label='$\\sigma_G$') plt.semilogy(vmag, sigmaGBp, 'b', label='$\\sigma_{G_\\mathrm{BP}}$' + ' for $(V-I)={0}$'.format(vmini)) plt.semilogy(vmag, sigmaGRp, 'r', label='$\\sigma_{G_\\mathrm{RP}}$' + ' for $(V-I)={0}$'.format(vmini)) plt.xlim((6, 20)) #plt.ylim(yminmax) plt.legend(loc=0) plt.xlabel('$V$ [mag]') else: ax = fig.add_subplot(111) plt.semilogy(gmag, sigmaG, 'k', label='$\\sigma_G$') plt.semilogy(gmag, sigmaGBp, 'b', label='$\\sigma_{G_\\mathrm{BP}}$' + ' for $(V-I)={0}$'.format(vmini)) plt.semilogy(gmag, sigmaGRp, 'r', label='$\\sigma_{G_\\mathrm{RP}}$' + ' for $(V-I)={0}$'.format(vmini)) plt.xlim((6, 20)) #plt.ylim(yminmax) plt.legend(loc=0) plt.xlabel('$G$ [mag]') plt.xticks(np.arange(6, 20, 2)) ax = plt.gca().yaxis #ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) #plt.ticklabel_format(axis='y',style='plain') plt.grid(which='both') plt.ylabel('Photometric error [mag]') if args['eom']: plt.title( 'End-of-mission mean photometry: sky averaged errors for $(V-I)={0}$' .format(vmini), fontsize=14) else: plt.title( 'Single-FoV-transit photometry: sky averaged errors for $(V-I)={0}$' .format(vmini), fontsize=14) basename = 'PhotometricErrors' if (args['pdfOutput']): plt.savefig(basename + '.pdf') elif (args['pngOutput']): plt.savefig(basename + '.png') else: plt.show()
def makePlot(args): """ Make the plot with photometry performance predictions. :argument args: command line arguments """ gmag=np.linspace(3.0,20.0,171) vmini = args['vmini'] vmag=gmag-gminvFromVmini(vmini) if args['eom']: sigmaG = gMagnitudeErrorEoM(gmag) sigmaGBp = bpMagnitudeErrorEoM(gmag, vmini) sigmaGRp = rpMagnitudeErrorEoM(gmag, vmini) yminmax = (1.0-4,0.1) else: sigmaG = gMagnitudeError(gmag) sigmaGBp = bpMagnitudeError(gmag, vmini) sigmaGRp = rpMagnitudeError(gmag, vmini) yminmax = (1.0-4,1) fig=plt.figure(figsize=(10,6.5)) if (args['vmagAbscissa']): plt.semilogy(vmag, sigmaG, 'k', label='$\\sigma_G$') plt.semilogy(vmag, sigmaGBp, 'b', label='$\\sigma_{G_\\mathrm{BP}}$'+' for $(V-I)={0}$'.format(vmini)) plt.semilogy(vmag, sigmaGRp, 'r', label='$\\sigma_{G_\\mathrm{RP}}$'+' for $(V-I)={0}$'.format(vmini)) plt.xlim((6,20)) #plt.ylim(yminmax) plt.legend(loc=0) plt.xlabel('$V$ [mag]') else: ax=fig.add_subplot(111) plt.semilogy(gmag, sigmaG, 'k', label='$\\sigma_G$') plt.semilogy(gmag, sigmaGBp, 'b', label='$\\sigma_{G_\\mathrm{BP}}$'+' for $(V-I)={0}$'.format(vmini)) plt.semilogy(gmag, sigmaGRp, 'r', label='$\\sigma_{G_\\mathrm{RP}}$'+' for $(V-I)={0}$'.format(vmini)) plt.xlim((6,20)) #plt.ylim(yminmax) plt.legend(loc=0) plt.xlabel('$G$ [mag]') plt.xticks(np.arange(6,20,2)) ax = plt.gca().yaxis #ax.set_major_formatter(matplotlib.ticker.ScalarFormatter()) #plt.ticklabel_format(axis='y',style='plain') plt.grid(which='both') plt.ylabel('Photometric error [mag]') if args['eom']: plt.title('End-of-mission mean photometry: sky averaged errors for $(V-I)={0}$'.format(vmini), fontsize=14) else: plt.title('Single-FoV-transit photometry: sky averaged errors for $(V-I)={0}$'.format(vmini), fontsize=14) basename = 'PhotometricErrors' if (args['pdfOutput']): plt.savefig(basename+'.pdf') elif (args['pngOutput']): plt.savefig(basename+'.png') else: plt.show()
def makePlot(args): """ Make the plot with parallax horizons. The plot shows V-band magnitude vs distance for a number of spectral types and over the range 5.7<G<20. In addition a set of crudely drawn contours show the points where 0.1, 1, and 10 per cent relative parallax accracy are reached. Parameters ---------- args - Command line arguments. """ distances = 10.0**np.linspace(1, 6, 10001) av = args['extinction'] ai = 0.479 * av #Cardelli et al R=3.1 spts = ['B0I', 'B1V', 'G2V', 'K4V', 'M0V', 'M6V', 'K1III', 'M0III'] pointOnePercD = [] pointOnePercV = [] onePercD = [] onePercV = [] tenPercD = [] tenPercV = [] vabsPointOnePerc = [] vabsOnePerc = [] vabsTenPerc = [] fig = plt.figure(figsize=(11, 7.8)) deltaHue = 240.0 / (len(spts) - 1) hues = (240.0 - np.arange(len(spts)) * deltaHue) / 360.0 hsv = np.zeros((1, 1, 3)) hsv[0, 0, 1] = 1.0 hsv[0, 0, 2] = 0.9 for hue, spt in zip(hues, spts): hsv[0, 0, 0] = hue vmags = vabsFromSpt(spt) + 5.0 * np.log10(distances) - 5.0 + av vmini = vminiFromSpt(spt) + av - ai #gmags = gabsFromSpt(spt)+5.0*np.log10(distances)-5.0 gmags = vmags + gminvFromVmini(vmini) relParErr = parallaxErrorSkyAvg(gmags, vmini) * distances / 1.0e6 observed = (gmags >= 5.7) & (gmags <= 20.0) relParErrObs = relParErr[observed] # Identify the points where the relative parallax accuracy is 0.1, 1, or 10 per cent. if (relParErrObs.min() < 0.001): index = len(relParErrObs[relParErrObs <= 0.001]) - 1 pointOnePercD.append(distances[observed][index]) pointOnePercV.append(vmags[observed][index]) vabsPointOnePerc.append(vabsFromSpt(spt)) if (relParErrObs.min() < 0.01): index = len(relParErrObs[relParErrObs <= 0.01]) - 1 onePercD.append(distances[observed][index]) onePercV.append(vmags[observed][index]) vabsOnePerc.append(vabsFromSpt(spt)) if (relParErrObs.min() < 0.1): index = len(relParErrObs[relParErrObs <= 0.1]) - 1 tenPercD.append(distances[observed][index]) tenPercV.append(vmags[observed][index]) vabsTenPerc.append(vabsFromSpt(spt)) plt.semilogx(distances[observed], vmags[observed], '-', label=spt, color=hsv_to_rgb(hsv)[0, 0, :]) if (spt == 'B0I'): plt.text(distances[observed][-1] - 1.0e5, vmags[observed][-1], spt, horizontalalignment='right', verticalalignment='bottom', fontsize=14) else: plt.text(distances[observed][-1], vmags[observed][-1], spt, horizontalalignment='center', verticalalignment='bottom', fontsize=14) # Draw the "contours" of constant relative parallax accuracy. pointOnePercD = np.array(pointOnePercD) pointOnePercV = np.array(pointOnePercV) indices = np.argsort(vabsPointOnePerc) plt.semilogx(pointOnePercD[indices], pointOnePercV[indices], 'k--') plt.text(pointOnePercD[indices][-1] * 1.2, pointOnePercV[indices][-1] - 2.5, "$0.1$\\%", ha='right', size=16, bbox=dict( boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) onePercD = np.array(onePercD) onePercV = np.array(onePercV) indices = np.argsort(vabsOnePerc) plt.semilogx(onePercD[indices], onePercV[indices], 'k--') plt.text(onePercD[indices][-1] * 1.2, onePercV[indices][-1] - 2.5, "$1$\\%", ha='right', size=16, bbox=dict( boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) tenPercD = np.array(tenPercD) tenPercV = np.array(tenPercV) indices = np.argsort(vabsTenPerc) plt.semilogx(tenPercD[indices], tenPercV[indices], 'k--') plt.text(tenPercD[indices][-1] * 1.5, tenPercV[indices][-1] - 2.5, "$10$\\%", ha='right', size=16, bbox=dict( boxstyle="round, pad=0.3", ec=(0.0, 0.0, 0.0), fc=(1.0, 1.0, 1.0), )) plt.title('Parallax relative accuracy horizons ($A_V={0}$)'.format(av)) plt.xlabel('Distance [pc]') plt.ylabel('V') plt.grid() #leg=plt.legend(loc=4, fontsize=14, labelspacing=0.5) plt.ylim(5, 26) basename = 'ParallaxHorizons' if (args['pdfOutput']): plt.savefig(basename + '.pdf') elif (args['pngOutput']): plt.savefig(basename + '.png') else: plt.show()