In [1]:
% matplotlib inline
from __future__ import (division,
print_function)
import os
import sys
import copy
import glob
import fnmatch
import warnings
import collections
import numpy as np
import scipy
try:
from scipy.stats import scoreatpercentile
except:
scoreatpercentile = False
from scipy.interpolate import interp1d
from scipy.ndimage import gaussian_filter
import cPickle as pickle
# Astropy
from astropy.io import fits
from astropy import units as u
from astropy.stats import sigma_clip
from astropy.table import Table, Column, join
from astropy.utils.console import ProgressBar
from astropy.convolution import convolve, Box1DKernel
# AstroML
from astroML.plotting import hist
from astroML.density_estimation import KNeighborsDensity
try:
from sklearn.neighbors import KernelDensity
use_sklearn_KDE = True
except:
import warnings
warnings.warn("KDE will be removed in astroML version 0.3. Please "
"upgrade to scikit-learn 0.14+ and use "
"sklearn.neighbors.KernelDensity.", DeprecationWarning)
from astroML.density_estimation import KDE
use_sklearn_KDE = False
from sklearn.neighbors import KDTree
from sklearn.neighbors import BallTree
# Matplotlib related
import matplotlib as mpl
mpl.style.use('classic')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import Ellipse
from matplotlib.ticker import NullFormatter, MaxNLocator, FormatStrFormatter
from matplotlib.collections import PatchCollection
# Personal
import hscUtils as hUtil
# Cosmology
import cosmology
c=cosmology.Cosmo(H0=70.0, omega_m=0.3, omega_l=0.7, flat=1)
import emcee
import corner
# Color map
from palettable.colorbrewer.sequential import Greys_9, OrRd_9, Blues_9, Purples_9, YlGn_9
BLK = Greys_9.mpl_colormap
ORG = OrRd_9.mpl_colormap
BLU = Blues_9.mpl_colormap
GRN = YlGn_9.mpl_colormap
PUR = Purples_9.mpl_colormap
# Personal tools
from hscUtils import songPlotSetup, removeIsNullCol
from hscUtils import confidence_interval, ma_confidence_interval_1d, confidence_interval_1d
## Constants
# SDSS pivot wavelength
sdss_u_pivot = 3551.0
sdss_g_pivot = 4686.0
sdss_r_pivot = 6165.0
sdss_i_pivot = 7481.0
sdss_z_pivot = 8931.0
# HSC pivot wavelength
hsc_g_pivot = 4782.2
hsc_r_pivot = 6101.7
hsc_i_pivot = 7648.0
hsc_z_pivot = 8883.0
hsc_y_pivot = 9750.8
hscFiltWave = np.asarray([hsc_g_pivot, hsc_r_pivot, hsc_i_pivot, hsc_z_pivot, hsc_y_pivot])
"""
Absolute magnitude of the Sun in HSC filters
Right now, just use the DES filters
"""
SUN_G = 5.08
SUN_R = 4.62
SUN_I = 4.52
SUN_Z = 4.52
SUN_Y = 4.51
# Solar stellar metallicity
Z_SUN = 0.02
# definitions for the axes
left, width = 0.15, 0.64
right = left + width
bottom, height = 0.13, 0.86
bottom_h = left_h = left + width + 0.02
recScat = [0.16, 0.11, 0.59, 0.88]
recHist = [0.75, 0.11, 0.24, 0.88]
SBP1 = [0.124, 0.085, 0.865, 0.33]
SBP2 = [0.124, 0.41, 0.865, 0.55]
EC1 = [0.19, 0.14, 0.65, 0.65]
EC2 = [0.19, 0.79, 0.65, 0.18]
EC3 = [0.84, 0.14, 0.157, 0.65]
REC = [0.12, 0.11, 0.87, 0.87]
COG1 = [0.143, 0.10, 0.850, 0.43]
COG2 = [0.143, 0.53, 0.850, 0.43]
# Universal RSMA array
RSMA_COMMON = np.arange(0.4, 4.2, 0.01)
RR50_COMMON = np.arange(0.0, 9.0, 0.01)
EMPTY = (RSMA_COMMON * np.nan)
# Color
BLUE0 = "#92c5de"
BLUE1 = "#0571b0"
RED0 = "#f4a582"
RED1 = "#ca0020"
PURPLE0 = '#af8dc3'
PURPLE1 = '#762a83'
BROWN0 = '#bf812d'
BROWN1 = '#543005'
GREEN0 = '#7fbf7b'
GREEN1 = '#1b7837'
# Color maps for different filters
from palettable.colorbrewer.sequential import Blues_9, Greens_9, Reds_9, Purples_9, Greys_9
GCMAP = Blues_9.mpl_colormap
RCMAP = Greens_9.mpl_colormap
ICMAP = Reds_9.mpl_colormap
ZCMAP = Purples_9.mpl_colormap
YCMAP = Greys_9.mpl_colormap
# 3-sigma
SIGMA1 = 0.3173
SIGMA2 = 0.0455
SIGMA3 = 0.0027
#import seaborn as sns
#sns.set(color_codes=False)
In [2]:
# Location of the data
homeDir = os.getenv('HOME')
synpipeDir = os.path.join(homeDir, 'astro4/synpipe/')
sampleDir = os.path.join(synpipeDir, 'sample/cosmos')
# Samples
#cosPhoFile = os.path.join(sampleDir, 'cosmos_mag25.2_shuang_photo.fits')
#cosHscFile = os.path.join(sampleDir, 'cosmos_mag25.2_shuang_photo_hscmatch.fits')
#cosPho = Table.read(cosPhoFile, format='fits')
#cosHsc = Table.read(cosHscFile, format='fits')
# Outputs
figDir = os.path.join(synpipeDir, 'figure')
outDir = os.path.join(synpipeDir, 'outputs')
inDir = os.path.join(synpipeDir, 'inputs')
starDir = os.path.join(outDir, 'star')
galaxyDir = os.path.join(outDir, 'galaxy')
In [3]:
glob.glob(inDir + '/*star*')
Out[3]:
In [4]:
glob.glob(starDir + '/*syn.fits')
Out[4]:
In [4]:
inputG1 = Table.read(os.path.join(inDir, 'star_8764_HSC-G.fits'), format='fits')
inputG2 = Table.read(os.path.join(inDir, 'star_9699_HSC-G.fits'), format='fits')
inputR1 = Table.read(os.path.join(inDir, 'star_8764_HSC-R.fits'), format='fits')
inputR2 = Table.read(os.path.join(inDir, 'star_9699_HSC-R.fits'), format='fits')
inputI1 = Table.read(os.path.join(inDir, 'star_8764_HSC-I.fits'), format='fits')
inputI2 = Table.read(os.path.join(inDir, 'star_9699_HSC-I.fits'), format='fits')
inputZ1 = Table.read(os.path.join(inDir, 'star_8764_HSC-Z.fits'), format='fits')
inputZ2 = Table.read(os.path.join(inDir, 'star_9699_HSC-Z.fits'), format='fits')
inputY1 = Table.read(os.path.join(inDir, 'star_8764_HSC-Y.fits'), format='fits')
inputY2 = Table.read(os.path.join(inDir, 'star_9699_HSC-Y.fits'), format='fits')
In [8]:
print(inputG1.colnames)
In [5]:
print(len(inputG1), len(inputG2))
In [5]:
starG1 = os.path.join(starDir, 'star1_HSC-G_syn.fits')
starR1 = os.path.join(starDir, 'star1_HSC-R_syn.fits')
starI1 = os.path.join(starDir, 'star1_HSC-I_syn.fits')
starZ1 = os.path.join(starDir, 'star1_HSC-Z_syn.fits')
starY1 = os.path.join(starDir, 'star1_HSC-Y_syn.fits')
starG2 = os.path.join(starDir, 'star2_HSC-G_syn.fits')
starR2 = os.path.join(starDir, 'star2_HSC-R_syn.fits')
starI2 = os.path.join(starDir, 'star2_HSC-I_syn.fits')
starZ2 = os.path.join(starDir, 'star2_HSC-Z_syn.fits')
starY2 = os.path.join(starDir, 'star2_HSC-Y_syn.fits')
In [6]:
catG1 = Table.read(starG1, format='fits')
catR1 = Table.read(starR1, format='fits')
catI1 = Table.read(starI1, format='fits')
catZ1 = Table.read(starZ1, format='fits')
catY1 = Table.read(starY1, format='fits')
catG2 = Table.read(starG2, format='fits')
catR2 = Table.read(starR2, format='fits')
catI2 = Table.read(starI2, format='fits')
catZ2 = Table.read(starZ2, format='fits')
catY2 = Table.read(starY2, format='fits')
In [7]:
oriG1 = os.path.join(starDir, 'star1_HSC-G_ori.fits')
oriR1 = os.path.join(starDir, 'star1_HSC-R_ori.fits')
oriI1 = os.path.join(starDir, 'star1_HSC-I_ori.fits')
oriZ1 = os.path.join(starDir, 'star1_HSC-Z_ori.fits')
oriY1 = os.path.join(starDir, 'star1_HSC-Y_ori.fits')
oriG2 = os.path.join(starDir, 'star2_HSC-G_ori.fits')
oriR2 = os.path.join(starDir, 'star2_HSC-R_ori.fits')
oriI2 = os.path.join(starDir, 'star2_HSC-I_ori.fits')
oriZ2 = os.path.join(starDir, 'star2_HSC-Z_ori.fits')
oriY2 = os.path.join(starDir, 'star2_HSC-Y_ori.fits')
In [8]:
oriG1 = Table.read(oriG1, format='fits')
oriR1 = Table.read(oriR1, format='fits')
oriI1 = Table.read(oriI1, format='fits')
oriZ1 = Table.read(oriZ1, format='fits')
oriY1 = Table.read(oriY1, format='fits')
oriG2 = Table.read(oriG2, format='fits')
oriR2 = Table.read(oriR2, format='fits')
oriI2 = Table.read(oriI2, format='fits')
oriZ2 = Table.read(oriZ2, format='fits')
oriY2 = Table.read(oriY2, format='fits')
In [9]:
print("# Number of columns : %d" % len(catG1.colnames))
print("\n# Columns related to flux")
print([col for col in catG1.colnames if 'flux' in col])
print("\n# Columns related to mag")
print([col for col in catG1.colnames if 'mag' in col])
print("\n# Columns related to coord")
print([col for col in catG1.colnames if 'coord' in col])
print("\n# Columns related to fake")
print([col for col in catG1.colnames if 'fake' in col.lower()])
print("\n# Columns related to id")
print([col for col in catG1.colnames if 'id' in col.lower()])
print("\n# Columns related to blend")
print([col for col in catG1.colnames if 'blend' in col.lower()])
print("\n# Columns related to flag")
print([col for col in catG1.colnames if 'flag' in col.lower()])
In [10]:
# HSC-G
print(len(oriG1), len(oriR1), len(oriI1), len(oriZ1), len(oriY1))
print("# HSC-G band")
ambG1 = oriG1[oriG1['id'] > 0]
ambG2 = oriG2[oriG2['id'] > 0]
print("## Star1: %d fake stars got ambiguously blended with real objects" % len(ambG1))
print("## Star2: %d fake stars got ambiguously blended with real objects" % len(ambG2))
# HSC-R
print("\n# HSC-R band")
ambR1 = oriR1[oriR1['id'] > 0]
ambR2 = oriR2[oriR2['id'] > 0]
print("## Star1: %d fake stars got ambiguously blended with real objects" % len(ambR1))
print("## Star2: %d fake stars got ambiguously blended with real objects" % len(ambR2))
# HSC-I
print("\n# HSC-I band")
ambI1 = oriI1[oriI1['id'] > 0]
ambI2 = oriI2[oriI2['id'] > 0]
print("## Star1: %d fake stars got ambiguously blended with real objects" % len(ambI1))
print("## Star2: %d fake stars got ambiguously blended with real objects" % len(ambI2))
# HSC-Z
print("\n# HSC-Z band")
ambZ1 = oriZ1[oriZ1['id'] > 0]
ambZ2 = oriZ2[oriZ2['id'] > 0]
print("## Star1: %d fake stars got ambiguously blended with real objects" % len(ambZ1))
print("## Star2: %d fake stars got ambiguously blended with real objects" % len(ambZ2))
# HSC-Y
print("\n# HSC-Y band")
ambY1 = oriY1[oriY1['id'] > 0]
ambY2 = oriY2[oriY2['id'] > 0]
print("## Star1: %d fake stars got ambiguously blended with real objects" % len(ambY1))
print("## Star2: %d fake stars got ambiguously blended with real objects" % len(ambY2))
In [13]:
useG1 = copy.deepcopy(catG1)
useG2 = copy.deepcopy(catG2)
useG1.remove_rows(np.nonzero(np.in1d(useG1['fakeId'], ambG1['fakeId']))[0])
useG2.remove_rows(np.nonzero(np.in1d(useG2['fakeId'], ambG2['fakeId']))[0])
useR1 = copy.deepcopy(catR1)
useR2 = copy.deepcopy(catR2)
useR1.remove_rows(np.nonzero(np.in1d(useR1['fakeId'], ambR1['fakeId']))[0])
useR2.remove_rows(np.nonzero(np.in1d(useR2['fakeId'], ambR2['fakeId']))[0])
useI1 = copy.deepcopy(catI1)
useI2 = copy.deepcopy(catI2)
useI1.remove_rows(np.nonzero(np.in1d(useI1['fakeId'], ambI1['fakeId']))[0])
useI2.remove_rows(np.nonzero(np.in1d(useI2['fakeId'], ambI2['fakeId']))[0])
useZ1 = copy.deepcopy(catZ1)
useZ2 = copy.deepcopy(catZ2)
useZ1.remove_rows(np.nonzero(np.in1d(useZ1['fakeId'], ambZ1['fakeId']))[0])
useZ2.remove_rows(np.nonzero(np.in1d(useZ2['fakeId'], ambZ2['fakeId']))[0])
useY1 = copy.deepcopy(catY1)
useY2 = copy.deepcopy(catY2)
useY1.remove_rows(np.nonzero(np.in1d(useY1['fakeId'], ambY1['fakeId']))[0])
useY2.remove_rows(np.nonzero(np.in1d(useY2['fakeId'], ambY2['fakeId']))[0])
In [30]:
useG1.write(os.path.join(starDir, 'star1_HSC-G_use.fits'), format='fits', overwrite=True)
useG2.write(os.path.join(starDir, 'star2_HSC-G_use.fits'), format='fits', overwrite=True)
useR1.write(os.path.join(starDir, 'star1_HSC-R_use.fits'), format='fits', overwrite=True)
useR2.write(os.path.join(starDir, 'star2_HSC-R_use.fits'), format='fits', overwrite=True)
useI1.write(os.path.join(starDir, 'star1_HSC-I_use.fits'), format='fits', overwrite=True)
useI2.write(os.path.join(starDir, 'star2_HSC-I_use.fits'), format='fits', overwrite=True)
useZ1.write(os.path.join(starDir, 'star1_HSC-Z_use.fits'), format='fits', overwrite=True)
useZ2.write(os.path.join(starDir, 'star2_HSC-Z_use.fits'), format='fits', overwrite=True)
useY1.write(os.path.join(starDir, 'star1_HSC-Y_use.fits'), format='fits', overwrite=True)
useY2.write(os.path.join(starDir, 'star2_HSC-Y_use.fits'), format='fits', overwrite=True)
In [12]:
useG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_use.fits'), format='fits')
useG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_use.fits'), format='fits')
useR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_use.fits'), format='fits')
useR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_use.fits'), format='fits')
useI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_use.fits'), format='fits')
useI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_use.fits'), format='fits')
useZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_use.fits'), format='fits')
useZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_use.fits'), format='fits')
useY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_use.fits'), format='fits')
useY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_use.fits'), format='fits')
In [14]:
# Star1
print("# HSC-G band")
print("# Star1 catalog has %d objects" % len(useG1))
# Matched ones
matchG1 = useG1[useG1['id'] > 0]
unMatchG1 = useG1[useG1['id'] == 0]
print("## %d synthetic stars are matched" % len(matchG1))
print("## %d synthetic stars are not matched" % len(unMatchG1))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchG1['mag_I']),
np.median(matchG1['mag_I'])))
# Star2
print("# \nStar2 catalog has %d objects" % len(useG2))
# Matched ones
matchG2 = useG2[useG2['id'] > 0]
unMatchG2 = useG2[useG2['id'] == 0]
print("## %d synthetic stars are matched" % len(matchG2))
print("## %d synthetic stars are not matched" % len(unMatchG2))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchG2['mag_I']),
np.median(matchG2['mag_I'])))
In [15]:
# Star1
print("# HSC-R band")
print("# Star1 catalog has %d objects" % len(useR1))
# Matched ones
matchR1 = useR1[useR1['id'] > 0]
unMatchR1 = useR1[useR1['id'] == 0]
print("## %d synthetic stars are matched" % len(matchR1))
print("## %d synthetic stars are not matched" % len(unMatchR1))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchR1['mag_I']),
np.median(matchR1['mag_I'])))
# Star2
print("# \nStar2 catalog has %d objects" % len(useR2))
# Matched ones
matchR2 = useR2[useR2['id'] > 0]
unMatchR2 = useR2[useR2['id'] == 0]
print("## %d synthetic stars are matched" % len(matchR2))
print("## %d synthetic stars are not matched" % len(unMatchR2))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchR2['mag_I']),
np.median(matchR2['mag_I'])))
In [16]:
# Star1
print("# HSC-I band")
print("# Star1 catalog has %d objects" % len(useI1))
# Matched ones
matchI1 = useI1[useI1['id'] > 0]
unMatchI1 = useI1[useI1['id'] == 0]
print("## %d synthetic stars are matched" % len(matchI1))
print("## %d synthetic stars are not matched" % len(unMatchI1))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchI1['mag_I']),
np.median(matchI1['mag_I'])))
# Star2
print("# \nStar2 catalog has %d objects" % len(useI2))
# Matched ones
matchI2 = useI2[useI2['id'] > 0]
unMatchI2 = useI2[useI2['id'] == 0]
print("## %d synthetic stars are matched" % len(matchI2))
print("## %d synthetic stars are not matched" % len(unMatchI2))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchI2['mag_I']),
np.median(matchI2['mag_I'])))
In [17]:
# Star1
print("# HSC-Z band")
print("# Star1 catalog has %d objects" % len(useZ1))
# Matched ones
matchZ1 = useZ1[useZ1['id'] > 0]
unMatchZ1 = useZ1[useZ1['id'] == 0]
print("## %d synthetic stars are matched" % len(matchZ1))
print("## %d synthetic stars are not matched" % len(unMatchZ1))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchZ1['mag_I']),
np.median(matchZ1['mag_I'])))
# Star2
print("# \nStar2 catalog has %d objects" % len(useZ2))
# Matched ones
matchZ2 = useZ2[useZ2['id'] > 0]
unMatchZ2 = useZ2[useZ2['id'] == 0]
print("## %d synthetic stars are matched" % len(matchZ2))
print("## %d synthetic stars are not matched" % len(unMatchZ2))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchZ2['mag_I']),
np.median(matchZ2['mag_I'])))
In [18]:
# Star1
print("# HSC-Y band")
print("# Star1 catalog has %d objects" % len(useY1))
# Matched ones
matchY1 = useY1[useY1['id'] > 0]
unMatchY1 = useY1[useY1['id'] == 0]
print("## %d synthetic stars are matched" % len(matchY1))
print("## %d synthetic stars are not matched" % len(unMatchY1))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchY1['mag_I']),
np.median(matchY1['mag_I'])))
# Star2
print("# \nStar2 catalog has %d objects" % len(useY2))
# Matched ones
matchY2 = useY2[useY2['id'] > 0]
unMatchY2 = useY2[useY2['id'] == 0]
print("## %d synthetic stars are matched" % len(matchY2))
print("## %d synthetic stars are not matched" % len(unMatchY2))
# Median I-band magntiudes of the unmatched and matched ones
print("## Median magnitude for unmatched and matched stars: %5.3f, %5.3f" % (np.median(unMatchY2['mag_I']),
np.median(matchY2['mag_I'])))
In [31]:
matchG1.write(os.path.join(starDir, 'star1_HSC-G_match.fits'), format='fits', overwrite=True)
matchG2.write(os.path.join(starDir, 'star2_HSC-G_match.fits'), format='fits', overwrite=True)
unMatchG1.write(os.path.join(starDir, 'star1_HSC-G_unmatch.fits'), format='fits', overwrite=True)
unMatchG2.write(os.path.join(starDir, 'star2_HSC-G_unmatch.fits'), format='fits', overwrite=True)
matchR1.write(os.path.join(starDir, 'star1_HSC-R_match.fits'), format='fits', overwrite=True)
matchR2.write(os.path.join(starDir, 'star2_HSC-R_match.fits'), format='fits', overwrite=True)
unMatchR1.write(os.path.join(starDir, 'star1_HSC-R_unmatch.fits'), format='fits', overwrite=True)
unMatchR2.write(os.path.join(starDir, 'star2_HSC-R_unmatch.fits'), format='fits', overwrite=True)
matchI1.write(os.path.join(starDir, 'star1_HSC-I_match.fits'), format='fits', overwrite=True)
matchI2.write(os.path.join(starDir, 'star2_HSC-I_match.fits'), format='fits', overwrite=True)
unMatchI1.write(os.path.join(starDir, 'star1_HSC-I_unmatch.fits'), format='fits', overwrite=True)
unMatchI2.write(os.path.join(starDir, 'star2_HSC-I_unmatch.fits'), format='fits', overwrite=True)
matchZ1.write(os.path.join(starDir, 'star1_HSC-Z_match.fits'), format='fits', overwrite=True)
matchZ2.write(os.path.join(starDir, 'star2_HSC-Z_match.fits'), format='fits', overwrite=True)
unMatchZ1.write(os.path.join(starDir, 'star1_HSC-Z_unmatch.fits'), format='fits', overwrite=True)
unMatchZ2.write(os.path.join(starDir, 'star2_HSC-Z_unmatch.fits'), format='fits', overwrite=True)
matchY1.write(os.path.join(starDir, 'star1_HSC-Y_match.fits'), format='fits', overwrite=True)
matchY2.write(os.path.join(starDir, 'star2_HSC-Y_match.fits'), format='fits', overwrite=True)
unMatchY1.write(os.path.join(starDir, 'star1_HSC-Y_unmatch.fits'), format='fits', overwrite=True)
unMatchY2.write(os.path.join(starDir, 'star2_HSC-Y_unmatch.fits'), format='fits', overwrite=True)
In [6]:
matchG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_match.fits'), format='fits')
matchG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_match.fits'), format='fits')
unMatchG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_unmatch.fits'), format='fits')
unMatchG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_unmatch.fits'), format='fits')
matchR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_match.fits'), format='fits')
matchR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_match.fits'), format='fits')
unMatchR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_unmatch.fits'), format='fits')
unMatchR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_unmatch.fits'), format='fits')
matchI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_match.fits'), format='fits')
matchI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_match.fits'), format='fits')
unMatchI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_unmatch.fits'), format='fits')
unMatchI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_unmatch.fits'), format='fits')
matchZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_match.fits'), format='fits')
matchZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_match.fits'), format='fits')
unMatchZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_unmatch.fits'), format='fits')
unMatchZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_unmatch.fits'), format='fits')
matchY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_match.fits'), format='fits')
matchY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_match.fits'), format='fits')
unMatchY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_unmatch.fits'), format='fits')
unMatchY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_unmatch.fits'), format='fits')
In [22]:
print([col for col in catG1.colnames if 'primary' in col.lower()])
print([col for col in catG1.colnames if 'match' in col.lower()])
print([col for col in catG1.colnames if 'child' in col.lower()])
print([col for col in catG1.colnames if 'close' in col.lower()])
print([col for col in catG1.colnames if 'extend' in col.lower()])
In [19]:
print("# HSC-G band")
primaryG1 = matchG1[(matchG1['detect.is-primary']) &
(matchG1['deblend.nchild'] == 0) &
(matchG1['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryG1))
primaryG2 = matchG2[(matchG2['detect.is-primary']) &
(matchG2['deblend.nchild'] == 0) &
(matchG2['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryG2))
In [20]:
print("# HSC-R band")
primaryR1 = matchR1[(matchR1['detect.is-primary']) &
(matchR1['deblend.nchild'] == 0) &
(matchR1['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryR1))
primaryR2 = matchR2[(matchR2['detect.is-primary']) &
(matchR2['deblend.nchild'] == 0) &
(matchR2['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryR2))
In [21]:
print("# HSC-I band")
primaryI1 = matchI1[(matchI1['detect.is-primary']) &
(matchI1['deblend.nchild'] == 0) &
(matchI1['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryI1))
primaryI2 = matchI2[(matchI2['detect.is-primary']) &
(matchI2['deblend.nchild'] == 0) &
(matchI2['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryI2))
In [22]:
print("# HSC-Z band")
primaryZ1 = matchZ1[(matchZ1['detect.is-primary']) &
(matchZ1['deblend.nchild'] == 0) &
(matchZ1['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryZ1))
primaryZ2 = matchZ2[(matchZ2['detect.is-primary']) &
(matchZ2['deblend.nchild'] == 0) &
(matchZ2['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryZ2))
In [23]:
print("# HSC-Y band")
primaryY1 = matchY1[(matchY1['detect.is-primary']) &
(matchY1['deblend.nchild'] == 0) &
(matchY1['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryY1))
primaryY2 = matchY2[(matchY2['detect.is-primary']) &
(matchY2['deblend.nchild'] == 0) &
(matchY2['fakeClosest'])]
print("# %d stars are primary, non-parent, closest matches" % len(primaryY2))
In [18]:
primaryG1.write(os.path.join(starDir, 'star1_HSC-G_primary.fits'), format='fits', overwrite=True)
primaryG2.write(os.path.join(starDir, 'star2_HSC-G_primary.fits'), format='fits', overwrite=True)
primaryR1.write(os.path.join(starDir, 'star1_HSC-R_primary.fits'), format='fits', overwrite=True)
primaryR2.write(os.path.join(starDir, 'star2_HSC-R_primary.fits'), format='fits', overwrite=True)
primaryI1.write(os.path.join(starDir, 'star1_HSC-I_primary.fits'), format='fits', overwrite=True)
primaryI2.write(os.path.join(starDir, 'star2_HSC-I_primary.fits'), format='fits', overwrite=True)
primaryZ1.write(os.path.join(starDir, 'star1_HSC-Z_primary.fits'), format='fits', overwrite=True)
primaryZ2.write(os.path.join(starDir, 'star2_HSC-Z_primary.fits'), format='fits', overwrite=True)
primaryY1.write(os.path.join(starDir, 'star1_HSC-Y_primary.fits'), format='fits', overwrite=True)
primaryY2.write(os.path.join(starDir, 'star2_HSC-Y_primary.fits'), format='fits', overwrite=True)
In [23]:
primaryG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_primary.fits'), format='fits')
primaryG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_primary.fits'), format='fits')
primaryR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_primary.fits'), format='fits')
primaryR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_primary.fits'), format='fits')
primaryI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_primary.fits'), format='fits')
primaryI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_primary.fits'), format='fits')
primaryZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_primary.fits'), format='fits')
primaryZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_primary.fits'), format='fits')
primaryY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_primary.fits'), format='fits')
primaryY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_primary.fits'), format='fits')
In [13]:
print([col for col in catG1.colnames if 'flag' in col.lower()])
In [24]:
def stellarQC(cat):
"""Quanlity control cuts."""
use = cat[(~cat['centroid.sdss.flags']) &
(~cat['blendedness.flags']) &
(~cat['flags.badcentroid']) &
(~cat['flags.pixel.bad']) &
(~cat['flags.pixel.cr.any']) &
(~cat['flags.pixel.edge']) &
(~cat['flags.pixel.interpolated.any']) &
(~cat['flags.pixel.offimage']) &
(~cat['flags.pixel.saturated.any']) &
(~cat['flags.pixel.suspect.any']) &
(~cat['flux.aperture.flags']) &
(~cat['flux.gaussian.flags']) &
(~cat['flux.psf.flags']) &
(~cat['flux.psf.flags.apcorr']) &
(~cat['shape.sdss.flags']) &
(~cat['shape.hsm.moments.flags']) &
(~cat['shape.sdss.flags.psf']) &
(np.isfinite(cat['force.classification.extendedness'])) &
(np.isfinite(cat['classification.extendedness'])) &
(np.isfinite(cat['mag.psf'])) &
(np.isfinite(cat['mag.psf.err'])) &
(np.isfinite(cat['mag.psf.apcorr'])) &
(np.isfinite(cat['force.mag.psf.apcorr'])) &
(np.isfinite(cat['force.mag.psf.err'])) &
(np.isfinite(cat['force.mag.psf']))]
return use
In [25]:
print("# HSC-G band")
starUseG1 = stellarQC(primaryG1)
print("## %d / %d stars are useful" % (len(starUseG1), len(primaryG1)))
starUseG2 = stellarQC(primaryG2)
print("## %d / %d stars are useful" % (len(starUseG2), len(primaryG2)))
print("\n# HSC-R band")
starUseR1 = stellarQC(primaryR1)
print("## %d / %d stars are useful" % (len(starUseR1), len(primaryR1)))
starUseR2 = stellarQC(primaryR2)
print("## %d / %d stars are useful" % (len(starUseR2), len(primaryR2)))
print("\n# HSC-I band")
starUseI1 = stellarQC(primaryI1)
print("## %d / %d stars are useful" % (len(starUseI1), len(primaryI1)))
starUseI2 = stellarQC(primaryI2)
print("## %d / %d stars are useful" % (len(starUseI2), len(primaryI2)))
print("\n# HSC-Z band")
starUseZ1 = stellarQC(primaryZ1)
print("## %d / %d stars are useful" % (len(starUseZ1), len(primaryZ1)))
starUseZ2 = stellarQC(primaryZ2)
print("## %d / %d stars are useful" % (len(starUseZ2), len(primaryZ2)))
print("\n# HSC-Y band")
starUseY1 = stellarQC(primaryY1)
print("## %d / %d stars are useful" % (len(starUseY1), len(primaryY1)))
starUseY2 = stellarQC(primaryY2)
print("## %d / %d stars are useful" % (len(starUseY2), len(primaryY2)))
In [ ]:
starUseG1.write(os.path.join(starDir, 'star1_HSC-G_use.fits'), format='fits', overwrite=True)
starUseG2.write(os.path.join(starDir, 'star2_HSC-G_use.fits'), format='fits', overwrite=True)
starUseR1.write(os.path.join(starDir, 'star1_HSC-R_use.fits'), format='fits', overwrite=True)
starUseR2.write(os.path.join(starDir, 'star2_HSC-R_use.fits'), format='fits', overwrite=True)
starUseI1.write(os.path.join(starDir, 'star1_HSC-I_use.fits'), format='fits', overwrite=True)
starUseI2.write(os.path.join(starDir, 'star2_HSC-I_use.fits'), format='fits', overwrite=True)
starUseZ1.write(os.path.join(starDir, 'star1_HSC-Z_use.fits'), format='fits', overwrite=True)
starUseZ2.write(os.path.join(starDir, 'star2_HSC-Z_use.fits'), format='fits', overwrite=True)
starUseY1.write(os.path.join(starDir, 'star1_HSC-Y_use.fits'), format='fits', overwrite=True)
starUseY2.write(os.path.join(starDir, 'star2_HSC-Y_use.fits'), format='fits', overwrite=True)
In [8]:
starUseG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_use.fits'), format='fits')
starUseG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_use.fits'), format='fits')
starUseR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_use.fits'), format='fits')
starUseR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_use.fits'), format='fits')
starUseI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_use.fits'), format='fits')
starUseI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_use.fits'), format='fits')
starUseZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_use.fits'), format='fits')
starUseZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_use.fits'), format='fits')
starUseY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_use.fits'), format='fits')
starUseY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_use.fits'), format='fits')
In [26]:
print("# HSC-G band")
misClassG1 = starUseG1[(starUseG1['force.classification.extendedness'] > 0.5)]
starGoodG1 = starUseG1[(starUseG1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassG1))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassG1['mag_G']),
np.nanmedian(starGoodG1['mag_G'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassG1['blendedness.abs.flux']),
np.nanmedian(starGoodG1['blendedness.abs.flux'])))
misClassG2 = starUseG2[(starUseG2['force.classification.extendedness'] > 0.5)]
starGoodG2 = starUseG2[(starUseG2['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassG2))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassG2['mag_G']),
np.nanmedian(starGoodG2['mag_G'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassG2['blendedness.abs.flux']),
np.nanmedian(starGoodG2['blendedness.abs.flux'])))
print("# \nHSC-R band")
misClassR1 = starUseR1[(starUseR1['force.classification.extendedness'] > 0.5)]
starGoodR1 = starUseR1[(starUseR1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassR1))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassR1['mag_R']),
np.nanmedian(starGoodR1['mag_R'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassR1['blendedness.abs.flux']),
np.nanmedian(starGoodR1['blendedness.abs.flux'])))
misClassR2 = starUseR2[(starUseR2['force.classification.extendedness'] > 0.5)]
starGoodR2 = starUseR2[(starUseR1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassR2))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassR2['mag_R']),
np.nanmedian(starGoodR2['mag_R'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassR2['blendedness.abs.flux']),
np.nanmedian(starGoodR2['blendedness.abs.flux'])))
print("# \nHSC-I band")
misClassI1 = starUseI1[(starUseI1['force.classification.extendedness'] > 0.5)]
starGoodI1 = starUseI1[(starUseI1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassI1))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassI1['mag_I']),
np.nanmedian(starGoodI1['mag_I'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassI1['blendedness.abs.flux']),
np.nanmedian(starGoodI1['blendedness.abs.flux'])))
misClassI2 = starUseI2[(starUseI2['force.classification.extendedness'] > 0.5)]
starGoodI2 = starUseI2[(starUseI2['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassI2))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassI2['mag_I']),
np.nanmedian(starGoodI2['mag_I'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassI2['blendedness.abs.flux']),
np.nanmedian(starGoodI2['blendedness.abs.flux'])))
print("# \nHSC-Z band")
misClassZ1 = starUseZ1[(starUseZ1['force.classification.extendedness'] > 0.5)]
starGoodZ1 = starUseZ1[(starUseZ1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassZ1))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassZ1['mag_Z']),
np.nanmedian(starGoodZ1['mag_Z'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassZ1['blendedness.abs.flux']),
np.nanmedian(starGoodZ1['blendedness.abs.flux'])))
misClassZ2 = starUseZ2[(starUseZ2['force.classification.extendedness'] > 0.5)]
starGoodZ2 = starUseZ2[(starUseZ2['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassZ2))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassZ2['mag_Z']),
np.nanmedian(starGoodZ2['mag_Z'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassZ2['blendedness.abs.flux']),
np.nanmedian(starGoodZ2['blendedness.abs.flux'])))
print("# \nHSC-Y band")
misClassY1 = starUseY1[(starUseY1['force.classification.extendedness'] > 0.5)]
starGoodY1 = starUseY1[(starUseY1['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassY1))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassY1['mag_Y']),
np.nanmedian(starGoodY1['mag_Y'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassY1['blendedness.abs.flux']),
np.nanmedian(starGoodY1['blendedness.abs.flux'])))
misClassY2 = starUseY2[(starUseY2['force.classification.extendedness'] > 0.5)]
starGoodY2 = starUseY2[(starUseY2['force.classification.extendedness'] <= 0.5)]
print("# %d stars are mis-classified as extended objects" % len(misClassY2))
print("## median magnitude for misclassified and good stars: %5.3f, %5.3f" % (np.nanmedian(misClassY2['mag_Y']),
np.nanmedian(starGoodY2['mag_Y'])))
print("## median blendedness for misclassified and good stars: %6.4f, %6.4f" % (np.nanmedian(misClassY2['blendedness.abs.flux']),
np.nanmedian(starGoodY2['blendedness.abs.flux'])))
# Need to see the magnitude and blendedness distributions of these objects
In [40]:
starGoodG1.write(os.path.join(starDir, 'star1_HSC-G_good.fits'), format='fits', overwrite=True)
starGoodG2.write(os.path.join(starDir, 'star2_HSC-G_good.fits'), format='fits', overwrite=True)
misClassG1.write(os.path.join(starDir, 'star1_HSC-G_misclass.fits'), format='fits', overwrite=True)
misClassG2.write(os.path.join(starDir, 'star2_HSC-G_misclass.fits'), format='fits', overwrite=True)
starGoodR1.write(os.path.join(starDir, 'star1_HSC-R_good.fits'), format='fits', overwrite=True)
starGoodR2.write(os.path.join(starDir, 'star2_HSC-R_good.fits'), format='fits', overwrite=True)
misClassR1.write(os.path.join(starDir, 'star1_HSC-R_misclass.fits'), format='fits', overwrite=True)
misClassR2.write(os.path.join(starDir, 'star2_HSC-R_misclass.fits'), format='fits', overwrite=True)
starGoodI1.write(os.path.join(starDir, 'star1_HSC-I_good.fits'), format='fits', overwrite=True)
starGoodI2.write(os.path.join(starDir, 'star2_HSC-I_good.fits'), format='fits', overwrite=True)
misClassI1.write(os.path.join(starDir, 'star1_HSC-I_misclass.fits'), format='fits', overwrite=True)
misClassI2.write(os.path.join(starDir, 'star2_HSC-I_misclass.fits'), format='fits', overwrite=True)
starGoodZ1.write(os.path.join(starDir, 'star1_HSC-Z_good.fits'), format='fits', overwrite=True)
starGoodZ2.write(os.path.join(starDir, 'star2_HSC-Z_good.fits'), format='fits', overwrite=True)
misClassZ1.write(os.path.join(starDir, 'star1_HSC-Z_misclass.fits'), format='fits', overwrite=True)
misClassZ2.write(os.path.join(starDir, 'star2_HSC-Z_misclass.fits'), format='fits', overwrite=True)
starGoodY1.write(os.path.join(starDir, 'star1_HSC-Y_good.fits'), format='fits', overwrite=True)
starGoodY2.write(os.path.join(starDir, 'star2_HSC-Y_good.fits'), format='fits', overwrite=True)
misClassY1.write(os.path.join(starDir, 'star1_HSC-Y_misclass.fits'), format='fits', overwrite=True)
misClassY2.write(os.path.join(starDir, 'star2_HSC-Y_misclass.fits'), format='fits', overwrite=True)
In [9]:
starGoodG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_good.fits'), format='fits')
starGoodG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_good.fits'), format='fits')
misClassG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_misclass.fits'), format='fits')
misClassG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_misclass.fits'), format='fits')
starGoodR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_good.fits'), format='fits')
starGoodR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_good.fits'), format='fits')
misClassR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_misclass.fits'), format='fits')
misClassR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_misclass.fits'), format='fits')
starGoodI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_good.fits'), format='fits')
starGoodI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_good.fits'), format='fits')
misClassI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_misclass.fits'), format='fits')
misClassI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_misclass.fits'), format='fits')
starGoodZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_good.fits'), format='fits')
starGoodZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_good.fits'), format='fits')
misClassZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_misclass.fits'), format='fits')
misClassZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_misclass.fits'), format='fits')
starGoodY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_good.fits'), format='fits')
starGoodY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_good.fits'), format='fits')
misClassY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_misclass.fits'), format='fits')
misClassY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_misclass.fits'), format='fits')
In [88]:
misClassI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_misclass.fits'), format='fits')
misClassI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_misclass.fits'), format='fits')
In [14]:
starGoodI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_good.fits'), format='fits')
starGoodI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_good.fits'), format='fits')
In [36]:
starGoodG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_good.fits'), format='fits')
starGoodG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_good.fits'), format='fits')
In [68]:
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(30,6))
fig.subplots_adjust(left=0.02, right=0.99, bottom=0.15, top=0.99,
hspace=0.0, wspace=0.0)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1 = fig.add_subplot(151)
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=25, xlabel=25, border=4.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## X, Y limits
xmin, xmax = 17.2, 26.9
ymin, ymax = -0.001, 0.309
# Good seeing
xx = starGoodI1['mag_G']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax1.fill(xPlot[:, None], np.exp(log_dens), facecolor=GCMAP(0.5), edgecolor=GCMAP(0.8),
alpha=0.6, linewidth=4.0, label=r'$\mathrm{Good\ Seeing}$')
# Bad seeing
xx = starGoodI2['mag_G']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax1.plot(xPlot, np.exp(log_dens), color=GCMAP(0.9), alpha=0.8, linewidth=6.0,
linestyle='--', dashes=(40,8), label=r'$\mathrm{Bad\ Seeing}$')
ax1.yaxis.set_major_formatter(NullFormatter())
xlabel = r'$g\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\#$'
ax1.set_xlabel(xlabel, size=26)
ax1.set_ylabel(ylabel, size=26)
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
ax1.legend(l_handles, l_labels, loc=(0.04, 0.72), shadow=True, fancybox=True,
numpoints=1, fontsize=24, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.2)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(GCMAP(0.6))
legend.legendHandles[1].set_color(GCMAP(0.9))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2 = fig.add_subplot(152)
ax2.grid()
ax2 = songPlotSetup(ax2, ylabel=25, xlabel=25, border=4.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Good seeing
xx = starGoodI1['mag_R']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=RCMAP(0.5), edgecolor=RCMAP(0.8),
alpha=0.6, linewidth=4.0)
# Bad seeing
xx = starGoodI2['mag_R']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.plot(xPlot, np.exp(log_dens), color=RCMAP(0.9), alpha=0.8, linewidth=6.0,
linestyle='--', dashes=(40,8))
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
xlabel = r'$r\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ax2.set_xlabel(xlabel, size=26)
## X, Y limits
xmin, xmax = 17.2, 26.9
ax2.set_xlim(xmin, xmax)
# --------------------------------------------------------------------------------------- #
## Ax3
ax3 = fig.add_subplot(153)
ax3.grid()
ax3 = songPlotSetup(ax3, ylabel=25, xlabel=25, border=4.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Good seeing
xx = starGoodI1['mag_I']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax3.fill(xPlot[:, None], np.exp(log_dens), facecolor=ICMAP(0.5), edgecolor=ICMAP(0.8),
alpha=0.6, linewidth=4.0)
# Bad seeing
xx = starGoodI2['mag_I']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax3.plot(xPlot, np.exp(log_dens), color=ICMAP(0.9), alpha=0.8, linewidth=6.0,
linestyle='--', dashes=(40,8))
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ax3.set_xlabel(xlabel, size=26)
## X, Y limits
xmin, xmax = 17.2, 26.9
ax3.set_xlim(xmin, xmax)
# --------------------------------------------------------------------------------------- #
## Ax4
ax4 = fig.add_subplot(154)
ax4.grid()
ax4 = songPlotSetup(ax4, ylabel=25, xlabel=25, border=4.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Good seeing
xx = starGoodI1['mag_Z']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax4.fill(xPlot[:, None], np.exp(log_dens), facecolor=ZCMAP(0.5), edgecolor=ZCMAP(0.8),
alpha=0.6, linewidth=4.0)
# Bad seeing
xx = starGoodI2['mag_Z']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax4.plot(xPlot, np.exp(log_dens), color=ZCMAP(0.9), alpha=0.8, linewidth=6.0,
linestyle='--', dashes=(40,8))
ax4.set_ylim(ax1.get_ylim())
ax4.yaxis.set_major_formatter(NullFormatter())
xlabel = r'$z\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ax4.set_xlabel(xlabel, size=26)
## X, Y limits
xmin, xmax = 17.2, 26.9
ax4.set_xlim(xmin, xmax)
# --------------------------------------------------------------------------------------- #
## Ax5
ax5 = fig.add_subplot(155)
ax5.grid()
ax5 = songPlotSetup(ax5, ylabel=25, xlabel=25, border=4.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Good seeing
xx = starGoodI1['mag_Y']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax5.fill(xPlot[:, None], np.exp(log_dens), facecolor=YCMAP(0.5), edgecolor=YCMAP(0.8),
alpha=0.6, linewidth=4.0)
# Bad seeing
xx = starGoodI2['mag_Y']
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax5.plot(xPlot, np.exp(log_dens), color=YCMAP(0.9), alpha=0.8, linewidth=6.0,
linestyle='--', dashes=(40,8))
ax5.set_ylim(ax1.get_ylim())
ax5.yaxis.set_major_formatter(NullFormatter())
xlabel = r'$Y\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ax5.set_xlabel(xlabel, size=26)
## X, Y limits
xmin, xmax = 17.2, 26.9
ax5.set_xlim(xmin, xmax)
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_hist_input_mag.pdf'),
format='pdf', dpi=90)
In [44]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -0.59, 2.49
ymin, ymax = -0.59, 2.89
xx = inputI1['mag_G'] - inputI1['mag_R']
yy = inputI1['mag_R'] - inputI1['mag_I']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = inputI2['mag_G'] - inputI2['mag_R']
yy2 = inputI2['mag_R'] - inputI2['mag_I']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(g-r)_{\mathrm{PSF}}} \mathrm{(mag)}$'
ylabel = r'$(r-i)_{\mathrm{PSF}}} \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%5.1f}$', r'$\mathbf{%5.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = plt.axes(EC1)
ax2 = plt.axes(EC2)
ax3 = plt.axes(EC3)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# HexBin
HB = ax1.hexbin(xx, yy, cmap=RCMAP, mincnt=1,
alpha=0.7, gridsize=[30, 20], label=r'$\mathrm{Good\ Seeing}$',
marginals=False, vmin=10, vmax=1250,
edgecolor=RCMAP(0.3))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(140, 140))
H = gaussian_filter(H, 2)
levels = np.linspace(1, H.max(), 6)
Nx, Ny = len(xbins), len(ybins)
CS = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(RCMAP(0.6), RCMAP(0.6)),
linewidths=6, levels=levels, alpha=0.7)
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.52, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(RCMAP(0.3))
legend.legendHandles[1].set_color(RCMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=RCMAP(0.3), edgecolor=RCMAP(0.6),
alpha=0.7, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx2[:, None])
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor='None', edgecolor=RCMAP(0.9),
alpha=0.6, linewidth=7.0, linestyle='-')
ax2.set_xlim(ax1.get_xlim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=RCMAP(0.3), edgecolor=RCMAP(0.6),
alpha=0.7, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=RCMAP(0.9),
alpha=0.6, linewidth=7.0, linestyle='-')
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G-R-input.pdf'),
format='pdf', dpi=90)
In [51]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -0.29, 1.19
ymin, ymax = -0.29, 0.59
xx = inputI1['mag_I'] - inputI1['mag_Z']
yy = inputI1['mag_Z'] - inputI1['mag_Y']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = inputI2['mag_I'] - inputI2['mag_Z']
yy2 = inputI2['mag_Z'] - inputI2['mag_Y']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(i-z)_{\mathrm{PSF}}} \mathrm{(mag)}$'
ylabel = r'$(z-y)_{\mathrm{PSF}}} \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%5.1f}$', r'$\mathbf{%5.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = plt.axes(EC1)
ax2 = plt.axes(EC2)
ax3 = plt.axes(EC3)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# HexBin
HB = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=5,
alpha=0.7, gridsize=[30, 20], label=r'$\mathrm{Good\ Seeing}$',
marginals=False, vmin=200, vmax=1450,
edgecolor=ICMAP(0.3))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(140, 140))
H = gaussian_filter(H, 2)
levels = np.linspace(3, H.max(), 6)
Nx, Ny = len(xbins), len(ybins)
CS = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.6)),
linewidths=6, levels=levels, alpha=0.7)
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.52, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=ICMAP(0.3), edgecolor=ICMAP(0.6),
alpha=0.7, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx2[:, None])
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor='None', edgecolor=ICMAP(0.9),
alpha=0.6, linewidth=7.0, linestyle='-')
ax2.set_xlim(ax1.get_xlim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.3), edgecolor=ICMAP(0.6),
alpha=0.7, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=ICMAP(0.9),
alpha=0.6, linewidth=7.0, linestyle='-')
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I-Z-input.pdf'),
format='pdf', dpi=90)
In [27]:
print(np.nanmin(starGoodI1['blendedness.abs.flux']), np.nanmax(starGoodI1['blendedness.abs.flux']))
print(np.nanmin(misClassI1['blendedness.abs.flux']), np.nanmax(misClassI1['blendedness.abs.flux']))
print(np.nanmin(starGoodI2['blendedness.abs.flux']), np.nanmax(starGoodI2['blendedness.abs.flux']))
print(np.nanmin(misClassI2['blendedness.abs.flux']), np.nanmax(misClassI2['blendedness.abs.flux']))
print(np.nanmin(starGoodI1['mag.psf']), np.nanmax(starGoodI1['mag.psf']))
print(np.nanmin(misClassI1['mag.psf']), np.nanmax(misClassI1['mag.psf']))
print(np.nanmin(starGoodI2['mag.psf']), np.nanmax(starGoodI2['mag.psf']))
print(np.nanmin(misClassI2['mag.psf']), np.nanmax(misClassI2['mag.psf']))
print(np.nanmin(starGoodI1['mag_I']), np.nanmax(starGoodI1['mag_I']))
print(np.nanmin(misClassI1['mag_I']), np.nanmax(misClassI1['mag_I']))
print(np.nanmin(starGoodI2['mag_I']), np.nanmax(starGoodI2['mag_I']))
print(np.nanmin(misClassI2['mag_I']), np.nanmax(misClassI2['mag_I']))
In [11]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starGoodI1['mag_I']
yy = starGoodI1['blendedness.abs.flux']
xx = xx[np.isfinite(yy) & (yy > 0.0)]
yy = yy[np.isfinite(yy) & (yy > 0.0)]
yy = np.log10(yy)
xx2 = starGoodI2['mag_I']
yy2 = starGoodI2['blendedness.abs.flux']
xx2 = xx2[np.isfinite(yy2) & (yy2 > 0.0)]
yy2 = yy2[np.isfinite(yy2) & (yy2 > 0.0)]
yy2 = np.log10(yy2)
xmin, xmax = 18.01, 25.6
ymin, ymax = -5.9, 0.15
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\mathrm{Blendedness}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax3 = plt.axes(recHist)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
hb1 = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=3,
alpha=1.0, gridsize=[46, 70], label='$\mathrm{Good}$',
marginals=False, vmin=3, vmax=110,
edgecolor=ICMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(160, 160))
H = gaussian_filter(H, 2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.8), ICMAP(0.6)),
linewidths=6, levels=levels, alpha=0.7)
ax1.axhline(-1.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax1.text(0.19, 0.87, '$\mathrm{Blended}$',
verticalalignment='bottom', horizontalalignment='center',
fontsize=56.0, transform=ax1.transAxes, weight='bold',
color='k')
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.52, 0.03), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.4), edgecolor=ICMAP(0.05),
alpha=0.8, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.05).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.plot(np.exp(log_dens), yPlot, color=ICMAP(0.9), alpha=0.7, linewidth=5.0)
#kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy2[:, None])
#log_dens = kde.score_samples(yPlot[:, None])
#ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=ICMAP(0.7),
# alpha=0.6, linewidth=4.0, linestyle='--')
ax3.axhline(-1.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
fig.savefig(os.path.join(figDir, 'star1_HSC-I_magI_blendedness.pdf'),
format='pdf', dpi=90)
In [28]:
starIsoG1 = starGoodG1[(np.isfinite(starGoodG1['blendedness.abs.flux'])) &
(starGoodG1['blendedness.abs.flux'] <= 0.05)]
starIsoG2 = starGoodG2[(starGoodG2['blendedness.abs.flux'] > 0.0) &
(starGoodG2['blendedness.abs.flux'] <= 0.05)]
starBldG1 = starGoodG1[(starGoodG1['blendedness.abs.flux'] > 0.05)]
starBldG2 = starGoodG2[(starGoodG2['blendedness.abs.flux'] > 0.05)]
starIsoR1 = starGoodR1[(starGoodR1['blendedness.abs.flux'] > 0.0) &
(starGoodR1['blendedness.abs.flux'] <= 0.05)]
starIsoR2 = starGoodR2[(starGoodR2['blendedness.abs.flux'] > 0.0) &
(starGoodR2['blendedness.abs.flux'] <= 0.05)]
starBldR1 = starGoodR1[(starGoodR1['blendedness.abs.flux'] > 0.05)]
starBldR2 = starGoodR2[(starGoodR2['blendedness.abs.flux'] > 0.05)]
starIsoI1 = starGoodI1[(starGoodI1['blendedness.abs.flux'] > 0.0) &
(starGoodI1['blendedness.abs.flux'] <= 0.05)]
starIsoI2 = starGoodI2[(starGoodI2['blendedness.abs.flux'] > 0.0) &
(starGoodI2['blendedness.abs.flux'] <= 0.05)]
starBldI1 = starGoodI1[(starGoodI1['blendedness.abs.flux'] > 0.05)]
starBldI2 = starGoodI2[(starGoodI2['blendedness.abs.flux'] > 0.05)]
starIsoZ1 = starGoodZ1[(starGoodZ1['blendedness.abs.flux'] > 0.0) &
(starGoodZ1['blendedness.abs.flux'] <= 0.05)]
starIsoZ2 = starGoodZ2[(starGoodZ2['blendedness.abs.flux'] > 0.0) &
(starGoodZ2['blendedness.abs.flux'] <= 0.05)]
starBldZ1 = starGoodZ1[(starGoodZ1['blendedness.abs.flux'] > 0.05)]
starBldZ2 = starGoodZ2[(starGoodZ2['blendedness.abs.flux'] > 0.05)]
starIsoY1 = starGoodY1[(starGoodY1['blendedness.abs.flux'] > 0.0) &
(starGoodY1['blendedness.abs.flux'] <= 0.05)]
starIsoY2 = starGoodY2[(starGoodY2['blendedness.abs.flux'] > 0.0) &
(starGoodY2['blendedness.abs.flux'] <= 0.05)]
starBldY1 = starGoodY1[(starGoodY1['blendedness.abs.flux'] > 0.05)]
starBldY2 = starGoodY2[(starGoodY2['blendedness.abs.flux'] > 0.05)]
In [29]:
print(len(starGoodG1), len(starIsoG1), len(starBldG1))
print(len(starGoodG1[starGoodG1['blendedness.abs.flux'] <= 0.05]))
In [96]:
print(len(starIsoG1), len(starBldG1))
print(len(starIsoG2), len(starBldG2))
starIsoG1.write(os.path.join(starDir, 'star1_HSC-G_isolate.fits'), format='fits', overwrite=True)
starIsoG2.write(os.path.join(starDir, 'star2_HSC-G_isolate.fits'), format='fits', overwrite=True)
starBldG1.write(os.path.join(starDir, 'star1_HSC-G_blended.fits'), format='fits', overwrite=True)
starBldG2.write(os.path.join(starDir, 'star2_HSC-G_blended.fits'), format='fits', overwrite=True)
print(len(starIsoR1), len(starBldR1))
print(len(starIsoR2), len(starBldR2))
starIsoR1.write(os.path.join(starDir, 'star1_HSC-R_isolate.fits'), format='fits', overwrite=True)
starIsoR2.write(os.path.join(starDir, 'star2_HSC-R_isolate.fits'), format='fits', overwrite=True)
starBldR1.write(os.path.join(starDir, 'star1_HSC-R_blended.fits'), format='fits', overwrite=True)
starBldR2.write(os.path.join(starDir, 'star2_HSC-R_blended.fits'), format='fits', overwrite=True)
print(len(starIsoI1), len(starBldI1))
print(len(starIsoI2), len(starBldI2))
starIsoI1.write(os.path.join(starDir, 'star1_HSC-I_isolate.fits'), format='fits', overwrite=True)
starIsoI2.write(os.path.join(starDir, 'star2_HSC-I_isolate.fits'), format='fits', overwrite=True)
starBldI1.write(os.path.join(starDir, 'star1_HSC-I_blended.fits'), format='fits', overwrite=True)
starBldI2.write(os.path.join(starDir, 'star2_HSC-I_blended.fits'), format='fits', overwrite=True)
print(len(starIsoZ1), len(starBldZ1))
print(len(starIsoZ2), len(starBldZ2))
starIsoZ1.write(os.path.join(starDir, 'star1_HSC-Z_isolate.fits'), format='fits', overwrite=True)
starIsoZ2.write(os.path.join(starDir, 'star2_HSC-Z_isolate.fits'), format='fits', overwrite=True)
starBldZ1.write(os.path.join(starDir, 'star1_HSC-Z_blended.fits'), format='fits', overwrite=True)
starBldZ2.write(os.path.join(starDir, 'star2_HSC-Z_blended.fits'), format='fits', overwrite=True)
print(len(starIsoY1), len(starBldY1))
print(len(starIsoY2), len(starBldY2))
starIsoY1.write(os.path.join(starDir, 'star1_HSC-Y_isolate.fits'), format='fits', overwrite=True)
starIsoY2.write(os.path.join(starDir, 'star2_HSC-Y_isolate.fits'), format='fits', overwrite=True)
starBldY1.write(os.path.join(starDir, 'star1_HSC-Y_blended.fits'), format='fits', overwrite=True)
starBldY2.write(os.path.join(starDir, 'star2_HSC-Y_blended.fits'), format='fits', overwrite=True)
In [10]:
starIsoG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_isolate.fits'), format='fits')
starIsoG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_isolate.fits'), format='fits')
starBldG1 = Table.read(os.path.join(starDir, 'star1_HSC-G_blended.fits'), format='fits')
starBldG2 = Table.read(os.path.join(starDir, 'star2_HSC-G_blended.fits'), format='fits')
starIsoR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_isolate.fits'), format='fits')
starIsoR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_isolate.fits'), format='fits')
starBldR1 = Table.read(os.path.join(starDir, 'star1_HSC-R_blended.fits'), format='fits')
starBldR2 = Table.read(os.path.join(starDir, 'star2_HSC-R_blended.fits'), format='fits')
starIsoI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_isolate.fits'), format='fits')
starIsoI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_isolate.fits'), format='fits')
starBldI1 = Table.read(os.path.join(starDir, 'star1_HSC-I_blended.fits'), format='fits')
starBldI2 = Table.read(os.path.join(starDir, 'star2_HSC-I_blended.fits'), format='fits')
starIsoZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_isolate.fits'), format='fits')
starIsoZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_isolate.fits'), format='fits')
starBldZ1 = Table.read(os.path.join(starDir, 'star1_HSC-Z_blended.fits'), format='fits')
starBldZ2 = Table.read(os.path.join(starDir, 'star2_HSC-Z_blended.fits'), format='fits')
starIsoY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_isolate.fits'), format='fits')
starIsoY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_isolate.fits'), format='fits')
starBldY1 = Table.read(os.path.join(starDir, 'star1_HSC-Y_blended.fits'), format='fits')
starBldY2 = Table.read(os.path.join(starDir, 'star2_HSC-Y_blended.fits'), format='fits')
In [159]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoI1['coord_ra'] - starIsoI1['RA']
yy = starIsoI1['coord_dec'] - starIsoI1['DEC']
xx *= 3600.0
yy *= 3600.0
xx2 = starBldI1['coord_ra'] - starBldI1['RA']
yy2 = starBldI1['coord_dec'] - starBldI1['DEC']
xx2 *= 3600.0
yy2 *= 3600.0
xx3 = starIsoI2['coord_ra'] - starIsoI2['RA']
yy3 = starIsoI2['coord_dec'] - starIsoI2['Dec']
xx3 *= 3600.0
yy3 *= 3600.0
xmin, xmax = -0.142, 0.142
ymin, ymax = -0.142, 0.142
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$\Delta\ \mathrm{R.A}\ (\mathrm{arcsec})$'
ylabel = r'$\Delta\ \mathrm{Dec}\ (\mathrm{arcsec})$'
xtickFormat, ytickFormat = r'$\mathbf{%5.2f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(16, 16))
ax1 = plt.axes(EC1)
ax2 = plt.axes(EC2)
ax3 = plt.axes(EC3)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.2), ICMAP(0.4), ICMAP(0.6), ICMAP(0.8), ICMAP(1.0)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx3, yy3, bins=(100, 100))
H = gaussian_filter(H, 2.0)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.4), YCMAP(0.5), YCMAP(0.6), YCMAP(0.7), YCMAP(0.8)),
linewidths=6, levels=levels, alpha=1.0)
ax1.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax1.axvline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.52, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.5))
legend.legendHandles[1].set_color(YCMAP(0.6))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=ICMAP(0.4), edgecolor=ICMAP(0.1),
alpha=1.0, linewidth=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(xx3[:, None])
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor='None', edgecolor=YCMAP(0.7),
alpha=0.8, linewidth=6.0, linestyle='-')
ax2.axvline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_xlim(ax1.get_xlim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.4), edgecolor=ICMAP(0.1),
alpha=1.0, linewidth=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=YCMAP(0.7),
alpha=0.8, linewidth=6.0, linestyle='-')
ax3.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_dRA_dDec_new.pdf'),
format='pdf', dpi=90)
In [160]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoI1['mag_I']
yy = np.log10(starIsoI1['flux.psf'] / starIsoI1['flux.psf.err'])
xx2 = starIsoI2['mag_I']
yy2 = np.log10(starIsoI2['flux.psf'] / starIsoI2['flux.psf.err'])
xx3 = starBldI1['mag_I']
yy3 = np.log10(starBldI1['flux.psf'] / starBldI1['flux.psf.err'])
xmin, xmax = 17.29, 26.99
ymin, ymax = 0.4, 3.89
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\log_{10}\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(120, 100))
H = gaussian_filter(H, 0.8)
levels = np.linspace(2, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ORG(0.3), ORG(0.5), ORG(0.8)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(120, 100))
H = gaussian_filter(H, 0.8)
levels = np.linspace(2, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.4), YCMAP(0.6), YCMAP(0.8)), linestyles='dashed',
linewidths=4, levels=levels, alpha=0.8)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.6), edgecolor='none',
alpha=0.2, s=15, label='$\mathrm{Blended}$', rasterized=True)
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.07, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=45, scatterpoints=1,
markerscale=2.5, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.7))
legend.legendHandles[1].set_color(ICMAP(0.3))
legend.legendHandles[2].set_color(YCMAP(0.7))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_magI_logSN_PSF_new.pdf'),
format='pdf', dpi=90)
In [148]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoG1['mag_G']
yy = np.log10(starIsoG1['flux.psf'] / starIsoG1['flux.psf.err'])
xx2 = starIsoG2['mag_G']
yy2 = np.log10(starIsoG2['flux.psf'] / starIsoG2['flux.psf.err'])
xx3 = starBldG1['mag_G']
yy3 = np.log10(starBldG1['flux.psf'] / starBldG1['flux.psf.err'])
xmin, xmax = 17.29, 26.99
ymin, ymax = 0.4, 3.89
xlabel = r'$g\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\log_{10}\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(120, 100))
H = gaussian_filter(H, 0.8)
levels = np.linspace(2, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.2), GCMAP(0.4), GCMAP(0.7)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(120, 100))
H = gaussian_filter(H, 0.8)
levels = np.linspace(2, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.5), YCMAP(0.7), YCMAP(0.9)), linestyles='dashed',
linewidths=4, levels=levels, alpha=0.8)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.6), edgecolor='none',
alpha=0.2, s=15, label='$\mathrm{Blended}$', rasterized=True)
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.07, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=45, scatterpoints=1,
markerscale=2.5, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.7))
legend.legendHandles[1].set_color(GCMAP(0.2))
legend.legendHandles[2].set_color(YCMAP(0.7))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G_magG_logSN_PSF_new.pdf'),
format='pdf', dpi=90)
In [31]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoG1['mag_G']
yy = np.log10(starIsoG1['flux.psf'] / starIsoG1['flux.psf.err'])
xx2 = starIsoG2['mag_G']
yy2 = np.log10(starIsoG2['flux.psf'] / starIsoG2['flux.psf.err'])
xx3 = starBldG1['mag_G']
yy3 = np.log10(starBldG1['flux.psf'] / starBldG1['flux.psf.err'])
xmin, xmax = 17.29, 26.99
ymin, ymax = 0.4, 3.89
xlabel = r'$g\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\log\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## Sscatter
ax1.scatter(xx3, yy3, color=GCMAP(0.4), marker='o', edgecolor='None', alpha=0.9,
zorder=0, s=30, label='$\mathrm{Blended}$')
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=GCMAP, mincnt=1,
alpha=0.7, gridsize=[45, 25], label='$\mathrm{Good}$',
marginals=False, vmin=1, vmax=1100,
edgecolor=GCMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(50, H.max(), 3)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.6), GCMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[1] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[1] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.61, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(GCMAP(0.3))
legend.legendHandles[1].set_color(GCMAP(0.6))
legend.legendHandles[2].set_color(GCMAP(0.8))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmax, xmin)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G_magG_logSN_fPSF.pdf'),
format='pdf', dpi=90)
In [112]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoR1['mag_R']
yy = np.log10(starIsoR1['flux.psf'] / starIsoR1['flux.psf.err'])
xx2 = starIsoR2['mag_R']
yy2 = np.log10(starIsoR2['flux.psf'] / starIsoR2['flux.psf.err'])
xx3 = starBldR1['mag_R']
yy3 = np.log10(starBldR1['flux.psf'] / starBldR1['flux.psf.err'])
xmin, xmax = 17.19, 27.4
ymin, ymax = 0.4, 3.89
xlabel = r'$r\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$r\ \mathrm{Band}\ \log\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=RCMAP, mincnt=1,
alpha=0.7, gridsize=[36, 22], label='$\mathrm{Good}$',
marginals=False, vmin=1, vmax=1200,
edgecolor=RCMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(50, H.max(), 3)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(RCMAP(0.6), RCMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Sscatter
ax1.scatter(xx3, yy3, color=RCMAP(0.4), marker='o', edgecolor='None', alpha=0.9,
zorder=0, s=30, label='$\mathrm{Blended}$')
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.61, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(RCMAP(0.3))
legend.legendHandles[1].set_color(RCMAP(0.6))
legend.legendHandles[2].set_color(RCMAP(0.8))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmax, xmin)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-R_magR_logSN_fPSF.pdf'),
format='pdf', dpi=90)
In [111]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoZ1['mag_Z']
yy = np.log10(starIsoZ1['flux.psf'] / starIsoZ1['flux.psf.err'])
xx2 = starIsoZ2['mag_Z']
yy2 = np.log10(starIsoZ2['flux.psf'] / starIsoZ2['flux.psf.err'])
xx3 = starBldZ1['mag_Z']
yy3 = np.log10(starBldZ1['flux.psf'] / starBldZ1['flux.psf.err'])
xmin, xmax = 17.09, 26.9
ymin, ymax = 0.4, 3.89
xlabel = r'$z\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$z\ \mathrm{Band}\ \log\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=ZCMAP, mincnt=1,
alpha=0.7, gridsize=[36, 22], label='$\mathrm{Good}$',
marginals=False, vmin=1, vmax=1200,
edgecolor=ZCMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(50, H.max(), 3)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.6), ZCMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Sscatter
ax1.scatter(xx3, yy3, color=ZCMAP(0.4), marker='o', edgecolor='None', alpha=0.9,
zorder=0, s=30, label='$\mathrm{Blended}$')
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.61, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ZCMAP(0.3))
legend.legendHandles[1].set_color(ZCMAP(0.6))
legend.legendHandles[2].set_color(ZCMAP(0.8))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmax, xmin)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-Z_magZ_logSN_fPSF.pdf'),
format='pdf', dpi=90)
In [71]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoY1['mag_Y']
yy = np.log10(starIsoY1['flux.psf'] / starIsoY1['flux.psf.err'])
xx2 = starIsoY2['mag_Y']
yy2 = np.log10(starIsoY2['flux.psf'] / starIsoY2['flux.psf.err'])
xx3 = starBldY1['mag_Y']
yy3 = np.log10(starBldY1['flux.psf'] / starBldY1['flux.psf.err'])
xmin, xmax = 16.89, 26.19
ymin, ymax = 0.4, 3.89
xlabel = r'$\mathrm{y\ Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$\mathrm{y\ Band}\ \log\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=YCMAP, mincnt=1,
alpha=0.7, gridsize=[36, 22], label='$\mathrm{Good}$',
marginals=False, vmin=1, vmax=1200,
edgecolor=YCMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(50, H.max(), 3)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.6), YCMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Sscatter
ax1.scatter(xx3, yy3, color=YCMAP(0.4), marker='o', edgecolor='None', alpha=0.9,
zorder=0, s=30, label='$\mathrm{Blended}$')
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.61, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.3))
legend.legendHandles[1].set_color(YCMAP(0.6))
legend.legendHandles[2].set_color(YCMAP(0.8))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmax, xmin)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-Y_magY_logSN_fPSF.pdf'),
format='pdf', dpi=90)
In [115]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starGoodI1['force.mag.psf']
yy = np.log10(starGoodI1['flux.psf'] / starGoodI1['flux.psf.err'])
xx2 = starGoodI2['force.mag.psf']
yy2 = np.log10(starGoodI2['flux.psf'] / starGoodI2['flux.psf.err'])
xx3 = starBldI1['force.mag.psf']
yy3 = np.log10(starBldI1['flux.psf'] / starBldI1['flux.psf.err'])
xmin, xmax = 17.49, 27.4
ymin, ymax = 0.4, 3.89
xlabel = r'$i\ \mathrm{Band\ Forced\ PSF\ Magnitude\ (mag)}$'
ylabel = r'$i\ \mathrm{Band}\ \log\ (\mathrm{S}/\mathrm{N})_{\mathrm{PSF}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.15, right=0.99,
bottom=0.15, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=1,
alpha=0.7, gridsize=[36, 22], label='$\mathrm{Good}$',
marginals=False, vmin=1, vmax=1600,
edgecolor=ICMAP(0.2))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 2)
levels = np.linspace(50, H.max(), 3)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Sscatter
ax1.scatter(xx3, yy3, color=ICMAP(0.4), marker='o', edgecolor='None', alpha=0.9,
zorder=0, s=30, label='$\mathrm{Blended}$')
ax1.axhline(np.log10(5.0), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.61, 0.12), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.6))
legend.legendHandles[2].set_color(ICMAP(0.8))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmax, xmin)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_ipsf_logSN_PSF.pdf'),
format='pdf', dpi=90)
In [178]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoG1['mag_G']
yy = starIsoG1['mag.psf'] - starIsoG1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
##
zz = starIsoG1['force.mag.psf.err']
zz = zz[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoG2['mag_G']
yy2 = starIsoG2['mag.psf'] - starIsoG2['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xx3 = starBldG1['mag_G']
yy3 = starBldG1['mag.psf'] - starBldG1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xmin, xmax = 16.9, 27.49
ymin, ymax = -0.099, 0.099
xlabel = r'$g\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$g_{\mathrm{\ Unforced},\ {\mathrm{PSF}}} - g_{\mathrm{\ Forced},\ {\mathrm{PSF}}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(18, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.3), GCMAP(0.5), GCMAP(0.7), GCMAP(1.0)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.6), GCMAP(0.8), GCMAP(0.9), GCMAP(1.0)), linestyles='--',
linewidths=6, levels=levels, alpha=1.0)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.5), edgecolor='none',
alpha=0.15, s=25, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
#l_handles[0] = mpatches.RegularPolygon((0,0), 6)
#l_labels[0] = '$\mathrm{Good\ Seeing}$'
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(GCMAP(0.3))
legend.legendHandles[2].set_color(GCMAP(0.7))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=GCMAP(0.3),
edgecolor=GCMAP(0.1), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, c=GCMAP(0.6), alpha=1.0, linewidth=6.0,
linestyle='--', dashes=(20, 6))
kde = KernelDensity(kernel='gaussian', bandwidth=0.005).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G_magG_dPSF-dfPSF_new.pdf'),
format='pdf', dpi=90)
In [20]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoR1['mag_R']
yy = starIsoR1['mag.psf'] - starIsoR1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
##
zz = starIsoR1['force.mag.psf.err']
zz = zz[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoR2['mag_R']
yy2 = starIsoR2['mag.psf'] - starIsoR2['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xx3 = starBldR1['mag_R']
yy3 = starBldR1['mag.psf'] - starBldR1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xmin, xmax = 16.9, 27.49
ymin, ymax = -0.099, 0.099
xlabel = r'$r\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$r_{\mathrm{\ Unforced},\ {\mathrm{PSF}}} - r_{\mathrm{\ Forced},\ {\mathrm{PSF}}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
## Scatter
ax1.scatter(xx3, yy3, color=RCMAP(0.4), marker='o', edgecolor='None', alpha=0.8,
zorder=0, s=30, label='$\mathrm{Blended}$')
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=RCMAP, mincnt=1,
alpha=0.7, gridsize=[42, 40],
marginals=False, vmin=12, vmax=800,
edgecolor=RCMAP(0.25))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(10, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(RCMAP(0.8), RCMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.8, c=BLK(0.8))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.8, c=BLK(0.8))
ax1.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=56)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[1] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[1] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(RCMAP(0.3))
legend.legendHandles[1].set_color(RCMAP(0.6))
legend.legendHandles[2].set_color(RCMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=RCMAP(0.3),
edgecolor=RCMAP(0.1), alpha=0.8, linewidth=3.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=RCMAP(0.7), alpha=0.8, linewidth=5.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.005).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=RCMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='--')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-R_magR_dPSF-dfPSF.pdf'),
format='pdf', dpi=90)
In [177]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoY1['mag_Y']
yy = starIsoY1['mag.psf'] - starIsoY1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
##
zz = starIsoY1['force.mag.psf.err']
zz = zz[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoY2['mag_Y']
yy2 = starIsoY2['mag.psf'] - starIsoY2['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xx3 = starBldY1['mag_Y']
yy3 = starBldY1['mag.psf'] - starBldY1['force.mag.psf']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 27.4) &
(yTemp >= -0.14) & (yTemp <= 0.14)]
xmin, xmax = 16.9, 27.49
ymin, ymax = -0.099, 0.099
xlabel = r'$y\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$y_{\mathrm{\ Unforced},\ {\mathrm{PSF}}} - y_{\mathrm{\ Forced},\ {\mathrm{PSF}}}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(18, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.3), YCMAP(0.5), YCMAP(0.7), YCMAP(1.0)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.6), YCMAP(0.8), YCMAP(0.9), YCMAP(1.0)), linestyles='--',
linewidths=6, levels=levels, alpha=1.0)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.7), edgecolor='none',
alpha=0.2, s=25, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
#l_handles[0] = mpatches.RegularPolygon((0,0), 6)
#l_labels[0] = '$\mathrm{Good\ Seeing}$'
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(YCMAP(0.3))
legend.legendHandles[2].set_color(YCMAP(0.7))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=YCMAP(0.3),
edgecolor=YCMAP(0.1), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.002).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, c=YCMAP(0.6), alpha=1.0, linewidth=6.0,
linestyle='--', dashes=(20, 6))
kde = KernelDensity(kernel='gaussian', bandwidth=0.005).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-Y_magY_dPSF-dfPSF_new.pdf'),
format='pdf', dpi=90)
In [65]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoI1['mag_I']
yy = starIsoI1['force.mag.psf'] - starIsoI1['mag_I'] - starIsoI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoI1['force.mag.psf.err'] ** 2.0 + starIsoI1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
yyErr = np.asarray([np.nanstd(yy[idx==k]) for k in range(total_bins)])
xx2 = starIsoI2['mag_I']
yy2 = starIsoI2['force.mag.psf'] - starIsoI2['mag_I'] - starIsoI2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldI1['mag_I']
yy3 = starBldI1['force.mag.psf'] - starBldI1['mag_I'] - starBldI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$i_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - i_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
## Scatter
ax1.scatter(xx3, yy3, color=ICMAP(0.4), marker='o', edgecolor='None', alpha=0.8,
zorder=0, s=30, label='$\mathrm{Blended}$')
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=1,
alpha=0.7, gridsize=[42, 38],
marginals=False, vmin=10, vmax=900,
edgecolor=ICMAP(0.25))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(6, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.8), ICMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.8, c=BLK(0.8))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.8, c=BLK(0.8))
ax1.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[1] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[1] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.6))
legend.legendHandles[2].set_color(ICMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.3),
edgecolor=ICMAP(0.1), alpha=0.8, linewidth=3.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=ICMAP(0.7), alpha=0.8, linewidth=5.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=ICMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='--')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_magI_dfPSF.pdf'),
format='pdf', dpi=90)
In [185]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoI1['mag_I']
yy = starIsoI1['force.mag.psf'] - starIsoI1['mag_I'] - starIsoI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoI1['force.mag.psf.err'] ** 2.0 + starIsoI1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
yyErr = np.asarray([np.nanstd(yy[idx==k]) for k in range(total_bins)])
xx2 = starIsoI2['mag_I']
yy2 = starIsoI2['force.mag.psf'] - starIsoI2['mag_I'] - starIsoI2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldI1['mag_I']
yy3 = starBldI1['force.mag.psf'] - starBldI1['mag_I'] - starBldI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$i_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - i_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.3), ICMAP(0.5), ICMAP(0.7), ICMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.6), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(ICMAP(0.3))
legend.legendHandles[2].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.25),
edgecolor=ICMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ICMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_magI_dfPSF_new.pdf'),
format='pdf', dpi=90)
In [115]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" i-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoI1['mag_I']
yy = starIsoI1['force.mag.psf'] - starIsoI1['mag_I'] - starIsoI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[0:])
print(yyErr[0:])
print("#--------------------------------------------------------------------------------")
xx = starIsoI1['mag_I']
yy = starIsoI1['mag.psf'] - starIsoI1['mag_I'] - starIsoI1['mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Unforced PSF; W/ apcorr")
print(yyStd[0:])
print(yyErr[0:])
print("#--------------------------------------------------------------------------------")
xx = starIsoI2['mag_I']
yy = starIsoI2['force.mag.psf'] - starIsoI2['mag_I'] - starIsoI2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldI1['mag_I']
yy = starBldI1['force.mag.psf'] - starBldI1['mag_I'] - starBldI1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 25.5) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [116]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" i-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoI1['mag_I'] + starIsoI1['force.mag.psf.apcorr']
ff = 10.0 ** ((27.0 - xx) / 2.5)
yy = starIsoI1['force.mag.psf'] - starIsoI1['mag_I'] - starIsoI1['force.mag.psf.apcorr']
zz = ((starIsoI1['force.flux.psf'] - ff) / ff) * 100.0
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 25.0) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 25.0) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
zz = zz[(xTemp >= 18.5) & (xTemp <= 25.0) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
zzStd = np.asarray([np.nanstd(zz[idx==k+1]) for k in range(total_bins)])
zzErr = np.asarray([np.nanmedian(zz[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(zzStd[1:])
print(zzErr[1:])
print("#--------------------------------------------------------------------------------")
In [186]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoG1['mag_G']
yy = starIsoG1['force.mag.psf'] - starIsoG1['mag_G'] - starIsoG1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoG1['force.mag.psf.err'] ** 2.0 + starIsoG1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoG2['mag_G']
yy2 = starIsoG2['force.mag.psf'] - starIsoG2['mag_G'] - starIsoG2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldG1['mag_G']
yy3 = starBldG1['force.mag.psf'] - starBldG1['mag_G'] - starBldG1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$g\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$g_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - g_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(1, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.3), GCMAP(0.5), GCMAP(0.7), GCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(1, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.6), GCMAP(0.7), GCMAP(0.9), GCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.6), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(GCMAP(0.3))
legend.legendHandles[2].set_color(GCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=GCMAP(0.2),
edgecolor=GCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=GCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G_magG_dfPSF_new.pdf'),
format='pdf', dpi=90)
In [188]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" g-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoG1['mag_G']
yy = starIsoG1['force.mag.psf'] - starIsoG1['mag_G'] - starIsoG1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoG1['mag_G']
yy = starIsoG1['mag.psf'] - starIsoG1['mag_G'] - starIsoG1['mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Unforced PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoG2['mag_G']
yy = starIsoG2['force.mag.psf'] - starIsoG2['mag_G'] - starIsoG2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldG1['mag_G']
yy = starBldG1['force.mag.psf'] - starBldG1['mag_G'] - starBldG1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [189]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
print("#--------------------------------------------------------------------------------")
print(" g-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoG1['mag_G'] + starIsoG1['force.mag.psf.apcorr']
ff = 10.0 ** ((27.0 - xx) / 2.5)
yy = starIsoG1['force.mag.psf'] - starIsoG1['mag_G'] - starIsoG1['force.mag.psf.apcorr']
zz = ((starIsoG1['force.flux.psf'] - ff) / ff) * 100.0
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
zz = zz[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
zzStd = np.asarray([np.nanstd(zz[idx==k+1]) for k in range(total_bins)])
zzErr = np.asarray([np.nanmedian(zz[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(zzStd[1:])
print(zzErr[1:])
print("#--------------------------------------------------------------------------------")
In [191]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoR1['mag_R']
yy = starIsoR1['force.mag.psf'] - starIsoR1['mag_R'] - starIsoR1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoR1['force.mag.psf.err'] ** 2.0 + starIsoR1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoR2['mag_R']
yy2 = starIsoR2['force.mag.psf'] - starIsoR2['mag_R'] - starIsoR2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldR1['mag_R']
yy3 = starBldR1['force.mag.psf'] - starBldR1['mag_R'] - starBldR1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$r\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$r_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - r_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(1, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(RCMAP(0.3), RCMAP(0.5), RCMAP(0.7), RCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(2, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(RCMAP(0.6), RCMAP(0.7), RCMAP(0.9), RCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.7), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(RCMAP(0.3))
legend.legendHandles[2].set_color(RCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=RCMAP(0.2),
edgecolor=RCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=RCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-R_magR_dfPSF_new.pdf'),
format='pdf', dpi=90)
In [193]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" r-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoR1['mag_R']
yy = starIsoR1['force.mag.psf'] - starIsoR1['mag_R'] - starIsoR1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoR1['mag_R']
yy = starIsoR1['mag.psf'] - starIsoR1['mag_R'] - starIsoR1['mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Unforced PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoR2['mag_R']
yy = starIsoR2['force.mag.psf'] - starIsoR2['mag_R'] - starIsoR2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldR1['mag_R']
yy = starBldR1['force.mag.psf'] - starBldR1['mag_R'] - starBldR1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [194]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
print("#--------------------------------------------------------------------------------")
print(" r-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoR1['mag_R'] + starIsoR1['force.mag.psf.apcorr']
ff = 10.0 ** ((27.0 - xx) / 2.5)
yy = starIsoR1['force.mag.psf'] - starIsoR1['mag_R'] - starIsoR1['force.mag.psf.apcorr']
zz = ((starIsoR1['force.flux.psf'] - ff) / ff) * 100.0
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
zz = zz[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
zzStd = np.asarray([np.nanstd(zz[idx==k+1]) for k in range(total_bins)])
zzErr = np.asarray([np.nanmedian(zz[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(zzStd[1:])
print(zzErr[1:])
print("#--------------------------------------------------------------------------------")
In [198]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoZ1['mag_Z']
yy = starIsoZ1['force.mag.psf'] - starIsoZ1['mag_Z'] - starIsoZ1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoZ1['force.mag.psf.err'] ** 2.0 + starIsoZ1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoZ2['mag_Z']
yy2 = starIsoZ2['force.mag.psf'] - starIsoZ2['mag_Z'] - starIsoZ2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldZ1['mag_Z']
yy3 = starBldZ1['force.mag.psf'] - starBldZ1['mag_Z'] - starBldZ1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$z\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$z_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - z_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.3), ZCMAP(0.5), ZCMAP(0.7), ZCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(1.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.6), ZCMAP(0.7), ZCMAP(0.9), ZCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.7), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(ZCMAP(0.3))
legend.legendHandles[2].set_color(ZCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ZCMAP(0.2),
edgecolor=ZCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ZCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-Z_magZ_dfPSF_new.pdf'),
format='pdf', dpi=90)
In [203]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" z-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoZ1['mag_Z']
yy = starIsoZ1['force.mag.psf'] - starIsoZ1['mag_Z'] - starIsoZ1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoZ1['mag_Z']
yy = starIsoZ1['mag.psf'] - starIsoZ1['mag_Z'] - starIsoZ1['mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Unforced PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoZ2['mag_Z']
yy = starIsoZ2['force.mag.psf'] - starIsoZ2['mag_Z'] - starIsoZ2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldZ1['mag_Z']
yy = starBldZ1['force.mag.psf'] - starBldZ1['mag_Z'] - starBldZ1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [200]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" z-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoZ1['mag_Z'] + starIsoZ1['force.mag.psf.apcorr']
ff = 10.0 ** ((27.0 - xx) / 2.5)
yy = starIsoZ1['force.mag.psf'] - starIsoZ1['mag_Z'] - starIsoZ1['force.mag.psf.apcorr']
zz = ((starIsoZ1['force.flux.psf'] - ff) / ff) * 100.0
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
zz = zz[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
zzStd = np.asarray([np.nanstd(zz[idx==k+1]) for k in range(total_bins)])
zzErr = np.asarray([np.nanmedian(zz[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(zzStd[1:])
print(zzErr[1:])
print("#--------------------------------------------------------------------------------")
In [204]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoY1['mag_Y']
yy = starIsoY1['force.mag.psf'] - starIsoY1['mag_Y'] - starIsoY1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
##
zz = np.sqrt(starIsoY1['force.mag.psf.err'] ** 2.0 + starIsoY1['force.mag.psf.apcorr.err'] ** 2.0)
zz = zz[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoY2['mag_Y']
yy2 = starIsoY2['force.mag.psf'] - starIsoY2['mag_Y'] - starIsoY2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy2 = yy2[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xx3 = starBldY1['mag_Y']
yy3 = starBldY1['force.mag.psf'] - starBldY1['mag_Y'] - starBldY1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy3 = yy3[(xTemp >= 16.9) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
xmin, xmax = 16.9, 27.29
ymin, ymax = -0.42, 0.59
xlabel = r'$y\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$y_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - y_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.3), YCMAP(0.5), YCMAP(0.7), YCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.0)
levels = np.linspace(1.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(YCMAP(0.6), YCMAP(0.7), YCMAP(0.9), YCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.7), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(YCMAP(0.3))
legend.legendHandles[2].set_color(YCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=YCMAP(0.2),
edgecolor=YCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=YCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-Y_magY_dfPSF_new.pdf'),
format='pdf', dpi=90)
In [205]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" y-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoY1['mag_Y']
yy = starIsoY1['force.mag.psf'] - starIsoY1['mag_Y'] - starIsoY1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoY1['mag_Y']
yy = starIsoY1['mag.psf'] - starIsoY1['mag_Y'] - starIsoY1['mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Unforced PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoY2['mag_Y']
yy = starIsoY2['force.mag.psf'] - starIsoY2['mag_Y'] - starIsoY2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldY1['mag_Y']
yy = starBldY1['force.mag.psf'] - starBldY1['mag_Y'] - starBldY1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [206]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" y-Band PSF")
print("#--------------------------------------------------------------------------------")
xx = starIsoY1['mag_Y'] + starIsoY1['force.mag.psf.apcorr']
ff = 10.0 ** ((27.0 - xx) / 2.5)
yy = starIsoY1['force.mag.psf'] - starIsoY1['mag_Y'] - starIsoY1['force.mag.psf.apcorr']
zz = ((starIsoY1['force.flux.psf'] - ff) / ff) * 100.0
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
yy = yy[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
zz = zz[(xTemp >= 19.1) & (xTemp <= 26.9) &
(yTemp >= -0.42) & (yTemp <= 0.59)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
zzStd = np.asarray([np.nanstd(zz[idx==k+1]) for k in range(total_bins)])
zzErr = np.asarray([np.nanmedian(zz[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(zzStd[:])
print(zzErr[:])
print("#--------------------------------------------------------------------------------")
In [214]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xx = starIsoI1['mag_I']
yy = starIsoI1['mag.psf'] - starIsoI1['cmodel.mag']
xmin, xmax = 16.9, 26.9
ymin, ymax = -0.29, 0.49
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = misClassI2['mag_I']
yy2 = misClassI2['mag.psf'] - misClassI2['cmodel.mag']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx3 = misClassI1['mag_I']
yy3 = misClassI1['mag.psf'] - misClassI1['cmodel.mag']
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy3 = yy3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$i_{\mathrm{PSF}} - i_{\mathrm{cModel}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.3), ICMAP(0.5), ICMAP(0.7), ICMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx3, yy3, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx, yy, marker='o', facecolor=YCMAP(0.5), edgecolor='none',
alpha=0.1, s=15, label='$\mathrm{Good\ Seeing}$', rasterized=True)
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Misclassified/Bad\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Misclassified/Good\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.6))
legend.legendHandles[1].set_color(ICMAP(0.3))
legend.legendHandles[2].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.25),
edgecolor=ICMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ICMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.5), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_magI_dPSF-cModel_new.pdf'),
format='pdf', dpi=90)
In [215]:
starIsoGI1 = join(starIsoG1, starIsoI1, join_type='inner', keys='id')
starIsoGI2 = join(starIsoG2, starIsoI2, join_type='inner', keys='id')
starBldGI1 = join(starBldG1, starBldI1, join_type='inner', keys='id')
In [217]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -1.19, 5.29
ymin, ymax = -0.79, 0.79
xx = starIsoGI1['mag_G_1'] - starIsoGI1['mag_I_1']
yy = (starIsoGI1['force.mag.psf_1'] - starIsoGI1['force.mag.psf.apcorr_1'] -
starIsoGI1['force.mag.psf_2'] + starIsoGI1['force.mag.psf.apcorr_2']) - xx
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
zz = np.sqrt(starIsoGI1['force.mag.psf.err_1'] ** 2.0 + starIsoGI1['force.mag.psf.err_2'] ** 2.0 +
starIsoGI1['force.mag.psf.apcorr.err_1'] ** 2.0 + starIsoGI1['force.mag.psf.apcorr.err_2'] ** 2.0)
zz = zz[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoGI2['mag_G_1'] - starIsoGI2['mag_I_1']
yy2 = (starIsoGI2['force.mag.psf_1'] - starIsoGI2['force.mag.psf.apcorr_1'] -
starIsoGI2['force.mag.psf_2'] + starIsoGI2['force.mag.psf.apcorr_2']) - xx2
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx3 = starBldGI1['mag_G_1'] - starBldGI1['mag_I_1']
yy3 = (starBldGI1['force.mag.psf_1'] - starBldGI1['force.mag.psf.apcorr_1'] -
starBldGI1['force.mag.psf_2'] + starBldGI1['force.mag.psf.apcorr_2']) - xx3
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy3 = yy3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(g-i)\ \mathrm{Input\ Color\ (mag)}$'
ylabel = r'$(g-i)_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - (g-i)_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.5)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.3), ICMAP(0.5), ICMAP(0.7), ICMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.5)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.8), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.8))
legend.legendHandles[1].set_color(ICMAP(0.3))
legend.legendHandles[2].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.25),
edgecolor=ICMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ICMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None',
edgecolor=YCMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G-I_giInput_giPSF_new.pdf'),
format='pdf', dpi=90)
In [219]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = 17.2, 26.9
ymin, ymax = -0.79, 0.79
xx = starIsoGI1['mag_I_1']
yy = (starIsoGI1['force.mag.psf_1'] - starIsoGI1['force.mag.psf.apcorr_1'] -
starIsoGI1['force.mag.psf_2'] + starIsoGI1['force.mag.psf.apcorr_2']) - (
starIsoGI1['mag_G_1'] - starIsoGI1['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
zz = np.sqrt(starIsoGI1['force.mag.psf.err_1'] ** 2.0 + starIsoGI1['force.mag.psf.err_2'] ** 2.0 +
starIsoGI1['force.mag.psf.apcorr.err_1'] ** 2.0 + starIsoGI1['force.mag.psf.apcorr.err_2'] ** 2.0)
zz = zz[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoGI2['mag_I_1']
yy2 = (starIsoGI2['force.mag.psf_1'] - starIsoGI2['force.mag.psf.apcorr_1'] -
starIsoGI2['force.mag.psf_2'] + starIsoGI2['force.mag.psf.apcorr_2']) - (
starIsoGI2['mag_G_1'] - starIsoGI2['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx3 = starBldGI1['mag_I_1']
yy3 = (starBldGI1['force.mag.psf_1'] - starBldGI1['force.mag.psf.apcorr_1'] -
starBldGI1['force.mag.psf_2'] + starBldGI1['force.mag.psf.apcorr_2']) - (
starBldGI1['mag_G_1'] - starBldGI1['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy3 = yy3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$(g-i)_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - (g-i)_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.3), ICMAP(0.5), ICMAP(0.7), ICMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.8), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.8))
legend.legendHandles[1].set_color(ICMAP(0.3))
legend.legendHandles[2].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ICMAP(0.25),
edgecolor=ICMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ICMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens) * 2.0, facecolor='None',
edgecolor=YCMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G-I_imag_giPSF_new.pdf'),
format='pdf', dpi=90)
In [243]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" g-i PSF color")
print("#--------------------------------------------------------------------------------")
xx = starIsoGI1['mag_I_1']
yy = (starIsoGI1['force.mag.psf_1'] - starIsoGI1['force.mag.psf.apcorr_1'] -
starIsoGI1['force.mag.psf_2'] + starIsoGI1['force.mag.psf.apcorr_2']) - (
starIsoGI1['mag_G_1'] - starIsoGI1['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoGI2['mag_I_1']
yy = (starIsoGI2['force.mag.psf_1'] - starIsoGI2['force.mag.psf.apcorr_1'] -
starIsoGI2['force.mag.psf_2'] + starIsoGI2['force.mag.psf.apcorr_2']) - (
starIsoGI2['mag_G_1'] - starIsoGI2['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Bad Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldGI1['mag_I_1']
yy = (starBldGI1['force.mag.psf_1'] - starBldGI1['force.mag.psf.apcorr_1'] -
starBldGI1['force.mag.psf_2'] + starBldGI1['force.mag.psf.apcorr_2']) - (
starBldGI1['mag_G_1'] - starBldGI1['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Blended; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [221]:
starIsoIY1 = join(starIsoI1, starIsoY1, join_type='inner', keys='id')
starIsoIY2 = join(starIsoI2, starIsoY2, join_type='inner', keys='id')
starBldIY1 = join(starBldI1, starBldY1, join_type='inner', keys='id')
In [222]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -0.99, 1.99
ymin, ymax = -0.79, 0.79
xx = starIsoIY1['mag_I_1'] - starIsoIY1['mag_Y_1']
yy = (starIsoIY1['force.mag.psf_1'] - starIsoIY1['force.mag.psf.apcorr_1'] -
starIsoIY1['force.mag.psf_2'] + starIsoIY1['force.mag.psf.apcorr_2']) - xx
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
zz = np.sqrt(starIsoIY1['force.mag.psf.err_1'] ** 2.0 + starIsoIY1['force.mag.psf.err_2'] ** 2.0 +
starIsoIY1['force.mag.psf.apcorr.err_1'] ** 2.0 + starIsoIY1['force.mag.psf.apcorr.err_2'] ** 2.0)
zz = zz[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoIY2['mag_I_1'] - starIsoIY2['mag_Y_1']
yy2 = (starIsoIY2['force.mag.psf_1'] - starIsoIY2['force.mag.psf.apcorr_1'] -
starIsoIY2['force.mag.psf_2'] + starIsoIY2['force.mag.psf.apcorr_2']) - xx2
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx3 = starBldIY1['mag_I_1'] - starBldIY1['mag_Y_1']
yy3 = (starBldIY1['force.mag.psf_1'] - starBldIY1['force.mag.psf.apcorr_1'] -
starBldIY1['force.mag.psf_2'] + starBldIY1['force.mag.psf.apcorr_2']) - xx3
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy3 = yy3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(i-y)\ \mathrm{Input\ Color\ (mag)}$'
ylabel = r'$(i-y)_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - (i-y)_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.3), ZCMAP(0.5), ZCMAP(0.7), ZCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.6), ZCMAP(0.7), ZCMAP(0.8), ZCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.8), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.8))
legend.legendHandles[1].set_color(ZCMAP(0.3))
legend.legendHandles[2].set_color(ZCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ZCMAP(0.25),
edgecolor=ZCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ZCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens) * 2.0, facecolor='None',
edgecolor=YCMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I-Y_iyInput_iyPSF_new.pdf'),
format='pdf', dpi=90)
In [228]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = 16.8, 26.9
ymin, ymax = -0.79, 0.79
xx = starIsoIY1['mag_I_1']
yy = (starIsoIY1['force.mag.psf_1'] - starIsoIY1['force.mag.psf.apcorr_1'] -
starIsoIY1['force.mag.psf_2'] + starIsoIY1['force.mag.psf.apcorr_2']) - (
starIsoIY1['mag_I_1'] - starIsoIY1['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
zz = np.sqrt(starIsoIY1['force.mag.psf.err_1'] ** 2.0 + starIsoIY1['force.mag.psf.err_2'] ** 2.0 +
starIsoIY1['force.mag.psf.apcorr.err_1'] ** 2.0 + starIsoIY1['force.mag.psf.apcorr.err_2'] ** 2.0)
zz = zz[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
total_bins = 20
bins = np.linspace(xx.min(), xx.max(), total_bins)
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins - delta / 2.0)
zzErr = np.asarray([np.nanmedian(zz[idx==k]) for k in range(total_bins)])
xx2 = starIsoIY2['mag_I_1']
yy2 = (starIsoIY2['force.mag.psf_1'] - starIsoIY2['force.mag.psf.apcorr_1'] -
starIsoIY2['force.mag.psf_2'] + starIsoIY2['force.mag.psf.apcorr_2']) - (
starIsoIY2['mag_I_1'] - starIsoIY2['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx3 = starBldIY1['mag_I_1']
yy3 = (starBldIY1['force.mag.psf_1'] - starBldIY1['force.mag.psf.apcorr_1'] -
starBldIY1['force.mag.psf_2'] + starBldIY1['force.mag.psf.apcorr_2']) - (
starBldIY1['mag_I_1'] - starBldIY1['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx3), copy.deepcopy(yy3)
xx3 = xx3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy3 = yy3[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$i\ \mathrm{Band\ Input\ Magnitude\ (mag)}$'
ylabel = r'$(i-y)_{\mathrm{Forced},\ {\mathrm{PSF}}} - (i-y)_{\mathrm{Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%4.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(17, 15))
ax1 = plt.axes(recScat)
ax2 = plt.axes(recHist)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.3), ZCMAP(0.5), ZCMAP(0.7), ZCMAP(1.0)),
linewidths=10, levels=levels, alpha=0.6)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1.2)
levels = np.linspace(0.5, H.max(), 4)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ZCMAP(0.6), ZCMAP(0.7), ZCMAP(0.8), ZCMAP(1.0)),
linestyles='--', linewidths=6, levels=levels, alpha=0.9)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
## Scatter
CS3 = ax1.scatter(xx3, yy3, marker='o', facecolor=YCMAP(0.8), edgecolor='none',
alpha=0.2, s=20, label='$\mathrm{Blended}$', rasterized=True)
## Running medians
ax1.plot(xxCen, zzErr,'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.plot(xxCen, zzErr * (-1.0),'--', lw=4, alpha=0.6, c=BLK(0.7), dashes=(40,10))
ax1.axhline(0.0, color=BLK(0.7), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.8)
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=60)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.09, 0.05), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=2.0, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(YCMAP(0.8))
legend.legendHandles[1].set_color(ZCMAP(0.3))
legend.legendHandles[2].set_color(ZCMAP(0.5))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=ZCMAP(0.25),
edgecolor=ZCMAP(0.05), alpha=1.0, linewidth=1.0, linestyle='-')
kde = KernelDensity(kernel='gaussian', bandwidth=0.001).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.plot(np.exp(log_dens), yPlot, linestyle='--', dashes=(20, 6), linewidth=6.0,
color=ZCMAP(0.6), alpha=1.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy3[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax2.fill_betweenx(yPlot, 0.0, np.exp(log_dens) * 2.0, facecolor='None',
edgecolor=YCMAP(0.8), alpha=0.8, linewidth=6.0,
linestyle='-')
ax2.axhline(0.0, color=BLK(0.8), linewidth=5.0, linestyle='--', dashes=(40, 10),
alpha=0.9)
ax2.set_ylim(ax1.get_ylim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I-Y_imag_iyPSF_new.pdf'),
format='pdf', dpi=90)
In [225]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
total_bins = 7
bins = np.asarray([18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5])
print("#--------------------------------------------------------------------------------")
print(" i-y PSF color")
print("#--------------------------------------------------------------------------------")
xx = starIsoIY1['mag_I_1']
yy = (starIsoIY1['force.mag.psf_1'] - starIsoIY1['force.mag.psf.apcorr_1'] -
starIsoIY1['force.mag.psf_2'] + starIsoIY1['force.mag.psf.apcorr_2']) - (
starIsoIY1['mag_I_1'] - starIsoIY1['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("Magnitude bins: ", xxCen)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starIsoIY2['mag_I_1']
yy = (starIsoIY2['force.mag.psf_1'] - starIsoIY2['force.mag.psf.apcorr_1'] -
starIsoIY2['force.mag.psf_2'] + starIsoIY2['force.mag.psf.apcorr_2']) - (
starIsoIY2['mag_I_1'] - starIsoIY2['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
xx = starBldIY1['mag_I_1']
yy = (starBldIY1['force.mag.psf_1'] - starBldIY1['force.mag.psf.apcorr_1'] -
starBldIY1['force.mag.psf_2'] + starBldIY1['force.mag.psf.apcorr_2']) - (
starBldIY1['mag_I_1'] - starBldIY1['mag_Y_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
yy = yy[(xTemp >= 18.5) & (xTemp <= 26.9) &
(yTemp >= -0.62) & (yTemp <= 0.69)]
delta = (bins[1] - bins[0])
idx = np.digitize(xx, bins)
xxCen = (bins + delta / 2.0)
print("#--------------------------------------------------------------------------------")
yyStd = np.asarray([np.nanstd(yy[idx==k+1]) for k in range(total_bins)])
yyErr = np.asarray([np.nanmedian(yy[idx==k+1]) for k in range(total_bins)])
print("# Good Seeing; Force PSF; W/ apcorr")
print(yyStd[:])
print(yyErr[:])
print("#--------------------------------------------------------------------------------")
In [227]:
starIsoGR1 = join(starIsoG1, starIsoR1, join_type='inner', keys='id')
starIsoGR2 = join(starIsoG2, starIsoR2, join_type='inner', keys='id')
starBldGR1 = join(starBldG1, starBldR1, join_type='inner', keys='id')
print(len(starIsoGR1), len(starIsoGR2), len(starBldR1))
starIsoGRI1 = join(starIsoGR1, starIsoI1, join_type='inner', keys='id')
starIsoGRI2 = join(starIsoGR2, starIsoI2, join_type='inner', keys='id')
starBldGRI1 = join(starBldGR1, starBldI1, join_type='inner', keys='id')
print(len(starIsoGRI1), len(starIsoGRI2), len(starBldGRI1))
In [230]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -0.39, 1.99
ymin, ymax = -0.39, 2.49
xx = starIsoGRI1['mag_G_1'] - starIsoGRI1['mag_R_1']
yy = starIsoGRI1['mag_R_1'] - starIsoGRI1['mag_I_1']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = (starIsoGRI1['force.mag.psf_1'] - starIsoGRI1['force.mag.psf.apcorr_1'] -
starIsoGRI1['force.mag.psf_2'] + starIsoGRI1['force.mag.psf.apcorr_2'])
yy2 = (starIsoGRI1['force.mag.psf_2'] - starIsoGRI1['force.mag.psf.apcorr_2'] -
starIsoGRI1['force.mag.psf'] + starIsoGRI1['force.mag.psf.apcorr'])
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(g-r)_{\mathrm{PSF}}} \mathrm{(mag)}$'
ylabel = r'$(r-i)_{\mathrm{PSF}}} \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%5.1f}$', r'$\mathbf{%5.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = plt.axes(EC1)
ax2 = plt.axes(EC2)
ax3 = plt.axes(EC3)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
## Contour
H, xbins, ybins = np.histogram2d(xx, yy, bins=(90, 90))
H = gaussian_filter(H, 1.2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS3 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(BLK(0.3), BLK(0.5), BLK(0.7), BLK(0.9)),
linewidths=10, levels=levels, alpha=0.6)
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(90, 90))
H = gaussian_filter(H, 1.2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(GCMAP(0.6), GCMAP(0.7), GCMAP(0.8), GCMAP(0.9)),
linewidths=6, levels=levels, alpha=0.8)
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles = []
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS3.collections]
l_handles.append(proxy[0])
l_handles.append(CS2.collections[-1])
l_labels = []
l_labels.append('$\mathrm{Input}$')
l_labels.append('$\mathrm{Forced\ PSF}$')
ax1.legend(l_handles, l_labels, loc=(0.07, 0.80), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(BLK(0.3))
legend.legendHandles[1].set_color(GCMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.008).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=BLK(0.3), edgecolor=BLK(0.0),
alpha=0.9, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.008).fit(xx2[:, None])
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor='None', edgecolor=GCMAP(0.8),
alpha=0.9, linewidth=7.0, linestyle='-')
ax2.set_xlim(ax1.get_xlim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=BLK(0.3), edgecolor=BLK(0.0),
alpha=0.9, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.02).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=GCMAP(0.8),
alpha=0.9, linewidth=7.0, linestyle='-')
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-G-R-I_grPSF_riPSF_new.pdf'),
format='pdf', dpi=90)
In [231]:
starIsoIZY1 = join(starIsoIY1, starIsoZ1, join_type='inner', keys='id')
starIsoIZY2 = join(starIsoIY2, starIsoZ2, join_type='inner', keys='id')
starBldIZY1 = join(starBldIY1, starBldZ1, join_type='inner', keys='id')
print(len(starIsoIZY1), len(starIsoIZY2), len(starBldIZY1))
In [233]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -0.29, 1.19
ymin, ymax = -0.29, 0.59
xx = starIsoIZY1['mag_I_1'] - starIsoIZY1['mag_Z_1']
yy = starIsoIZY1['mag_Z_1'] - starIsoIZY1['mag_Y_1']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = (starIsoIZY1['force.mag.psf_1'] - starIsoIZY1['force.mag.psf.apcorr_1'] -
starIsoIZY1['force.mag.psf'] + starIsoIZY1['force.mag.psf.apcorr'])
yy2 = (starIsoIZY1['force.mag.psf'] - starIsoIZY1['force.mag.psf.apcorr'] -
starIsoIZY1['force.mag.psf_2'] + starIsoIZY1['force.mag.psf.apcorr_2'])
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$(i-z)_{\mathrm{PSF}}} \mathrm{(mag)}$'
ylabel = r'$(z-y)_{\mathrm{PSF}}} \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%5.1f}$', r'$\mathbf{%5.1f}\ $'
ytickFormat2 = r'$\mathbf{%3.1f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = plt.axes(EC1)
ax2 = plt.axes(EC2)
ax3 = plt.axes(EC3)
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
ax2 = songPlotSetup(ax2, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
ax3 = songPlotSetup(ax3, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat2)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
## Contour
H, xbins, ybins = np.histogram2d(xx, yy, bins=(90, 90))
H = gaussian_filter(H, 1.2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS3 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(BLK(0.3), BLK(0.5), BLK(0.7), BLK(0.9)),
linewidths=10, levels=levels, alpha=0.6)
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(90, 90))
H = gaussian_filter(H, 1.2)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(0.9)),
linewidths=6, levels=levels, alpha=0.8)
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles = []
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_handles.append(CS2.collections[-1])
l_labels = []
l_labels.append('$\mathrm{Input}$')
l_labels.append('$\mathrm{Forced\ PSF}$')
ax1.legend(l_handles, l_labels, loc=(0.07, 0.82), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.2, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(BLK(0.3))
legend.legendHandles[1].set_color(ICMAP(0.8))
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax2
ax2.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx[:, None])
xPlot = np.linspace(xmin, xmax, 500)
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor=BLK(0.3), edgecolor=BLK(0.0),
alpha=0.9, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(xx2[:, None])
log_dens = kde.score_samples(xPlot[:, None])
ax2.fill(xPlot[:, None], np.exp(log_dens), facecolor='None', edgecolor=ICMAP(0.8),
alpha=0.9, linewidth=7.0, linestyle='-')
ax2.set_xlim(ax1.get_xlim())
ax2.yaxis.set_major_formatter(NullFormatter())
ax2.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
## Ax3
ax3.grid()
# Gaussian KDE
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy[:, None])
yPlot = np.linspace(ymin, ymax, 500)
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor=BLK(0.3), edgecolor=BLK(0.0),
alpha=0.9, linewidth=4.0)
kde = KernelDensity(kernel='gaussian', bandwidth=0.01).fit(yy2[:, None])
log_dens = kde.score_samples(yPlot[:, None])
ax3.fill_betweenx(yPlot, 0.0, np.exp(log_dens), facecolor='None', edgecolor=ICMAP(0.8),
alpha=0.9, linewidth=7.0, linestyle='-')
ax3.set_ylim(ax1.get_ylim())
ax3.yaxis.set_major_formatter(NullFormatter())
ax3.xaxis.set_major_formatter(NullFormatter())
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I-Z-Y_izPSF_zyPSF_new.pdf'),
format='pdf', dpi=90)
In [83]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -6.69, 0.29
ymin, ymax = 0.00, 0.04
starUse1 = starGoodI1[(starGoodI1['blendedness.abs.flux'] > 0.0) &
(starGoodI1['mag_I'] <= 24.0)]
starUse2 = starGoodI2[(starGoodI2['blendedness.abs.flux'] > 0.0) &
(starGoodI2['mag_I'] <= 24.0)]
xx = np.log10(starUse1['blendedness.abs.flux'])
yy = starUse1['force.mag.psf.err']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = np.log10(starUse2['blendedness.abs.flux'])
yy2 = starUse2['force.mag.psf.err']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$\log\ (\mathrm{Blendedness})$'
ylabel = r'$i\ \mathrm{Band\ PSF\ Magnitude\ Error}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%5.2f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.17, right=0.99,
bottom=0.13, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=3,
alpha=0.8, gridsize=[60, 35], label='$\mathrm{Good}$',
marginals=False, vmin=5, vmax=200,
edgecolor=ICMAP(0.3))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(220, 200))
H = gaussian_filter(H, 2)
levels = np.linspace(2, H.max(), 6)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.8), ICMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
ax1.axvline(np.log10(0.10), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.05, 0.78), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.6))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(-0.002, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_Blendedness_PSFError.pdf'),
format='pdf', dpi=90)
In [239]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -6.69, 0.29
ymin, ymax = -0.25, 0.55
starUse1 = starGoodI1[(starGoodI1['blendedness.abs.flux'] > 0.0) &
(starGoodI1['mag_I'] <= 24.0)]
starUse2 = starGoodI2[(starGoodI2['blendedness.abs.flux'] > 0.0) &
(starGoodI2['mag_I'] <= 24.0)]
xx = np.log10(starUse1['blendedness.abs.flux'])
yy = starUse1['force.mag.psf'] - starUse1['mag_I'] - starUse1['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = np.log10(starUse2['blendedness.abs.flux'])
yy2 = starUse2['force.mag.psf'] - starUse2['mag_I'] - starUse2['force.mag.psf.apcorr']
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$\log_{10}\ (\mathrm{Blendedness})$'
ylabel = r'$i_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - i_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%5.2f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.20, right=0.99,
bottom=0.13, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.2), ICMAP(0.3), ICMAP(0.4), ICMAP(0.6), ICMAP(0.8)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(0.5, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.5), ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(0.9)),
linestyles='--', linewidths=6, levels=levels, alpha=1.0)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
ax1.axhline(0.0, color=BLK(0.9), linewidth=4.0,
linestyle='-', alpha=0.9, zorder=0)
ax1.axvline(np.log10(0.10), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.05, 0.78), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.2))
legend.legendHandles[1].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(-0.19, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_Blendedness_dPSF_new.pdf'),
format='pdf', dpi=90)
In [240]:
starGoodGI1 = join(starGoodG1, starGoodI1, join_type='inner', keys='id')
starGoodGI2 = join(starGoodG2, starGoodI2, join_type='inner', keys='id')
In [87]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -6.69, 0.29
ymin, ymax = 0.02, 0.21
starUse1 = starGoodGI1[(starGoodGI1['blendedness.abs.flux_1'] > 0.0) &
(starGoodGI1['force.mag.psf_2'] <= 24.0)]
starUse2 = starGoodGI2[(starGoodGI2['blendedness.abs.flux_1'] > 0.0) &
(starGoodGI2['force.mag.psf_2'] <= 24.0)]
xx = np.log10(starUse1['blendedness.abs.flux_1'])
yy = np.sqrt(starUse1['force.mag.psf.err_1'] ** 2.0 + starUse1['force.mag.psf.err_2'] ** 2.0 +
starUse1['force.mag.psf.apcorr.err_1'] ** 2.0 + starUse1['force.mag.psf.apcorr.err_2'] ** 2.0)
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = np.log10(starUse2['blendedness.abs.flux_1'])
yy2 = np.sqrt(starUse2['force.mag.psf.err_1'] ** 2.0 + starUse2['force.mag.psf.err_2'] ** 2.0 +
starUse2['force.mag.psf.apcorr.err_1'] ** 2.0 + starUse2['force.mag.psf.apcorr.err_2'] ** 2.0)
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$\log\ (\mathrm{Blendedness})$'
ylabel = r'$(g-i)\ \mathrm{PSF\ Color\ Error}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%5.2f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.20, right=0.99,
bottom=0.13, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
## HexBin
hb1 = ax1.hexbin(xx, yy, cmap=ICMAP, mincnt=3,
alpha=0.8, gridsize=[60, 35], label='$\mathrm{Good}$',
marginals=False, vmin=5, vmax=100,
edgecolor=ICMAP(0.3))
## Contour
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(250, 250))
H = gaussian_filter(H, 2)
levels = np.linspace(0.5, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.6), ICMAP(0.6)),
linewidths=4, levels=levels, alpha=0.9)
ax1.axvline(np.log10(0.10), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
l_handles[0] = mpatches.RegularPolygon((0,0), 6)
l_handles.append(CS1.collections[-1])
l_labels[0] = '$\mathrm{Good\ Seeing}$'
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.05, 0.78), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.3))
legend.legendHandles[1].set_color(ICMAP(0.6))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(0.005, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_Blendedness_giErr.pdf'),
format='pdf', dpi=90)
In [244]:
# --------------------------------------------------------------------------------------- #
## Prepare the data
xmin, xmax = -6.69, 0.29
ymin, ymax = -0.69, 0.69
starUse1 = starGoodGI1[(starGoodGI1['blendedness.abs.flux_1'] > 0.0) &
(starGoodGI1['force.mag.psf_2'] <= 24.0)]
starUse2 = starGoodGI2[(starGoodGI2['blendedness.abs.flux_1'] > 0.0) &
(starGoodGI2['force.mag.psf_2'] <= 24.0)]
xx = np.log10(starUse1['blendedness.abs.flux_1'])
yy = (starUse1['force.mag.psf_1'] - starUse1['force.mag.psf.apcorr_1'] -
starUse1['force.mag.psf_2'] + starUse1['force.mag.psf.apcorr_2']) - (
starUse1['mag_G_1'] - starUse1['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx), copy.deepcopy(yy)
xx = xx[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy = yy[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xx2 = np.log10(starUse2['blendedness.abs.flux_1'])
yy2 = (starUse2['force.mag.psf_1'] - starUse2['force.mag.psf.apcorr_1'] -
starUse2['force.mag.psf_2'] + starUse2['force.mag.psf.apcorr_2']) - (
starUse2['mag_G_1'] - starUse2['mag_I_1'])
xTemp, yTemp = copy.deepcopy(xx2), copy.deepcopy(yy2)
xx2 = xx2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
yy2 = yy2[(xTemp >= xmin) & (xTemp <= xmax) &
(yTemp >= ymin) & (yTemp <= ymax)]
xlabel = r'$\log_{10}\ (\mathrm{Blendedness})$'
#ylabel = r'$i\ \mathrm{Band\ PSF\ Magnitude\ Error}$'
ylabel = r'$(g-i)_{\mathrm{\ Forced},\ {\mathrm{PSF}}} - (g-i)_{\mathrm{\ Input}}\ \mathrm{(mag)}$'
xtickFormat, ytickFormat = r'$\mathbf{%4.1f}$', r'$\mathbf{%5.2f}\ $'
ytickFormat2 = r'$\mathbf{%5.2f}$'
# --------------------------------------------------------------------------------------- #
## Setup up figure
fig = plt.figure(figsize=(15, 15))
ax1 = fig.add_subplot(111)
fig.subplots_adjust(left=0.20, right=0.99,
bottom=0.13, top=0.99,
wspace=0.00, hspace=0.00)
# --------------------------------------------------------------------------------------- #
## Ax1
ax1.grid()
ax1 = songPlotSetup(ax1, ylabel=50, xlabel=50, border=7.0,
xtickFormat=xtickFormat, ytickFormat=ytickFormat)
# Contour 1
H, xbins, ybins = np.histogram2d(xx, yy, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS1 = ax1.contourf(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.2), ICMAP(0.3), ICMAP(0.4), ICMAP(0.6), ICMAP(0.8)),
linewidths=10, levels=levels, alpha=1.0)
## Contour 2
H, xbins, ybins = np.histogram2d(xx2, yy2, bins=(100, 100))
H = gaussian_filter(H, 1)
levels = np.linspace(1, H.max(), 5)
Nx, Ny = len(xbins), len(ybins)
CS2 = ax1.contour(H.T, extent=[xbins[0], xbins[-1], ybins[0], ybins[-1]],
colors=(ICMAP(0.5), ICMAP(0.6), ICMAP(0.7), ICMAP(0.8), ICMAP(0.9)),
linestyles='--', linewidths=6, levels=levels, alpha=1.0)
for c in CS2.collections:
c.set_dashes([(0, (20, 6.0))])
ax1.axhline(0.0, color=BLK(0.9), linewidth=4.0,
linestyle='-', alpha=0.9, zorder=0)
ax1.axvline(np.log10(0.10), color=BLK(0.8), linewidth=5.0,
linestyle='--', dashes=(40, 10), alpha=0.9)
# --------------------------------------------------------------------------------------- #
## Legend
l_handles, l_labels = ax1.get_legend_handles_labels()
proxy = [plt.Rectangle((0,0), 1, 1, fc = pc.get_facecolor()[0])
for pc in CS1.collections]
l_handles.append(proxy[0])
l_handles.append(CS2.collections[-1])
l_labels.append('$\mathrm{Good\ Seeing}$')
l_labels.append('$\mathrm{Bad\ Seeing}$')
ax1.legend(l_handles, l_labels, loc=(0.05, 0.78), shadow=True, fancybox=True,
numpoints=1, fontsize=40, scatterpoints=1,
markerscale=1.1, borderpad=0.2, handletextpad=0.3)
legend = ax1.get_legend()
legend.legendHandles[0].set_color(ICMAP(0.2))
legend.legendHandles[1].set_color(ICMAP(0.5))
# --------------------------------------------------------------------------------------- #
ax1.set_xlabel(xlabel, size=54)
ax1.set_ylabel(ylabel, size=54)
## X, Y limits
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(-0.49, ymax)
# --------------------------------------------------------------------------------------- #
# --------------------------------------------------------------------------------------- #
fig.savefig(os.path.join(figDir, 'star1_HSC-I_Blendedness_gi_dColor_new.pdf'),
format='pdf', dpi=90)