Comments (4)
I am not 100% sure what you asking, but (assumingy you have a result
which you use are using to get mp_instance
) you could try:
tracer = result.max_log_likelihood_tracer
fit = al.FitPointDict(point_dict=point_dict, tracer=tracer, positions_solver=solver)
fit["point_0"].positions.model_positions
This should give you the positions from the model.
from pyautolens.
Hi, first thanks for your answer and sorry for not being clear, second my true doubt is I can reproduce the same configuration in Lenstronomy just using the parameters obtained from Pyautolens or i have to make some change in the parameters for example.
I made a toy model in lenstronomy
angle=30# degrees positive from x axis
e1,e2 = param_util.phi_q2_ellipticity((angle)*np.pi/180.,q=0.7)
kwargs_lens=[{'theta_E': 0.8, 'e1': e1, 'e2': e2, 'center_x': 0.5, 'center_y': 0.5, 'gamma': 2.0}]
lensModel=LensModel(lens_model_list=['PEMD'])#SIE whit gamma variable.
source_x,source_y=0.3,0.3
numPix = 500 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
lens_model_class = LensModel(lens_model_list=['PEMD'], z_lens=0.5, z_source=2, cosmo=Cosmo)
lensEquationSolver = LensEquationSolver(lens_model_class)
x_image, y_image = lensEquationSolver.findBrightImage(source_x, source_y, kwargs_lens,
min_distance=deltaPix, search_window=numPix * deltaPix)
And obtain:
#Coord x,y
[0.03349649 0.86431612] [-0.43449932 0.79154548]
Whit that coords i made a .json file
[
{
"name": "point_0",
"positions": [
[
-0.43449932,
0.03349649
],
[
0.79154548,
0.86431612
]
],
"positions_noise_map": [
0.003,
0.003
],
"fluxes": [
21.83,
19.39
],
"fluxes_noise_map": [
1.0,
1.0
]
}
]
And made the model from the .json file similar to your examples in pointsource
point_0=al.ps.PointFlux
point_dict = al.PointDict.from_json(file_path=path.join("someplace","exp1.json"))
pixel_scale_precision=0.025
source = af.Model(al.Galaxy, redshift=2, point_0=point_0)
model = af.Collection(galaxies=af.Collection(lens_0=af.Model(al.Galaxy, redshift=0.5, mass=al.mp.EllIsothermal),source=source))
model.galaxies.lens_0.mass.centre_0=0.5
model.galaxies.lens_0.mass.centre_1=0.5
samples = result.samples
mp_vector = samples.median_pdf_vector
grid = al.Grid2D.uniform(shape_native=(200,200), pixel_scales=(0.05, 0.05))
positions_solver = al.PositionsSolver(grid=grid, pixel_scale_precision=pixel_scale_precision)
path_prefix="/mnt/c/Users/jataq/Desktop"
dataset_name="ajustes"
search = af.DynestyStatic(path_prefix=path_prefix, name="fv2", unique_tag=dataset_name,
nlive=406,
number_of_cores=4)
analysis = al.AnalysisPoint(point_dict=point_dict, solver=positions_solver)
result = search.fit(model=model, analysis=analysis)
And then
tracer = al.Tracer.from_galaxies(galaxies=result.max_log_likelihood_tracer.galaxies)
solver = al.PositionsSolver(grid=grid,pixel_scale_precision=pixel_scale_precision)
fit = al.FitPointDict(point_dict=point_dict, tracer=tracer, positions_solver=solver)
And obtein these results from fit["point_0"].positions.model_positions
[[-0.4375 0.0375]
[ 0.7875 0.8625]]
And from print result.max_log_likelihood_tracer.galaxies
EllIsothermal
centre: (0.5, 0.5)
elliptical_comps: (-0.07790185612420741, 0.16393196492822135)
axis_ratio: 0.6927628904038955
angle: -12.70873115953642
einstein_radius: 0.7428787155501909
slope: 2.0
core_radius: 0.0
id: 9601
_is_frozen: False
_frozen_cache: {}
_assertions: [], Redshift: 2]
Then with these results i wanna obtain the same images from the fit in the lenstromy code
e1,e2 = param_util.phi_q2_ellipticity((-12.70873115953642)*np.pi/180.,q=0.6927628904038955)#
kwargs_lens=[{'theta_E': 0.7428787155501909, 'e1': e1, 'e2': e2, 'center_x': 0.5, 'center_y': 0.5, 'gamma': 2.0}]
lensModel=LensModel(lens_model_list=['PEMD'])
source_x,source_y=mp_vector[1],mp_vector[0]
numPix = 500 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
lens_model_class = LensModel(lens_model_list=['PEMD'], z_lens=0.5, z_source=2, cosmo=Cosmo) #primer cambio
#lensModel = LensModel(lens_model_list=lens_model_list)
#lensModelExtensions = LensModelExtensions(lensModel=lensModel)
lensEquationSolver = LensEquationSolver(lens_model_class)
x_image, y_image = lensEquationSolver.findBrightImage(source_x, source_y, kwargs_lens,
min_distance=deltaPix, search_window=numPix * deltaPix)
And obtein :
coords x,y
[0.02850714 0.87231816] [-0.44667117 0.79612796]
So finally, the "originals" images are
#Coord x,y
[0.03349649 0.86431612] [-0.43449932 0.79154548]
from fit:
[[-0.4375 0.0375]
[ 0.7875 0.8625]]
And from lenstronomy using the parameters obtained from the model.
[0.02850714 0.87231816] [-0.44667117 0.79612796]
So my doubt is if you know where these differences come from, the model is pretty similar from the toy original model less in the angle parameter. Thanks alot for your answer.
Felipe Avila
from pyautolens.
I honestly have no idea.
It is highly like that autolens and lenstronomy adopt different conventions for parameters. Especially something like angle
, which could be defined from the x axis or y axis in the clockwise or counter clockwise direction.
I doubt I can provide much more help!
from pyautolens.
Ok, thanks for your answer. Cheers Felipe
from pyautolens.
Related Issues (20)
- Self interacting dark matter profile deflections
- Hernquist Light Profile
- Decide how to pass size of projected grid and whether to remove its centre through code
- Getting an AttributeError in the mass fitting code given on the GitHub page. HOT 6
- Saving / Loading a Tracer to .json format
- Source Plane Interpolation Mapping
- Voronoi Interpolation HOT 4
- Delaunay Interpolation HOT 7
- Delaunay Implementation HOT 9
- W Tilde Imaging With Interpolation
- Create Tracer from result with same API as instance
- Galaxy.dict() not returning parameters correctly HOT 3
- How to handle memory error while modeling a dataset? HOT 2
- Unit test failing due to from_dict HOT 1
- Multiprocessing RuntimeError HOT 13
- API consistency issues? HOT 1
- Multicore task in a cluster HOT 10
- Autoconf conf.py - Key error HOT 5
- Fix Aggregator Tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyautolens.