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

windhorst et al 2023 F200W mag Priors #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 31 additions & 2 deletions astropath/chance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from scipy import interpolate

from importlib.resources import files
import os

from IPython import embed


Expand All @@ -12,7 +15,8 @@
driver_spl = interpolate.UnivariateSpline._from_tck(driver_tck)


def driver_sigma(rmag):

def driver_sigma(mag):
"""
Estimated incidence of galaxies per sq arcsec with r > rmag
using Driver et al. 2016 number counts.
Expand All @@ -26,7 +30,32 @@ def driver_sigma(rmag):
float or np.ndarray: Galaxy number density

"""
return 10**driver_spl(rmag)
return 10**driver_spl(mag)

def windhorst_sigma(mag):
"""
Estimated incidence of galaxies per sq arcsec with F200W > mag
using Windhorst et al. 2024 number counts.

Spline parameters (globals) are for F200W vs Num counts

Args:
mag (float or np.ndarray): F200W band magnitude of galaxy

Returns:
float or np.ndarray: Galaxy number density

"""
data_path = os.path.join(files('astropath'),'data','galaxy_num_counts','windhorst2023_F200W.npz')
data = np.load(data_path)
mag_f200w = data['mag']
Num = data['Num(N/arcsec/0.5mag))']

winhorst_spline = interpolate.interp1d(mag_f200w, Num, kind='cubic', fill_value='extrapolate')

num_counts = winhorst_spline(mag)

return num_counts


def bloom_sigma(rmag):
Expand Down
Binary file not shown.
7 changes: 5 additions & 2 deletions astropath/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from astropath import localization
from astropath import priors

from IPython import embed


class PATH(object):
"""Convenience class to run PATH analysis
Expand Down Expand Up @@ -122,7 +124,7 @@ def init_localization(self, ltype:str, **kwargs):
assert localization.vet_localization(self.localiz), 'Bad candidate prior input'
logging.info("Localization is ready!")

def calc_priors(self):
def calc_priors(self, ifilter:str='r'):
"""Calculate and normalize the P(O) values for the candidates

Raises:
Expand All @@ -138,7 +140,8 @@ def calc_priors(self):
logging.info("Calculating priors")
self.raw_prior_Oi = priors.raw_prior_Oi(
self.cand_prior['P_O_method'], self.candidates['ang_size'],
mag=self.candidates['mag'] if 'mag' in self.candidates.keys() else None)
mag=self.candidates['mag'] if 'mag' in self.candidates.keys() else None,
filter=ifilter)

# Normalize
logging.info("Normalizing priors")
Expand Down
17 changes: 14 additions & 3 deletions astropath/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
help='Label for this prior.'),
}

splines = {
'r': 'driver',
'F200W':'windhorst'
}


def raw_prior_Oi(method, ang_size, mag=None, filter='r'):
Expand All @@ -52,11 +56,18 @@ def raw_prior_Oi(method, ang_size, mag=None, filter='r'):
float or np.ndarray:

"""
# Setting spline_fit
# Convenience
if method not in ['identical']:
if filter != 'r':
raise IOError("Not ready for this. Best to go with what you have that is closest to r-band")
Sigma_m = chance.driver_sigma(mag)
if filter not in splines.keys():
raise IOError("Not ready for this. Best to go with what you have that is closest to r-band or F200W")
else:
spline_fit = splines[filter]
if spline_fit == 'driver':
Sigma_m = chance.driver_sigma(mag)

elif spline_fit == 'windhorst':
Sigma_m = chance.windhorst_sigma(mag)

# Do it
if method == 'inverse':
Expand Down
Loading
Loading