Giter VIP home page Giter VIP logo

lenstronomy-tutorials's Introduction

lenstronomy tutorial notebooks

In this repository you can find a variety of notebooks with tutorials on how to use lenstronomy as well as more advanced and specific example use cases.

If you are new to gravitational lensing, check also out the mini lecture series giving an introduction to gravitational lensing with interactive Jupyter notebooks in the cloud.

You can also check out this self-work tutorial with assignments and Jupyter notebooks designed for undergraduate students to learn the basics of lens modeling with lenstronomy.

Index

Getting started
Lens modeling
Line-of-sight effects
Numerics
Simulations
Galaxy light fitting
Dark matter substructure
Time-delay cosmography
Clusters

Requirements

The notebooks require lenstronomy release version 1.11.2. Instructions for installing lenstronomy and its dependencies can be found in the Installation section of the lenstronomy documentation.

If you are using the GitHub branch of lenstronomy, you may be a bit ahead of the notebooks.

Need help or provide feedback?

Get in touch with the lenstronomy developers ([email protected]) if you encounter problems.

Attribution

A first set of notebooks were written by Simon Birrer sibirrer as the lenstronomy_extensions package. Please follow the lenstronomy citation guidelines in using these notebooks.

lenstronomy-tutorials's People

Contributors

ajshajib avatar dangilman avatar martin-millon avatar nataliehogg avatar sibirrer avatar vikramb1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lenstronomy-tutorials's Issues

KeyError: 'e1'

I am trying to test with an elliptical-NFW and shear lens as follows. The initial error was KeyError: 'alpha_Rs' when I used 'theta_Rs' instead of 'alpha_Rs'. After I change the key in the dictionary kwargs_lens_init, the error became KeyError: 'e1'.
The same error occurs if I change 'gamma1' and 'gamma2' to 'e1' and 'e2' respectively.
I believe it may be some mistake of parameter naming? Can someone point it out if otherwise?

image
image


KeyError Traceback (most recent call last)
in
6
7 start_time = time.time()
----> 8 chain_list_pso = fitting_seq.fit_sequence(fitting_kwargs_list)
9 kwargs_result = fitting_seq.best_fit()
10 end_time = time.time()

~\AppData\Roaming\Python\Python38\site-packages\lenstronomy\Workflow\fitting_sequence.py in fit_sequence(self, fitting_list)
78
79 elif fitting_type == 'PSO':
---> 80 kwargs_result, chain, param = self.pso(**kwargs)
81 self._updateManager.update_param_state(**kwargs_result)
82 chain_list.append([fitting_type, chain, param])

~\AppData\Roaming\Python\Python38\site-packages\lenstronomy\Workflow\fitting_sequence.py in pso(self, n_particles, n_iterations, sigma_scale, print_key, threadCount)
250 param_class = self.param_class
251 kwargs_temp = self._updateManager.parameter_state
--> 252 init_pos = param_class.kwargs2args(**kwargs_temp)
253 kwargs_sigma = self._updateManager.sigma_kwargs
254 sigma_start = param_class.kwargs2args(**kwargs_sigma)

~\AppData\Roaming\Python\Python38\site-packages\lenstronomy\Sampling\parameters.py in kwargs2args(self, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_special, kwargs_extinction)
312 """
313
--> 314 args = self.lensParams.setParams(kwargs_lens)
315 args += self.souceParams.setParams(kwargs_source)
316 args += self.lensLightParams.setParams(kwargs_lens_light)

~\AppData\Roaming\Python\Python38\site-packages\lenstronomy\LensModel\lens_param.py in setParams(self, kwargs_list)
115 # pass
116 else:
--> 117 args.append(kwargs[name])
118 return args
119

KeyError: 'e1'

simulation_util

Hi Simon,

I am playing around using your example quad model. The first thing this does is create a mock dataset, however lenstronomy.Util.simulation_util does not exist in the installed package nor anywhere in the documentation. Has this not been implemented yet?

Cheers,
Hannah

Colab link for notebooks

direct links to google colab or any other free online Jupyter server could enhance the visibility and usability of the notebooks without the need to download them and having lenstronomy installed locally.
What we would need to change in all the notebooks is that the installation of lenstronomy (and potentially other software) need to be done in the notebook itself with

!pip install lenstronomy

One way to not double install lenstronomy if operated in the current form is to have a condition:

try:
import lenstronomy
except:
!pip install lenstronomy

Simulation API

There is a minor error in the simulation_api notebook 13/14/15 where SimAPI() calls kwargs_numerics as a parameter although SimAPI does not take this parameter, rather SimAPI.image_model_class() seems to take this. Also, running that cell of code after moving kwargs_numerics to the image_model_class() gives a TypeError in SimulationAPI.data_api in .init() that gives the error that .init() got an unexpected keyword argument psf_model.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.