Skip to content

Commit

Permalink
Merge pull request #26 from ACTCollaboration/dev
Browse files Browse the repository at this point in the history
Allow both faint and bright abs mag cuts
  • Loading branch information
mattyowl authored Jul 23, 2023
2 parents 492dc1d + 62a52c8 commit b62b84e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 13 additions & 3 deletions bin/zCluster
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ def makeParser():
default = None)
parser.add_argument("-Z", "--z-prior-max", dest="zPriorMax", help="Set maximum redshift of prior.",
default = None)
parser.add_argument("-b", "--brighter-absmag-cut", dest="absMagCut", help="Set bright absolute magnitude cut.",
default = -24., type = float)
parser.add_argument("-b", "--absmag-cut", dest="absMagCut",
help="Set absolute (r-band) magnitude cut to use in magnitude-based prior. If a single number\
is given, p(z) for objects brighter than this limit will be set to 0. If a\
list of numbers is given (e.g., [-15,-24]), p(z) will be set to 0\
for objects outside of the absolute magnitude range.", default = -24.)
parser.add_argument("-n", "--name", dest="name", help="Find photo-z of only the named cluster in the catalog.")
parser.add_argument("-t", "--templates-directory", dest="templatesDir", help="Specify a directory containing\
a custom set of spectral templates.", default = None)
Expand Down Expand Up @@ -494,7 +497,14 @@ if __name__ == '__main__':
MPIEnabled=args.MPIEnabled
maxMagError=float(args.maxMagError)
#magsBrighterMStarCut=float(args.magsBrighterMStarCut)
absMagCut=float(args.absMagCut)
try:
absMagCut=float(args.absMagCut)
except:
vals=args.absMagCut.replace("[", "").replace("]", "").split(",")
if len(vals) != 2:
raise Exception("If you want to give a range for --absmag-cut, write as e.g. [-15,-23]")
absMagCut=[float(vals[0]), float(vals[1])]
absMagCut.sort() # Bright mag comes first
writeGalaxyCatalogs=args.writeGalaxyCatalogs
writePlots=args.writePlots
maskPath=args.mask
Expand Down
7 changes: 6 additions & 1 deletion zCluster/PhotoRedshiftEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,12 @@ def calcPhotoRedshifts(self, galaxyCatalog, calcMLRedshiftAndOdds = False, retur
pz=np.max(chiSqProb, axis = 0)
# Mag prior
absMag=magAB[self.magPriorBand]-5.0*np.log10(1e5*self.dlRange)
pPrior=np.array(np.greater(absMag, self.magPriorCut), dtype = float)
if type(self.magPriorCut) == float:
pPrior=np.array(np.greater(absMag, self.magPriorCut), dtype = float)
elif len(self.magPriorCut) == 2:
pPrior=np.array(np.logical_and(np.greater(absMag, self.magPriorCut[0]), np.less(absMag, self.magPriorCut[1]), dtype = float))
else:
raise Exception("magPriorCut should have only 1 or 2 elements")
pz=pz*pPrior
# Normalise
pzNorm=np.trapz(pz, self.zRange)
Expand Down

0 comments on commit b62b84e

Please sign in to comment.