LSSTApplications  19.0.0-14-gb0260a2+599893a4c6,20.0.0+126303c00d,20.0.0+2f3d0e5c40,20.0.0+36ef800059,20.0.0+5ac7adcc0c,20.0.0+693a64958a,20.0.0+bebc1f60e8,20.0.0+cad136aba6,20.0.0+e2e26847c2,20.0.0+e69b5d60e7,20.0.0-1-g10df615+11b215b765,20.0.0-1-g253301a+36ef800059,20.0.0-1-g2b7511a+bebc1f60e8,20.0.0-1-g4d801e7+aeeb640673,20.0.0-1-g5b95a8c+f111d5f02f,20.0.0-1-g660595b+f45b7d88f4,20.0.0-1-gc96f8cb+e3b38461e6,20.0.0-1-gd1c87d7+85c46248f3,20.0.0-1-gedffbd8+d0b27f8bcb,20.0.0-16-g111fe95+e3b38461e6,20.0.0-16-g18096c8+d1a4df0137,20.0.0-16-g233ea98+a4df35922d,20.0.0-17-ga9337b4+41f27cfd54,20.0.0-2-g4dae9ad+e3b38461e6,20.0.0-2-g7818986+85c46248f3,20.0.0-2-gec03fae+ff10c6d78d,20.0.0-28-g282f9e7e+feda6aebd8,20.0.0-3-g4cc78c6+63636aeed8,20.0.0-3-g6a8623c+d1a4df0137,20.0.0-3-g750bffe+f5427621ce,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-5-gfcebe35+e2b15ed341,20.0.0-52-g73d9071+9bf1eb8e0a,20.0.0-7-gcda7bf1+773ba852cb,20.0.0-8-g4540fe2a+952f6d3c43,20.0.0-9-g61a2a9a3d+14f89e4eca,w.2020.40
LSSTDataManagementBasePackage
Functions
lsst.synpipe.matchFakeStars Namespace Reference

Functions

def getFakeSources (rootdir, dataId, tol=0.1)
 
def main ()
 

Detailed Description

matchFakes.py
matches fakes based on position stored in the calibrated exposure image header

Function Documentation

◆ getFakeSources()

def lsst.synpipe.matchFakeStars.getFakeSources (   rootdir,
  dataId,
  tol = 0.1 
)
Get list of sources which agree in position with fake ones with tol

Definition at line 15 of file matchFakeStars.py.

15 def getFakeSources(rootdir, dataId, tol=0.1):
16  """Get list of sources which agree in position with fake ones with tol
17  """
18  butler = dafPersist.Butler(rootdir)
19 
20  sources = butler.get('src', dataId)
21  cal_md = butler.get('calexp_md', dataId)
22 
23  # Get the X, Y locations of objects on the CCD
24  srcX, srcY = sources.getX(), sources.getY()
25  # Get the zeropoint
26  zeropoint = 2.5*np.log10(cal_md.getScalar("FLUXMAG0"))
27  # Get the PSF flux and its error
28  flux, ferr = sources.getPsfFlux(), sources.getPsfFluxErr()
29  # Convert them into magnitude and its error
30  mag, merr = 2.5*np.log10(flux), 2.5/np.log(10)*(ferr/flux)
31  mag = zeropoint - mag
32 
33  # X, Y locations of the fake stars
34  fakeXY = collections.defaultdict(tuple)
35  # Regular Expression
36  fakename = re.compile('FAKE([0-9]+)')
37  for card in cal_md.names():
38  m = fakename.match(card)
39  if m is not None:
40  x, y = list(map(float, (cal_md.getScalar(card)).split(',')))
41  fakeXY[int(m.group(1))] = (x, y)
42 
43  srcIndex = collections.defaultdict(list)
44  for fid, fcoord in fakeXY.items():
45  matched = ((np.abs(srcX-fcoord[0]) < tol) &
46  (np.abs(srcY-fcoord[1]) < tol))
47  srcIndex[fid] = np.where(matched)[0]
48 
49  srcPsfMag = []
50  srcPsfMerr = []
51  matchX = []
52  matchY = []
53  for s in srcIndex.values():
54  if len(s) > 0:
55  ss = s[0]
56  srcPsfMag.append(mag[ss])
57  srcPsfMerr.append(merr[ss])
58  matchX.append(srcX[ss])
59  matchY.append(srcY[ss])
60  else:
61  srcPsfMag.append(0)
62  srcPsfMerr.append(0)
63  matchX.append(0)
64  matchY.append(0)
65 
66  return srcIndex, fakeXY, matchX, matchY, srcPsfMag, srcPsfMerr
67 
68 

◆ main()

def lsst.synpipe.matchFakeStars.main ( )

Definition at line 69 of file matchFakeStars.py.

69 def main():
70 
71  # TODO: this should use the LSST/HSC conventions
72  parser = argparse.ArgumentParser()
73  parser.add_argument('rootDir', help='root dir of data repo')
74  parser.add_argument('visit', help='id of visit', type=int)
75  parser.add_argument('ccd', help='id of ccd', type=int)
76  args = parser.parse_args()
77 
78  starIndex, fakeXY, matchX, matchY, starPsfMag, starPsfMerr = getFakeSources(args.rootDir,
79  {'visit': args.visit,
80  'ccd': args.ccd})
81 
82  nInject = len(fakeXY)
83  nMatch = len(np.argwhere(starPsfMag))
84  print("# Number of Injected Stars : %d" % nInject)
85  print("# Number of Matched Stars : %d" % nMatch)
86  print("# Visit = %d CCD = %d" % (args.visit, args.ccd))
87  print("# FakeX FakeY PSFMag PSFMagErr Deblend ")
88 
89  for i in range(nInject):
90  if len(starIndex[i]) > 1:
91  deblend = "blended"
92  elif starPsfMag[i] > 0:
93  deblend = "isolate"
94  else:
95  deblend = "nomatch"
96 
97  injectXY = fakeXY[i]
98 
99  print("%6.1d %6.1d %7.3f %6.3f %s" % (injectXY[0], injectXY[1],
100  starPsfMag[i], starPsfMerr[i], deblend))
101 
102 
lsst::daf::persistence.butler.Butler
Definition: butler.py:321
lsst.synpipe.matchFakeStars.getFakeSources
def getFakeSources(rootdir, dataId, tol=0.1)
Definition: matchFakeStars.py:15
list
daf::base::PropertyList * list
Definition: fits.cc:913
lsst.synpipe.matchFakeStars.main
def main()
Definition: matchFakeStars.py:69