repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
sibirrer/lenstronomy | lenstronomy/Util/util.py | averaging | def averaging(grid, numGrid, numPix):
"""
resize 2d pixel grid with numGrid to numPix and averages over the pixels
:param grid: higher resolution pixel grid
:param numGrid: number of pixels per axis in the high resolution input image
:param numPix: lower number of pixels per axis in the output image... | python | def averaging(grid, numGrid, numPix):
"""
resize 2d pixel grid with numGrid to numPix and averages over the pixels
:param grid: higher resolution pixel grid
:param numGrid: number of pixels per axis in the high resolution input image
:param numPix: lower number of pixels per axis in the output image... | [
"def",
"averaging",
"(",
"grid",
",",
"numGrid",
",",
"numPix",
")",
":",
"Nbig",
"=",
"numGrid",
"Nsmall",
"=",
"numPix",
"small",
"=",
"grid",
".",
"reshape",
"(",
"[",
"int",
"(",
"Nsmall",
")",
",",
"int",
"(",
"Nbig",
"/",
"Nsmall",
")",
",",
... | resize 2d pixel grid with numGrid to numPix and averages over the pixels
:param grid: higher resolution pixel grid
:param numGrid: number of pixels per axis in the high resolution input image
:param numPix: lower number of pixels per axis in the output image (numGrid/numPix is integer number)
:return: | [
"resize",
"2d",
"pixel",
"grid",
"with",
"numGrid",
"to",
"numPix",
"and",
"averages",
"over",
"the",
"pixels",
":",
"param",
"grid",
":",
"higher",
"resolution",
"pixel",
"grid",
":",
"param",
"numGrid",
":",
"number",
"of",
"pixels",
"per",
"axis",
"in",... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L244-L256 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | displaceAbs | def displaceAbs(x, y, sourcePos_x, sourcePos_y):
"""
calculates a grid of distances to the observer in angel
:param mapped_cartcoord: mapped cartesian coordinates
:type mapped_cartcoord: numpy array (n,2)
:param sourcePos: source position
:type sourcePos: numpy vector [x0,y0]
:returns: arr... | python | def displaceAbs(x, y, sourcePos_x, sourcePos_y):
"""
calculates a grid of distances to the observer in angel
:param mapped_cartcoord: mapped cartesian coordinates
:type mapped_cartcoord: numpy array (n,2)
:param sourcePos: source position
:type sourcePos: numpy vector [x0,y0]
:returns: arr... | [
"def",
"displaceAbs",
"(",
"x",
",",
"y",
",",
"sourcePos_x",
",",
"sourcePos_y",
")",
":",
"x_mapped",
"=",
"x",
"-",
"sourcePos_x",
"y_mapped",
"=",
"y",
"-",
"sourcePos_y",
"absmapped",
"=",
"np",
".",
"sqrt",
"(",
"x_mapped",
"**",
"2",
"+",
"y_map... | calculates a grid of distances to the observer in angel
:param mapped_cartcoord: mapped cartesian coordinates
:type mapped_cartcoord: numpy array (n,2)
:param sourcePos: source position
:type sourcePos: numpy vector [x0,y0]
:returns: array of displacement
:raises: AttributeError, KeyError | [
"calculates",
"a",
"grid",
"of",
"distances",
"to",
"the",
"observer",
"in",
"angel"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L259-L273 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | min_square_dist | def min_square_dist(x_1, y_1, x_2, y_2):
"""
return minimum of quadratic distance of pairs (x1, y1) to pairs (x2, y2)
:param x_1:
:param y_1:
:param x_2:
:param y_2:
:return:
"""
dist = np.zeros_like(x_1)
for i in range(len(x_1)):
dist[i] = np.min((x_1[i] - x_2)**2 + (y_1... | python | def min_square_dist(x_1, y_1, x_2, y_2):
"""
return minimum of quadratic distance of pairs (x1, y1) to pairs (x2, y2)
:param x_1:
:param y_1:
:param x_2:
:param y_2:
:return:
"""
dist = np.zeros_like(x_1)
for i in range(len(x_1)):
dist[i] = np.min((x_1[i] - x_2)**2 + (y_1... | [
"def",
"min_square_dist",
"(",
"x_1",
",",
"y_1",
",",
"x_2",
",",
"y_2",
")",
":",
"dist",
"=",
"np",
".",
"zeros_like",
"(",
"x_1",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"x_1",
")",
")",
":",
"dist",
"[",
"i",
"]",
"=",
"np",
"."... | return minimum of quadratic distance of pairs (x1, y1) to pairs (x2, y2)
:param x_1:
:param y_1:
:param x_2:
:param y_2:
:return: | [
"return",
"minimum",
"of",
"quadratic",
"distance",
"of",
"pairs",
"(",
"x1",
"y1",
")",
"to",
"pairs",
"(",
"x2",
"y2",
")",
":",
"param",
"x_1",
":",
":",
"param",
"y_1",
":",
":",
"param",
"x_2",
":",
":",
"param",
"y_2",
":",
":",
"return",
"... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L318-L330 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | points_on_circle | def points_on_circle(radius, points):
"""
returns a set of uniform points around a circle
:param radius: radius of the circle
:param points: number of points on the circle
:return:
"""
angle = np.linspace(0, 2*np.pi, points)
x_coord = np.cos(angle)*radius
y_coord = np.sin(angle)*radi... | python | def points_on_circle(radius, points):
"""
returns a set of uniform points around a circle
:param radius: radius of the circle
:param points: number of points on the circle
:return:
"""
angle = np.linspace(0, 2*np.pi, points)
x_coord = np.cos(angle)*radius
y_coord = np.sin(angle)*radi... | [
"def",
"points_on_circle",
"(",
"radius",
",",
"points",
")",
":",
"angle",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
"np",
".",
"pi",
",",
"points",
")",
"x_coord",
"=",
"np",
".",
"cos",
"(",
"angle",
")",
"*",
"radius",
"y_coord",
"... | returns a set of uniform points around a circle
:param radius: radius of the circle
:param points: number of points on the circle
:return: | [
"returns",
"a",
"set",
"of",
"uniform",
"points",
"around",
"a",
"circle",
":",
"param",
"radius",
":",
"radius",
"of",
"the",
"circle",
":",
"param",
"points",
":",
"number",
"of",
"points",
"on",
"the",
"circle",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L356-L366 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | neighborSelect | def neighborSelect(a, x, y):
"""
finds (local) minima in a 2d grid
:param a: 1d array of displacements from the source positions
:type a: numpy array with length numPix**2 in float
:returns: array of indices of local minima, values of those minima
:raises: AttributeError, KeyError
"""
... | python | def neighborSelect(a, x, y):
"""
finds (local) minima in a 2d grid
:param a: 1d array of displacements from the source positions
:type a: numpy array with length numPix**2 in float
:returns: array of indices of local minima, values of those minima
:raises: AttributeError, KeyError
"""
... | [
"def",
"neighborSelect",
"(",
"a",
",",
"x",
",",
"y",
")",
":",
"dim",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"len",
"(",
"a",
")",
")",
")",
"values",
"=",
"[",
"]",
"x_mins",
"=",
"[",
"]",
"y_mins",
"=",
"[",
"]",
"for",
"i",
"in",
... | finds (local) minima in a 2d grid
:param a: 1d array of displacements from the source positions
:type a: numpy array with length numPix**2 in float
:returns: array of indices of local minima, values of those minima
:raises: AttributeError, KeyError | [
"finds",
"(",
"local",
")",
"minima",
"in",
"a",
"2d",
"grid"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L369-L410 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | make_subgrid | def make_subgrid(ra_coord, dec_coord, subgrid_res=2):
"""
return a grid with subgrid resolution
:param ra_coord:
:param dec_coord:
:param subgrid_res:
:return:
"""
ra_array = array2image(ra_coord)
dec_array = array2image(dec_coord)
n = len(ra_array)
d_ra_x = ra_array[0][1] - ... | python | def make_subgrid(ra_coord, dec_coord, subgrid_res=2):
"""
return a grid with subgrid resolution
:param ra_coord:
:param dec_coord:
:param subgrid_res:
:return:
"""
ra_array = array2image(ra_coord)
dec_array = array2image(dec_coord)
n = len(ra_array)
d_ra_x = ra_array[0][1] - ... | [
"def",
"make_subgrid",
"(",
"ra_coord",
",",
"dec_coord",
",",
"subgrid_res",
"=",
"2",
")",
":",
"ra_array",
"=",
"array2image",
"(",
"ra_coord",
")",
"dec_array",
"=",
"array2image",
"(",
"dec_coord",
")",
"n",
"=",
"len",
"(",
"ra_array",
")",
"d_ra_x",... | return a grid with subgrid resolution
:param ra_coord:
:param dec_coord:
:param subgrid_res:
:return: | [
"return",
"a",
"grid",
"with",
"subgrid",
"resolution",
":",
"param",
"ra_coord",
":",
":",
"param",
"dec_coord",
":",
":",
"param",
"subgrid_res",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L453-L478 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spep.py | SPEP.function | def function(self, x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0):
"""
:param x: set of x-coordinates
:type x: array of size (n)
:param theta_E: Einstein radius of lense
:type theta_E: float.
:param gamma: power law slope of mass profifle
:type gamma: <2 fl... | python | def function(self, x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0):
"""
:param x: set of x-coordinates
:type x: array of size (n)
:param theta_E: Einstein radius of lense
:type theta_E: float.
:param gamma: power law slope of mass profifle
:type gamma: <2 fl... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"gamma",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"phi_G",
",",
"q",
"=",
"param_util",
".",
"ellipticity2phi_q",
"(",
"e1",
","... | :param x: set of x-coordinates
:type x: array of size (n)
:param theta_E: Einstein radius of lense
:type theta_E: float.
:param gamma: power law slope of mass profifle
:type gamma: <2 float
:param q: Axis ratio
:type q: 0<q<1
:param phi_G: position angel o... | [
":",
"param",
"x",
":",
"set",
"of",
"x",
"-",
"coordinates",
":",
"type",
"x",
":",
"array",
"of",
"size",
"(",
"n",
")",
":",
"param",
"theta_E",
":",
"Einstein",
"radius",
"of",
"lense",
":",
"type",
"theta_E",
":",
"float",
".",
":",
"param",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spep.py#L20-L47 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spep.py | SPEP.mass_3d_lens | def mass_3d_lens(self, r, theta_E, gamma, e1, e2):
"""
computes the spherical power-law mass enclosed (with SPP routiune)
:param r:
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:return:
"""
return self.spp.mass_3d_lens(r, theta_E, ... | python | def mass_3d_lens(self, r, theta_E, gamma, e1, e2):
"""
computes the spherical power-law mass enclosed (with SPP routiune)
:param r:
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:return:
"""
return self.spp.mass_3d_lens(r, theta_E, ... | [
"def",
"mass_3d_lens",
"(",
"self",
",",
"r",
",",
"theta_E",
",",
"gamma",
",",
"e1",
",",
"e2",
")",
":",
"return",
"self",
".",
"spp",
".",
"mass_3d_lens",
"(",
"r",
",",
"theta_E",
",",
"gamma",
")"
] | computes the spherical power-law mass enclosed (with SPP routiune)
:param r:
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:return: | [
"computes",
"the",
"spherical",
"power",
"-",
"law",
"mass",
"enclosed",
"(",
"with",
"SPP",
"routiune",
")",
":",
"param",
"r",
":",
":",
"param",
"theta_E",
":",
":",
"param",
"gamma",
":",
":",
"param",
"q",
":",
":",
"param",
"phi_G",
":",
":",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spep.py#L115-L125 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spep.py | SPEP._param_bounds | def _param_bounds(self, gamma, q):
"""
bounds parameters
:param gamma:
:param q:
:return:
"""
if gamma < 1.4:
gamma = 1.4
if gamma > 2.9:
gamma = 2.9
if q < 0.01:
q = 0.01
return float(gamma), q | python | def _param_bounds(self, gamma, q):
"""
bounds parameters
:param gamma:
:param q:
:return:
"""
if gamma < 1.4:
gamma = 1.4
if gamma > 2.9:
gamma = 2.9
if q < 0.01:
q = 0.01
return float(gamma), q | [
"def",
"_param_bounds",
"(",
"self",
",",
"gamma",
",",
"q",
")",
":",
"if",
"gamma",
"<",
"1.4",
":",
"gamma",
"=",
"1.4",
"if",
"gamma",
">",
"2.9",
":",
"gamma",
"=",
"2.9",
"if",
"q",
"<",
"0.01",
":",
"q",
"=",
"0.01",
"return",
"float",
"... | bounds parameters
:param gamma:
:param q:
:return: | [
"bounds",
"parameters"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spep.py#L127-L141 |
sibirrer/lenstronomy | lenstronomy/Sampling/Likelihoods/position_likelihood.py | PositionLikelihood.solver_penalty | def solver_penalty(self, kwargs_lens, kwargs_ps, kwargs_cosmo, tolerance):
"""
test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: add penalty when solver does not find a solution
"""
dist = self._pa... | python | def solver_penalty(self, kwargs_lens, kwargs_ps, kwargs_cosmo, tolerance):
"""
test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: add penalty when solver does not find a solution
"""
dist = self._pa... | [
"def",
"solver_penalty",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kwargs_cosmo",
",",
"tolerance",
")",
":",
"dist",
"=",
"self",
".",
"_param",
".",
"check_solver",
"(",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kwargs_cosmo",
")",
"if",
"dist"... | test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: add penalty when solver does not find a solution | [
"test",
"whether",
"the",
"image",
"positions",
"map",
"back",
"to",
"the",
"same",
"source",
"position",
":",
"param",
"kwargs_lens",
":",
":",
"param",
"kwargs_ps",
":",
":",
"return",
":",
"add",
"penalty",
"when",
"solver",
"does",
"not",
"find",
"a",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/Likelihoods/position_likelihood.py#L51-L61 |
sibirrer/lenstronomy | lenstronomy/Sampling/Likelihoods/position_likelihood.py | PositionLikelihood.check_additional_images | def check_additional_images(self, kwargs_ps, kwargs_lens):
"""
checks whether additional images have been found and placed in kwargs_ps
:param kwargs_ps: point source kwargs
:return: bool, True if more image positions are found than originally been assigned
"""
ra_image_l... | python | def check_additional_images(self, kwargs_ps, kwargs_lens):
"""
checks whether additional images have been found and placed in kwargs_ps
:param kwargs_ps: point source kwargs
:return: bool, True if more image positions are found than originally been assigned
"""
ra_image_l... | [
"def",
"check_additional_images",
"(",
"self",
",",
"kwargs_ps",
",",
"kwargs_lens",
")",
":",
"ra_image_list",
",",
"dec_image_list",
"=",
"self",
".",
"_pointSource",
".",
"image_position",
"(",
"kwargs_ps",
"=",
"kwargs_ps",
",",
"kwargs_lens",
"=",
"kwargs_len... | checks whether additional images have been found and placed in kwargs_ps
:param kwargs_ps: point source kwargs
:return: bool, True if more image positions are found than originally been assigned | [
"checks",
"whether",
"additional",
"images",
"have",
"been",
"found",
"and",
"placed",
"in",
"kwargs_ps",
":",
"param",
"kwargs_ps",
":",
"point",
"source",
"kwargs",
":",
"return",
":",
"bool",
"True",
"if",
"more",
"image",
"positions",
"are",
"found",
"th... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/Likelihoods/position_likelihood.py#L63-L73 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/sersic.py | Sersic.function | def function(self, x, y, amp, R_sersic, n_sersic, center_x=0, center_y=0):
"""
returns Sersic profile
"""
#if n_sersic < 0.2:
# n_sersic = 0.2
#if R_sersic < 10.**(-6):
# R_sersic = 10.**(-6)
R_sersic = np.maximum(0, R_sersic)
x_shift = x - c... | python | def function(self, x, y, amp, R_sersic, n_sersic, center_x=0, center_y=0):
"""
returns Sersic profile
"""
#if n_sersic < 0.2:
# n_sersic = 0.2
#if R_sersic < 10.**(-6):
# R_sersic = 10.**(-6)
R_sersic = np.maximum(0, R_sersic)
x_shift = x - c... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"R_sersic",
",",
"n_sersic",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"#if n_sersic < 0.2:",
"# n_sersic = 0.2",
"#if R_sersic < 10.**(-6):",
"# R_sersic = 10.**(-6... | returns Sersic profile | [
"returns",
"Sersic",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/sersic.py#L18-L48 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/sersic.py | SersicElliptic.function | def function(self, x, y, amp, R_sersic, n_sersic, e1, e2, center_x=0, center_y=0):
"""
returns Sersic profile
"""
#if n_sersic < 0.2:
# n_sersic = 0.2
#if R_sersic < 10.**(-6):
# R_sersic = 10.**(-6)
R_sersic = np.maximum(0, R_sersic)
phi_G, ... | python | def function(self, x, y, amp, R_sersic, n_sersic, e1, e2, center_x=0, center_y=0):
"""
returns Sersic profile
"""
#if n_sersic < 0.2:
# n_sersic = 0.2
#if R_sersic < 10.**(-6):
# R_sersic = 10.**(-6)
R_sersic = np.maximum(0, R_sersic)
phi_G, ... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"R_sersic",
",",
"n_sersic",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"#if n_sersic < 0.2:",
"# n_sersic = 0.2",
"#if R_sersic < 10.**(-6):... | returns Sersic profile | [
"returns",
"Sersic",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/sersic.py#L59-L97 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/sersic.py | CoreSersic.function | def function(self, x, y, amp, R_sersic, Re, n_sersic, gamma, e1, e2, center_x=0, center_y=0, alpha=3.):
"""
returns Core-Sersic function
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
Rb = R_sersic
x_shift = x - center_x
y_shift = y - center_y
cos_ph... | python | def function(self, x, y, amp, R_sersic, Re, n_sersic, gamma, e1, e2, center_x=0, center_y=0, alpha=3.):
"""
returns Core-Sersic function
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
Rb = R_sersic
x_shift = x - center_x
y_shift = y - center_y
cos_ph... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"R_sersic",
",",
"Re",
",",
"n_sersic",
",",
"gamma",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
",",
"alpha",
"=",
"3.",
")",
":",
"phi_G",
... | returns Core-Sersic function | [
"returns",
"Core",
"-",
"Sersic",
"function"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/sersic.py#L110-L141 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sis_truncate.py | SIS_truncate.derivatives | def derivatives(self, x, y, theta_E, r_trunc, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
x_shift = x - center_x
y_shift = y - center_y
dphi_dr = self._dphi_dr(x_shift, y_shift, theta_E, r_trunc)
dr_dx, dr_dy = self._dr_dx(x_shift, y_... | python | def derivatives(self, x, y, theta_E, r_trunc, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
x_shift = x - center_x
y_shift = y - center_y
dphi_dr = self._dphi_dr(x_shift, y_shift, theta_E, r_trunc)
dr_dx, dr_dy = self._dr_dx(x_shift, y_... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"r_trunc",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_shift",
"=",
"x",
"-",
"center_x",
"y_shift",
"=",
"y",
"-",
"center_y",
"dphi_dr",
"=",
"self... | returns df/dx and df/dy of the function | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sis_truncate.py#L32-L43 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sis_truncate.py | SIS_truncate.hessian | def hessian(self, x, y, theta_E, r_trunc, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
x_shift = x - center_x
y_shift = y - center_y
dphi_dr = self._dphi_dr(x_shift, y_shift, theta_E, r_trunc)
d2phi_dr2 = self._... | python | def hessian(self, x, y, theta_E, r_trunc, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
x_shift = x - center_x
y_shift = y - center_y
dphi_dr = self._dphi_dr(x_shift, y_shift, theta_E, r_trunc)
d2phi_dr2 = self._... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"r_trunc",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_shift",
"=",
"x",
"-",
"center_x",
"y_shift",
"=",
"y",
"-",
"center_y",
"dphi_dr",
"=",
"self",
... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | [
"returns",
"Hessian",
"matrix",
"of",
"function",
"d^2f",
"/",
"dx^2",
"d^f",
"/",
"dy^2",
"d^2",
"/",
"dxdy"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sis_truncate.py#L45-L58 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sis_truncate.py | SIS_truncate._dr_dx | def _dr_dx(self, x, y):
"""
derivative of dr/dx, dr/dy
:param x:
:param y:
:return:
"""
r = np.sqrt(x**2 + y**2)
if isinstance(r, int) or isinstance(r, float):
if r == 0:
r = 1
else:
r[r == 0] = 1
r... | python | def _dr_dx(self, x, y):
"""
derivative of dr/dx, dr/dy
:param x:
:param y:
:return:
"""
r = np.sqrt(x**2 + y**2)
if isinstance(r, int) or isinstance(r, float):
if r == 0:
r = 1
else:
r[r == 0] = 1
r... | [
"def",
"_dr_dx",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"r",
"=",
"np",
".",
"sqrt",
"(",
"x",
"**",
"2",
"+",
"y",
"**",
"2",
")",
"if",
"isinstance",
"(",
"r",
",",
"int",
")",
"or",
"isinstance",
"(",
"r",
",",
"float",
")",
":",
"... | derivative of dr/dx, dr/dy
:param x:
:param y:
:return: | [
"derivative",
"of",
"dr",
"/",
"dx",
"dr",
"/",
"dy",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sis_truncate.py#L110-L124 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/hernquist_ellipse.py | Hernquist_Ellipse.function | def function(self, x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0):
"""
returns double integral of NFW profile
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
sin_phi = np.sin(phi_... | python | def function(self, x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0):
"""
returns double integral of NFW profile
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
sin_phi = np.sin(phi_... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"sigma0",
",",
"Rs",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"phi_G",
",",
"q",
"=",
"param_util",
".",
"ellipticity2phi_q",
"(",
"e1",
",",
... | returns double integral of NFW profile | [
"returns",
"double",
"integral",
"of",
"NFW",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/hernquist_ellipse.py#L20-L33 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/hernquist_ellipse.py | Hernquist_Ellipse.derivatives | def derivatives(self, x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
... | python | def derivatives(self, x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"sigma0",
",",
"Rs",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"phi_G",
",",
"q",
"=",
"param_util",
".",
"ellipticity2phi_q",
"(",
"e1",
",",... | returns df/dx and df/dy of the function (integral of NFW) | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function",
"(",
"integral",
"of",
"NFW",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/hernquist_ellipse.py#L35-L53 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW._nfw_func | def _nfw_func(self, x):
"""
Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return:
"""
c = 0.000001
if isinstance(x, np.ndarray):
x[np.where(x<c)] = c
nfwvals = np.ones_like(x)
inds1 = np.where(x < 1)
... | python | def _nfw_func(self, x):
"""
Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return:
"""
c = 0.000001
if isinstance(x, np.ndarray):
x[np.where(x<c)] = c
nfwvals = np.ones_like(x)
inds1 = np.where(x < 1)
... | [
"def",
"_nfw_func",
"(",
"self",
",",
"x",
")",
":",
"c",
"=",
"0.000001",
"if",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
":",
"x",
"[",
"np",
".",
"where",
"(",
"x",
"<",
"c",
")",
"]",
"=",
"c",
"nfwvals",
"=",
"np",
".",
"... | Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return: | [
"Classic",
"NFW",
"function",
"in",
"terms",
"of",
"arctanh",
"and",
"arctan",
":",
"param",
"x",
":",
"r",
"/",
"Rs",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L44-L71 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW._F | def _F(self, X, b, c = 0.001):
"""
analytic solution of the projection integral
:param x: a dimensionless quantity, either r/rs or r/rc
:type x: float >0
"""
if b == 1:
b = 1 + c
prefac = (b - 1) ** -2
if isinstance(X, np.ndarray):
... | python | def _F(self, X, b, c = 0.001):
"""
analytic solution of the projection integral
:param x: a dimensionless quantity, either r/rs or r/rc
:type x: float >0
"""
if b == 1:
b = 1 + c
prefac = (b - 1) ** -2
if isinstance(X, np.ndarray):
... | [
"def",
"_F",
"(",
"self",
",",
"X",
",",
"b",
",",
"c",
"=",
"0.001",
")",
":",
"if",
"b",
"==",
"1",
":",
"b",
"=",
"1",
"+",
"c",
"prefac",
"=",
"(",
"b",
"-",
"1",
")",
"**",
"-",
"2",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
... | analytic solution of the projection integral
:param x: a dimensionless quantity, either r/rs or r/rc
:type x: float >0 | [
"analytic",
"solution",
"of",
"the",
"projection",
"integral"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L73-L114 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW.density | def density(self, R, Rs, rho0, r_core):
"""
three dimenstional truncated NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (central core density)
:type rho0: floa... | python | def density(self, R, Rs, rho0, r_core):
"""
three dimenstional truncated NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (central core density)
:type rho0: floa... | [
"def",
"density",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_core",
")",
":",
"M0",
"=",
"4",
"*",
"np",
".",
"pi",
"*",
"rho0",
"*",
"Rs",
"**",
"3",
"return",
"(",
"M0",
"/",
"4",
"/",
"np",
".",
"pi",
")",
"*",
"(",
"(",
... | three dimenstional truncated NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (central core density)
:type rho0: float
:return: rho(R) density | [
"three",
"dimenstional",
"truncated",
"NFW",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L191-L205 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW.density_2d | def density_2d(self, x, y, Rs, rho0, r_core, center_x=0, center_y=0):
"""
projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization ... | python | def density_2d(self, x, y, Rs, rho0, r_core, center_x=0, center_y=0):
"""
projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization ... | [
"def",
"density_2d",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"rho0",
",",
"r_core",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"R",
"=",
"np",
"."... | projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
:param r200: radius of (sub)hal... | [
"projected",
"two",
"dimenstional",
"NFW",
"profile",
"(",
"kappa",
"*",
"Sigma_crit",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L207-L228 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW.mass_3d | def mass_3d(self, R, Rs, rho0, r_core):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
b = r_core * Rs ** -1
x = R * Rs ** -1
M_0 = 4 * np.pi * Rs**3 * rho0
return M_0 * (x * (1+x) ** -1 * ... | python | def mass_3d(self, R, Rs, rho0, r_core):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
b = r_core * Rs ** -1
x = R * Rs ** -1
M_0 = 4 * np.pi * Rs**3 * rho0
return M_0 * (x * (1+x) ** -1 * ... | [
"def",
"mass_3d",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_core",
")",
":",
"b",
"=",
"r_core",
"*",
"Rs",
"**",
"-",
"1",
"x",
"=",
"R",
"*",
"Rs",
"**",
"-",
"1",
"M_0",
"=",
"4",
"*",
"np",
".",
"pi",
"*",
"Rs",
"**",
"... | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L230-L245 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/cnfw.py | CNFW.cnfwAlpha | def cnfwAlpha(self, R, Rs, rho0, r_core, ax_x, ax_y):
"""
deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (c... | python | def cnfwAlpha(self, R, Rs, rho0, r_core, ax_x, ax_y):
"""
deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (c... | [
"def",
"cnfwAlpha",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_core",
",",
"ax_x",
",",
"ax_y",
")",
":",
"if",
"isinstance",
"(",
"R",
",",
"int",
")",
"or",
"isinstance",
"(",
"R",
",",
"float",
")",
":",
"R",
"=",
"max",
"(",
"... | deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
:param r200: radi... | [
"deflection",
"angel",
"of",
"NFW",
"profile",
"along",
"the",
"projection",
"to",
"coordinate",
"axis"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/cnfw.py#L247-L274 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw_ellipse.py | NFW_ELLIPSE.function | def function(self, x, y, Rs, theta_Rs, e1, e2, center_x=0, center_y=0):
"""
returns double integral of NFW profile
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
sin_phi = np.sin(ph... | python | def function(self, x, y, Rs, theta_Rs, e1, e2, center_x=0, center_y=0):
"""
returns double integral of NFW profile
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
sin_phi = np.sin(ph... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"theta_Rs",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"phi_G",
",",
"q",
"=",
"param_util",
".",
"ellipticity2phi_q",
"(",
"e1",
",",
... | returns double integral of NFW profile | [
"returns",
"double",
"integral",
"of",
"NFW",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw_ellipse.py#L25-L42 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw_ellipse.py | NFW_ELLIPSE.derivatives | def derivatives(self, x, y, Rs, theta_Rs, e1, e2, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
... | python | def derivatives(self, x, y, Rs, theta_Rs, e1, e2, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
phi_G, q = param_util.ellipticity2phi_q(e1, e2)
x_shift = x - center_x
y_shift = y - center_y
cos_phi = np.cos(phi_G)
... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"theta_Rs",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"phi_G",
",",
"q",
"=",
"param_util",
".",
"ellipticity2phi_q",
"(",
"e1",
",... | returns df/dx and df/dy of the function (integral of NFW) | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function",
"(",
"integral",
"of",
"NFW",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw_ellipse.py#L44-L65 |
sibirrer/lenstronomy | lenstronomy/Workflow/alignment_matching.py | AlignmentFitting.pso | def pso(self, n_particles=10, n_iterations=10, lowerLimit=-0.2, upperLimit=0.2, threadCount=1, mpi=False, print_key='default'):
"""
returns the best fit for the lense model on catalogue basis with particle swarm optimizer
"""
init_pos = self.chain.get_args(self.chain.kwargs_data_init)
... | python | def pso(self, n_particles=10, n_iterations=10, lowerLimit=-0.2, upperLimit=0.2, threadCount=1, mpi=False, print_key='default'):
"""
returns the best fit for the lense model on catalogue basis with particle swarm optimizer
"""
init_pos = self.chain.get_args(self.chain.kwargs_data_init)
... | [
"def",
"pso",
"(",
"self",
",",
"n_particles",
"=",
"10",
",",
"n_iterations",
"=",
"10",
",",
"lowerLimit",
"=",
"-",
"0.2",
",",
"upperLimit",
"=",
"0.2",
",",
"threadCount",
"=",
"1",
",",
"mpi",
"=",
"False",
",",
"print_key",
"=",
"'default'",
"... | returns the best fit for the lense model on catalogue basis with particle swarm optimizer | [
"returns",
"the",
"best",
"fit",
"for",
"the",
"lense",
"model",
"on",
"catalogue",
"basis",
"with",
"particle",
"swarm",
"optimizer"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Workflow/alignment_matching.py#L21-L63 |
sibirrer/lenstronomy | lenstronomy/Workflow/alignment_matching.py | AlignmentLikelihood._likelihood | def _likelihood(self, args):
"""
routine to compute X2 given variable parameters for a MCMC/PSO chainF
"""
#generate image and computes likelihood
kwargs_data = self.update_data(args)
imageModel = class_creator.create_image_model(kwargs_data, self._kwargs_psf, self._kwarg... | python | def _likelihood(self, args):
"""
routine to compute X2 given variable parameters for a MCMC/PSO chainF
"""
#generate image and computes likelihood
kwargs_data = self.update_data(args)
imageModel = class_creator.create_image_model(kwargs_data, self._kwargs_psf, self._kwarg... | [
"def",
"_likelihood",
"(",
"self",
",",
"args",
")",
":",
"#generate image and computes likelihood",
"kwargs_data",
"=",
"self",
".",
"update_data",
"(",
"args",
")",
"imageModel",
"=",
"class_creator",
".",
"create_image_model",
"(",
"kwargs_data",
",",
"self",
"... | routine to compute X2 given variable parameters for a MCMC/PSO chainF | [
"routine",
"to",
"compute",
"X2",
"given",
"variable",
"parameters",
"for",
"a",
"MCMC",
"/",
"PSO",
"chainF"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Workflow/alignment_matching.py#L83-L91 |
sibirrer/lenstronomy | lenstronomy/LensModel/Optimizer/optimizer.py | Optimizer.optimize | def optimize(self, n_particles=50, n_iterations=250, restart=1):
"""
the best result of all optimizations will be returned.
total number of lens models sovled: n_particles*n_iterations
:param n_particles: number of particle swarm particles
:param n_iterations: number of particl... | python | def optimize(self, n_particles=50, n_iterations=250, restart=1):
"""
the best result of all optimizations will be returned.
total number of lens models sovled: n_particles*n_iterations
:param n_particles: number of particle swarm particles
:param n_iterations: number of particl... | [
"def",
"optimize",
"(",
"self",
",",
"n_particles",
"=",
"50",
",",
"n_iterations",
"=",
"250",
",",
"restart",
"=",
"1",
")",
":",
"if",
"restart",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"parameter 'restart' must be integer of value > 0\"",
")",
"# part... | the best result of all optimizations will be returned.
total number of lens models sovled: n_particles*n_iterations
:param n_particles: number of particle swarm particles
:param n_iterations: number of particle swarm iternations
:param restart: number of times to execute the optimizatio... | [
"the",
"best",
"result",
"of",
"all",
"optimizations",
"will",
"be",
"returned",
".",
"total",
"number",
"of",
"lens",
"models",
"sovled",
":",
"n_particles",
"*",
"n_iterations"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Optimizer/optimizer.py#L145-L195 |
sibirrer/lenstronomy | lenstronomy/LensModel/Optimizer/optimizer.py | Optimizer._pso | def _pso(self, n_particles, n_iterations, optimizer):
"""
:param n_particles: number of PSO particles
:param n_iterations: number of PSO iterations
:param optimizer: instance of SinglePlaneOptimizer or MultiPlaneOptimizer
:return: optimized kwargs_lens
"""
pso =... | python | def _pso(self, n_particles, n_iterations, optimizer):
"""
:param n_particles: number of PSO particles
:param n_iterations: number of PSO iterations
:param optimizer: instance of SinglePlaneOptimizer or MultiPlaneOptimizer
:return: optimized kwargs_lens
"""
pso =... | [
"def",
"_pso",
"(",
"self",
",",
"n_particles",
",",
"n_iterations",
",",
"optimizer",
")",
":",
"pso",
"=",
"ParticleSwarmOptimizer",
"(",
"optimizer",
",",
"low",
"=",
"self",
".",
"_lower_limit",
",",
"high",
"=",
"self",
".",
"_upper_limit",
",",
"part... | :param n_particles: number of PSO particles
:param n_iterations: number of PSO iterations
:param optimizer: instance of SinglePlaneOptimizer or MultiPlaneOptimizer
:return: optimized kwargs_lens | [
":",
"param",
"n_particles",
":",
"number",
"of",
"PSO",
"particles",
":",
"param",
"n_iterations",
":",
"number",
"of",
"PSO",
"iterations",
":",
"param",
"optimizer",
":",
"instance",
"of",
"SinglePlaneOptimizer",
"or",
"MultiPlaneOptimizer",
":",
"return",
":... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Optimizer/optimizer.py#L228-L244 |
sibirrer/lenstronomy | lenstronomy/Util/multi_gauss_expansion.py | de_projection_3d | def de_projection_3d(amplitudes, sigmas):
"""
de-projects a gaussian (or list of multiple Gaussians from a 2d projected to a 3d profile)
:param amplitudes:
:param sigmas:
:return:
"""
amplitudes_3d = amplitudes / sigmas / np.sqrt(2*np.pi)
return amplitudes_3d, sigmas | python | def de_projection_3d(amplitudes, sigmas):
"""
de-projects a gaussian (or list of multiple Gaussians from a 2d projected to a 3d profile)
:param amplitudes:
:param sigmas:
:return:
"""
amplitudes_3d = amplitudes / sigmas / np.sqrt(2*np.pi)
return amplitudes_3d, sigmas | [
"def",
"de_projection_3d",
"(",
"amplitudes",
",",
"sigmas",
")",
":",
"amplitudes_3d",
"=",
"amplitudes",
"/",
"sigmas",
"/",
"np",
".",
"sqrt",
"(",
"2",
"*",
"np",
".",
"pi",
")",
"return",
"amplitudes_3d",
",",
"sigmas"
] | de-projects a gaussian (or list of multiple Gaussians from a 2d projected to a 3d profile)
:param amplitudes:
:param sigmas:
:return: | [
"de",
"-",
"projects",
"a",
"gaussian",
"(",
"or",
"list",
"of",
"multiple",
"Gaussians",
"from",
"a",
"2d",
"projected",
"to",
"a",
"3d",
"profile",
")",
":",
"param",
"amplitudes",
":",
":",
"param",
"sigmas",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/multi_gauss_expansion.py#L64-L72 |
sibirrer/lenstronomy | lenstronomy/Data/psf.py | PSF.set_pixel_size | def set_pixel_size(self, deltaPix):
"""
update pixel size
:param deltaPix:
:return:
"""
self._pixel_size = deltaPix
if self.psf_type == 'GAUSSIAN':
try:
del self._kernel_point_source
except:
pass | python | def set_pixel_size(self, deltaPix):
"""
update pixel size
:param deltaPix:
:return:
"""
self._pixel_size = deltaPix
if self.psf_type == 'GAUSSIAN':
try:
del self._kernel_point_source
except:
pass | [
"def",
"set_pixel_size",
"(",
"self",
",",
"deltaPix",
")",
":",
"self",
".",
"_pixel_size",
"=",
"deltaPix",
"if",
"self",
".",
"psf_type",
"==",
"'GAUSSIAN'",
":",
"try",
":",
"del",
"self",
".",
"_kernel_point_source",
"except",
":",
"pass"
] | update pixel size
:param deltaPix:
:return: | [
"update",
"pixel",
"size"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Data/psf.py#L166-L178 |
sibirrer/lenstronomy | lenstronomy/Data/psf.py | PSF.psf_convolution | def psf_convolution(self, grid, grid_scale, psf_subgrid=False, subgrid_res=1):
"""
convolves a given pixel grid with a PSF
"""
psf_type = self.psf_type
if psf_type == 'NONE':
return grid
elif psf_type == 'GAUSSIAN':
sigma = self._sigma_gaussian/gri... | python | def psf_convolution(self, grid, grid_scale, psf_subgrid=False, subgrid_res=1):
"""
convolves a given pixel grid with a PSF
"""
psf_type = self.psf_type
if psf_type == 'NONE':
return grid
elif psf_type == 'GAUSSIAN':
sigma = self._sigma_gaussian/gri... | [
"def",
"psf_convolution",
"(",
"self",
",",
"grid",
",",
"grid_scale",
",",
"psf_subgrid",
"=",
"False",
",",
"subgrid_res",
"=",
"1",
")",
":",
"psf_type",
"=",
"self",
".",
"psf_type",
"if",
"psf_type",
"==",
"'NONE'",
":",
"return",
"grid",
"elif",
"p... | convolves a given pixel grid with a PSF | [
"convolves",
"a",
"given",
"pixel",
"grid",
"with",
"a",
"PSF"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Data/psf.py#L186-L205 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/dipole.py | Dipole_util.com | def com(self, center1_x, center1_y, center2_x, center2_y, Fm):
"""
:return: center of mass
"""
com_x = (Fm * center1_x + center2_x)/(Fm + 1.)
com_y = (Fm * center1_y + center2_y)/(Fm + 1.)
return com_x, com_y | python | def com(self, center1_x, center1_y, center2_x, center2_y, Fm):
"""
:return: center of mass
"""
com_x = (Fm * center1_x + center2_x)/(Fm + 1.)
com_y = (Fm * center1_y + center2_y)/(Fm + 1.)
return com_x, com_y | [
"def",
"com",
"(",
"self",
",",
"center1_x",
",",
"center1_y",
",",
"center2_x",
",",
"center2_y",
",",
"Fm",
")",
":",
"com_x",
"=",
"(",
"Fm",
"*",
"center1_x",
"+",
"center2_x",
")",
"/",
"(",
"Fm",
"+",
"1.",
")",
"com_y",
"=",
"(",
"Fm",
"*"... | :return: center of mass | [
":",
"return",
":",
"center",
"of",
"mass"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/dipole.py#L85-L91 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/dipole.py | Dipole_util.angle | def angle(self, center1_x, center1_y, center2_x, center2_y):
"""
compute the rotation angle of the dipole
:return:
"""
phi_G = np.arctan2(center2_y - center1_y, center2_x - center1_x)
return phi_G | python | def angle(self, center1_x, center1_y, center2_x, center2_y):
"""
compute the rotation angle of the dipole
:return:
"""
phi_G = np.arctan2(center2_y - center1_y, center2_x - center1_x)
return phi_G | [
"def",
"angle",
"(",
"self",
",",
"center1_x",
",",
"center1_y",
",",
"center2_x",
",",
"center2_y",
")",
":",
"phi_G",
"=",
"np",
".",
"arctan2",
"(",
"center2_y",
"-",
"center1_y",
",",
"center2_x",
"-",
"center1_x",
")",
"return",
"phi_G"
] | compute the rotation angle of the dipole
:return: | [
"compute",
"the",
"rotation",
"angle",
"of",
"the",
"dipole",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/dipole.py#L102-L108 |
sibirrer/lenstronomy | lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py | TimeDelayLikelihood.logL | def logL(self, kwargs_lens, kwargs_ps, kwargs_cosmo):
"""
routine to compute the log likelihood of the time delay distance
:param kwargs_lens: lens model kwargs list
:param kwargs_ps: point source kwargs list
:param kwargs_cosmo: cosmology and other kwargs
:return: log li... | python | def logL(self, kwargs_lens, kwargs_ps, kwargs_cosmo):
"""
routine to compute the log likelihood of the time delay distance
:param kwargs_lens: lens model kwargs list
:param kwargs_ps: point source kwargs list
:param kwargs_cosmo: cosmology and other kwargs
:return: log li... | [
"def",
"logL",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kwargs_cosmo",
")",
":",
"x_pos",
",",
"y_pos",
"=",
"self",
".",
"_pointSource",
".",
"image_position",
"(",
"kwargs_ps",
"=",
"kwargs_ps",
",",
"kwargs_lens",
"=",
"kwargs_lens",
")",
... | routine to compute the log likelihood of the time delay distance
:param kwargs_lens: lens model kwargs list
:param kwargs_ps: point source kwargs list
:param kwargs_cosmo: cosmology and other kwargs
:return: log likelihood of the model given the time delay data | [
"routine",
"to",
"compute",
"the",
"log",
"likelihood",
"of",
"the",
"time",
"delay",
"distance",
":",
"param",
"kwargs_lens",
":",
"lens",
"model",
"kwargs",
"list",
":",
"param",
"kwargs_ps",
":",
"point",
"source",
"kwargs",
"list",
":",
"param",
"kwargs_... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py#L31-L46 |
sibirrer/lenstronomy | lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py | TimeDelayLikelihood._logL_delays | def _logL_delays(self, delays_model, delays_measured, delays_errors):
"""
log likelihood of modeled delays vs measured time delays under considerations of errors
:param delays_model: n delays of the model (not relative delays)
:param delays_measured: relative delays (1-2,1-3,1-4) relati... | python | def _logL_delays(self, delays_model, delays_measured, delays_errors):
"""
log likelihood of modeled delays vs measured time delays under considerations of errors
:param delays_model: n delays of the model (not relative delays)
:param delays_measured: relative delays (1-2,1-3,1-4) relati... | [
"def",
"_logL_delays",
"(",
"self",
",",
"delays_model",
",",
"delays_measured",
",",
"delays_errors",
")",
":",
"delta_t_model",
"=",
"np",
".",
"array",
"(",
"delays_model",
"[",
"1",
":",
"]",
")",
"-",
"delays_model",
"[",
"0",
"]",
"logL",
"=",
"np"... | log likelihood of modeled delays vs measured time delays under considerations of errors
:param delays_model: n delays of the model (not relative delays)
:param delays_measured: relative delays (1-2,1-3,1-4) relative to the first in the list
:param delays_errors: gaussian errors on the measured ... | [
"log",
"likelihood",
"of",
"modeled",
"delays",
"vs",
"measured",
"time",
"delays",
"under",
"considerations",
"of",
"errors"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/Likelihoods/time_delay_likelihood.py#L48-L59 |
sibirrer/lenstronomy | lenstronomy/Data/coord_transforms.py | Coordinates.shift_coordinate_grid | def shift_coordinate_grid(self, x_shift, y_shift, pixel_unit=False):
"""
shifts the coordinate system
:param x_shif: shift in x (or RA)
:param y_shift: shift in y (or DEC)
:param pixel_unit: bool, if True, units of pixels in input, otherwise RA/DEC
:return: updated data c... | python | def shift_coordinate_grid(self, x_shift, y_shift, pixel_unit=False):
"""
shifts the coordinate system
:param x_shif: shift in x (or RA)
:param y_shift: shift in y (or DEC)
:param pixel_unit: bool, if True, units of pixels in input, otherwise RA/DEC
:return: updated data c... | [
"def",
"shift_coordinate_grid",
"(",
"self",
",",
"x_shift",
",",
"y_shift",
",",
"pixel_unit",
"=",
"False",
")",
":",
"if",
"pixel_unit",
"is",
"True",
":",
"ra_shift",
",",
"dec_shift",
"=",
"self",
".",
"map_pix2coord",
"(",
"x_shift",
",",
"y_shift",
... | shifts the coordinate system
:param x_shif: shift in x (or RA)
:param y_shift: shift in y (or DEC)
:param pixel_unit: bool, if True, units of pixels in input, otherwise RA/DEC
:return: updated data class with change in coordinate system | [
"shifts",
"the",
"coordinate",
"system",
":",
"param",
"x_shif",
":",
"shift",
"in",
"x",
"(",
"or",
"RA",
")",
":",
"param",
"y_shift",
":",
"shift",
"in",
"y",
"(",
"or",
"DEC",
")",
":",
"param",
"pixel_unit",
":",
"bool",
"if",
"True",
"units",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Data/coord_transforms.py#L85-L100 |
sibirrer/lenstronomy | lenstronomy/LensModel/Solver/solver4point.py | Solver4Point._extract_array | def _extract_array(self, kwargs_list):
"""
inverse of _update_kwargs
:param kwargs_list:
:return:
"""
if self._solver_type == 'PROFILE_SHEAR':
e1 = kwargs_list[1]['e1']
e2 = kwargs_list[1]['e2']
phi_ext, gamma_ext = param_util.elliptici... | python | def _extract_array(self, kwargs_list):
"""
inverse of _update_kwargs
:param kwargs_list:
:return:
"""
if self._solver_type == 'PROFILE_SHEAR':
e1 = kwargs_list[1]['e1']
e2 = kwargs_list[1]['e2']
phi_ext, gamma_ext = param_util.elliptici... | [
"def",
"_extract_array",
"(",
"self",
",",
"kwargs_list",
")",
":",
"if",
"self",
".",
"_solver_type",
"==",
"'PROFILE_SHEAR'",
":",
"e1",
"=",
"kwargs_list",
"[",
"1",
"]",
"[",
"'e1'",
"]",
"e2",
"=",
"kwargs_list",
"[",
"1",
"]",
"[",
"'e2'",
"]",
... | inverse of _update_kwargs
:param kwargs_list:
:return: | [
"inverse",
"of",
"_update_kwargs",
":",
"param",
"kwargs_list",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Solver/solver4point.py#L141-L174 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/interpol.py | Interpol.derivatives | def derivatives(self, x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None):
"""
returns df/dx and df/dy of the function
"""
#self._check_interp(grid_interp_x, grid_interp_y, f_, f_x, f_y, f_xx, f_yy, f_xy)
n = len(np.atleast_... | python | def derivatives(self, x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None):
"""
returns df/dx and df/dy of the function
"""
#self._check_interp(grid_interp_x, grid_interp_y, f_, f_x, f_y, f_xx, f_yy, f_xy)
n = len(np.atleast_... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"grid_interp_x",
"=",
"None",
",",
"grid_interp_y",
"=",
"None",
",",
"f_",
"=",
"None",
",",
"f_x",
"=",
"None",
",",
"f_y",
"=",
"None",
",",
"f_xx",
"=",
"None",
",",
"f_yy",
"=",
"No... | returns df/dx and df/dy of the function | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/interpol.py#L40-L64 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/interpol.py | Interpol.hessian | def hessian(self, x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
#self._check_interp(grid_interp_x, grid_interp_y, f_, f_x, f_y, f_xx, f_yy, f_xy)
... | python | def hessian(self, x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
#self._check_interp(grid_interp_x, grid_interp_y, f_, f_x, f_y, f_xx, f_yy, f_xy)
... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"grid_interp_x",
"=",
"None",
",",
"grid_interp_y",
"=",
"None",
",",
"f_",
"=",
"None",
",",
"f_x",
"=",
"None",
",",
"f_y",
"=",
"None",
",",
"f_xx",
"=",
"None",
",",
"f_yy",
"=",
"None",... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | [
"returns",
"Hessian",
"matrix",
"of",
"function",
"d^2f",
"/",
"dx^2",
"d^f",
"/",
"dy^2",
"d^2",
"/",
"dxdy"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/interpol.py#L66-L94 |
sibirrer/lenstronomy | lenstronomy/Plots/output_plots.py | lens_model_plot | def lens_model_plot(ax, lensModel, kwargs_lens, numPix=500, deltaPix=0.01, sourcePos_x=0, sourcePos_y=0,
point_source=False, with_caustics=False):
"""
plots a lens model (convergence) and the critical curves and caustics
:param ax:
:param kwargs_lens:
:param numPix:
:param d... | python | def lens_model_plot(ax, lensModel, kwargs_lens, numPix=500, deltaPix=0.01, sourcePos_x=0, sourcePos_y=0,
point_source=False, with_caustics=False):
"""
plots a lens model (convergence) and the critical curves and caustics
:param ax:
:param kwargs_lens:
:param numPix:
:param d... | [
"def",
"lens_model_plot",
"(",
"ax",
",",
"lensModel",
",",
"kwargs_lens",
",",
"numPix",
"=",
"500",
",",
"deltaPix",
"=",
"0.01",
",",
"sourcePos_x",
"=",
"0",
",",
"sourcePos_y",
"=",
"0",
",",
"point_source",
"=",
"False",
",",
"with_caustics",
"=",
... | plots a lens model (convergence) and the critical curves and caustics
:param ax:
:param kwargs_lens:
:param numPix:
:param deltaPix:
:return: | [
"plots",
"a",
"lens",
"model",
"(",
"convergence",
")",
"and",
"the",
"critical",
"curves",
"and",
"caustics"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Plots/output_plots.py#L71-L122 |
sibirrer/lenstronomy | lenstronomy/Plots/output_plots.py | plot_mcmc_behaviour | def plot_mcmc_behaviour(ax, samples_mcmc, param_mcmc, dist_mcmc, num_average=100):
"""
plots the MCMC behaviour and looks for convergence of the chain
:param samples_mcmc: parameters sampled 2d numpy array
:param param_mcmc: list of parameters
:param dist_mcmc: log likelihood of the chain
:param... | python | def plot_mcmc_behaviour(ax, samples_mcmc, param_mcmc, dist_mcmc, num_average=100):
"""
plots the MCMC behaviour and looks for convergence of the chain
:param samples_mcmc: parameters sampled 2d numpy array
:param param_mcmc: list of parameters
:param dist_mcmc: log likelihood of the chain
:param... | [
"def",
"plot_mcmc_behaviour",
"(",
"ax",
",",
"samples_mcmc",
",",
"param_mcmc",
",",
"dist_mcmc",
",",
"num_average",
"=",
"100",
")",
":",
"num_samples",
"=",
"len",
"(",
"samples_mcmc",
"[",
":",
",",
"0",
"]",
")",
"num_average",
"=",
"int",
"(",
"nu... | plots the MCMC behaviour and looks for convergence of the chain
:param samples_mcmc: parameters sampled 2d numpy array
:param param_mcmc: list of parameters
:param dist_mcmc: log likelihood of the chain
:param num_average: number of samples to average (should coincide with the number of samples in the e... | [
"plots",
"the",
"MCMC",
"behaviour",
"and",
"looks",
"for",
"convergence",
"of",
"the",
"chain",
":",
"param",
"samples_mcmc",
":",
"parameters",
"sampled",
"2d",
"numpy",
"array",
":",
"param",
"param_mcmc",
":",
"list",
"of",
"parameters",
":",
"param",
"d... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Plots/output_plots.py#L724-L747 |
sibirrer/lenstronomy | lenstronomy/Plots/output_plots.py | LensModelPlot.plot_main | def plot_main(self, with_caustics=False, image_names=False):
"""
print the main plots together in a joint frame
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.data_plot(ax=axes[0, 0])
self.model_plot(ax=axes[0, 1], image_names=True)
self... | python | def plot_main(self, with_caustics=False, image_names=False):
"""
print the main plots together in a joint frame
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.data_plot(ax=axes[0, 0])
self.model_plot(ax=axes[0, 1], image_names=True)
self... | [
"def",
"plot_main",
"(",
"self",
",",
"with_caustics",
"=",
"False",
",",
"image_names",
"=",
"False",
")",
":",
"f",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"2",
",",
"3",
",",
"figsize",
"=",
"(",
"16",
",",
"8",
")",
")",
"self",
".",
... | print the main plots together in a joint frame
:return: | [
"print",
"the",
"main",
"plots",
"together",
"in",
"a",
"joint",
"frame"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Plots/output_plots.py#L639-L655 |
sibirrer/lenstronomy | lenstronomy/Plots/output_plots.py | LensModelPlot.plot_separate | def plot_separate(self):
"""
plot the different model components separately
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.decomposition_plot(ax=axes[0, 0], text='Lens light', lens_light_add=True, unconvolved=True)
self.decomposition_plot(ax=axe... | python | def plot_separate(self):
"""
plot the different model components separately
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.decomposition_plot(ax=axes[0, 0], text='Lens light', lens_light_add=True, unconvolved=True)
self.decomposition_plot(ax=axe... | [
"def",
"plot_separate",
"(",
"self",
")",
":",
"f",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"2",
",",
"3",
",",
"figsize",
"=",
"(",
"16",
",",
"8",
")",
")",
"self",
".",
"decomposition_plot",
"(",
"ax",
"=",
"axes",
"[",
"0",
",",
"0",... | plot the different model components separately
:return: | [
"plot",
"the",
"different",
"model",
"components",
"separately"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Plots/output_plots.py#L657-L675 |
sibirrer/lenstronomy | lenstronomy/Plots/output_plots.py | LensModelPlot.plot_subtract_from_data_all | def plot_subtract_from_data_all(self):
"""
subtract model components from data
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.subtract_from_data_plot(ax=axes[0, 0], text='Data')
self.subtract_from_data_plot(ax=axes[0, 1], text='Data - Point Sour... | python | def plot_subtract_from_data_all(self):
"""
subtract model components from data
:return:
"""
f, axes = plt.subplots(2, 3, figsize=(16, 8))
self.subtract_from_data_plot(ax=axes[0, 0], text='Data')
self.subtract_from_data_plot(ax=axes[0, 1], text='Data - Point Sour... | [
"def",
"plot_subtract_from_data_all",
"(",
"self",
")",
":",
"f",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"2",
",",
"3",
",",
"figsize",
"=",
"(",
"16",
",",
"8",
")",
")",
"self",
".",
"subtract_from_data_plot",
"(",
"ax",
"=",
"axes",
"[",
... | subtract model components from data
:return: | [
"subtract",
"model",
"components",
"from",
"data"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Plots/output_plots.py#L677-L695 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets.derivatives | def derivatives(self, x, y, coeffs, beta, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
shapelets = self._createShapelet(coeffs)
r, phi = param_util.cart2polar(x, y, center=np.array([center_x, center_y]))
alpha1_shapelets, alpha2_shapelets = sel... | python | def derivatives(self, x, y, coeffs, beta, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
shapelets = self._createShapelet(coeffs)
r, phi = param_util.cart2polar(x, y, center=np.array([center_x, center_y]))
alpha1_shapelets, alpha2_shapelets = sel... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"coeffs",
",",
"beta",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"shapelets",
"=",
"self",
".",
"_createShapelet",
"(",
"coeffs",
")",
"r",
",",
"phi",
"=",
"param_ut... | returns df/dx and df/dy of the function | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L33-L42 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets.hessian | def hessian(self, x, y, coeffs, beta, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
shapelets = self._createShapelet(coeffs)
r, phi = param_util.cart2polar(x, y, center=np.array([center_x, center_y]))
kappa_shapelets=sel... | python | def hessian(self, x, y, coeffs, beta, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
shapelets = self._createShapelet(coeffs)
r, phi = param_util.cart2polar(x, y, center=np.array([center_x, center_y]))
kappa_shapelets=sel... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"coeffs",
",",
"beta",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"shapelets",
"=",
"self",
".",
"_createShapelet",
"(",
"coeffs",
")",
"r",
",",
"phi",
"=",
"param_util",... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | [
"returns",
"Hessian",
"matrix",
"of",
"function",
"d^2f",
"/",
"dx^2",
"d^f",
"/",
"dy^2",
"d^2",
"/",
"dxdy"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L44-L58 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets._createShapelet | def _createShapelet(self,coeff):
"""
returns a shapelet array out of the coefficients *a, up to order l
:param num_l: order of shapelets
:type num_l: int.
:param coeff: shapelet coefficients
:type coeff: floats
:returns: complex array
:raises: AttributeE... | python | def _createShapelet(self,coeff):
"""
returns a shapelet array out of the coefficients *a, up to order l
:param num_l: order of shapelets
:type num_l: int.
:param coeff: shapelet coefficients
:type coeff: floats
:returns: complex array
:raises: AttributeE... | [
"def",
"_createShapelet",
"(",
"self",
",",
"coeff",
")",
":",
"n_coeffs",
"=",
"len",
"(",
"coeff",
")",
"num_l",
"=",
"self",
".",
"_get_num_l",
"(",
"n_coeffs",
")",
"shapelets",
"=",
"np",
".",
"zeros",
"(",
"(",
"num_l",
"+",
"1",
",",
"num_l",
... | returns a shapelet array out of the coefficients *a, up to order l
:param num_l: order of shapelets
:type num_l: int.
:param coeff: shapelet coefficients
:type coeff: floats
:returns: complex array
:raises: AttributeError, KeyError | [
"returns",
"a",
"shapelet",
"array",
"out",
"of",
"the",
"coefficients",
"*",
"a",
"up",
"to",
"order",
"l"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L60-L94 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets._shapeletOutput | def _shapeletOutput(self, r, phi, beta, shapelets):
"""
returns the the numerical values of a set of shapelets at polar coordinates
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:param coordPolar: set of coordinates in polar units
:... | python | def _shapeletOutput(self, r, phi, beta, shapelets):
"""
returns the the numerical values of a set of shapelets at polar coordinates
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:param coordPolar: set of coordinates in polar units
:... | [
"def",
"_shapeletOutput",
"(",
"self",
",",
"r",
",",
"phi",
",",
"beta",
",",
"shapelets",
")",
":",
"if",
"type",
"(",
"r",
")",
"==",
"float",
"or",
"type",
"(",
"r",
")",
"==",
"int",
"or",
"type",
"(",
"r",
")",
"==",
"type",
"(",
"np",
... | returns the the numerical values of a set of shapelets at polar coordinates
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:param coordPolar: set of coordinates in polar units
:type coordPolar: array of size (n,2)
:returns: array of same si... | [
"returns",
"the",
"the",
"numerical",
"values",
"of",
"a",
"set",
"of",
"shapelets",
"at",
"polar",
"coordinates",
":",
"param",
"shapelets",
":",
"set",
"of",
"shapelets",
"[",
"l",
"=",
"r",
"=",
"a_lr",
"=",
"]",
":",
"type",
"shapelets",
":",
"arra... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L96-L114 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets._chi_lr | def _chi_lr(self,r, phi, nl,nr,beta):
"""
computes the generalized polar basis function in the convention of Massey&Refregier eqn 8
:param nl: left basis
:type nl: int
:param nr: right basis
:type nr: int
:param beta: beta --the characteristic scale typically cho... | python | def _chi_lr(self,r, phi, nl,nr,beta):
"""
computes the generalized polar basis function in the convention of Massey&Refregier eqn 8
:param nl: left basis
:type nl: int
:param nr: right basis
:type nr: int
:param beta: beta --the characteristic scale typically cho... | [
"def",
"_chi_lr",
"(",
"self",
",",
"r",
",",
"phi",
",",
"nl",
",",
"nr",
",",
"beta",
")",
":",
"m",
"=",
"int",
"(",
"(",
"nr",
"-",
"nl",
")",
".",
"real",
")",
"n",
"=",
"int",
"(",
"(",
"nr",
"+",
"nl",
")",
".",
"real",
")",
"p",... | computes the generalized polar basis function in the convention of Massey&Refregier eqn 8
:param nl: left basis
:type nl: int
:param nr: right basis
:type nr: int
:param beta: beta --the characteristic scale typically choosen to be close to the size of the object.
:type ... | [
"computes",
"the",
"generalized",
"polar",
"basis",
"function",
"in",
"the",
"convention",
"of",
"Massey&Refregier",
"eqn",
"8"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L116-L142 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets._kappaShapelets | def _kappaShapelets(self, shapelets, beta):
"""
calculates the convergence kappa given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of kappa shapelets.
:raises: A... | python | def _kappaShapelets(self, shapelets, beta):
"""
calculates the convergence kappa given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of kappa shapelets.
:raises: A... | [
"def",
"_kappaShapelets",
"(",
"self",
",",
"shapelets",
",",
"beta",
")",
":",
"output",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"shapelets",
")",
"+",
"1",
",",
"len",
"(",
"shapelets",
")",
"+",
"1",
")",
",",
"'complex'",
")",
"for",
"... | calculates the convergence kappa given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of kappa shapelets.
:raises: AttributeError, KeyError | [
"calculates",
"the",
"convergence",
"kappa",
"given",
"lensing",
"potential",
"shapelet",
"coefficients",
"(",
"laplacian",
"/",
"2",
")",
":",
"param",
"shapelets",
":",
"set",
"of",
"shapelets",
"[",
"l",
"=",
"r",
"=",
"a_lr",
"=",
"]",
":",
"type",
"... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L144-L163 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/shapelet_pot_polar.py | PolarShapelets._alphaShapelets | def _alphaShapelets(self,shapelets, beta):
"""
calculates the deflection angles given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of alpha shapelets.
:raises: At... | python | def _alphaShapelets(self,shapelets, beta):
"""
calculates the deflection angles given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of alpha shapelets.
:raises: At... | [
"def",
"_alphaShapelets",
"(",
"self",
",",
"shapelets",
",",
"beta",
")",
":",
"output_x",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"shapelets",
")",
"+",
"1",
",",
"len",
"(",
"shapelets",
")",
"+",
"1",
")",
",",
"'complex'",
")",
"output_... | calculates the deflection angles given lensing potential shapelet coefficients (laplacian/2)
:param shapelets: set of shapelets [l=,r=,a_lr=]
:type shapelets: array of size (n,3)
:returns: set of alpha shapelets.
:raises: AttributeError, KeyError | [
"calculates",
"the",
"deflection",
"angles",
"given",
"lensing",
"potential",
"shapelet",
"coefficients",
"(",
"laplacian",
"/",
"2",
")",
":",
"param",
"shapelets",
":",
"set",
"of",
"shapelets",
"[",
"l",
"=",
"r",
"=",
"a_lr",
"=",
"]",
":",
"type",
"... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/shapelet_pot_polar.py#L166-L189 |
sibirrer/lenstronomy | lenstronomy/GalKin/cosmo.py | Cosmo.epsilon_crit | def epsilon_crit(self):
"""
returns the critical projected mass density in units of M_sun/Mpc^2 (physical units)
"""
const_SI = const.c**2 / (4*np.pi * const.G) #c^2/(4*pi*G) in units of [kg/m]
conversion = const.Mpc / const.M_sun # converts [kg/m] to [M_sun/Mpc]
pre_co... | python | def epsilon_crit(self):
"""
returns the critical projected mass density in units of M_sun/Mpc^2 (physical units)
"""
const_SI = const.c**2 / (4*np.pi * const.G) #c^2/(4*pi*G) in units of [kg/m]
conversion = const.Mpc / const.M_sun # converts [kg/m] to [M_sun/Mpc]
pre_co... | [
"def",
"epsilon_crit",
"(",
"self",
")",
":",
"const_SI",
"=",
"const",
".",
"c",
"**",
"2",
"/",
"(",
"4",
"*",
"np",
".",
"pi",
"*",
"const",
".",
"G",
")",
"#c^2/(4*pi*G) in units of [kg/m]",
"conversion",
"=",
"const",
".",
"Mpc",
"/",
"const",
"... | returns the critical projected mass density in units of M_sun/Mpc^2 (physical units) | [
"returns",
"the",
"critical",
"projected",
"mass",
"density",
"in",
"units",
"of",
"M_sun",
"/",
"Mpc^2",
"(",
"physical",
"units",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/cosmo.py#L23-L31 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.L | def L(self, x, tau):
"""
Logarithm that appears frequently
:param x: r/Rs
:param tau: t/Rs
:return:
"""
return np.log(x * (tau + np.sqrt(tau ** 2 + x ** 2)) ** -1) | python | def L(self, x, tau):
"""
Logarithm that appears frequently
:param x: r/Rs
:param tau: t/Rs
:return:
"""
return np.log(x * (tau + np.sqrt(tau ** 2 + x ** 2)) ** -1) | [
"def",
"L",
"(",
"self",
",",
"x",
",",
"tau",
")",
":",
"return",
"np",
".",
"log",
"(",
"x",
"*",
"(",
"tau",
"+",
"np",
".",
"sqrt",
"(",
"tau",
"**",
"2",
"+",
"x",
"**",
"2",
")",
")",
"**",
"-",
"1",
")"
] | Logarithm that appears frequently
:param x: r/Rs
:param tau: t/Rs
:return: | [
"Logarithm",
"that",
"appears",
"frequently",
":",
"param",
"x",
":",
"r",
"/",
"Rs",
":",
"param",
"tau",
":",
"t",
"/",
"Rs",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L50-L58 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.F | def F(self, x):
"""
Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return:
"""
if isinstance(x, np.ndarray):
nfwvals = np.ones_like(x)
inds1 = np.where(x < 1)
inds2 = np.where(x > 1)
nfwvals[inds1] = (1 ... | python | def F(self, x):
"""
Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return:
"""
if isinstance(x, np.ndarray):
nfwvals = np.ones_like(x)
inds1 = np.where(x < 1)
inds2 = np.where(x > 1)
nfwvals[inds1] = (1 ... | [
"def",
"F",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
":",
"nfwvals",
"=",
"np",
".",
"ones_like",
"(",
"x",
")",
"inds1",
"=",
"np",
".",
"where",
"(",
"x",
"<",
"1",
")",
"inds2",
"=",
... | Classic NFW function in terms of arctanh and arctan
:param x: r/Rs
:return: | [
"Classic",
"NFW",
"function",
"in",
"terms",
"of",
"arctanh",
"and",
"arctan",
":",
"param",
"x",
":",
"r",
"/",
"Rs",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L60-L80 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.density_2d | def density_2d(self, x, y, Rs, rho0, r_trunc, center_x=0, center_y=0):
"""
projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization... | python | def density_2d(self, x, y, Rs, rho0, r_trunc, center_x=0, center_y=0):
"""
projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization... | [
"def",
"density_2d",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"rho0",
",",
"r_trunc",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"R",
"=",
"np",
".... | projected two dimenstional NFW profile (kappa*Sigma_crit)
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
:param r200: radius of (sub)hal... | [
"projected",
"two",
"dimenstional",
"NFW",
"profile",
"(",
"kappa",
"*",
"Sigma_crit",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L128-L148 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.mass_3d | def mass_3d(self, R, Rs, rho0, r_trunc):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
x = R * Rs ** -1
func = (r_trunc ** 2 * (-2 * x * (1 + r_trunc ** 2) + 4 * (1 + x) * r_trunc * np.arctan(x / r_trunc)... | python | def mass_3d(self, R, Rs, rho0, r_trunc):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
x = R * Rs ** -1
func = (r_trunc ** 2 * (-2 * x * (1 + r_trunc ** 2) + 4 * (1 + x) * r_trunc * np.arctan(x / r_trunc)... | [
"def",
"mass_3d",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_trunc",
")",
":",
"x",
"=",
"R",
"*",
"Rs",
"**",
"-",
"1",
"func",
"=",
"(",
"r_trunc",
"**",
"2",
"*",
"(",
"-",
"2",
"*",
"x",
"*",
"(",
"1",
"+",
"r_trunc",
"**"... | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L150-L168 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.nfwPot | def nfwPot(self, R, Rs, rho0, r_trunc):
"""
lensing potential of NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
... | python | def nfwPot(self, R, Rs, rho0, r_trunc):
"""
lensing potential of NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
... | [
"def",
"nfwPot",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_trunc",
")",
":",
"x",
"=",
"R",
"/",
"Rs",
"tau",
"=",
"float",
"(",
"r_trunc",
")",
"/",
"Rs",
"hx",
"=",
"self",
".",
"_h",
"(",
"x",
",",
"tau",
")",
"return",
"2",... | lensing potential of NFW profile
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
:return: Epsilon(R) projected density at radius R | [
"lensing",
"potential",
"of",
"NFW",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L170-L185 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.nfwAlpha | def nfwAlpha(self, R, Rs, rho0, r_trunc, ax_x, ax_y):
"""
deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (c... | python | def nfwAlpha(self, R, Rs, rho0, r_trunc, ax_x, ax_y):
"""
deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (c... | [
"def",
"nfwAlpha",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_trunc",
",",
"ax_x",
",",
"ax_y",
")",
":",
"if",
"isinstance",
"(",
"R",
",",
"int",
")",
"or",
"isinstance",
"(",
"R",
",",
"float",
")",
":",
"R",
"=",
"max",
"(",
"... | deflection angel of NFW profile along the projection to coordinate axis
:param R: radius of interest
:type R: float/numpy array
:param Rs: scale radius
:type Rs: float
:param rho0: density normalization (characteristic density)
:type rho0: float
:param r200: radi... | [
"deflection",
"angel",
"of",
"NFW",
"profile",
"along",
"the",
"projection",
"to",
"coordinate",
"axis"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L187-L212 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW.mass_2d | def mass_2d(self,R,Rs,rho0,r_trunc):
"""
analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0
"""
x = R / Rs
tau = r_trunc / Rs
gx = self._g(x,tau)
m_2d = 4 * rho0 * Rs * R ** 2 * gx / x ** 2 * np.p... | python | def mass_2d(self,R,Rs,rho0,r_trunc):
"""
analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0
"""
x = R / Rs
tau = r_trunc / Rs
gx = self._g(x,tau)
m_2d = 4 * rho0 * Rs * R ** 2 * gx / x ** 2 * np.p... | [
"def",
"mass_2d",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
",",
"r_trunc",
")",
":",
"x",
"=",
"R",
"/",
"Rs",
"tau",
"=",
"r_trunc",
"/",
"Rs",
"gx",
"=",
"self",
".",
"_g",
"(",
"x",
",",
"tau",
")",
"m_2d",
"=",
"4",
"*",
"rho0",
... | analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0 | [
"analytic",
"solution",
"of",
"the",
"projection",
"integral",
"(",
"convergence",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L248-L262 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW._F | def _F(self, X, tau):
"""
analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0
"""
t2 = tau ** 2
#Fx = self.F(X)
_F = self.F(X)
a = t2*(t2+1)**-2
if isinstance(X, np.ndarray):
#b ... | python | def _F(self, X, tau):
"""
analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0
"""
t2 = tau ** 2
#Fx = self.F(X)
_F = self.F(X)
a = t2*(t2+1)**-2
if isinstance(X, np.ndarray):
#b ... | [
"def",
"_F",
"(",
"self",
",",
"X",
",",
"tau",
")",
":",
"t2",
"=",
"tau",
"**",
"2",
"#Fx = self.F(X)",
"_F",
"=",
"self",
".",
"F",
"(",
"X",
")",
"a",
"=",
"t2",
"*",
"(",
"t2",
"+",
"1",
")",
"**",
"-",
"2",
"if",
"isinstance",
"(",
... | analytic solution of the projection integral
(convergence)
:param x: R/Rs
:type x: float >0 | [
"analytic",
"solution",
"of",
"the",
"projection",
"integral",
"(",
"convergence",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L264-L296 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW._g | def _g(self, x, tau):
"""
analytic solution of integral for NFW profile to compute deflection angel and gamma
:param x: R/Rs
:type x: float >0
"""
return tau ** 2 * (tau ** 2 + 1) ** -2 * (
(tau ** 2 + 1 + 2 * (x ** 2 - 1)) * self.F(x) + tau * np.pi + (ta... | python | def _g(self, x, tau):
"""
analytic solution of integral for NFW profile to compute deflection angel and gamma
:param x: R/Rs
:type x: float >0
"""
return tau ** 2 * (tau ** 2 + 1) ** -2 * (
(tau ** 2 + 1 + 2 * (x ** 2 - 1)) * self.F(x) + tau * np.pi + (ta... | [
"def",
"_g",
"(",
"self",
",",
"x",
",",
"tau",
")",
":",
"return",
"tau",
"**",
"2",
"*",
"(",
"tau",
"**",
"2",
"+",
"1",
")",
"**",
"-",
"2",
"*",
"(",
"(",
"tau",
"**",
"2",
"+",
"1",
"+",
"2",
"*",
"(",
"x",
"**",
"2",
"-",
"1",
... | analytic solution of integral for NFW profile to compute deflection angel and gamma
:param x: R/Rs
:type x: float >0 | [
"analytic",
"solution",
"of",
"integral",
"for",
"NFW",
"profile",
"to",
"compute",
"deflection",
"angel",
"and",
"gamma"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L298-L307 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/tnfw.py | TNFW._h | def _h(self, X, tau):
"""
a horrible expression for the integral to compute potential
:param x: R/Rs
:param tau: t/Rs
:type x: float >0
"""
def cos_func(y):
if isinstance(y, float) or isinstance(y, int):
if y > 1:
... | python | def _h(self, X, tau):
"""
a horrible expression for the integral to compute potential
:param x: R/Rs
:param tau: t/Rs
:type x: float >0
"""
def cos_func(y):
if isinstance(y, float) or isinstance(y, int):
if y > 1:
... | [
"def",
"_h",
"(",
"self",
",",
"X",
",",
"tau",
")",
":",
"def",
"cos_func",
"(",
"y",
")",
":",
"if",
"isinstance",
"(",
"y",
",",
"float",
")",
"or",
"isinstance",
"(",
"y",
",",
"int",
")",
":",
"if",
"y",
">",
"1",
":",
"return",
"np",
... | a horrible expression for the integral to compute potential
:param x: R/Rs
:param tau: t/Rs
:type x: float >0 | [
"a",
"horrible",
"expression",
"for",
"the",
"integral",
"to",
"compute",
"potential"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/tnfw.py#L309-L396 |
sibirrer/lenstronomy | lenstronomy/Util/param_util.py | cart2polar | def cart2polar(x, y, center=np.array([0, 0])):
"""
transforms cartesian coords [x,y] into polar coords [r,phi] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of... | python | def cart2polar(x, y, center=np.array([0, 0])):
"""
transforms cartesian coords [x,y] into polar coords [r,phi] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of... | [
"def",
"cart2polar",
"(",
"x",
",",
"y",
",",
"center",
"=",
"np",
".",
"array",
"(",
"[",
"0",
",",
"0",
"]",
")",
")",
":",
"coordShift_x",
"=",
"x",
"-",
"center",
"[",
"0",
"]",
"coordShift_y",
"=",
"y",
"-",
"center",
"[",
"1",
"]",
"r",... | transforms cartesian coords [x,y] into polar coords [r,phi] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of same size with coords [r,phi]
:raises: AttributeError,... | [
"transforms",
"cartesian",
"coords",
"[",
"x",
"y",
"]",
"into",
"polar",
"coords",
"[",
"r",
"phi",
"]",
"in",
"the",
"frame",
"of",
"the",
"lense",
"center"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L4-L19 |
sibirrer/lenstronomy | lenstronomy/Util/param_util.py | polar2cart | def polar2cart(r, phi, center):
"""
transforms polar coords [r,phi] into cartesian coords [x,y] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of same size with... | python | def polar2cart(r, phi, center):
"""
transforms polar coords [r,phi] into cartesian coords [x,y] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of same size with... | [
"def",
"polar2cart",
"(",
"r",
",",
"phi",
",",
"center",
")",
":",
"x",
"=",
"r",
"*",
"np",
".",
"cos",
"(",
"phi",
")",
"y",
"=",
"r",
"*",
"np",
".",
"sin",
"(",
"phi",
")",
"return",
"x",
"-",
"center",
"[",
"0",
"]",
",",
"y",
"-",
... | transforms polar coords [r,phi] into cartesian coords [x,y] in the frame of the lense center
:param coord: set of coordinates
:type coord: array of size (n,2)
:param center: rotation point
:type center: array of size (2)
:returns: array of same size with coords [x,y]
:raises: AttributeError, K... | [
"transforms",
"polar",
"coords",
"[",
"r",
"phi",
"]",
"into",
"cartesian",
"coords",
"[",
"x",
"y",
"]",
"in",
"the",
"frame",
"of",
"the",
"lense",
"center"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L22-L35 |
sibirrer/lenstronomy | lenstronomy/Util/param_util.py | ellipticity2phi_gamma | def ellipticity2phi_gamma(e1, e2):
"""
:param e1: ellipticity component
:param e2: ellipticity component
:return: angle and abs value of ellipticity
"""
phi = np.arctan2(e2, e1)/2
gamma = np.sqrt(e1**2+e2**2)
return phi, gamma | python | def ellipticity2phi_gamma(e1, e2):
"""
:param e1: ellipticity component
:param e2: ellipticity component
:return: angle and abs value of ellipticity
"""
phi = np.arctan2(e2, e1)/2
gamma = np.sqrt(e1**2+e2**2)
return phi, gamma | [
"def",
"ellipticity2phi_gamma",
"(",
"e1",
",",
"e2",
")",
":",
"phi",
"=",
"np",
".",
"arctan2",
"(",
"e2",
",",
"e1",
")",
"/",
"2",
"gamma",
"=",
"np",
".",
"sqrt",
"(",
"e1",
"**",
"2",
"+",
"e2",
"**",
"2",
")",
"return",
"phi",
",",
"ga... | :param e1: ellipticity component
:param e2: ellipticity component
:return: angle and abs value of ellipticity | [
":",
"param",
"e1",
":",
"ellipticity",
"component",
":",
"param",
"e2",
":",
"ellipticity",
"component",
":",
"return",
":",
"angle",
"and",
"abs",
"value",
"of",
"ellipticity"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L50-L58 |
sibirrer/lenstronomy | lenstronomy/Util/param_util.py | transform_e1e2 | def transform_e1e2(x, y, e1, e2, center_x=0, center_y=0):
"""
maps the coordinates x, y with eccentricities e1 e2 into a new elliptical coordiante system
:param x:
:param y:
:param e1:
:param e2:
:param center_x:
:param center_y:
:return:
"""
x_shift = x - center_x
y_shi... | python | def transform_e1e2(x, y, e1, e2, center_x=0, center_y=0):
"""
maps the coordinates x, y with eccentricities e1 e2 into a new elliptical coordiante system
:param x:
:param y:
:param e1:
:param e2:
:param center_x:
:param center_y:
:return:
"""
x_shift = x - center_x
y_shi... | [
"def",
"transform_e1e2",
"(",
"x",
",",
"y",
",",
"e1",
",",
"e2",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_shift",
"=",
"x",
"-",
"center_x",
"y_shift",
"=",
"y",
"-",
"center_y",
"x_",
"=",
"(",
"1",
"-",
"e1",
")",
... | maps the coordinates x, y with eccentricities e1 e2 into a new elliptical coordiante system
:param x:
:param y:
:param e1:
:param e2:
:param center_x:
:param center_y:
:return: | [
"maps",
"the",
"coordinates",
"x",
"y",
"with",
"eccentricities",
"e1",
"e2",
"into",
"a",
"new",
"elliptical",
"coordiante",
"system"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L73-L90 |
sibirrer/lenstronomy | lenstronomy/Util/param_util.py | ellipticity2phi_q | def ellipticity2phi_q(e1, e2):
"""
:param e1:
:param e2:
:return:
"""
phi = np.arctan2(e2, e1)/2
c = np.sqrt(e1**2+e2**2)
if c > 0.999:
c = 0.999
q = (1-c)/(1+c)
return phi, q | python | def ellipticity2phi_q(e1, e2):
"""
:param e1:
:param e2:
:return:
"""
phi = np.arctan2(e2, e1)/2
c = np.sqrt(e1**2+e2**2)
if c > 0.999:
c = 0.999
q = (1-c)/(1+c)
return phi, q | [
"def",
"ellipticity2phi_q",
"(",
"e1",
",",
"e2",
")",
":",
"phi",
"=",
"np",
".",
"arctan2",
"(",
"e2",
",",
"e1",
")",
"/",
"2",
"c",
"=",
"np",
".",
"sqrt",
"(",
"e1",
"**",
"2",
"+",
"e2",
"**",
"2",
")",
"if",
"c",
">",
"0.999",
":",
... | :param e1:
:param e2:
:return: | [
":",
"param",
"e1",
":",
":",
"param",
"e2",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/param_util.py#L93-L104 |
sibirrer/lenstronomy | lenstronomy/Analysis/lens_properties.py | LensProp.time_delays | def time_delays(self, kwargs_lens, kwargs_ps, kappa_ext=0):
"""
predicts the time delays of the image positions
:param kwargs_lens: lens model parameters
:param kwargs_ps: point source parameters
:param kappa_ext: external convergence (optional)
:return: time delays at i... | python | def time_delays(self, kwargs_lens, kwargs_ps, kappa_ext=0):
"""
predicts the time delays of the image positions
:param kwargs_lens: lens model parameters
:param kwargs_ps: point source parameters
:param kappa_ext: external convergence (optional)
:return: time delays at i... | [
"def",
"time_delays",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kappa_ext",
"=",
"0",
")",
":",
"fermat_pot",
"=",
"self",
".",
"lens_analysis",
".",
"fermat_potential",
"(",
"kwargs_lens",
",",
"kwargs_ps",
")",
"time_delay",
"=",
"self",
"."... | predicts the time delays of the image positions
:param kwargs_lens: lens model parameters
:param kwargs_ps: point source parameters
:param kappa_ext: external convergence (optional)
:return: time delays at image positions for the fixed cosmology | [
"predicts",
"the",
"time",
"delays",
"of",
"the",
"image",
"positions"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Analysis/lens_properties.py#L39-L50 |
sibirrer/lenstronomy | lenstronomy/Analysis/lens_properties.py | LensProp.velocity_dispersion | def velocity_dispersion(self, kwargs_lens, kwargs_lens_light, lens_light_model_bool_list=None, aniso_param=1,
r_eff=None, R_slit=0.81, dR_slit=0.1, psf_fwhm=0.7, num_evaluate=1000):
"""
computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit an... | python | def velocity_dispersion(self, kwargs_lens, kwargs_lens_light, lens_light_model_bool_list=None, aniso_param=1,
r_eff=None, R_slit=0.81, dR_slit=0.1, psf_fwhm=0.7, num_evaluate=1000):
"""
computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit an... | [
"def",
"velocity_dispersion",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_lens_light",
",",
"lens_light_model_bool_list",
"=",
"None",
",",
"aniso_param",
"=",
"1",
",",
"r_eff",
"=",
"None",
",",
"R_slit",
"=",
"0.81",
",",
"dR_slit",
"=",
"0.1",
",",
"ps... | computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit and seeing psf_fwhm.
The assumptions are a Hernquist light profile and the spherical power-law lens model at the first position.
Further information can be found in the AnalyticKinematics() class.
:param kw... | [
"computes",
"the",
"LOS",
"velocity",
"dispersion",
"of",
"the",
"lens",
"within",
"a",
"slit",
"of",
"size",
"R_slit",
"x",
"dR_slit",
"and",
"seeing",
"psf_fwhm",
".",
"The",
"assumptions",
"are",
"a",
"Hernquist",
"light",
"profile",
"and",
"the",
"spheri... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Analysis/lens_properties.py#L52-L80 |
sibirrer/lenstronomy | lenstronomy/Analysis/lens_properties.py | LensProp.velocity_dispersion_numerical | def velocity_dispersion_numerical(self, kwargs_lens, kwargs_lens_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm,
aperture_type, anisotropy_model, r_eff=None, kwargs_numerics={}, MGE_light=False,
MGE_mass=False, lens_model_kinematics_bool=N... | python | def velocity_dispersion_numerical(self, kwargs_lens, kwargs_lens_light, kwargs_anisotropy, kwargs_aperture, psf_fwhm,
aperture_type, anisotropy_model, r_eff=None, kwargs_numerics={}, MGE_light=False,
MGE_mass=False, lens_model_kinematics_bool=N... | [
"def",
"velocity_dispersion_numerical",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_lens_light",
",",
"kwargs_anisotropy",
",",
"kwargs_aperture",
",",
"psf_fwhm",
",",
"aperture_type",
",",
"anisotropy_model",
",",
"r_eff",
"=",
"None",
",",
"kwargs_numerics",
"=",... | Computes the LOS velocity dispersion of the deflector galaxy with arbitrary combinations of light and mass models.
For a detailed description, visit the description of the Galkin() class.
Additionaly to executing the Galkin routine, it has an optional Multi-Gaussian-Expansion decomposition of lens
... | [
"Computes",
"the",
"LOS",
"velocity",
"dispersion",
"of",
"the",
"deflector",
"galaxy",
"with",
"arbitrary",
"combinations",
"of",
"light",
"and",
"mass",
"models",
".",
"For",
"a",
"detailed",
"description",
"visit",
"the",
"description",
"of",
"the",
"Galkin",... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Analysis/lens_properties.py#L82-L172 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa.function | def function(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns Gaussian
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
c = 1. / (2 * sigma_x * sigma_y)
num_int = self._num_integral(r, c... | python | def function(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns Gaussian
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
c = 1. / (2 * sigma_x * sigma_y)
num_int = self._num_integral(r, c... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"sigma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",
".",
"sqrt",
"(",
... | returns Gaussian | [
"returns",
"Gaussian"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L22-L35 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa._num_integral | def _num_integral(self, r, c):
"""
numerical integral (1-e^{-c*x^2})/x dx [0..r]
:param r: radius
:param c: 1/2sigma^2
:return:
"""
out = integrate.quad(lambda x: (1-np.exp(-c*x**2))/x, 0, r)
return out[0] | python | def _num_integral(self, r, c):
"""
numerical integral (1-e^{-c*x^2})/x dx [0..r]
:param r: radius
:param c: 1/2sigma^2
:return:
"""
out = integrate.quad(lambda x: (1-np.exp(-c*x**2))/x, 0, r)
return out[0] | [
"def",
"_num_integral",
"(",
"self",
",",
"r",
",",
"c",
")",
":",
"out",
"=",
"integrate",
".",
"quad",
"(",
"lambda",
"x",
":",
"(",
"1",
"-",
"np",
".",
"exp",
"(",
"-",
"c",
"*",
"x",
"**",
"2",
")",
")",
"/",
"x",
",",
"0",
",",
"r",... | numerical integral (1-e^{-c*x^2})/x dx [0..r]
:param r: radius
:param c: 1/2sigma^2
:return: | [
"numerical",
"integral",
"(",
"1",
"-",
"e^",
"{",
"-",
"c",
"*",
"x^2",
"}",
")",
"/",
"x",
"dx",
"[",
"0",
"..",
"r",
"]",
":",
"param",
"r",
":",
"radius",
":",
"param",
"c",
":",
"1",
"/",
"2sigma^2",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L37-L45 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa.derivatives | def derivatives(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
x_ = x - center_x
y_ = y - center_y
R = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
if isinstance(R, int) or isinstance(R, float):
... | python | def derivatives(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function
"""
x_ = x - center_x
y_ = y - center_y
R = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
if isinstance(R, int) or isinstance(R, float):
... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"sigma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"R",
"=",
"np",
".",
"sqrt",
"(... | returns df/dx and df/dy of the function | [
"returns",
"df",
"/",
"dx",
"and",
"df",
"/",
"dy",
"of",
"the",
"function"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L47-L60 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa.hessian | def hessian(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
if isinstance(r, int) or is... | python | def hessian(self, x, y, amp, sigma, center_x=0, center_y=0):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 + y_**2)
sigma_x, sigma_y = sigma, sigma
if isinstance(r, int) or is... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"sigma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",
".",
"sqrt",
"(",
... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | [
"returns",
"Hessian",
"matrix",
"of",
"function",
"d^2f",
"/",
"dx^2",
"d^f",
"/",
"dy^2",
"d^2",
"/",
"dxdy"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L62-L80 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa.alpha_abs | def alpha_abs(self, R, amp, sigma):
"""
absolute value of the deflection
:param R:
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
sigma_x, sigma_y = sigma, sigma
amp_density = self._amp2d_to_3d(amp, sigma_x, sigma_y)
alpha... | python | def alpha_abs(self, R, amp, sigma):
"""
absolute value of the deflection
:param R:
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
sigma_x, sigma_y = sigma, sigma
amp_density = self._amp2d_to_3d(amp, sigma_x, sigma_y)
alpha... | [
"def",
"alpha_abs",
"(",
"self",
",",
"R",
",",
"amp",
",",
"sigma",
")",
":",
"sigma_x",
",",
"sigma_y",
"=",
"sigma",
",",
"sigma",
"amp_density",
"=",
"self",
".",
"_amp2d_to_3d",
"(",
"amp",
",",
"sigma_x",
",",
"sigma_y",
")",
"alpha",
"=",
"sel... | absolute value of the deflection
:param R:
:param amp:
:param sigma_x:
:param sigma_y:
:return: | [
"absolute",
"value",
"of",
"the",
"deflection",
":",
"param",
"R",
":",
":",
"param",
"amp",
":",
":",
"param",
"sigma_x",
":",
":",
"param",
"sigma_y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L133-L145 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa._amp3d_to_2d | def _amp3d_to_2d(self, amp, sigma_x, sigma_y):
"""
converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
return amp * np.sqrt(np.pi) * np.sqrt(sigma_x * sigma_y * 2) | python | def _amp3d_to_2d(self, amp, sigma_x, sigma_y):
"""
converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
return amp * np.sqrt(np.pi) * np.sqrt(sigma_x * sigma_y * 2) | [
"def",
"_amp3d_to_2d",
"(",
"self",
",",
"amp",
",",
"sigma_x",
",",
"sigma_y",
")",
":",
"return",
"amp",
"*",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
"*",
"np",
".",
"sqrt",
"(",
"sigma_x",
"*",
"sigma_y",
"*",
"2",
")"
] | converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return: | [
"converts",
"3d",
"density",
"into",
"2d",
"density",
"parameter",
":",
"param",
"amp",
":",
":",
"param",
"sigma_x",
":",
":",
"param",
"sigma_y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L188-L196 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/gaussian_kappa.py | GaussianKappa._amp2d_to_3d | def _amp2d_to_3d(self, amp, sigma_x, sigma_y):
"""
converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
return amp / (np.sqrt(np.pi) * np.sqrt(sigma_x * sigma_y * 2)) | python | def _amp2d_to_3d(self, amp, sigma_x, sigma_y):
"""
converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return:
"""
return amp / (np.sqrt(np.pi) * np.sqrt(sigma_x * sigma_y * 2)) | [
"def",
"_amp2d_to_3d",
"(",
"self",
",",
"amp",
",",
"sigma_x",
",",
"sigma_y",
")",
":",
"return",
"amp",
"/",
"(",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
"*",
"np",
".",
"sqrt",
"(",
"sigma_x",
"*",
"sigma_y",
"*",
"2",
")",
")"
] | converts 3d density into 2d density parameter
:param amp:
:param sigma_x:
:param sigma_y:
:return: | [
"converts",
"3d",
"density",
"into",
"2d",
"density",
"parameter",
":",
"param",
"amp",
":",
":",
"param",
"sigma_x",
":",
":",
"param",
"sigma_y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/gaussian_kappa.py#L198-L206 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/moffat.py | Moffat.function | def function(self, x, y, amp, alpha, beta, center_x, center_y):
"""
returns Moffat profile
"""
x_shift = x - center_x
y_shift = y - center_y
return amp * (1. + (x_shift**2+y_shift**2)/alpha**2)**(-beta) | python | def function(self, x, y, amp, alpha, beta, center_x, center_y):
"""
returns Moffat profile
"""
x_shift = x - center_x
y_shift = y - center_y
return amp * (1. + (x_shift**2+y_shift**2)/alpha**2)**(-beta) | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"amp",
",",
"alpha",
",",
"beta",
",",
"center_x",
",",
"center_y",
")",
":",
"x_shift",
"=",
"x",
"-",
"center_x",
"y_shift",
"=",
"y",
"-",
"center_y",
"return",
"amp",
"*",
"(",
"1.",
"+... | returns Moffat profile | [
"returns",
"Moffat",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/moffat.py#L15-L21 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spemd_smooth.py | SPEMD_SMOOTH._parameter_constraints | def _parameter_constraints(self, theta_E, gamma, q, phi_G, s_scale):
"""
sets bounds to parameters due to numerical stability
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:param s_scale:
:return:
"""
if theta_E < 0:
the... | python | def _parameter_constraints(self, theta_E, gamma, q, phi_G, s_scale):
"""
sets bounds to parameters due to numerical stability
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:param s_scale:
:return:
"""
if theta_E < 0:
the... | [
"def",
"_parameter_constraints",
"(",
"self",
",",
"theta_E",
",",
"gamma",
",",
"q",
",",
"phi_G",
",",
"s_scale",
")",
":",
"if",
"theta_E",
"<",
"0",
":",
"theta_E",
"=",
"0",
"if",
"s_scale",
"<",
"0.00000001",
":",
"s_scale",
"=",
"0.00000001",
"i... | sets bounds to parameters due to numerical stability
:param theta_E:
:param gamma:
:param q:
:param phi_G:
:param s_scale:
:return: | [
"sets",
"bounds",
"to",
"parameters",
"due",
"to",
"numerical",
"stability",
":",
"param",
"theta_E",
":",
":",
"param",
"gamma",
":",
":",
"param",
"q",
":",
":",
"param",
"phi_G",
":",
":",
"param",
"s_scale",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spemd_smooth.py#L26-L52 |
sibirrer/lenstronomy | lenstronomy/Util/prob_density.py | compute_lower_upper_errors | def compute_lower_upper_errors(sample, num_sigma=1):
"""
computes the upper and lower sigma from the median value.
This functions gives good error estimates for skewed pdf's
:param sample: 1-D sample
:return: median, lower_sigma, upper_sigma
"""
if num_sigma > 3:
raise ValueError("Nu... | python | def compute_lower_upper_errors(sample, num_sigma=1):
"""
computes the upper and lower sigma from the median value.
This functions gives good error estimates for skewed pdf's
:param sample: 1-D sample
:return: median, lower_sigma, upper_sigma
"""
if num_sigma > 3:
raise ValueError("Nu... | [
"def",
"compute_lower_upper_errors",
"(",
"sample",
",",
"num_sigma",
"=",
"1",
")",
":",
"if",
"num_sigma",
">",
"3",
":",
"raise",
"ValueError",
"(",
"\"Number of sigma-constraints restircted to three. %s not valid\"",
"%",
"num_sigma",
")",
"num",
"=",
"len",
"("... | computes the upper and lower sigma from the median value.
This functions gives good error estimates for skewed pdf's
:param sample: 1-D sample
:return: median, lower_sigma, upper_sigma | [
"computes",
"the",
"upper",
"and",
"lower",
"sigma",
"from",
"the",
"median",
"value",
".",
"This",
"functions",
"gives",
"good",
"error",
"estimates",
"for",
"skewed",
"pdf",
"s",
":",
"param",
"sample",
":",
"1",
"-",
"D",
"sample",
":",
"return",
":",... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/prob_density.py#L137-L169 |
sibirrer/lenstronomy | lenstronomy/Util/prob_density.py | SkewGaussian.pdf | def pdf(self, x, e=0., w=1., a=0.):
"""
probability density function
see: https://en.wikipedia.org/wiki/Skew_normal_distribution
:param x: input value
:param e:
:param w:
:param a:
:return:
"""
t = (x-e) / w
return 2. / w * stats.no... | python | def pdf(self, x, e=0., w=1., a=0.):
"""
probability density function
see: https://en.wikipedia.org/wiki/Skew_normal_distribution
:param x: input value
:param e:
:param w:
:param a:
:return:
"""
t = (x-e) / w
return 2. / w * stats.no... | [
"def",
"pdf",
"(",
"self",
",",
"x",
",",
"e",
"=",
"0.",
",",
"w",
"=",
"1.",
",",
"a",
"=",
"0.",
")",
":",
"t",
"=",
"(",
"x",
"-",
"e",
")",
"/",
"w",
"return",
"2.",
"/",
"w",
"*",
"stats",
".",
"norm",
".",
"pdf",
"(",
"t",
")",... | probability density function
see: https://en.wikipedia.org/wiki/Skew_normal_distribution
:param x: input value
:param e:
:param w:
:param a:
:return: | [
"probability",
"density",
"function",
"see",
":",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Skew_normal_distribution",
":",
"param",
"x",
":",
"input",
"value",
":",
"param",
"e",
":",
":",
"param",
"w",
":",
":",
"para... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/prob_density.py#L12-L23 |
sibirrer/lenstronomy | lenstronomy/Util/prob_density.py | SkewGaussian.pdf_new | def pdf_new(self, x, mu, sigma, skw):
"""
function with different parameterisation
:param x:
:param mu: mean
:param sigma: sigma
:param skw: skewness
:return:
"""
if skw > 1 or skw < -1:
print("skewness %s out of range" % skw)
... | python | def pdf_new(self, x, mu, sigma, skw):
"""
function with different parameterisation
:param x:
:param mu: mean
:param sigma: sigma
:param skw: skewness
:return:
"""
if skw > 1 or skw < -1:
print("skewness %s out of range" % skw)
... | [
"def",
"pdf_new",
"(",
"self",
",",
"x",
",",
"mu",
",",
"sigma",
",",
"skw",
")",
":",
"if",
"skw",
">",
"1",
"or",
"skw",
"<",
"-",
"1",
":",
"print",
"(",
"\"skewness %s out of range\"",
"%",
"skw",
")",
"skw",
"=",
"1.",
"e",
",",
"w",
",",... | function with different parameterisation
:param x:
:param mu: mean
:param sigma: sigma
:param skw: skewness
:return: | [
"function",
"with",
"different",
"parameterisation",
":",
"param",
"x",
":",
":",
"param",
"mu",
":",
"mean",
":",
"param",
"sigma",
":",
"sigma",
":",
"param",
"skw",
":",
"skewness",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/prob_density.py#L25-L39 |
sibirrer/lenstronomy | lenstronomy/Util/prob_density.py | SkewGaussian._w_sigma_delta | def _w_sigma_delta(self, sigma, delta):
"""
invert variance
:param sigma:
:param delta:
:return: w parameter
"""
sigma2=sigma**2
w2 = sigma2/(1-2*delta**2/np.pi)
w = np.sqrt(w2)
return w | python | def _w_sigma_delta(self, sigma, delta):
"""
invert variance
:param sigma:
:param delta:
:return: w parameter
"""
sigma2=sigma**2
w2 = sigma2/(1-2*delta**2/np.pi)
w = np.sqrt(w2)
return w | [
"def",
"_w_sigma_delta",
"(",
"self",
",",
"sigma",
",",
"delta",
")",
":",
"sigma2",
"=",
"sigma",
"**",
"2",
"w2",
"=",
"sigma2",
"/",
"(",
"1",
"-",
"2",
"*",
"delta",
"**",
"2",
"/",
"np",
".",
"pi",
")",
"w",
"=",
"np",
".",
"sqrt",
"(",... | invert variance
:param sigma:
:param delta:
:return: w parameter | [
"invert",
"variance",
":",
"param",
"sigma",
":",
":",
"param",
"delta",
":",
":",
"return",
":",
"w",
"parameter"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/prob_density.py#L59-L69 |
sibirrer/lenstronomy | lenstronomy/Util/prob_density.py | SkewGaussian.map_mu_sigma_skw | def map_mu_sigma_skw(self, mu, sigma, skw):
"""
map to parameters e, w, a
:param mu: mean
:param sigma: standard deviation
:param skw: skewness
:return: e, w, a
"""
delta = self._delta_skw(skw)
a = self._alpha_delta(delta)
w = self._w_sigma... | python | def map_mu_sigma_skw(self, mu, sigma, skw):
"""
map to parameters e, w, a
:param mu: mean
:param sigma: standard deviation
:param skw: skewness
:return: e, w, a
"""
delta = self._delta_skw(skw)
a = self._alpha_delta(delta)
w = self._w_sigma... | [
"def",
"map_mu_sigma_skw",
"(",
"self",
",",
"mu",
",",
"sigma",
",",
"skw",
")",
":",
"delta",
"=",
"self",
".",
"_delta_skw",
"(",
"skw",
")",
"a",
"=",
"self",
".",
"_alpha_delta",
"(",
"delta",
")",
"w",
"=",
"self",
".",
"_w_sigma_delta",
"(",
... | map to parameters e, w, a
:param mu: mean
:param sigma: standard deviation
:param skw: skewness
:return: e, w, a | [
"map",
"to",
"parameters",
"e",
"w",
"a",
":",
"param",
"mu",
":",
"mean",
":",
"param",
"sigma",
":",
"standard",
"deviation",
":",
"param",
"skw",
":",
"skewness",
":",
"return",
":",
"e",
"w",
"a"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/prob_density.py#L82-L94 |
sibirrer/lenstronomy | lenstronomy/Sampling/sampler.py | Sampler.pso | def pso(self, n_particles, n_iterations, lower_start=None, upper_start=None, threadCount=1, init_pos=None,
mpi=False, print_key='PSO'):
"""
returns the best fit for the lense model on catalogue basis with particle swarm optimizer
"""
if lower_start is None or upper_start is N... | python | def pso(self, n_particles, n_iterations, lower_start=None, upper_start=None, threadCount=1, init_pos=None,
mpi=False, print_key='PSO'):
"""
returns the best fit for the lense model on catalogue basis with particle swarm optimizer
"""
if lower_start is None or upper_start is N... | [
"def",
"pso",
"(",
"self",
",",
"n_particles",
",",
"n_iterations",
",",
"lower_start",
"=",
"None",
",",
"upper_start",
"=",
"None",
",",
"threadCount",
"=",
"1",
",",
"init_pos",
"=",
"None",
",",
"mpi",
"=",
"False",
",",
"print_key",
"=",
"'PSO'",
... | returns the best fit for the lense model on catalogue basis with particle swarm optimizer | [
"returns",
"the",
"best",
"fit",
"for",
"the",
"lense",
"model",
"on",
"catalogue",
"basis",
"with",
"particle",
"swarm",
"optimizer"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/sampler.py#L37-L96 |
sibirrer/lenstronomy | lenstronomy/Sampling/sampler.py | Sampler.mcmc_CH | def mcmc_CH(self, walkerRatio, n_run, n_burn, mean_start, sigma_start, threadCount=1, init_pos=None, mpi=False):
"""
runs mcmc on the parameter space given parameter bounds with CosmoHammerSampler
returns the chain
"""
lowerLimit, upperLimit = self.lower_limit, self.upper_limit
... | python | def mcmc_CH(self, walkerRatio, n_run, n_burn, mean_start, sigma_start, threadCount=1, init_pos=None, mpi=False):
"""
runs mcmc on the parameter space given parameter bounds with CosmoHammerSampler
returns the chain
"""
lowerLimit, upperLimit = self.lower_limit, self.upper_limit
... | [
"def",
"mcmc_CH",
"(",
"self",
",",
"walkerRatio",
",",
"n_run",
",",
"n_burn",
",",
"mean_start",
",",
"sigma_start",
",",
"threadCount",
"=",
"1",
",",
"init_pos",
"=",
"None",
",",
"mpi",
"=",
"False",
")",
":",
"lowerLimit",
",",
"upperLimit",
"=",
... | runs mcmc on the parameter space given parameter bounds with CosmoHammerSampler
returns the chain | [
"runs",
"mcmc",
"on",
"the",
"parameter",
"space",
"given",
"parameter",
"bounds",
"with",
"CosmoHammerSampler",
"returns",
"the",
"chain"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/sampler.py#L117-L189 |
sibirrer/lenstronomy | lenstronomy/Util/data_util.py | bkg_noise | def bkg_noise(readout_noise, exposure_time, sky_brightness, pixel_scael, num_exposures=1):
"""
computes the expected Gaussian background noise of a pixel in units of counts/second
:param readout_noise: noise added per readout
:param exposure_time: exposure time per exposure (in seconds)
:param sky_... | python | def bkg_noise(readout_noise, exposure_time, sky_brightness, pixel_scael, num_exposures=1):
"""
computes the expected Gaussian background noise of a pixel in units of counts/second
:param readout_noise: noise added per readout
:param exposure_time: exposure time per exposure (in seconds)
:param sky_... | [
"def",
"bkg_noise",
"(",
"readout_noise",
",",
"exposure_time",
",",
"sky_brightness",
",",
"pixel_scael",
",",
"num_exposures",
"=",
"1",
")",
":",
"exposure_time_tot",
"=",
"num_exposures",
"*",
"exposure_time",
"readout_noise_tot",
"=",
"num_exposures",
"*",
"rea... | computes the expected Gaussian background noise of a pixel in units of counts/second
:param readout_noise: noise added per readout
:param exposure_time: exposure time per exposure (in seconds)
:param sky_brightness: counts per second per unit arcsecond square
:param pixel_scael: size of pixel in units ... | [
"computes",
"the",
"expected",
"Gaussian",
"background",
"noise",
"of",
"a",
"pixel",
"in",
"units",
"of",
"counts",
"/",
"second"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/data_util.py#L4-L19 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_model.py | ImageModel.reset_point_source_cache | def reset_point_source_cache(self, bool=True):
"""
deletes all the cache in the point source class and saves it from then on
:return:
"""
if self.PointSource is not None:
self.PointSource.delete_lens_model_cach()
self.PointSource.set_save_cache(bool) | python | def reset_point_source_cache(self, bool=True):
"""
deletes all the cache in the point source class and saves it from then on
:return:
"""
if self.PointSource is not None:
self.PointSource.delete_lens_model_cach()
self.PointSource.set_save_cache(bool) | [
"def",
"reset_point_source_cache",
"(",
"self",
",",
"bool",
"=",
"True",
")",
":",
"if",
"self",
".",
"PointSource",
"is",
"not",
"None",
":",
"self",
".",
"PointSource",
".",
"delete_lens_model_cach",
"(",
")",
"self",
".",
"PointSource",
".",
"set_save_ca... | deletes all the cache in the point source class and saves it from then on
:return: | [
"deletes",
"all",
"the",
"cache",
"in",
"the",
"point",
"source",
"class",
"and",
"saves",
"it",
"from",
"then",
"on"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L55-L63 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_model.py | ImageModel.linear_response_matrix | def linear_response_matrix(self, kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None):
"""
computes the linear response matrix (m x n), with n beeing the data size and m being the coefficients
:param kwargs_lens:
:param kwargs_source:
:param kwargs_lens_... | python | def linear_response_matrix(self, kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None):
"""
computes the linear response matrix (m x n), with n beeing the data size and m being the coefficients
:param kwargs_lens:
:param kwargs_source:
:param kwargs_lens_... | [
"def",
"linear_response_matrix",
"(",
"self",
",",
"kwargs_lens",
"=",
"None",
",",
"kwargs_source",
"=",
"None",
",",
"kwargs_lens_light",
"=",
"None",
",",
"kwargs_ps",
"=",
"None",
")",
":",
"A",
"=",
"self",
".",
"_response_matrix",
"(",
"self",
".",
"... | computes the linear response matrix (m x n), with n beeing the data size and m being the coefficients
:param kwargs_lens:
:param kwargs_source:
:param kwargs_lens_light:
:param kwargs_ps:
:return: | [
"computes",
"the",
"linear",
"response",
"matrix",
"(",
"m",
"x",
"n",
")",
"with",
"n",
"beeing",
"the",
"data",
"size",
"and",
"m",
"being",
"the",
"coefficients"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L163-L175 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_model.py | ImageModel.data_response | def data_response(self):
"""
returns the 1d array of the data element that is fitted for (including masking)
:return: 1d numpy array
"""
d = self.ImageNumerics.image2array(self.Data.data * self.ImageNumerics.mask)
return d | python | def data_response(self):
"""
returns the 1d array of the data element that is fitted for (including masking)
:return: 1d numpy array
"""
d = self.ImageNumerics.image2array(self.Data.data * self.ImageNumerics.mask)
return d | [
"def",
"data_response",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"ImageNumerics",
".",
"image2array",
"(",
"self",
".",
"Data",
".",
"data",
"*",
"self",
".",
"ImageNumerics",
".",
"mask",
")",
"return",
"d"
] | returns the 1d array of the data element that is fitted for (including masking)
:return: 1d numpy array | [
"returns",
"the",
"1d",
"array",
"of",
"the",
"data",
"element",
"that",
"is",
"fitted",
"for",
"(",
"including",
"masking",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L178-L185 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_model.py | ImageModel.error_response | def error_response(self, kwargs_lens, kwargs_ps):
"""
returns the 1d array of the error estimate corresponding to the data response
:return: 1d numpy array of response, 2d array of additonal errors (e.g. point source uncertainties)
"""
model_error = self.error_map(kwargs_lens, k... | python | def error_response(self, kwargs_lens, kwargs_ps):
"""
returns the 1d array of the error estimate corresponding to the data response
:return: 1d numpy array of response, 2d array of additonal errors (e.g. point source uncertainties)
"""
model_error = self.error_map(kwargs_lens, k... | [
"def",
"error_response",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
")",
":",
"model_error",
"=",
"self",
".",
"error_map",
"(",
"kwargs_lens",
",",
"kwargs_ps",
")",
"error_map_1d",
"=",
"self",
".",
"ImageNumerics",
".",
"image2array",
"(",
"model_er... | returns the 1d array of the error estimate corresponding to the data response
:return: 1d numpy array of response, 2d array of additonal errors (e.g. point source uncertainties) | [
"returns",
"the",
"1d",
"array",
"of",
"the",
"error",
"estimate",
"corresponding",
"to",
"the",
"data",
"response"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L187-L196 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_model.py | ImageModel.reduced_chi2 | def reduced_chi2(self, model, error_map=0):
"""
returns reduced chi2
:param model:
:param error_map:
:return:
"""
chi2 = self.reduced_residuals(model, error_map)
return np.sum(chi2**2) / self.num_data_evaluate() | python | def reduced_chi2(self, model, error_map=0):
"""
returns reduced chi2
:param model:
:param error_map:
:return:
"""
chi2 = self.reduced_residuals(model, error_map)
return np.sum(chi2**2) / self.num_data_evaluate() | [
"def",
"reduced_chi2",
"(",
"self",
",",
"model",
",",
"error_map",
"=",
"0",
")",
":",
"chi2",
"=",
"self",
".",
"reduced_residuals",
"(",
"model",
",",
"error_map",
")",
"return",
"np",
".",
"sum",
"(",
"chi2",
"**",
"2",
")",
"/",
"self",
".",
"... | returns reduced chi2
:param model:
:param error_map:
:return: | [
"returns",
"reduced",
"chi2",
":",
"param",
"model",
":",
":",
"param",
"error_map",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L296-L304 |
sibirrer/lenstronomy | lenstronomy/Sampling/parameters.py | Param.kwargs2args | def kwargs2args(self, kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_cosmo=None):
"""
inverse of getParam function
:param kwargs_lens: keyword arguments depending on model options
:param kwargs_source: keyword arguments depending on model options
... | python | def kwargs2args(self, kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_cosmo=None):
"""
inverse of getParam function
:param kwargs_lens: keyword arguments depending on model options
:param kwargs_source: keyword arguments depending on model options
... | [
"def",
"kwargs2args",
"(",
"self",
",",
"kwargs_lens",
"=",
"None",
",",
"kwargs_source",
"=",
"None",
",",
"kwargs_lens_light",
"=",
"None",
",",
"kwargs_ps",
"=",
"None",
",",
"kwargs_cosmo",
"=",
"None",
")",
":",
"args",
"=",
"self",
".",
"lensParams",... | inverse of getParam function
:param kwargs_lens: keyword arguments depending on model options
:param kwargs_source: keyword arguments depending on model options
:return: tuple of parameters | [
"inverse",
"of",
"getParam",
"function",
":",
"param",
"kwargs_lens",
":",
"keyword",
"arguments",
"depending",
"on",
"model",
"options",
":",
"param",
"kwargs_source",
":",
"keyword",
"arguments",
"depending",
"on",
"model",
"options",
":",
"return",
":",
"tupl... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/parameters.py#L205-L218 |
sibirrer/lenstronomy | lenstronomy/Sampling/parameters.py | Param.image2source_plane | def image2source_plane(self, kwargs_source, kwargs_lens, image_plane=False):
"""
maps the image plane position definition of the source plane
:param kwargs_source:
:param kwargs_lens:
:return:
"""
kwargs_source_copy = copy.deepcopy(kwargs_source)
for i, k... | python | def image2source_plane(self, kwargs_source, kwargs_lens, image_plane=False):
"""
maps the image plane position definition of the source plane
:param kwargs_source:
:param kwargs_lens:
:return:
"""
kwargs_source_copy = copy.deepcopy(kwargs_source)
for i, k... | [
"def",
"image2source_plane",
"(",
"self",
",",
"kwargs_source",
",",
"kwargs_lens",
",",
"image_plane",
"=",
"False",
")",
":",
"kwargs_source_copy",
"=",
"copy",
".",
"deepcopy",
"(",
"kwargs_source",
")",
"for",
"i",
",",
"kwargs",
"in",
"enumerate",
"(",
... | maps the image plane position definition of the source plane
:param kwargs_source:
:param kwargs_lens:
:return: | [
"maps",
"the",
"image",
"plane",
"position",
"definition",
"of",
"the",
"source",
"plane"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/parameters.py#L268-L284 |
sibirrer/lenstronomy | lenstronomy/Sampling/parameters.py | Param.update_lens_scaling | def update_lens_scaling(self, kwargs_cosmo, kwargs_lens, inverse=False):
"""
multiplies the scaling parameters of the profiles
:param args:
:param kwargs_lens:
:param i:
:param inverse:
:return:
"""
kwargs_lens_updated = copy.deepcopy(kwargs_lens)... | python | def update_lens_scaling(self, kwargs_cosmo, kwargs_lens, inverse=False):
"""
multiplies the scaling parameters of the profiles
:param args:
:param kwargs_lens:
:param i:
:param inverse:
:return:
"""
kwargs_lens_updated = copy.deepcopy(kwargs_lens)... | [
"def",
"update_lens_scaling",
"(",
"self",
",",
"kwargs_cosmo",
",",
"kwargs_lens",
",",
"inverse",
"=",
"False",
")",
":",
"kwargs_lens_updated",
"=",
"copy",
".",
"deepcopy",
"(",
"kwargs_lens",
")",
"if",
"self",
".",
"_mass_scaling",
"is",
"False",
":",
... | multiplies the scaling parameters of the profiles
:param args:
:param kwargs_lens:
:param i:
:param inverse:
:return: | [
"multiplies",
"the",
"scaling",
"parameters",
"of",
"the",
"profiles"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/parameters.py#L354-L381 |
sibirrer/lenstronomy | lenstronomy/Sampling/parameters.py | Param.check_solver | def check_solver(self, kwargs_lens, kwargs_ps, kwargs_cosmo={}):
"""
test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: Euclidean distance between the rayshooting of the image positions
"""
if self.... | python | def check_solver(self, kwargs_lens, kwargs_ps, kwargs_cosmo={}):
"""
test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: Euclidean distance between the rayshooting of the image positions
"""
if self.... | [
"def",
"check_solver",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_ps",
",",
"kwargs_cosmo",
"=",
"{",
"}",
")",
":",
"if",
"self",
".",
"_solver",
"is",
"True",
":",
"image_x",
",",
"image_y",
"=",
"kwargs_ps",
"[",
"0",
"]",
"[",
"'ra_image'",
"]",... | test whether the image positions map back to the same source position
:param kwargs_lens:
:param kwargs_ps:
:return: Euclidean distance between the rayshooting of the image positions | [
"test",
"whether",
"the",
"image",
"positions",
"map",
"back",
"to",
"the",
"same",
"source",
"position",
":",
"param",
"kwargs_lens",
":",
":",
"param",
"kwargs_ps",
":",
":",
"return",
":",
"Euclidean",
"distance",
"between",
"the",
"rayshooting",
"of",
"t... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/parameters.py#L391-L404 |
sibirrer/lenstronomy | lenstronomy/Sampling/parameters.py | Param.print_setting | def print_setting(self):
"""
prints the setting of the parameter class
:return:
"""
num, param_list = self.num_param()
num_linear = self.num_param_linear()
print("The following model options are chosen:")
print("Lens models:", self._lens_model_list)
... | python | def print_setting(self):
"""
prints the setting of the parameter class
:return:
"""
num, param_list = self.num_param()
num_linear = self.num_param_linear()
print("The following model options are chosen:")
print("Lens models:", self._lens_model_list)
... | [
"def",
"print_setting",
"(",
"self",
")",
":",
"num",
",",
"param_list",
"=",
"self",
".",
"num_param",
"(",
")",
"num_linear",
"=",
"self",
".",
"num_param_linear",
"(",
")",
"print",
"(",
"\"The following model options are chosen:\"",
")",
"print",
"(",
"\"L... | prints the setting of the parameter class
:return: | [
"prints",
"the",
"setting",
"of",
"the",
"parameter",
"class"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Sampling/parameters.py#L428-L458 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.