Skip to content

Commit

Permalink
AD : cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Denis committed Sep 5, 2024
1 parent 71bdc89 commit f770d62
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ForMoSA/nested_sampling/nested_modif_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def lsq_fct(global_params, wave, indobs, flx_obs_spectro, err_obs_spectro, star_
if len(system_obs) > 0:
system_obs_ind = system_obs[ind,:][0]

flx_mod_spectro_ind *= transm_obs_ind / 120
flx_mod_spectro_ind *= transm_obs_ind
star_flx_0_ind = star_flx_obs_ind[:,len(star_flx_obs_ind[0]) // 2]

# # # # # Continuum estimation with lowpass filtering
Expand All @@ -80,22 +80,21 @@ def lsq_fct(global_params, wave, indobs, flx_obs_spectro, err_obs_spectro, star_
#
# Construction of the matrix
if len(system_obs) > 0:
A_matrix = np.zeros([np.size(flx_obs_spectro_ind), 1 + len(star_flx_obs_ind[0]) + len(system_obs_ind[0])])
A = np.zeros([np.size(flx_obs_spectro_ind), 1 + len(star_flx_obs_ind[0]) + len(system_obs_ind[0])])
for j in range(len(system_obs[0])):
A_matrix[:,1+len(star_flx_obs_ind[0])+j] = system_obs_ind[:,j]
A[:,1+len(star_flx_obs_ind[0])+j] = system_obs_ind[:,j]
else:
A_matrix = np.zeros([np.size(flx_obs_spectro_ind), 1 + len(star_flx_obs_ind[0])])
A = np.zeros([np.size(flx_obs_spectro_ind), 1 + len(star_flx_obs_ind[0])])

for j in range(len(star_flx_obs[0])):
A_matrix[:,1+j] = star_flx_obs_ind[:,j] * 1 / np.sqrt(err_obs_spectro_ind)
A[:,1+j] = star_flx_obs_ind[:,j] * 1 / np.sqrt(err_obs_spectro_ind)

A_matrix[:,0] = flx_mod_spectro_ind * 1 / np.sqrt(err_obs_spectro_ind)
A[:,0] = flx_mod_spectro_ind * 1 / np.sqrt(err_obs_spectro_ind)

# Least square
# Solve the linear system A.x = b
A = A_matrix
b = flx_obs_spectro_ind * 1 / np.sqrt(err_obs_spectro_ind)
res = optimize.lsq_linear(A_matrix, b, bounds = (0, 1))
res = optimize.lsq_linear(A, b, bounds = (0, 1))

cp_ind = res.x[0]

Expand Down

0 comments on commit f770d62

Please sign in to comment.