Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow both faint and bright abs mag cuts #26

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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