Skip to content

Commit

Permalink
Update fitting.py
Browse files Browse the repository at this point in the history
redshift function
  • Loading branch information
mtakahiro committed Jan 1, 2024
1 parent 4b54469 commit 174d92a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gsf/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def __init__(self, inputs, c:float=3e18, Mpc_cm:float=3.08568025e+24, m0set:floa
'CAT_BB', 'CAT_BB_DUST', 'SNLIM',
'MORP', 'MORP_FILE',
'SPEC_FILE', 'DIR_EXTR', 'MAGZP_SPEC', 'UNIT_SPEC', 'DIFF_CONV',
'CZ0', 'CZ1', 'CZ2', 'LINE', ],
'CZ0', 'CZ1', 'CZ2', 'LINE', 'PA', ],

'Misc' : ['CONFIG', 'DIR_OUT', 'FILTER', 'SKIPFILT', 'FIR_FILTER']
'Misc' : ['CONFIG', 'DIR_OUT', 'FILTER', 'SKIPFILT', 'FIR_FILTER', 'DIR_FILT']

}

Expand Down Expand Up @@ -600,7 +600,7 @@ def update_input(self, inputs, c:float=3e18, Mpc_cm:float=3.08568025e+24, m0set:
self.fzmc = int(inputs['F_ZMC'])
except:
self.fzmc = 0
self.logger.warning('Cannot find ZMC. Set to %d.'%(self.fzmc))
self.logger.warning('Cannot find F_ZMC. Set to %d.'%(self.fzmc))

# Metallicity
self.has_ZFIX = False
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def fit_redshift(self, xm_tmp, fm_tmp, delzz=0.01, ezmin=0.01, #zliml=0.01, zlim
x_cz = self.dict['x'][con_cz] # Observed range
NR_cz = self.dict['NR'][con_cz]
if len(NR_cz) == 0:
self.logger.error('No data point exists at SN>%.1f'%(snlim))
self.logger.error('No data point exists at SNR > `snlim` (%.1f)'%(snlim))
self.logger.error('Decrease `snlim` or turn `f_exclude_negative` to False')
return False

Expand Down Expand Up @@ -2414,6 +2414,7 @@ def search_redshift(self, dict, xm_tmp, fm_tmp, zliml=0.01, zlimu=6.0, delzz=0.0
fit_par_cz.add('C%d'%nn, value=1., min=0., max=1e5)

def residual_z(pars,z):
''''''
vals = pars.valuesdict()
xm_s = xm_tmp * (1+z)
fm_s = np.zeros(len(xm_tmp),float)
Expand All @@ -2422,7 +2423,6 @@ def residual_z(pars,z):
fm_s += fm_tmp[nn,:] * pars['C%d'%nn]

fint = interpolate.interp1d(xm_s, fm_s, kind='nearest', fill_value="extrapolate")
#fm_int = np.interp(xobs, xm_s, fm_s)
fm_int = fint(xobs)

if fcon is None:
Expand All @@ -2433,7 +2433,6 @@ def residual_z(pars,z):

# Start redshift search;
for zz in range(len(zspace)):
# Best fit
out_cz = minimize(residual_z, fit_par_cz, args=([zspace[zz]]), method=method)
keys = fit_report(out_cz).split('\n')

Expand Down

0 comments on commit 174d92a

Please sign in to comment.