Skip to content

Commit

Permalink
Accidentally removed outputdir from gradientdescent causing a crash
Browse files Browse the repository at this point in the history
Fixed an initialization bug which wrote intial x0 guess to x1 instead
  • Loading branch information
darcykenworthy committed Jul 3, 2024
1 parent 8117597 commit 5ecf211
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions saltshaker/training/TrainSALT.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ def bestfit(p):

from numpy.random import default_rng
rng = default_rng(134912348)

for sn in datadict.keys():
if self.options.snparlist:
# hacky matching, but SN names are a mess as usual
Expand All @@ -354,8 +353,8 @@ def bestfit(p):
else:
guess[parlist==f'x{i}_{sn}'] = rng.standard_normal()
if snpar['x0'][iSN]<= 0:
log.warning(f'Bad input value for {sn}: x0= {snpar["x0"][iSN]}')
guess[parlist==f'x{i}_{sn}'] = 10**(-0.4*(cosmo.distmod(datadict[sn].zHelio).value-19.36-10.635))
log.warning(f'Bad input value for {sn}: x0={ float(snpar["x0"][iSN])}')
guess[parlist==f'x0_{sn}'] = 10**(-0.4*(cosmo.distmod(datadict[sn].zHelio).value-19.36-10.635))

guess[parlist == 'c0_%s'%sn] = snpar['c'][iSN]
guess[parlist == 'c1_%s'%sn] = np.random.exponential(0.2)
Expand Down
14 changes: 7 additions & 7 deletions saltshaker/training/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ def mkcuts(self,datadict):
return outdict,cutdict

def filter_select(self,survey,flt):
select = True
if flt in self.options.__dict__[f"{survey.split('(')[0]}_ignore_filters"].replace(' ','').split(','):
select = False
return False

lambdaeff = self.kcordict[survey][flt]['lambdaeff']
if lambdaeff < self.options.filtercen_obs_waverange[0] or \
lambdaeff > self.options.filtercen_obs_waverange[1] :
select = False
else:
lambdaeff = self.kcordict[survey][flt]['lambdaeff']
if lambdaeff < self.options.filtercen_obs_waverange[0] or \
lambdaeff > self.options.filtercen_obs_waverange[1] :
return False

return select
return True
# end filter_select
1 change: 1 addition & 0 deletions saltshaker/training/optimizers/gradientdescent.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self,guess,saltresids,outputdir,options):
self.saltobj=saltresids
for x in self.configoptionnames:
self.__dict__[x]=getattr(options,x)
self.outputdir=options.outputdir
assert(0<self.searchsize<1)
assert(0<self.searchtolerance<1)
assert(0<self.etaminus<1)
Expand Down

0 comments on commit 5ecf211

Please sign in to comment.