dartoon / galight

A python package that decompose the light into PSF and Sersic, fitting based on lenstronomy
MIT License
45 stars 20 forks source link

AttributeError: 'FittingSpecify' object has no attribute 'imageModel' #7

Closed wills-astro closed 1 year ago

wills-astro commented 1 year ago

Hello,

I am an undergraduate attempting to work through the GaLight galight_hst_QSO.ipynb tutorial before using it on my own work. In the cell "#Setting the fitting method and run" I am getting the following results and Attribute Error:

Computing the PSO ... 10 20 30 40 50 Max iteration reached! Stopping. -1.0707842721152985 reduced X^2 of best position -7247.603345812398 logL 13537.0 effective number of data points [] lens result [] source result [{'amp': 1, 'R_sersic': 0.38666619680009284, 'n_sersic': 4, 'e1': -0.022096159868187745, 'e2': -0.4453877445287039, 'center_x': -0.10595217820276748, 'center_y': 0.12255507200599276}, {'amp': 1, 'R_sersic': 0.5234385199161239, 'n_sersic': 1.1694787949844492, 'e1': -0.05072379898905925, 'e2': -0.4994422659942345, 'center_x': -2.8524320644268926, 'center_y': -1.0525580054914583}, {'amp': 1, 'R_sersic': 0.16020498507891734, 'n_sersic': 5.420891413673527, 'e1': -0.4925077338338324, 'e2': -0.27729442818227623, 'center_x': -3.9510706792239767, 'center_y': -1.6123984023508169}] lens light result [{'ra_image': array([-0.10595218]), 'dec_image': array([0.12255507]), 'point_amp': array([1.])}] point source result {} special param result 6.391066312789917 time used for PSO

100%|██████████| 130/130 [01:23<00:00, 1.55it/s] Computing the MCMC... Number of walkers = 170 Burn-in iterations: 100 Sampling iterations (in current run): 130 84.4948480129242 time taken for MCMC sampling 90.924 total time taken for the overall fitting (s) ============ CONGRATULATION, YOUR JOB WAS SUCCESSFUL ================ Start transfering the Params to fluxs...


AttributeError Traceback (most recent call last) Cell In[18], line 17 6 fit_run = FittingProcess(fit_sepc, savename = 'HST_result', fitting_level='norm') 7 #For the fitting_level, you can also put ['norm', 'deep'] for the later ['PSO', 'MCMC'] corresplingly. 8 9 #Setting the fitting approach and Run: (...) 15 # input template: {'n_burn': 50, 'n_run': 100, 'walkerRatio': 10, 'sigma_scale': .1} 16 # if setting_list = [None, None, None], default values would be given ---> 17 fit_run.run(algorithm_list = ['PSO', 'MCMC'], setting_list = None) 19 # Plot all the fitting results, including: 20 # run_diag() : The convergence of the chains. 21 # model_plot(): The model plot (by lenstronomy) 22 # plot_params_corner(): The mcmc corner for all the chains (MCMC should be peformed) 23 # plot_flux_corner(): The flux corner for all the component (MCMC should be peformed) 24 # plot_final_qso_fit() or plot_final_galaxy_fit(): Plot the overall plot (data, model, data-ps, resudal, 1D profile) 25 fit_run.plot_all()

File ~/.local/lib/python3.9/site-packages/galight/fitting_process.py:172, in FittingProcess.run(self, algorithm_list, fitting_level, setting_list, threadCount, refresh) 170 if len(fitting_specify_class.point_source_list) > 0: 171 for j in range(len(fitting_specify_class.point_source_list)): --> 172 image_ps_j = fitting_specify_class.imageModel.point_source(kwargs_ps_out, k=j) 173 flux_list_quasar.append(np.sum(image_ps_j)) 174 flux_list_galaxy = []

AttributeError: 'FittingSpecify' object has no attribute 'imageModel'

My initial suspicion was a version issue, but I have checked all dependencies based on requirements.txt and after updating (or downgrading) to the suggested requirements and I am still encountering this issue. What should I try as my next troubleshooting steps? Thank you for the help!

dartoon commented 1 year ago

Hi, I also find this issue on my side. I think this is happening because the recent updates of galight, let me fix this issue. At this moment, you can run 'PSO' and skip 'MCMC'.

wills-astro commented 1 year ago

Hi, I decided to play with the lenstronomy version after your message. The requirements.txt file listed on GitHub recommends lenstronomy==1.10.3, which I had installed. I uninstalled it and then reinstalled with version 1.11.2 and it worked.

Very excited to make more progress soon. Thanks!

dartoon commented 1 year ago

Hi, I am not sure why the lenstronomy version is causing this problem. But glad to hear it works.

I think the previous issue is still by galight, I have fixed it on my side now. I will make a quick galight release today. I recommend you update lenstronomy (1.11.2) and galight (0.1.13, which will be available by tomorrow) to the latest version just in case.

wills-astro commented 1 year ago

Great, it seems to have been a fluke because the error has already popped up again. Thanks for your work and I'll update to the new version in the morning. Thanks again.

dartoon commented 1 year ago

The 0.1.13 version is just released. You can update to the new version and try it out!

wills-astro commented 1 year ago

Success! Thank you! I'll let you know if I have any other issues. I really appreciate your prompt support