2 Compare the input fake galaxy model to the output one
14 from .matchFakes
import getFakeSources
19 return the semi-major axis, axis ratio and position angle (in degrees)
21 fluxType = {
'dev':
'cmodel.dev',
24 'cmodel':
'cmodel'}[galType]
27 q = (e.getB() / e.getA())
29 pa = (e.getTheta() * 180.0 / np.pi)
33 def getMag(record, fluxType='cmodel'):
35 return the magnitude and error
37 flux, fluxerr = record.get(fluxType), record.get(fluxType+
'.err')
38 mag, magerr = -2.5 * np.log10(flux), 2.5/np.log(10.0)*fluxerr/flux
39 mag += record.get(
'zeropoint')
44 """Writes output to numpy
46 npTable = np.recarray(len(fakeTable),
47 dtype={
'names': [
'id',
'fakeid',
'visit',
'ccd',
48 'cmodelMag',
'expMag',
52 'expPosAng',
'devPosAng',
53 'cmodelMagErr',
'expMagErr',
54 'devMagErr',
'nchild',
'parent'],
55 'formats': [int, int, int, int,
57 float, float, float, float,
58 float, float, float, float,
59 float, float, int, int]})
60 for indFake, fake
in enumerate(fakeTable):
61 npTable[indFake][
'id'] = fake.get(
'id')
62 npTable[indFake][
'fakeid'] = fake.get(
'fakeId')
63 npTable[indFake][
'ccd'] = fake.get(
'ccd')
64 npTable[indFake][
'visit'] = fake.get(
'visit')
65 nameMatch = {
'sersic':
'cmodel',
69 for name
in (
'cmodel',
'exp',
'dev'):
70 m1, m2 =
getMag(fake, nameMatch[name]+
'.flux')
71 npTable[indFake][name+
'Mag'] = m1
72 npTable[indFake][name+
'MagErr'] = m2
73 for name
in (
'exp',
'dev'):
75 npTable[indFake][name+
'Reff'] = params[0]
76 npTable[indFake][name+
'BA'] = params[1]
77 npTable[indFake][name+
'PosAng'] = params[2]
78 npTable[indFake][
'nchild'] = fake.get(
'deblend.nchild')
79 npTable[indFake][
'parent'] = fake.get(
'parent')
83 def main(root, visit, ccds, galType='sersic', output='outputs/'):
85 main function for controlling fake source comparison
90 dataId = {
'visit': visit,
'ccd': ccd}
97 fakeTable = temp.copy(
True)
99 fakeTable.extend(temp,
True)
102 rerunName = root.split(
'/')[-2]
103 tableFileName = output +
'/' + rerunName +
'_galMags.txt'
104 astropy.table.Table(npTable).
write(tableFileName, format=
'ascii')
107 if __name__ ==
'__main__':
108 parser = argparse.ArgumentParser()
109 parser.add_argument(
'root', help=
"Root directory of data repository")
110 parser.add_argument(
"visit", type=int, help=
"Visit")
111 parser.add_argument(
"--ccd", nargs=
'+', type=int, help=
"CCD(s)")
112 parser.add_argument(
'-g',
'--galtype', type=str, dest=
'galType',
113 choices=[
'exp',
'dev',
'sersic'])
114 parser.add_argument(
'-o',
'--outputpath', dest=
'outpath',
115 help=
'path for output')
116 args = parser.parse_args()
118 main(args.root, args.visit, args.ccd, galType=args.galType,