Skip to content

Commit

Permalink
Merge pull request #11 from kadrlica/marigo2017
Browse files Browse the repository at this point in the history
Remove spurious point in Marigo 2017 isochrone
  • Loading branch information
kadrlica authored May 12, 2018
2 parents 85faa65 + f8603d9 commit ccb503d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ dist/

### ugali data files
ugali/data/*/
healpix
mask
*.tar.gz
29 changes: 18 additions & 11 deletions tests/test_loglike.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,34 @@ def test_loglike():
loglike = ugali.analysis.loglike.createLoglike(CONFIG,lon=LON,lat=LAT)

source = loglike.source
np.testing.assert_equal(source.isochrone.name,'Bressan2012')
np.testing.assert_equal(source.kernel.name,'RadialPlummer')
np.testing.assert_equal(source.richness,1000.)

# Probability calculations
np.testing.assert_allclose(loglike.f,0.1945461,rtol=1e-6)
np.testing.assert_allclose(loglike.f,0.08614111,rtol=1e-6)

np.testing.assert_allclose(loglike.u[IDX],
[1.11721569e-11, 3.67872840e-03, 3.25216604e-02])
[5.29605173e-03, 1.80040569e-03, 5.52283081e-09],
rtol=1e-6)
np.testing.assert_allclose(loglike.b[IDX],
[4215.31143651, 9149.29106545, 1698.22182173])
[4215.31143651, 9149.29106545, 1698.22182173],
rtol=1e-6)
np.testing.assert_allclose(loglike.p[IDX],
[2.65037519e-12, 4.01916371e-04, 1.87905722e-02])
np.testing.assert_allclose(loglike(),390.153891)
np.testing.assert_allclose(loglike.ts(),780.30778)
np.testing.assert_allclose(loglike.nobs,194.546134)
[1.25480793e-03, 1.96742181e-04, 3.25212568e-09],
rtol=1e-6)
np.testing.assert_allclose(loglike(),3947.9703876)
np.testing.assert_allclose(loglike.ts(),7895.94077)
np.testing.assert_allclose(loglike.nobs,86.1411187)

# Fit the richness
interval = loglike.richness_interval()
np.testing.assert_allclose(interval,(1713.4082, 1969.1216))
np.testing.assert_allclose(interval,(31516.82584, 32836.37888))

lnl,rich,para = loglike.fit_richness()
np.testing.assert_allclose(lnl,418.666213)
np.testing.assert_allclose(rich,1839.005237)
np.testing.assert_allclose(loglike.source.richness,1839.005237)
np.testing.assert_allclose(lnl,8443.79621)
np.testing.assert_allclose(rich,32171.788052)
np.testing.assert_allclose(loglike.source.richness,32171.78805)

# Write membership
filename = 'test-membership.fits'
Expand Down
3 changes: 2 additions & 1 deletion ugali/analysis/imf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def integrate(self, mass_min, mass_max, log_mode=True, weight=False, steps=10000
else:
return np.sum(d_mass * self.pdf(mass, log_mode=False))

def sample(self, n, mass_min=0.1, mass_max=10., steps=10000):
def sample(self, n, mass_min=0.1, mass_max=10., steps=10000, seed=None):
"""
Sample n initial mass values between mass_min and mass_max, following the IMF distribution.
"""
if seed is not None: np.random.seed(seed)
d_mass = (mass_max - mass_min) / float(steps)
mass = numpy.linspace(mass_min, mass_max, steps)
cdf = numpy.insert(numpy.cumsum(d_mass * self.pdf(mass[1:], log_mode=False)), 0, 0.)
Expand Down
9 changes: 7 additions & 2 deletions ugali/config/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,23 @@ kernel: &kernel
isochrone: &isochrone
name: Bressan2012
age: 12.0
z: 0.0001
z: 0.00010
distance_modulus : 17.0
band_1 : *band1
band_2 : *band2
band_1_detection : *detection

# Default source specification
source: &source
kernel : *kernel
isochrone: *isochrone

likelihood:
#delta_mag: 0.01 # 1.e-3
delta_mag: 0.01 # 1.e-3

### ### ### ### ### ### ### ### ### ###
### Options for analysis components ###
### Options for pipeline components ###
### ### ### ### ### ### ### ### ### ###

output:
Expand Down
3 changes: 3 additions & 0 deletions ugali/isochrone/parsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ def _parse(self,filename):

kwargs = dict(usecols=list(columns.keys()),dtype=list(columns.values()))
self.data = np.genfromtxt(filename,**kwargs)
# cut out anomalous point:
# https://github.com/DarkEnergySurvey/ugali/issues/29
self.data = self.data[self.data['stage'] != 9]

self.mass_init = self.data['mass_init']
self.mass_act = self.data['mass_act']
Expand Down

0 comments on commit ccb503d

Please sign in to comment.