Skip to content

Commit

Permalink
bugfixes in p-beta when const_phi=True: update data file names, ensur…
Browse files Browse the repository at this point in the history
…e logm is an array before item assignment
  • Loading branch information
wangbingjie committed Apr 3, 2024
1 parent 899e30e commit e6924e1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions prospect/models/priors_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def __init__(self, parnames=[], name='', **kwargs):
self.update(**kwargs)

if self.params['const_phi']:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z_l20.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20, unpack=True)
else:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20t18, unpack=True)

self.finterp_z_pdf, self.finterp_cdf_z = norm_pz(self.params['zred_mini'], self.params['zred_maxi'], zreds, pdf_zred)
self.mgrid = np.linspace(self.params['mass_mini'], self.params['mass_maxi'], 101)
Expand Down Expand Up @@ -768,9 +768,9 @@ def __init__(self, parnames=[], name='', **kwargs):
self.update(**kwargs)

if self.params['const_phi']:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z_l20.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20, unpack=True)
else:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20t18, unpack=True)

self.finterp_z_pdf, self.finterp_cdf_z = norm_pz(self.params['zred_mini'], self.params['zred_maxi'], zreds, pdf_zred)

Expand Down Expand Up @@ -1160,9 +1160,9 @@ def __init__(self, parnames=[], name='', **kwargs):
# the tables were calculated in pdf_z_tables.ipynb
# redshift range is 0 - 20
if self.params['const_phi']:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z_l20.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20, unpack=True)
else:
zreds, pdf_zred = np.loadtxt(os.path.join(prior_data_dir, 'pdf_of_z.txt'), unpack=True)
zreds, pdf_zred = np.loadtxt(file_pdf_of_z_l20t18, unpack=True)

self.finterp_z_pdf, self.finterp_cdf_z = norm_pz(self.params['zred_mini'], self.params['zred_maxi'], zreds, pdf_zred)

Expand Down Expand Up @@ -1514,8 +1514,9 @@ def mass_func_at_z(z, this_logm, const_phi=False, bounds=[6.0, 12.5]):
else:
phi = high_z_mass_func(z0=12, this_m=10**this_logm)

phi[this_logm < bounds[0]] = 0
phi[this_logm > bounds[1]] = 0
if hasattr(this_logm, "__len__"):
phi[this_logm < bounds[0]] = 0
phi[this_logm > bounds[1]] = 0
return np.squeeze(phi)


Expand Down

0 comments on commit e6924e1

Please sign in to comment.