Skip to content

Commit

Permalink
Correct FSPLarge
Browse files Browse the repository at this point in the history
  • Loading branch information
ebachelet committed Oct 25, 2023
1 parent 88d0102 commit 2052b58
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pyLIMA/fits/ML_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def model_guess(self):

if self.model.model_type() == 'FSPLarge':
guess_paczynski_parameters, f_source = \
pyLIMA.priors.guess.initial_guess_FSPL(
pyLIMA.priors.guess.initial_guess_FSPLarge(
self.model.event)

if self.model.model_type() == 'DSPL':
Expand Down Expand Up @@ -541,9 +541,11 @@ def initial_guess(self):

try:

index = np.where(
self.model.fancy_to_pyLIMA_dictionnary[key] == np.array(
list_of_keys))[0][0]
# index = np.where(
# self.model.fancy_to_pyLIMA_dictionnary[key] == np.array(
# list_of_keys))[0][0]

index = np.where(key == np.array(list_of_keys))[0][0]

parameter = self.model.fancy_to_pyLIMA_dictionnary[key]
value = fit_parameters_guess[index]
Expand Down
3 changes: 2 additions & 1 deletion pyLIMA/fits/TRF_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def fit(self):
for telescope in self.model.event.telescopes:
n_data = n_data + telescope.n_data('flux')

if self.model.Jacobian_flag != 'No Way':
if self.model.Jacobian_flag != 'Numerical':

jacobian_function = self.residuals_Jacobian

Expand All @@ -62,6 +62,7 @@ def fit(self):
loss=loss, xtol=10**-10, ftol=10**-10,
gtol=10**-10,
x_scale=scaling)

fit_results = trf_fit['x'].tolist()
fit_chi2 = trf_fit['cost'] * 2 # chi2

Expand Down
12 changes: 12 additions & 0 deletions pyLIMA/models/FSPLarge_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

class FSPLargemodel(FSPLmodel):

def model_type(self):

return 'FSPLarge'

def paczynski_model_parameters(self):
"""
[to,u0,tE,rho]
"""
model_dictionary = {'t0': 0, 'u0': 1, 'tE': 2, 'rho': 3}
self.Jacobian_flag = 'Numerical'

return model_dictionary
def model_magnification(self, telescope, pyLIMA_parameters,
return_impact_parameter=False):
"""
Expand Down
23 changes: 22 additions & 1 deletion pyLIMA/priors/guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,33 @@ def initial_guess_FSPL(event):
PSPL_guess, fs_guess = initial_guess_PSPL(event)
# Dummy guess
rho_guess = 0.05

FSPL_guess = PSPL_guess + [rho_guess]

# [to,uo,tE,rho], fsource
return FSPL_guess, fs_guess

def initial_guess_FSPLarge(event):
"""
Function to find initial FSPL guess, i.e. PSPL guess + rho = 0.05
Parameters
----------
event : object, an event object
Returns
-------
guess_model : list, [t0,u0,tE,rho] the FSPL guess
fs_guess : float, the source flux guess
"""
PSPL_guess, fs_guess = initial_guess_PSPL(event)

Amax = np.array(event.telescopes[0].lightcurve_flux['flux'].max())/fs_guess
rho_guess = 2/(Amax**2-1)**0.5

FSPL_guess = PSPL_guess + [rho_guess]

# [to,uo,tE,rho], fsource
return FSPL_guess, fs_guess

def initial_guess_DSPL(event):
"""
Expand Down

0 comments on commit 2052b58

Please sign in to comment.