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 |
|---|---|---|---|---|---|---|---|---|---|---|
mardiros/pyshop | pyshop/models.py | User.validate | def validate(self, session):
"""
Validate that the current user can be saved.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: ``True``
:rtype: bool
:raise: :class:`pyshop.helpers.sqla.ModelError` if user is not valid
... | python | def validate(self, session):
"""
Validate that the current user can be saved.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: ``True``
:rtype: bool
:raise: :class:`pyshop.helpers.sqla.ModelError` if user is not valid
... | [
"def",
"validate",
"(",
"self",
",",
"session",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"login",
":",
"errors",
".",
"append",
"(",
"u'login is required'",
")",
"else",
":",
"other",
"=",
"User",
".",
"by_login",
"(",
"session",
... | Validate that the current user can be saved.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: ``True``
:rtype: bool
:raise: :class:`pyshop.helpers.sqla.ModelError` if user is not valid | [
"Validate",
"that",
"the",
"current",
"user",
"can",
"be",
"saved",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L368-L397 |
mardiros/pyshop | pyshop/models.py | Classifier.by_name | def by_name(cls, session, name, **kwargs):
"""
Get a classifier from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the classifier
:type name: `unicode
:return: classifier instance
:rtype... | python | def by_name(cls, session, name, **kwargs):
"""
Get a classifier from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the classifier
:type name: `unicode
:return: classifier instance
:rtype... | [
"def",
"by_name",
"(",
"cls",
",",
"session",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"classifier",
"=",
"cls",
".",
"first",
"(",
"session",
",",
"where",
"=",
"(",
"cls",
".",
"name",
"==",
"name",
",",
")",
")",
"if",
"not",
"kwargs",
... | Get a classifier from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the classifier
:type name: `unicode
:return: classifier instance
:rtype: :class:`pyshop.models.Classifier` | [
"Get",
"a",
"classifier",
"from",
"a",
"given",
"name",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L429-L463 |
mardiros/pyshop | pyshop/models.py | Package.sorted_releases | def sorted_releases(self):
"""
Releases sorted by version.
"""
releases = [(parse_version(release.version), release)
for release in self.releases]
releases.sort(reverse=True)
return [release[1] for release in releases] | python | def sorted_releases(self):
"""
Releases sorted by version.
"""
releases = [(parse_version(release.version), release)
for release in self.releases]
releases.sort(reverse=True)
return [release[1] for release in releases] | [
"def",
"sorted_releases",
"(",
"self",
")",
":",
"releases",
"=",
"[",
"(",
"parse_version",
"(",
"release",
".",
"version",
")",
",",
"release",
")",
"for",
"release",
"in",
"self",
".",
"releases",
"]",
"releases",
".",
"sort",
"(",
"reverse",
"=",
"... | Releases sorted by version. | [
"Releases",
"sorted",
"by",
"version",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L512-L519 |
mardiros/pyshop | pyshop/models.py | Package.by_name | def by_name(cls, session, name):
"""
Get a package from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the package
:type name: `unicode
:return: package instance
:rtype: :class:`pyshop.mo... | python | def by_name(cls, session, name):
"""
Get a package from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the package
:type name: `unicode
:return: package instance
:rtype: :class:`pyshop.mo... | [
"def",
"by_name",
"(",
"cls",
",",
"session",
",",
"name",
")",
":",
"# XXX the field \"name\" should be created with a",
"# case insensitive collation.",
"pkg",
"=",
"cls",
".",
"first",
"(",
"session",
",",
"where",
"=",
"(",
"cls",
".",
"name",
".",
"like",
... | Get a package from a given name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param name: name of the package
:type name: `unicode
:return: package instance
:rtype: :class:`pyshop.models.Package` | [
"Get",
"a",
"package",
"from",
"a",
"given",
"name",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L522-L545 |
mardiros/pyshop | pyshop/models.py | Package.by_filter | def by_filter(cls, session, opts, **kwargs):
"""
Get packages from given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: `dict
:return: package instances
:rtype: generator... | python | def by_filter(cls, session, opts, **kwargs):
"""
Get packages from given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: `dict
:return: package instances
:rtype: generator... | [
"def",
"by_filter",
"(",
"cls",
",",
"session",
",",
"opts",
",",
"*",
"*",
"kwargs",
")",
":",
"where",
"=",
"[",
"]",
"if",
"opts",
".",
"get",
"(",
"'local_only'",
")",
":",
"where",
".",
"append",
"(",
"cls",
".",
"local",
"==",
"True",
")",
... | Get packages from given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: `dict
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | [
"Get",
"packages",
"from",
"given",
"filters",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L548-L579 |
mardiros/pyshop | pyshop/models.py | Package.by_owner | def by_owner(cls, session, owner_name):
"""
Get packages from a given owner username.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param owner_name: owner username
:type owner_name: unicode
:return: package instances
:r... | python | def by_owner(cls, session, owner_name):
"""
Get packages from a given owner username.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param owner_name: owner username
:type owner_name: unicode
:return: package instances
:r... | [
"def",
"by_owner",
"(",
"cls",
",",
"session",
",",
"owner_name",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"join",
"=",
"(",
"cls",
".",
"owners",
")",
",",
"where",
"=",
"(",
"User",
".",
"login",
"==",
"owner_name",
",",
")",
... | Get packages from a given owner username.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param owner_name: owner username
:type owner_name: unicode
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | [
"Get",
"packages",
"from",
"a",
"given",
"owner",
"username",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L582-L598 |
mardiros/pyshop | pyshop/models.py | Package.by_maintainer | def by_maintainer(cls, session, maintainer_name):
"""
Get package from a given maintainer name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param maintainer_name: maintainer username
:type maintainer_name: unicode
:return: pac... | python | def by_maintainer(cls, session, maintainer_name):
"""
Get package from a given maintainer name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param maintainer_name: maintainer username
:type maintainer_name: unicode
:return: pac... | [
"def",
"by_maintainer",
"(",
"cls",
",",
"session",
",",
"maintainer_name",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"join",
"=",
"(",
"cls",
".",
"maintainers",
")",
",",
"where",
"=",
"(",
"User",
".",
"login",
"==",
"maintainer_n... | Get package from a given maintainer name.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param maintainer_name: maintainer username
:type maintainer_name: unicode
:return: package instances
:rtype: generator of :class:`pyshop.models.Pack... | [
"Get",
"package",
"from",
"a",
"given",
"maintainer",
"name",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L601-L617 |
mardiros/pyshop | pyshop/models.py | Package.get_locals | def get_locals(cls, session):
"""
Get all local packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package`
"""
return cls.find(session,
... | python | def get_locals(cls, session):
"""
Get all local packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package`
"""
return cls.find(session,
... | [
"def",
"get_locals",
"(",
"cls",
",",
"session",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"where",
"=",
"(",
"cls",
".",
"local",
"==",
"True",
",",
")",
")"
] | Get all local packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | [
"Get",
"all",
"local",
"packages",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L620-L631 |
mardiros/pyshop | pyshop/models.py | Package.get_mirrored | def get_mirrored(cls, session):
"""
Get all mirrored packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package`
"""
return cls.find(session,
... | python | def get_mirrored(cls, session):
"""
Get all mirrored packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package`
"""
return cls.find(session,
... | [
"def",
"get_mirrored",
"(",
"cls",
",",
"session",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"where",
"=",
"(",
"cls",
".",
"local",
"==",
"False",
",",
")",
")"
] | Get all mirrored packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | [
"Get",
"all",
"mirrored",
"packages",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L634-L645 |
mardiros/pyshop | pyshop/models.py | Release.by_version | def by_version(cls, session, package_name, version):
"""
Get release for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unicode
:param version: version
... | python | def by_version(cls, session, package_name, version):
"""
Get release for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unicode
:param version: version
... | [
"def",
"by_version",
"(",
"cls",
",",
"session",
",",
"package_name",
",",
"version",
")",
":",
"return",
"cls",
".",
"first",
"(",
"session",
",",
"join",
"=",
"(",
"Package",
",",
")",
",",
"where",
"=",
"(",
"(",
"Package",
".",
"name",
"==",
"p... | Get release for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unicode
:param version: version
:type version: unicode
:return: release instance
:rtype... | [
"Get",
"release",
"for",
"a",
"given",
"version",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L716-L735 |
mardiros/pyshop | pyshop/models.py | Release.by_classifiers | def by_classifiers(cls, session, classifiers):
"""
Get releases for given classifiers.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param classifiers: classifiers
:type classifiers: unicode
:return: release instances
:r... | python | def by_classifiers(cls, session, classifiers):
"""
Get releases for given classifiers.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param classifiers: classifiers
:type classifiers: unicode
:return: release instances
:r... | [
"def",
"by_classifiers",
"(",
"cls",
",",
"session",
",",
"classifiers",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"join",
"=",
"(",
"cls",
".",
"classifiers",
",",
")",
",",
"where",
"=",
"(",
"Classifier",
".",
"name",
".",
"in_"... | Get releases for given classifiers.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param classifiers: classifiers
:type classifiers: unicode
:return: release instances
:rtype: generator of :class:`pyshop.models.Release` | [
"Get",
"releases",
"for",
"given",
"classifiers",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L738-L754 |
mardiros/pyshop | pyshop/models.py | Release.search | def search(cls, session, opts, operator):
"""
Get releases for given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: dict
:param operator: filtering options joining operator (`and... | python | def search(cls, session, opts, operator):
"""
Get releases for given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: dict
:param operator: filtering options joining operator (`and... | [
"def",
"search",
"(",
"cls",
",",
"session",
",",
"opts",
",",
"operator",
")",
":",
"available",
"=",
"{",
"'name'",
":",
"Package",
".",
"name",
",",
"'version'",
":",
"cls",
".",
"version",
",",
"'author'",
":",
"User",
".",
"login",
",",
"'author... | Get releases for given filters.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param opts: filtering options
:type opts: dict
:param operator: filtering options joining operator (`and` or `or`)
:type operator: basestring
:return... | [
"Get",
"releases",
"for",
"given",
"filters",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L757-L806 |
mardiros/pyshop | pyshop/models.py | ReleaseFile.by_release | def by_release(cls, session, package_name, version):
"""
Get release files for a given package
name and for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unico... | python | def by_release(cls, session, package_name, version):
"""
Get release files for a given package
name and for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unico... | [
"def",
"by_release",
"(",
"cls",
",",
"session",
",",
"package_name",
",",
"version",
")",
":",
"return",
"cls",
".",
"find",
"(",
"session",
",",
"join",
"=",
"(",
"Release",
",",
"Package",
")",
",",
"where",
"=",
"(",
"Package",
".",
"name",
"==",... | Get release files for a given package
name and for a given version.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param package_name: package name
:type package_name: unicode
:param version: version
:type version: unicode
... | [
"Get",
"release",
"files",
"for",
"a",
"given",
"package",
"name",
"and",
"for",
"a",
"given",
"version",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L842-L863 |
mardiros/pyshop | pyshop/models.py | ReleaseFile.by_filename | def by_filename(cls, session, release, filename):
"""
Get a release file for a given release and a given filename.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param release: release
:type release: :class:`pyshop.models.Release`
... | python | def by_filename(cls, session, release, filename):
"""
Get a release file for a given release and a given filename.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param release: release
:type release: :class:`pyshop.models.Release`
... | [
"def",
"by_filename",
"(",
"cls",
",",
"session",
",",
"release",
",",
"filename",
")",
":",
"return",
"cls",
".",
"first",
"(",
"session",
",",
"where",
"=",
"(",
"ReleaseFile",
".",
"release_id",
"==",
"release",
".",
"id",
",",
"ReleaseFile",
".",
"... | Get a release file for a given release and a given filename.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:param release: release
:type release: :class:`pyshop.models.Release`
:param filename: filename of the release file
:type filename... | [
"Get",
"a",
"release",
"file",
"for",
"a",
"given",
"release",
"and",
"a",
"given",
"filename",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L866-L885 |
mardiros/pyshop | pyshop/config.py | add_urlhelpers | def add_urlhelpers(event):
"""
Add helpers to the template engine.
"""
event['static_url'] = lambda x: static_path(x, event['request'])
event['route_url'] = lambda name, *args, **kwargs: \
route_path(name, event['request'], *args, **kwargs)
event['parse_rest'] = parse_rest
event['has... | python | def add_urlhelpers(event):
"""
Add helpers to the template engine.
"""
event['static_url'] = lambda x: static_path(x, event['request'])
event['route_url'] = lambda name, *args, **kwargs: \
route_path(name, event['request'], *args, **kwargs)
event['parse_rest'] = parse_rest
event['has... | [
"def",
"add_urlhelpers",
"(",
"event",
")",
":",
"event",
"[",
"'static_url'",
"]",
"=",
"lambda",
"x",
":",
"static_path",
"(",
"x",
",",
"event",
"[",
"'request'",
"]",
")",
"event",
"[",
"'route_url'",
"]",
"=",
"lambda",
"name",
",",
"*",
"args",
... | Add helpers to the template engine. | [
"Add",
"helpers",
"to",
"the",
"template",
"engine",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/config.py#L21-L29 |
mardiros/pyshop | pyshop/config.py | includeme | def includeme(config):
"""
Pyramid includeme file for the :class:`pyramid.config.Configurator`
"""
settings = config.registry.settings
# config.add_renderer('json', JSONP())
# release file download
config.add_renderer('repository', dl_renderer_factory)
# Jinja configuration
# We do... | python | def includeme(config):
"""
Pyramid includeme file for the :class:`pyramid.config.Configurator`
"""
settings = config.registry.settings
# config.add_renderer('json', JSONP())
# release file download
config.add_renderer('repository', dl_renderer_factory)
# Jinja configuration
# We do... | [
"def",
"includeme",
"(",
"config",
")",
":",
"settings",
"=",
"config",
".",
"registry",
".",
"settings",
"# config.add_renderer('json', JSONP())",
"# release file download",
"config",
".",
"add_renderer",
"(",
"'repository'",
",",
"dl_renderer_factory",
")",
"# Jinja c... | Pyramid includeme file for the :class:`pyramid.config.Configurator` | [
"Pyramid",
"includeme",
"file",
"for",
"the",
":",
"class",
":",
"pyramid",
".",
"config",
".",
"Configurator"
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/config.py#L32-L214 |
mardiros/pyshop | pyshop/views/xmlrpc.py | list_packages | def list_packages(request):
"""
Retrieve a list of the package names registered with the package index.
Returns a list of name strings.
"""
session = DBSession()
names = [p.name for p in Package.all(session, order_by=Package.name)]
return names | python | def list_packages(request):
"""
Retrieve a list of the package names registered with the package index.
Returns a list of name strings.
"""
session = DBSession()
names = [p.name for p in Package.all(session, order_by=Package.name)]
return names | [
"def",
"list_packages",
"(",
"request",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"names",
"=",
"[",
"p",
".",
"name",
"for",
"p",
"in",
"Package",
".",
"all",
"(",
"session",
",",
"order_by",
"=",
"Package",
".",
"name",
")",
"]",
"return",
... | Retrieve a list of the package names registered with the package index.
Returns a list of name strings. | [
"Retrieve",
"a",
"list",
"of",
"the",
"package",
"names",
"registered",
"with",
"the",
"package",
"index",
".",
"Returns",
"a",
"list",
"of",
"name",
"strings",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L19-L26 |
mardiros/pyshop | pyshop/views/xmlrpc.py | package_releases | def package_releases(request, package_name, show_hidden=False):
"""
Retrieve a list of the releases registered for the given package_name.
Returns a list with all version strings if show_hidden is True or
only the non-hidden ones otherwise."""
session = DBSession()
package = Package.by_name(sess... | python | def package_releases(request, package_name, show_hidden=False):
"""
Retrieve a list of the releases registered for the given package_name.
Returns a list with all version strings if show_hidden is True or
only the non-hidden ones otherwise."""
session = DBSession()
package = Package.by_name(sess... | [
"def",
"package_releases",
"(",
"request",
",",
"package_name",
",",
"show_hidden",
"=",
"False",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"package",
"=",
"Package",
".",
"by_name",
"(",
"session",
",",
"package_name",
")",
"return",
"[",
"rel",
".... | Retrieve a list of the releases registered for the given package_name.
Returns a list with all version strings if show_hidden is True or
only the non-hidden ones otherwise. | [
"Retrieve",
"a",
"list",
"of",
"the",
"releases",
"registered",
"for",
"the",
"given",
"package_name",
".",
"Returns",
"a",
"list",
"with",
"all",
"version",
"strings",
"if",
"show_hidden",
"is",
"True",
"or",
"only",
"the",
"non",
"-",
"hidden",
"ones",
"... | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L30-L37 |
mardiros/pyshop | pyshop/views/xmlrpc.py | package_roles | def package_roles(request, package_name):
"""
Retrieve a list of users and their attributes roles for a given
package_name. Role is either 'Maintainer' or 'Owner'.
"""
session = DBSession()
package = Package.by_name(session, package_name)
owners = [('Owner', o.name) for o in package.owners]
... | python | def package_roles(request, package_name):
"""
Retrieve a list of users and their attributes roles for a given
package_name. Role is either 'Maintainer' or 'Owner'.
"""
session = DBSession()
package = Package.by_name(session, package_name)
owners = [('Owner', o.name) for o in package.owners]
... | [
"def",
"package_roles",
"(",
"request",
",",
"package_name",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"package",
"=",
"Package",
".",
"by_name",
"(",
"session",
",",
"package_name",
")",
"owners",
"=",
"[",
"(",
"'Owner'",
",",
"o",
".",
"name",
... | Retrieve a list of users and their attributes roles for a given
package_name. Role is either 'Maintainer' or 'Owner'. | [
"Retrieve",
"a",
"list",
"of",
"users",
"and",
"their",
"attributes",
"roles",
"for",
"a",
"given",
"package_name",
".",
"Role",
"is",
"either",
"Maintainer",
"or",
"Owner",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L41-L50 |
mardiros/pyshop | pyshop/views/xmlrpc.py | user_packages | def user_packages(request, user):
"""
Retrieve a list of [role_name, package_name] for a given username.
Role is either 'Maintainer' or 'Owner'.
"""
session = DBSession()
owned = Package.by_owner(session, user)
maintained = Package.by_maintainer(session, user)
owned = [('Owner', p.name) ... | python | def user_packages(request, user):
"""
Retrieve a list of [role_name, package_name] for a given username.
Role is either 'Maintainer' or 'Owner'.
"""
session = DBSession()
owned = Package.by_owner(session, user)
maintained = Package.by_maintainer(session, user)
owned = [('Owner', p.name) ... | [
"def",
"user_packages",
"(",
"request",
",",
"user",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"owned",
"=",
"Package",
".",
"by_owner",
"(",
"session",
",",
"user",
")",
"maintained",
"=",
"Package",
".",
"by_maintainer",
"(",
"session",
",",
"us... | Retrieve a list of [role_name, package_name] for a given username.
Role is either 'Maintainer' or 'Owner'. | [
"Retrieve",
"a",
"list",
"of",
"[",
"role_name",
"package_name",
"]",
"for",
"a",
"given",
"username",
".",
"Role",
"is",
"either",
"Maintainer",
"or",
"Owner",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L54-L64 |
mardiros/pyshop | pyshop/views/xmlrpc.py | release_downloads | def release_downloads(request, package_name, version):
"""
Retrieve a list of files and download count for a given package and
release version.
"""
session = DBSession()
release_files = ReleaseFile.by_release(session, package_name, version)
if release_files:
release_files = [(f.relea... | python | def release_downloads(request, package_name, version):
"""
Retrieve a list of files and download count for a given package and
release version.
"""
session = DBSession()
release_files = ReleaseFile.by_release(session, package_name, version)
if release_files:
release_files = [(f.relea... | [
"def",
"release_downloads",
"(",
"request",
",",
"package_name",
",",
"version",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"release_files",
"=",
"ReleaseFile",
".",
"by_release",
"(",
"session",
",",
"package_name",
",",
"version",
")",
"if",
"release_f... | Retrieve a list of files and download count for a given package and
release version. | [
"Retrieve",
"a",
"list",
"of",
"files",
"and",
"download",
"count",
"for",
"a",
"given",
"package",
"and",
"release",
"version",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L68-L78 |
mardiros/pyshop | pyshop/views/xmlrpc.py | release_urls | def release_urls(request, package_name, version):
"""
Retrieve a list of download URLs for the given package release.
Returns a list of dicts with the following keys:
url
packagetype ('sdist', 'bdist', etc)
filename
size
md5_digest
downloads
has_sig
... | python | def release_urls(request, package_name, version):
"""
Retrieve a list of download URLs for the given package release.
Returns a list of dicts with the following keys:
url
packagetype ('sdist', 'bdist', etc)
filename
size
md5_digest
downloads
has_sig
... | [
"def",
"release_urls",
"(",
"request",
",",
"package_name",
",",
"version",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"release_files",
"=",
"ReleaseFile",
".",
"by_release",
"(",
"session",
",",
"package_name",
",",
"version",
")",
"return",
"[",
"{",... | Retrieve a list of download URLs for the given package release.
Returns a list of dicts with the following keys:
url
packagetype ('sdist', 'bdist', etc)
filename
size
md5_digest
downloads
has_sig
python_version (required version, or 'source', or 'any')... | [
"Retrieve",
"a",
"list",
"of",
"download",
"URLs",
"for",
"the",
"given",
"package",
"release",
".",
"Returns",
"a",
"list",
"of",
"dicts",
"with",
"the",
"following",
"keys",
":",
"url",
"packagetype",
"(",
"sdist",
"bdist",
"etc",
")",
"filename",
"size"... | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L82-L108 |
mardiros/pyshop | pyshop/views/xmlrpc.py | release_data | def release_data(request, package_name, version):
"""
Retrieve metadata describing a specific package release.
Returns a dict with keys for:
name
version
stable_version
author
author_email
maintainer
maintainer_email
home_page
license
... | python | def release_data(request, package_name, version):
"""
Retrieve metadata describing a specific package release.
Returns a dict with keys for:
name
version
stable_version
author
author_email
maintainer
maintainer_email
home_page
license
... | [
"def",
"release_data",
"(",
"request",
",",
"package_name",
",",
"version",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"release",
"=",
"Release",
".",
"by_version",
"(",
"session",
",",
"package_name",
",",
"version",
")",
"if",
"release",
":",
"resu... | Retrieve metadata describing a specific package release.
Returns a dict with keys for:
name
version
stable_version
author
author_email
maintainer
maintainer_email
home_page
license
summary
description
keywords
pl... | [
"Retrieve",
"metadata",
"describing",
"a",
"specific",
"package",
"release",
".",
"Returns",
"a",
"dict",
"with",
"keys",
"for",
":",
"name",
"version",
"stable_version",
"author",
"author_email",
"maintainer",
"maintainer_email",
"home_page",
"license",
"summary",
... | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L112-L178 |
mardiros/pyshop | pyshop/views/xmlrpc.py | search | def search(request, spec, operator='and'):
"""
Search the package database using the indicated search spec.
The spec may include any of the keywords described in the above list
(except 'stable_version' and 'classifiers'),
for example: {'description': 'spam'} will search description fields.
With... | python | def search(request, spec, operator='and'):
"""
Search the package database using the indicated search spec.
The spec may include any of the keywords described in the above list
(except 'stable_version' and 'classifiers'),
for example: {'description': 'spam'} will search description fields.
With... | [
"def",
"search",
"(",
"request",
",",
"spec",
",",
"operator",
"=",
"'and'",
")",
":",
"api",
"=",
"pypi",
".",
"proxy",
"rv",
"=",
"[",
"]",
"# search in proxy",
"for",
"k",
",",
"v",
"in",
"spec",
".",
"items",
"(",
")",
":",
"rv",
"+=",
"api",... | Search the package database using the indicated search spec.
The spec may include any of the keywords described in the above list
(except 'stable_version' and 'classifiers'),
for example: {'description': 'spam'} will search description fields.
Within the spec, a field's value can be a string or a list ... | [
"Search",
"the",
"package",
"database",
"using",
"the",
"indicated",
"search",
"spec",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L182-L229 |
mardiros/pyshop | pyshop/views/xmlrpc.py | browse | def browse(request, classifiers):
"""
Retrieve a list of (name, version) pairs of all releases classified
with all of the given classifiers. 'classifiers' must be a list of
Trove classifier strings.
changelog(since)
Retrieve a list of four-tuples (name, version, timestamp, action)
since the... | python | def browse(request, classifiers):
"""
Retrieve a list of (name, version) pairs of all releases classified
with all of the given classifiers. 'classifiers' must be a list of
Trove classifier strings.
changelog(since)
Retrieve a list of four-tuples (name, version, timestamp, action)
since the... | [
"def",
"browse",
"(",
"request",
",",
"classifiers",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"release",
"=",
"Release",
".",
"by_classifiers",
"(",
"session",
",",
"classifiers",
")",
"rv",
"=",
"[",
"(",
"r",
".",
"package",
".",
"name",
",",... | Retrieve a list of (name, version) pairs of all releases classified
with all of the given classifiers. 'classifiers' must be a list of
Trove classifier strings.
changelog(since)
Retrieve a list of four-tuples (name, version, timestamp, action)
since the given timestamp. All timestamps are UTC value... | [
"Retrieve",
"a",
"list",
"of",
"(",
"name",
"version",
")",
"pairs",
"of",
"all",
"releases",
"classified",
"with",
"all",
"of",
"the",
"given",
"classifiers",
".",
"classifiers",
"must",
"be",
"a",
"list",
"of",
"Trove",
"classifier",
"strings",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/xmlrpc.py#L233-L247 |
mardiros/pyshop | pyshop/helpers/pypi.py | set_proxy | def set_proxy(proxy_url, transport_proxy=None):
"""Create the proxy to PyPI XML-RPC Server"""
global proxy, PYPI_URL
PYPI_URL = proxy_url
proxy = xmlrpc.ServerProxy(
proxy_url,
transport=RequestsTransport(proxy_url.startswith('https://')),
allow_none=True) | python | def set_proxy(proxy_url, transport_proxy=None):
"""Create the proxy to PyPI XML-RPC Server"""
global proxy, PYPI_URL
PYPI_URL = proxy_url
proxy = xmlrpc.ServerProxy(
proxy_url,
transport=RequestsTransport(proxy_url.startswith('https://')),
allow_none=True) | [
"def",
"set_proxy",
"(",
"proxy_url",
",",
"transport_proxy",
"=",
"None",
")",
":",
"global",
"proxy",
",",
"PYPI_URL",
"PYPI_URL",
"=",
"proxy_url",
"proxy",
"=",
"xmlrpc",
".",
"ServerProxy",
"(",
"proxy_url",
",",
"transport",
"=",
"RequestsTransport",
"("... | Create the proxy to PyPI XML-RPC Server | [
"Create",
"the",
"proxy",
"to",
"PyPI",
"XML",
"-",
"RPC",
"Server"
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/helpers/pypi.py#L104-L111 |
mardiros/pyshop | pyshop/helpers/pypi.py | RequestsTransport.request | def request(self, host, handler, request_body, verbose):
"""
Make an xmlrpc request.
"""
headers = {'User-Agent': self.user_agent,
#Proxy-Connection': 'Keep-Alive',
#'Content-Range': 'bytes oxy1.0/-1',
'Accept': 'text/xml',
... | python | def request(self, host, handler, request_body, verbose):
"""
Make an xmlrpc request.
"""
headers = {'User-Agent': self.user_agent,
#Proxy-Connection': 'Keep-Alive',
#'Content-Range': 'bytes oxy1.0/-1',
'Accept': 'text/xml',
... | [
"def",
"request",
"(",
"self",
",",
"host",
",",
"handler",
",",
"request_body",
",",
"verbose",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
",",
"#Proxy-Connection': 'Keep-Alive',",
"#'Content-Range': 'bytes oxy1.0/-1',",
"'Accept... | Make an xmlrpc request. | [
"Make",
"an",
"xmlrpc",
"request",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/helpers/pypi.py#L48-L71 |
mardiros/pyshop | pyshop/views/credentials.py | authbasic | def authbasic(request):
"""
Authentification basic, Upload pyshop repository access
"""
if len(request.environ.get('HTTP_AUTHORIZATION', '')) > 0:
auth = request.environ.get('HTTP_AUTHORIZATION')
scheme, data = auth.split(None, 1)
assert scheme.lower() == 'basic'
data = b... | python | def authbasic(request):
"""
Authentification basic, Upload pyshop repository access
"""
if len(request.environ.get('HTTP_AUTHORIZATION', '')) > 0:
auth = request.environ.get('HTTP_AUTHORIZATION')
scheme, data = auth.split(None, 1)
assert scheme.lower() == 'basic'
data = b... | [
"def",
"authbasic",
"(",
"request",
")",
":",
"if",
"len",
"(",
"request",
".",
"environ",
".",
"get",
"(",
"'HTTP_AUTHORIZATION'",
",",
"''",
")",
")",
">",
"0",
":",
"auth",
"=",
"request",
".",
"environ",
".",
"get",
"(",
"'HTTP_AUTHORIZATION'",
")"... | Authentification basic, Upload pyshop repository access | [
"Authentification",
"basic",
"Upload",
"pyshop",
"repository",
"access"
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/credentials.py#L65-L86 |
mardiros/pyshop | pyshop/security.py | RootFactory.get_acl | def get_acl(self, request):
"""
Get ACL.
Initialize the __acl__ from the sql database once,
then use the cached version.
:param request: pyramid request
:type login: :class:`pyramid.request.Request`
:return: ACLs in pyramid format. (Allow, group name, permission... | python | def get_acl(self, request):
"""
Get ACL.
Initialize the __acl__ from the sql database once,
then use the cached version.
:param request: pyramid request
:type login: :class:`pyramid.request.Request`
:return: ACLs in pyramid format. (Allow, group name, permission... | [
"def",
"get_acl",
"(",
"self",
",",
"request",
")",
":",
"if",
"RootFactory",
".",
"_acl",
"is",
"None",
":",
"acl",
"=",
"[",
"]",
"session",
"=",
"DBSession",
"(",
")",
"groups",
"=",
"Group",
".",
"all",
"(",
"session",
")",
"for",
"g",
"in",
... | Get ACL.
Initialize the __acl__ from the sql database once,
then use the cached version.
:param request: pyramid request
:type login: :class:`pyramid.request.Request`
:return: ACLs in pyramid format. (Allow, group name, permission name)
:rtype: list of tupple | [
"Get",
"ACL",
".",
"Initialize",
"the",
"__acl__",
"from",
"the",
"sql",
"database",
"once",
"then",
"use",
"the",
"cached",
"version",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/security.py#L76-L96 |
mardiros/pyshop | pyshop/views/repository.py | show_release_file | def show_release_file(root, request):
"""
Download a release file.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
settings = request.registry.settings
whlify = asbool(settings.get('pysh... | python | def show_release_file(root, request):
"""
Download a release file.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
settings = request.registry.settings
whlify = asbool(settings.get('pysh... | [
"def",
"show_release_file",
"(",
"root",
",",
"request",
")",
":",
"settings",
"=",
"request",
".",
"registry",
".",
"settings",
"whlify",
"=",
"asbool",
"(",
"settings",
".",
"get",
"(",
"'pyshop.mirror.wheelify'",
",",
"'0'",
")",
")",
"session",
"=",
"D... | Download a release file.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict | [
"Download",
"a",
"release",
"file",
".",
"Must",
"be",
"used",
"with",
":",
"func",
":",
"pyshop",
".",
"helpers",
".",
"download",
".",
"renderer_factory",
"to",
"download",
"the",
"release",
"file",
"."
] | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/repository.py#L12-L47 |
mardiros/pyshop | pyshop/views/repository.py | show_external_release_file | def show_external_release_file(root, request):
"""
Download a release from a download url from its package information.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
session = DBSession()
... | python | def show_external_release_file(root, request):
"""
Download a release from a download url from its package information.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
session = DBSession()
... | [
"def",
"show_external_release_file",
"(",
"root",
",",
"request",
")",
":",
"session",
"=",
"DBSession",
"(",
")",
"settings",
"=",
"request",
".",
"registry",
".",
"settings",
"whlify",
"=",
"asbool",
"(",
"settings",
".",
"get",
"(",
"'pyshop.mirror.wheelify... | Download a release from a download url from its package information.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict | [
"Download",
"a",
"release",
"from",
"a",
"download",
"url",
"from",
"its",
"package",
"information",
".",
"Must",
"be",
"used",
"with",
":",
"func",
":",
"pyshop",
".",
"helpers",
".",
"download",
".",
"renderer_factory",
"to",
"download",
"the",
"release",
... | train | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/views/repository.py#L50-L79 |
bcoe/secure-smtpd | secure_smtpd/smtp_channel.py | decode_b64 | def decode_b64(data):
'''Wrapper for b64decode, without having to struggle with bytestrings.'''
byte_string = data.encode('utf-8')
decoded = base64.b64decode(byte_string)
return decoded.decode('utf-8') | python | def decode_b64(data):
'''Wrapper for b64decode, without having to struggle with bytestrings.'''
byte_string = data.encode('utf-8')
decoded = base64.b64decode(byte_string)
return decoded.decode('utf-8') | [
"def",
"decode_b64",
"(",
"data",
")",
":",
"byte_string",
"=",
"data",
".",
"encode",
"(",
"'utf-8'",
")",
"decoded",
"=",
"base64",
".",
"b64decode",
"(",
"byte_string",
")",
"return",
"decoded",
".",
"decode",
"(",
"'utf-8'",
")"
] | Wrapper for b64decode, without having to struggle with bytestrings. | [
"Wrapper",
"for",
"b64decode",
"without",
"having",
"to",
"struggle",
"with",
"bytestrings",
"."
] | train | https://github.com/bcoe/secure-smtpd/blob/f3f76e72c7d610759097921405e88782a19129fe/secure_smtpd/smtp_channel.py#L13-L17 |
bcoe/secure-smtpd | secure_smtpd/smtp_channel.py | encode_b64 | def encode_b64(data):
'''Wrapper for b64encode, without having to struggle with bytestrings.'''
byte_string = data.encode('utf-8')
encoded = base64.b64encode(byte_string)
return encoded.decode('utf-8') | python | def encode_b64(data):
'''Wrapper for b64encode, without having to struggle with bytestrings.'''
byte_string = data.encode('utf-8')
encoded = base64.b64encode(byte_string)
return encoded.decode('utf-8') | [
"def",
"encode_b64",
"(",
"data",
")",
":",
"byte_string",
"=",
"data",
".",
"encode",
"(",
"'utf-8'",
")",
"encoded",
"=",
"base64",
".",
"b64encode",
"(",
"byte_string",
")",
"return",
"encoded",
".",
"decode",
"(",
"'utf-8'",
")"
] | Wrapper for b64encode, without having to struggle with bytestrings. | [
"Wrapper",
"for",
"b64encode",
"without",
"having",
"to",
"struggle",
"with",
"bytestrings",
"."
] | train | https://github.com/bcoe/secure-smtpd/blob/f3f76e72c7d610759097921405e88782a19129fe/secure_smtpd/smtp_channel.py#L20-L24 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_numerics.py | ImageNumerics.array2image | def array2image(self, array, subgrid_res=1):
"""
maps a 1d array into a (nx, ny) 2d grid with array populating the idex_mask indices
:param array: 1d array
:param idex_mask: 1d array of length nx*ny
:param nx: x-axis of 2d grid
:param ny: y-axis of 2d grid
:return... | python | def array2image(self, array, subgrid_res=1):
"""
maps a 1d array into a (nx, ny) 2d grid with array populating the idex_mask indices
:param array: 1d array
:param idex_mask: 1d array of length nx*ny
:param nx: x-axis of 2d grid
:param ny: y-axis of 2d grid
:return... | [
"def",
"array2image",
"(",
"self",
",",
"array",
",",
"subgrid_res",
"=",
"1",
")",
":",
"nx",
",",
"ny",
"=",
"self",
".",
"_nx",
"*",
"subgrid_res",
",",
"self",
".",
"_ny",
"*",
"subgrid_res",
"if",
"self",
".",
"_idex_mask_bool",
"is",
"True",
":... | maps a 1d array into a (nx, ny) 2d grid with array populating the idex_mask indices
:param array: 1d array
:param idex_mask: 1d array of length nx*ny
:param nx: x-axis of 2d grid
:param ny: y-axis of 2d grid
:return: | [
"maps",
"a",
"1d",
"array",
"into",
"a",
"(",
"nx",
"ny",
")",
"2d",
"grid",
"with",
"array",
"populating",
"the",
"idex_mask",
"indices",
":",
"param",
"array",
":",
"1d",
"array",
":",
"param",
"idex_mask",
":",
"1d",
"array",
"of",
"length",
"nx",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_numerics.py#L151-L172 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_numerics.py | ImageNumerics.image2array | def image2array(self, image):
"""
returns 1d array of values in image in idex_mask
:param image:
:param idex_mask:
:return:
"""
idex_mask = self._idex_mask
array = util.image2array(image)
if self._idex_mask_bool is True:
return array[id... | python | def image2array(self, image):
"""
returns 1d array of values in image in idex_mask
:param image:
:param idex_mask:
:return:
"""
idex_mask = self._idex_mask
array = util.image2array(image)
if self._idex_mask_bool is True:
return array[id... | [
"def",
"image2array",
"(",
"self",
",",
"image",
")",
":",
"idex_mask",
"=",
"self",
".",
"_idex_mask",
"array",
"=",
"util",
".",
"image2array",
"(",
"image",
")",
"if",
"self",
".",
"_idex_mask_bool",
"is",
"True",
":",
"return",
"array",
"[",
"idex_ma... | returns 1d array of values in image in idex_mask
:param image:
:param idex_mask:
:return: | [
"returns",
"1d",
"array",
"of",
"values",
"in",
"image",
"in",
"idex_mask",
":",
"param",
"image",
":",
":",
"param",
"idex_mask",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_numerics.py#L174-L186 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_numerics.py | ImageNumerics._init_mask_psf | def _init_mask_psf(self):
"""
smaller frame that encolses all the idex_mask
:param idex_mask:
:param nx:
:param ny:
:return:
"""
if not hasattr(self, '_x_min_psf'):
idex_2d = self._idex_mask_2d
self._x_min_psf = np.min(np.where(idex... | python | def _init_mask_psf(self):
"""
smaller frame that encolses all the idex_mask
:param idex_mask:
:param nx:
:param ny:
:return:
"""
if not hasattr(self, '_x_min_psf'):
idex_2d = self._idex_mask_2d
self._x_min_psf = np.min(np.where(idex... | [
"def",
"_init_mask_psf",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_x_min_psf'",
")",
":",
"idex_2d",
"=",
"self",
".",
"_idex_mask_2d",
"self",
".",
"_x_min_psf",
"=",
"np",
".",
"min",
"(",
"np",
".",
"where",
"(",
"idex_2d",... | smaller frame that encolses all the idex_mask
:param idex_mask:
:param nx:
:param ny:
:return: | [
"smaller",
"frame",
"that",
"encolses",
"all",
"the",
"idex_mask",
":",
"param",
"idex_mask",
":",
":",
"param",
"nx",
":",
":",
"param",
"ny",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_numerics.py#L208-L221 |
sibirrer/lenstronomy | lenstronomy/ImSim/image_numerics.py | ImageNumerics._cutout_psf | def _cutout_psf(self, image, subgrid_res):
"""
cutout the part of the image relevant for the psf convolution
:param image:
:return:
"""
self._init_mask_psf()
return image[self._x_min_psf*subgrid_res:(self._x_max_psf+1)*subgrid_res, self._y_min_psf*subgrid_res:(sel... | python | def _cutout_psf(self, image, subgrid_res):
"""
cutout the part of the image relevant for the psf convolution
:param image:
:return:
"""
self._init_mask_psf()
return image[self._x_min_psf*subgrid_res:(self._x_max_psf+1)*subgrid_res, self._y_min_psf*subgrid_res:(sel... | [
"def",
"_cutout_psf",
"(",
"self",
",",
"image",
",",
"subgrid_res",
")",
":",
"self",
".",
"_init_mask_psf",
"(",
")",
"return",
"image",
"[",
"self",
".",
"_x_min_psf",
"*",
"subgrid_res",
":",
"(",
"self",
".",
"_x_max_psf",
"+",
"1",
")",
"*",
"sub... | cutout the part of the image relevant for the psf convolution
:param image:
:return: | [
"cutout",
"the",
"part",
"of",
"the",
"image",
"relevant",
"for",
"the",
"psf",
"convolution",
":",
"param",
"image",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_numerics.py#L223-L230 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/shapelets_polar.py | ShapeletsPolar.index2poly | def index2poly(self, index):
"""
manages the convention from an iterative index to the specific polynomial n, m, (real/imaginary part)
:param index: int, index of list
:return: n, m bool
"""
n = self._index2n(index)
num_prev = n * (n + 1) / 2
num = inde... | python | def index2poly(self, index):
"""
manages the convention from an iterative index to the specific polynomial n, m, (real/imaginary part)
:param index: int, index of list
:return: n, m bool
"""
n = self._index2n(index)
num_prev = n * (n + 1) / 2
num = inde... | [
"def",
"index2poly",
"(",
"self",
",",
"index",
")",
":",
"n",
"=",
"self",
".",
"_index2n",
"(",
"index",
")",
"num_prev",
"=",
"n",
"*",
"(",
"n",
"+",
"1",
")",
"/",
"2",
"num",
"=",
"index",
"+",
"1",
"delta",
"=",
"int",
"(",
"num",
"-",... | manages the convention from an iterative index to the specific polynomial n, m, (real/imaginary part)
:param index: int, index of list
:return: n, m bool | [
"manages",
"the",
"convention",
"from",
"an",
"iterative",
"index",
"to",
"the",
"specific",
"polynomial",
"n",
"m",
"(",
"real",
"/",
"imaginary",
"part",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/shapelets_polar.py#L80-L110 |
sibirrer/lenstronomy | lenstronomy/LightModel/Profiles/shapelets_polar.py | ShapeletSetPolar.decomposition | def decomposition(self, image, x, y, n_max, beta, deltaPix, center_x=0, center_y=0):
"""
decomposes an image into the shapelet coefficients in same order as for the function call
:param image:
:param x:
:param y:
:param n_max:
:param beta:
:param center_x:... | python | def decomposition(self, image, x, y, n_max, beta, deltaPix, center_x=0, center_y=0):
"""
decomposes an image into the shapelet coefficients in same order as for the function call
:param image:
:param x:
:param y:
:param n_max:
:param beta:
:param center_x:... | [
"def",
"decomposition",
"(",
"self",
",",
"image",
",",
"x",
",",
"y",
",",
"n_max",
",",
"beta",
",",
"deltaPix",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"num_param",
"=",
"self",
".",
"shapelets",
".",
"num_param",
"(",
"n... | decomposes an image into the shapelet coefficients in same order as for the function call
:param image:
:param x:
:param y:
:param n_max:
:param beta:
:param center_x:
:param center_y:
:return: | [
"decomposes",
"an",
"image",
"into",
"the",
"shapelet",
"coefficients",
"in",
"same",
"order",
"as",
"for",
"the",
"function",
"call",
":",
"param",
"image",
":",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"n_max",
":",
":",
"param",... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/Profiles/shapelets_polar.py#L355-L378 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | de_shift_kernel | def de_shift_kernel(kernel, shift_x, shift_y, iterations=20):
"""
de-shifts a shifted kernel to the center of a pixel. This is performed iteratively.
The input kernel is the solution of a linear interpolated shift of a sharper kernel centered in the middle of the
pixel. To find the de-shifted kernel, ... | python | def de_shift_kernel(kernel, shift_x, shift_y, iterations=20):
"""
de-shifts a shifted kernel to the center of a pixel. This is performed iteratively.
The input kernel is the solution of a linear interpolated shift of a sharper kernel centered in the middle of the
pixel. To find the de-shifted kernel, ... | [
"def",
"de_shift_kernel",
"(",
"kernel",
",",
"shift_x",
",",
"shift_y",
",",
"iterations",
"=",
"20",
")",
":",
"nx",
",",
"ny",
"=",
"np",
".",
"shape",
"(",
"kernel",
")",
"kernel_new",
"=",
"np",
".",
"zeros",
"(",
"(",
"nx",
"+",
"2",
",",
"... | de-shifts a shifted kernel to the center of a pixel. This is performed iteratively.
The input kernel is the solution of a linear interpolated shift of a sharper kernel centered in the middle of the
pixel. To find the de-shifted kernel, we perform an iterative correction of proposed de-shifted kernels and comp... | [
"de",
"-",
"shifts",
"a",
"shifted",
"kernel",
"to",
"the",
"center",
"of",
"a",
"pixel",
".",
"This",
"is",
"performed",
"iteratively",
"."
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L12-L41 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | center_kernel | def center_kernel(kernel, iterations=20):
"""
given a kernel that might not be perfectly centered, this routine computes its light weighted center and then
moves the center in an iterative process such that it is centered
:param kernel: 2d array (odd numbers)
:param iterations: int, number of itera... | python | def center_kernel(kernel, iterations=20):
"""
given a kernel that might not be perfectly centered, this routine computes its light weighted center and then
moves the center in an iterative process such that it is centered
:param kernel: 2d array (odd numbers)
:param iterations: int, number of itera... | [
"def",
"center_kernel",
"(",
"kernel",
",",
"iterations",
"=",
"20",
")",
":",
"kernel",
"=",
"kernel_norm",
"(",
"kernel",
")",
"nx",
",",
"ny",
"=",
"np",
".",
"shape",
"(",
"kernel",
")",
"if",
"nx",
"%",
"2",
"==",
"0",
":",
"raise",
"ValueErro... | given a kernel that might not be perfectly centered, this routine computes its light weighted center and then
moves the center in an iterative process such that it is centered
:param kernel: 2d array (odd numbers)
:param iterations: int, number of iterations
:return: centered kernel | [
"given",
"a",
"kernel",
"that",
"might",
"not",
"be",
"perfectly",
"centered",
"this",
"routine",
"computes",
"its",
"light",
"weighted",
"center",
"and",
"then",
"moves",
"the",
"center",
"in",
"an",
"iterative",
"process",
"such",
"that",
"it",
"is",
"cent... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L44-L64 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | subgrid_kernel | def subgrid_kernel(kernel, subgrid_res, odd=False, num_iter=100):
"""
creates a higher resolution kernel with subgrid resolution as an interpolation of the original kernel in an
iterative approach
:param kernel: initial kernel
:param subgrid_res: subgrid resolution required
:return: kernel with... | python | def subgrid_kernel(kernel, subgrid_res, odd=False, num_iter=100):
"""
creates a higher resolution kernel with subgrid resolution as an interpolation of the original kernel in an
iterative approach
:param kernel: initial kernel
:param subgrid_res: subgrid resolution required
:return: kernel with... | [
"def",
"subgrid_kernel",
"(",
"kernel",
",",
"subgrid_res",
",",
"odd",
"=",
"False",
",",
"num_iter",
"=",
"100",
")",
":",
"subgrid_res",
"=",
"int",
"(",
"subgrid_res",
")",
"if",
"subgrid_res",
"==",
"1",
":",
"return",
"kernel",
"nx",
",",
"ny",
"... | creates a higher resolution kernel with subgrid resolution as an interpolation of the original kernel in an
iterative approach
:param kernel: initial kernel
:param subgrid_res: subgrid resolution required
:return: kernel with higher resolution (larger) | [
"creates",
"a",
"higher",
"resolution",
"kernel",
"with",
"subgrid",
"resolution",
"as",
"an",
"interpolation",
"of",
"the",
"original",
"kernel",
"in",
"an",
"iterative",
"approach"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L78-L138 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | averaging_even_kernel | def averaging_even_kernel(kernel_high_res, subgrid_res):
"""
makes a lower resolution kernel based on the kernel_high_res (odd numbers) and the subgrid_res (even number), both
meant to be centered.
:param kernel_high_res: high resolution kernel with even subsampling resolution, centered
:param subg... | python | def averaging_even_kernel(kernel_high_res, subgrid_res):
"""
makes a lower resolution kernel based on the kernel_high_res (odd numbers) and the subgrid_res (even number), both
meant to be centered.
:param kernel_high_res: high resolution kernel with even subsampling resolution, centered
:param subg... | [
"def",
"averaging_even_kernel",
"(",
"kernel_high_res",
",",
"subgrid_res",
")",
":",
"n_high",
"=",
"len",
"(",
"kernel_high_res",
")",
"n_low",
"=",
"int",
"(",
"(",
"n_high",
"+",
"1",
")",
"/",
"subgrid_res",
")",
"kernel_low_res",
"=",
"np",
".",
"zer... | makes a lower resolution kernel based on the kernel_high_res (odd numbers) and the subgrid_res (even number), both
meant to be centered.
:param kernel_high_res: high resolution kernel with even subsampling resolution, centered
:param subgrid_res: subsampling resolution (even number)
:return: averaged u... | [
"makes",
"a",
"lower",
"resolution",
"kernel",
"based",
"on",
"the",
"kernel_high_res",
"(",
"odd",
"numbers",
")",
"and",
"the",
"subgrid_res",
"(",
"even",
"number",
")",
"both",
"meant",
"to",
"be",
"centered",
"."
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L141-L174 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | kernel_pixelsize_change | def kernel_pixelsize_change(kernel, deltaPix_in, deltaPix_out):
"""
change the pixel size of a given kernel
:param kernel:
:param deltaPix_in:
:param deltaPix_out:
:return:
"""
numPix = len(kernel)
numPix_new = int(round(numPix * deltaPix_in/deltaPix_out))
if numPix_new % 2 == 0:... | python | def kernel_pixelsize_change(kernel, deltaPix_in, deltaPix_out):
"""
change the pixel size of a given kernel
:param kernel:
:param deltaPix_in:
:param deltaPix_out:
:return:
"""
numPix = len(kernel)
numPix_new = int(round(numPix * deltaPix_in/deltaPix_out))
if numPix_new % 2 == 0:... | [
"def",
"kernel_pixelsize_change",
"(",
"kernel",
",",
"deltaPix_in",
",",
"deltaPix_out",
")",
":",
"numPix",
"=",
"len",
"(",
"kernel",
")",
"numPix_new",
"=",
"int",
"(",
"round",
"(",
"numPix",
"*",
"deltaPix_in",
"/",
"deltaPix_out",
")",
")",
"if",
"n... | change the pixel size of a given kernel
:param kernel:
:param deltaPix_in:
:param deltaPix_out:
:return: | [
"change",
"the",
"pixel",
"size",
"of",
"a",
"given",
"kernel",
":",
"param",
"kernel",
":",
":",
"param",
"deltaPix_in",
":",
":",
"param",
"deltaPix_out",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L177-L193 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | cut_psf | def cut_psf(psf_data, psf_size):
"""
cut the psf properly
:param psf_data: image of PSF
:param psf_size: size of psf
:return: re-sized and re-normalized PSF
"""
kernel = image_util.cut_edges(psf_data, psf_size)
kernel = kernel_norm(kernel)
return kernel | python | def cut_psf(psf_data, psf_size):
"""
cut the psf properly
:param psf_data: image of PSF
:param psf_size: size of psf
:return: re-sized and re-normalized PSF
"""
kernel = image_util.cut_edges(psf_data, psf_size)
kernel = kernel_norm(kernel)
return kernel | [
"def",
"cut_psf",
"(",
"psf_data",
",",
"psf_size",
")",
":",
"kernel",
"=",
"image_util",
".",
"cut_edges",
"(",
"psf_data",
",",
"psf_size",
")",
"kernel",
"=",
"kernel_norm",
"(",
"kernel",
")",
"return",
"kernel"
] | cut the psf properly
:param psf_data: image of PSF
:param psf_size: size of psf
:return: re-sized and re-normalized PSF | [
"cut",
"the",
"psf",
"properly",
":",
"param",
"psf_data",
":",
"image",
"of",
"PSF",
":",
"param",
"psf_size",
":",
"size",
"of",
"psf",
":",
"return",
":",
"re",
"-",
"sized",
"and",
"re",
"-",
"normalized",
"PSF"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L196-L205 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | pixel_kernel | def pixel_kernel(point_source_kernel, subgrid_res=7):
"""
converts a pixelised kernel of a point source to a kernel representing a uniform extended pixel
:param point_source_kernel:
:param subgrid_res:
:return: convolution kernel for an extended pixel
"""
kernel_subgrid = subgrid_kernel(poi... | python | def pixel_kernel(point_source_kernel, subgrid_res=7):
"""
converts a pixelised kernel of a point source to a kernel representing a uniform extended pixel
:param point_source_kernel:
:param subgrid_res:
:return: convolution kernel for an extended pixel
"""
kernel_subgrid = subgrid_kernel(poi... | [
"def",
"pixel_kernel",
"(",
"point_source_kernel",
",",
"subgrid_res",
"=",
"7",
")",
":",
"kernel_subgrid",
"=",
"subgrid_kernel",
"(",
"point_source_kernel",
",",
"subgrid_res",
",",
"num_iter",
"=",
"10",
")",
"kernel_size",
"=",
"len",
"(",
"point_source_kerne... | converts a pixelised kernel of a point source to a kernel representing a uniform extended pixel
:param point_source_kernel:
:param subgrid_res:
:return: convolution kernel for an extended pixel | [
"converts",
"a",
"pixelised",
"kernel",
"of",
"a",
"point",
"source",
"to",
"a",
"kernel",
"representing",
"a",
"uniform",
"extended",
"pixel"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L208-L225 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | split_kernel | def split_kernel(kernel, kernel_subgrid, subsampling_size, subgrid_res):
"""
pixel kernel and subsampling kernel such that the convolution of both applied on an image can be
performed, i.e. smaller subsampling PSF and hole in larger PSF
:param kernel: PSF kernel of the size of the pixel
:param kern... | python | def split_kernel(kernel, kernel_subgrid, subsampling_size, subgrid_res):
"""
pixel kernel and subsampling kernel such that the convolution of both applied on an image can be
performed, i.e. smaller subsampling PSF and hole in larger PSF
:param kernel: PSF kernel of the size of the pixel
:param kern... | [
"def",
"split_kernel",
"(",
"kernel",
",",
"kernel_subgrid",
",",
"subsampling_size",
",",
"subgrid_res",
")",
":",
"n",
"=",
"len",
"(",
"kernel",
")",
"n_sub",
"=",
"len",
"(",
"kernel_subgrid",
")",
"if",
"subsampling_size",
"%",
"2",
"==",
"0",
":",
... | pixel kernel and subsampling kernel such that the convolution of both applied on an image can be
performed, i.e. smaller subsampling PSF and hole in larger PSF
:param kernel: PSF kernel of the size of the pixel
:param kernel_subgrid: subsampled kernel
:param subsampling_size: size of subsampling PSF in... | [
"pixel",
"kernel",
"and",
"subsampling",
"kernel",
"such",
"that",
"the",
"convolution",
"of",
"both",
"applied",
"on",
"an",
"image",
"can",
"be",
"performed",
"i",
".",
"e",
".",
"smaller",
"subsampling",
"PSF",
"and",
"hole",
"in",
"larger",
"PSF"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L241-L271 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | cutout_source | def cutout_source(x_pos, y_pos, image, kernelsize, shift=True):
"""
cuts out point source (e.g. PSF estimate) out of image and shift it to the center of a pixel
:param x_pos:
:param y_pos:
:param image:
:param kernelsize:
:return:
"""
if kernelsize % 2 == 0:
raise ValueError(... | python | def cutout_source(x_pos, y_pos, image, kernelsize, shift=True):
"""
cuts out point source (e.g. PSF estimate) out of image and shift it to the center of a pixel
:param x_pos:
:param y_pos:
:param image:
:param kernelsize:
:return:
"""
if kernelsize % 2 == 0:
raise ValueError(... | [
"def",
"cutout_source",
"(",
"x_pos",
",",
"y_pos",
",",
"image",
",",
"kernelsize",
",",
"shift",
"=",
"True",
")",
":",
"if",
"kernelsize",
"%",
"2",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"even pixel number kernel size not supported!\"",
")",
"x_int"... | cuts out point source (e.g. PSF estimate) out of image and shift it to the center of a pixel
:param x_pos:
:param y_pos:
:param image:
:param kernelsize:
:return: | [
"cuts",
"out",
"point",
"source",
"(",
"e",
".",
"g",
".",
"PSF",
"estimate",
")",
"out",
"of",
"image",
"and",
"shift",
"it",
"to",
"the",
"center",
"of",
"a",
"pixel",
":",
"param",
"x_pos",
":",
":",
"param",
"y_pos",
":",
":",
"param",
"image",... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L274-L311 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | fwhm_kernel | def fwhm_kernel(kernel):
"""
computes the full width at half maximum of a (PSF) kernel
:param kernel: (psf) kernel, 2d numpy array
:return: fwhm in units of pixels
"""
n = len(kernel)
if n % 2 == 0:
raise ValueError('only works with odd number of pixels in kernel!')
max_flux = ke... | python | def fwhm_kernel(kernel):
"""
computes the full width at half maximum of a (PSF) kernel
:param kernel: (psf) kernel, 2d numpy array
:return: fwhm in units of pixels
"""
n = len(kernel)
if n % 2 == 0:
raise ValueError('only works with odd number of pixels in kernel!')
max_flux = ke... | [
"def",
"fwhm_kernel",
"(",
"kernel",
")",
":",
"n",
"=",
"len",
"(",
"kernel",
")",
"if",
"n",
"%",
"2",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'only works with odd number of pixels in kernel!'",
")",
"max_flux",
"=",
"kernel",
"[",
"int",
"(",
"(",
... | computes the full width at half maximum of a (PSF) kernel
:param kernel: (psf) kernel, 2d numpy array
:return: fwhm in units of pixels | [
"computes",
"the",
"full",
"width",
"at",
"half",
"maximum",
"of",
"a",
"(",
"PSF",
")",
"kernel",
":",
"param",
"kernel",
":",
"(",
"psf",
")",
"kernel",
"2d",
"numpy",
"array",
":",
"return",
":",
"fwhm",
"in",
"units",
"of",
"pixels"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L314-L331 |
sibirrer/lenstronomy | lenstronomy/Util/kernel_util.py | estimate_amp | def estimate_amp(data, x_pos, y_pos, psf_kernel):
"""
estimates the amplitude of a point source located at x_pos, y_pos
:param data:
:param x_pos:
:param y_pos:
:param deltaPix:
:return:
"""
numPix_x, numPix_y = np.shape(data)
#data_center = int((numPix-1.)/2)
x_int = int(rou... | python | def estimate_amp(data, x_pos, y_pos, psf_kernel):
"""
estimates the amplitude of a point source located at x_pos, y_pos
:param data:
:param x_pos:
:param y_pos:
:param deltaPix:
:return:
"""
numPix_x, numPix_y = np.shape(data)
#data_center = int((numPix-1.)/2)
x_int = int(rou... | [
"def",
"estimate_amp",
"(",
"data",
",",
"x_pos",
",",
"y_pos",
",",
"psf_kernel",
")",
":",
"numPix_x",
",",
"numPix_y",
"=",
"np",
".",
"shape",
"(",
"data",
")",
"#data_center = int((numPix-1.)/2)",
"x_int",
"=",
"int",
"(",
"round",
"(",
"x_pos",
"-",
... | estimates the amplitude of a point source located at x_pos, y_pos
:param data:
:param x_pos:
:param y_pos:
:param deltaPix:
:return: | [
"estimates",
"the",
"amplitude",
"of",
"a",
"point",
"source",
"located",
"at",
"x_pos",
"y_pos",
":",
"param",
"data",
":",
":",
"param",
"x_pos",
":",
":",
"param",
"y_pos",
":",
":",
"param",
"deltaPix",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L334-L355 |
sibirrer/lenstronomy | lenstronomy/GalKin/light_profile.py | LightProfile.draw_light_2d_linear | def draw_light_2d_linear(self, kwargs_list, n=1, new_compute=False, r_eff=1.):
"""
constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return:
"""
if not hasattr(self, '_light_cdf') or new_compute is True:
r_array... | python | def draw_light_2d_linear(self, kwargs_list, n=1, new_compute=False, r_eff=1.):
"""
constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return:
"""
if not hasattr(self, '_light_cdf') or new_compute is True:
r_array... | [
"def",
"draw_light_2d_linear",
"(",
"self",
",",
"kwargs_list",
",",
"n",
"=",
"1",
",",
"new_compute",
"=",
"False",
",",
"r_eff",
"=",
"1.",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_light_cdf'",
")",
"or",
"new_compute",
"is",
"True",
"... | constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return: | [
"constructs",
"the",
"CDF",
"and",
"draws",
"from",
"it",
"random",
"realizations",
"of",
"projected",
"radii",
"R",
":",
"param",
"kwargs_list",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/light_profile.py#L61-L82 |
sibirrer/lenstronomy | lenstronomy/GalKin/light_profile.py | LightProfile.draw_light_2d | def draw_light_2d(self, kwargs_list, n=1, new_compute=False):
"""
constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return:
"""
if not hasattr(self, '_light_cdf_log') or new_compute is True:
r_array = np.logspac... | python | def draw_light_2d(self, kwargs_list, n=1, new_compute=False):
"""
constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return:
"""
if not hasattr(self, '_light_cdf_log') or new_compute is True:
r_array = np.logspac... | [
"def",
"draw_light_2d",
"(",
"self",
",",
"kwargs_list",
",",
"n",
"=",
"1",
",",
"new_compute",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_light_cdf_log'",
")",
"or",
"new_compute",
"is",
"True",
":",
"r_array",
"=",
"np",
".... | constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return: | [
"constructs",
"the",
"CDF",
"and",
"draws",
"from",
"it",
"random",
"realizations",
"of",
"projected",
"radii",
"R",
":",
"param",
"kwargs_list",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/light_profile.py#L84-L105 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.derivatives | def derivatives(self, x, y, Rs, theta_Rs, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
rho0_input = self._alpha2rho0(theta_Rs=theta_Rs, Rs=Rs)
if Rs < 0.0000001:
Rs = 0.0000001
x_ = x - center_x
y_ = y - ce... | python | def derivatives(self, x, y, Rs, theta_Rs, center_x=0, center_y=0):
"""
returns df/dx and df/dy of the function (integral of NFW)
"""
rho0_input = self._alpha2rho0(theta_Rs=theta_Rs, Rs=Rs)
if Rs < 0.0000001:
Rs = 0.0000001
x_ = x - center_x
y_ = y - ce... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"theta_Rs",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"rho0_input",
"=",
"self",
".",
"_alpha2rho0",
"(",
"theta_Rs",
"=",
"theta_Rs",
",",
"Rs",
"=",
"Rs"... | 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.py#L56-L67 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.density | def density(self, R, Rs, rho0):
"""
three dimenstional 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
:retur... | python | def density(self, R, Rs, rho0):
"""
three dimenstional 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
:retur... | [
"def",
"density",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
")",
":",
"return",
"rho0",
"/",
"(",
"R",
"/",
"Rs",
"*",
"(",
"1",
"+",
"R",
"/",
"Rs",
")",
"**",
"2",
")"
] | three dimenstional 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: rho(R) density | [
"three",
"dimenstional",
"NFW",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L86-L98 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.density_2d | def density_2d(self, x, y, Rs, rho0, 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 (charact... | python | def density_2d(self, x, y, Rs, rho0, 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 (charact... | [
"def",
"density_2d",
"(",
"self",
",",
"x",
",",
"y",
",",
"Rs",
",",
"rho0",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"R",
"=",
"np",
".",
"sqrt",
"(",
... | 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/nfw.py#L100-L119 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.mass_3d | def mass_3d(self, R, Rs, rho0):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
Rs = float(Rs)
m_3d = 4. * np.pi * rho0 * Rs**3 *(np.log((Rs + R)/Rs) - R/(Rs + R))
return m_3d | python | def mass_3d(self, R, Rs, rho0):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
Rs = float(Rs)
m_3d = 4. * np.pi * rho0 * Rs**3 *(np.log((Rs + R)/Rs) - R/(Rs + R))
return m_3d | [
"def",
"mass_3d",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
")",
":",
"Rs",
"=",
"float",
"(",
"Rs",
")",
"m_3d",
"=",
"4.",
"*",
"np",
".",
"pi",
"*",
"rho0",
"*",
"Rs",
"**",
"3",
"*",
"(",
"np",
".",
"log",
"(",
"(",
"Rs",
"+",
... | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r",
":",
"param",
"r",
":",
":",
"param",
"Ra",
":",
":",
"param",
"Rs",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L121-L131 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.mass_3d_lens | def mass_3d_lens(self, R, Rs, theta_Rs):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
rho0 = self._alpha2rho0(theta_Rs, Rs)
m_3d = self.mass_3d(R, Rs, rho0)
return m_3d | python | def mass_3d_lens(self, R, Rs, theta_Rs):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
rho0 = self._alpha2rho0(theta_Rs, Rs)
m_3d = self.mass_3d(R, Rs, rho0)
return m_3d | [
"def",
"mass_3d_lens",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"theta_Rs",
")",
":",
"rho0",
"=",
"self",
".",
"_alpha2rho0",
"(",
"theta_Rs",
",",
"Rs",
")",
"m_3d",
"=",
"self",
".",
"mass_3d",
"(",
"R",
",",
"Rs",
",",
"rho0",
")",
"return",
"m... | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r",
":",
"param",
"r",
":",
":",
"param",
"Ra",
":",
":",
"param",
"Rs",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L133-L143 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.mass_2d | def mass_2d(self, R, Rs, rho0):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
x = R/Rs
gx = self.g_(x)
m_2d = 4*rho0*Rs*R**2*gx/x**2 * np.pi
return m_2d | python | def mass_2d(self, R, Rs, rho0):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return:
"""
x = R/Rs
gx = self.g_(x)
m_2d = 4*rho0*Rs*R**2*gx/x**2 * np.pi
return m_2d | [
"def",
"mass_2d",
"(",
"self",
",",
"R",
",",
"Rs",
",",
"rho0",
")",
":",
"x",
"=",
"R",
"/",
"Rs",
"gx",
"=",
"self",
".",
"g_",
"(",
"x",
")",
"m_2d",
"=",
"4",
"*",
"rho0",
"*",
"Rs",
"*",
"R",
"**",
"2",
"*",
"gx",
"/",
"x",
"**",
... | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r",
":",
"param",
"r",
":",
":",
"param",
"Ra",
":",
":",
"param",
"Rs",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L145-L156 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.F_ | def F_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_F_interp'):
if self._lookup:
x = self._x_lookup
F_x = self._f_lookup
else:
... | python | def F_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_F_interp'):
if self._lookup:
x = self._x_lookup
F_x = self._f_lookup
else:
... | [
"def",
"F_",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"_interpol",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_F_interp'",
")",
":",
"if",
"self",
".",
"_lookup",
":",
"x",
"=",
"self",
".",
"_x_lookup",
"F_x",
"=",
"self",
".",
... | computes h()
:param X:
:return: | [
"computes",
"h",
"()"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L231-L251 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW._F | def _F(self, X):
"""
analytic solution of the projection integral
:param x: R/Rs
:type x: float >0
"""
if isinstance(X, int) or isinstance(X, float):
if X < 1 and X > 0:
a = 1/(X**2-1)*(1-2/np.sqrt(1-X**2)*np.arctanh(np.sqrt((1-X)/(1+X))))
... | python | def _F(self, X):
"""
analytic solution of the projection integral
:param x: R/Rs
:type x: float >0
"""
if isinstance(X, int) or isinstance(X, float):
if X < 1 and X > 0:
a = 1/(X**2-1)*(1-2/np.sqrt(1-X**2)*np.arctanh(np.sqrt((1-X)/(1+X))))
... | [
"def",
"_F",
"(",
"self",
",",
"X",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"int",
")",
"or",
"isinstance",
"(",
"X",
",",
"float",
")",
":",
"if",
"X",
"<",
"1",
"and",
"X",
">",
"0",
":",
"a",
"=",
"1",
"/",
"(",
"X",
"**",
"2",
... | analytic solution of the projection integral
:param x: R/Rs
:type x: float >0 | [
"analytic",
"solution",
"of",
"the",
"projection",
"integral"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L253-L284 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.g_ | def g_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_g_interp'):
if self._lookup:
x = self._x_lookup
g_x = self._g_lookup
else:
... | python | def g_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_g_interp'):
if self._lookup:
x = self._x_lookup
g_x = self._g_lookup
else:
... | [
"def",
"g_",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"_interpol",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_g_interp'",
")",
":",
"if",
"self",
".",
"_lookup",
":",
"x",
"=",
"self",
".",
"_x_lookup",
"g_x",
"=",
"self",
".",
... | computes h()
:param X:
:return: | [
"computes",
"h",
"()"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L286-L306 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW.h_ | def h_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_h_interp'):
if self._lookup:
x = self._x_lookup
h_x = self._h_lookup
else:
... | python | def h_(self, X):
"""
computes h()
:param X:
:return:
"""
if self._interpol:
if not hasattr(self, '_h_interp'):
if self._lookup:
x = self._x_lookup
h_x = self._h_lookup
else:
... | [
"def",
"h_",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"_interpol",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_h_interp'",
")",
":",
"if",
"self",
".",
"_lookup",
":",
"x",
"=",
"self",
".",
"_x_lookup",
"h_x",
"=",
"self",
".",
... | computes h()
:param X:
:return: | [
"computes",
"h",
"()"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L337-L357 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW._alpha2rho0 | def _alpha2rho0(self, theta_Rs, Rs):
"""
convert angle at Rs into rho0
"""
rho0 = theta_Rs / (4. * Rs ** 2 * (1. + np.log(1. / 2.)))
return rho0 | python | def _alpha2rho0(self, theta_Rs, Rs):
"""
convert angle at Rs into rho0
"""
rho0 = theta_Rs / (4. * Rs ** 2 * (1. + np.log(1. / 2.)))
return rho0 | [
"def",
"_alpha2rho0",
"(",
"self",
",",
"theta_Rs",
",",
"Rs",
")",
":",
"rho0",
"=",
"theta_Rs",
"/",
"(",
"4.",
"*",
"Rs",
"**",
"2",
"*",
"(",
"1.",
"+",
"np",
".",
"log",
"(",
"1.",
"/",
"2.",
")",
")",
")",
"return",
"rho0"
] | convert angle at Rs into rho0 | [
"convert",
"angle",
"at",
"Rs",
"into",
"rho0"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L383-L390 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nfw.py | NFW._rho02alpha | def _rho02alpha(self, rho0, Rs):
"""
convert rho0 to angle at Rs
:param rho0:
:param Rs:
:return:
"""
theta_Rs = rho0 * (4 * Rs ** 2 * (1 + np.log(1. / 2.)))
return theta_Rs | python | def _rho02alpha(self, rho0, Rs):
"""
convert rho0 to angle at Rs
:param rho0:
:param Rs:
:return:
"""
theta_Rs = rho0 * (4 * Rs ** 2 * (1 + np.log(1. / 2.)))
return theta_Rs | [
"def",
"_rho02alpha",
"(",
"self",
",",
"rho0",
",",
"Rs",
")",
":",
"theta_Rs",
"=",
"rho0",
"*",
"(",
"4",
"*",
"Rs",
"**",
"2",
"*",
"(",
"1",
"+",
"np",
".",
"log",
"(",
"1.",
"/",
"2.",
")",
")",
")",
"return",
"theta_Rs"
] | convert rho0 to angle at Rs
:param rho0:
:param Rs:
:return: | [
"convert",
"rho0",
"to",
"angle",
"at",
"Rs"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nfw.py#L392-L403 |
sibirrer/lenstronomy | lenstronomy/LightModel/light_model.py | LightModel.param_name_list | def param_name_list(self):
"""
returns the list of all parameter names
:return: list of list of strings (for each light model separately)
"""
name_list = []
for func in self.func_list:
name_list.append(func.param_names)
return name_list | python | def param_name_list(self):
"""
returns the list of all parameter names
:return: list of list of strings (for each light model separately)
"""
name_list = []
for func in self.func_list:
name_list.append(func.param_names)
return name_list | [
"def",
"param_name_list",
"(",
"self",
")",
":",
"name_list",
"=",
"[",
"]",
"for",
"func",
"in",
"self",
".",
"func_list",
":",
"name_list",
".",
"append",
"(",
"func",
".",
"param_names",
")",
"return",
"name_list"
] | returns the list of all parameter names
:return: list of list of strings (for each light model separately) | [
"returns",
"the",
"list",
"of",
"all",
"parameter",
"names"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/light_model.py#L90-L99 |
sibirrer/lenstronomy | lenstronomy/LightModel/light_model.py | LightModel.surface_brightness | def surface_brightness(self, x, y, kwargs_list, k=None):
"""
:param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array
"""
x = np.array(x, dtype=float)
y = np.array(y, dtype=float)
flux = np.zeros_like(x)
... | python | def surface_brightness(self, x, y, kwargs_list, k=None):
"""
:param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array
"""
x = np.array(x, dtype=float)
y = np.array(y, dtype=float)
flux = np.zeros_like(x)
... | [
"def",
"surface_brightness",
"(",
"self",
",",
"x",
",",
"y",
",",
"kwargs_list",
",",
"k",
"=",
"None",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
",",
"dtype",
"=",
"float",
")",
"y",
"=",
"np",
".",
"array",
"(",
"y",
",",
"dtype",
... | :param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array | [
":",
"param",
"x",
":",
"coordinate",
"in",
"units",
"of",
"arcsec",
"relative",
"to",
"the",
"center",
"of",
"the",
"image",
":",
"type",
"x",
":",
"set",
"or",
"single",
"1d",
"numpy",
"array"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/light_model.py#L101-L113 |
sibirrer/lenstronomy | lenstronomy/LightModel/light_model.py | LightModel.light_3d | def light_3d(self, r, kwargs_list, k=None):
"""
computes 3d density at radius r
:param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array
"""
r = np.array(r, dtype=float)
flux = np.zeros_like(r)
for i... | python | def light_3d(self, r, kwargs_list, k=None):
"""
computes 3d density at radius r
:param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array
"""
r = np.array(r, dtype=float)
flux = np.zeros_like(r)
for i... | [
"def",
"light_3d",
"(",
"self",
",",
"r",
",",
"kwargs_list",
",",
"k",
"=",
"None",
")",
":",
"r",
"=",
"np",
".",
"array",
"(",
"r",
",",
"dtype",
"=",
"float",
")",
"flux",
"=",
"np",
".",
"zeros_like",
"(",
"r",
")",
"for",
"i",
",",
"fun... | computes 3d density at radius r
:param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array | [
"computes",
"3d",
"density",
"at",
"radius",
"r",
":",
"param",
"x",
":",
"coordinate",
"in",
"units",
"of",
"arcsec",
"relative",
"to",
"the",
"center",
"of",
"the",
"image",
":",
"type",
"x",
":",
"set",
"or",
"single",
"1d",
"numpy",
"array"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/light_model.py#L115-L133 |
sibirrer/lenstronomy | lenstronomy/LightModel/light_model.py | LightModel.total_flux | def total_flux(self, kwargs_list, norm=False, k=None):
"""
Computes the total flux of each individual light profile. This allows to estimate the total flux as
well as lenstronomy amp to magnitude conversions. Not all models are supported
:param kwargs_list: list of keyword arguments cor... | python | def total_flux(self, kwargs_list, norm=False, k=None):
"""
Computes the total flux of each individual light profile. This allows to estimate the total flux as
well as lenstronomy amp to magnitude conversions. Not all models are supported
:param kwargs_list: list of keyword arguments cor... | [
"def",
"total_flux",
"(",
"self",
",",
"kwargs_list",
",",
"norm",
"=",
"False",
",",
"k",
"=",
"None",
")",
":",
"norm_flux_list",
"=",
"[",
"]",
"for",
"i",
",",
"model",
"in",
"enumerate",
"(",
"self",
".",
"profile_type_list",
")",
":",
"if",
"k"... | Computes the total flux of each individual light profile. This allows to estimate the total flux as
well as lenstronomy amp to magnitude conversions. Not all models are supported
:param kwargs_list: list of keyword arguments corresponding to the light profiles. The 'amp' parameter can be missing.
... | [
"Computes",
"the",
"total",
"flux",
"of",
"each",
"individual",
"light",
"profile",
".",
"This",
"allows",
"to",
"estimate",
"the",
"total",
"flux",
"as",
"well",
"as",
"lenstronomy",
"amp",
"to",
"magnitude",
"conversions",
".",
"Not",
"all",
"models",
"are... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LightModel/light_model.py#L246-L274 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic_utils.py | SersicUtil.k_bn | def k_bn(self, n, Re):
"""
returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope
"""
bn = self.b_n(n)
k = bn*Re**(-1./n)
return k, bn | python | def k_bn(self, n, Re):
"""
returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope
"""
bn = self.b_n(n)
k = bn*Re**(-1./n)
return k, bn | [
"def",
"k_bn",
"(",
"self",
",",
"n",
",",
"Re",
")",
":",
"bn",
"=",
"self",
".",
"b_n",
"(",
"n",
")",
"k",
"=",
"bn",
"*",
"Re",
"**",
"(",
"-",
"1.",
"/",
"n",
")",
"return",
"k",
",",
"bn"
] | returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope | [
"returns",
"normalisation",
"of",
"the",
"sersic",
"profile",
"such",
"that",
"Re",
"is",
"the",
"half",
"light",
"radius",
"given",
"n_sersic",
"slope"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sersic_utils.py#L13-L19 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic_utils.py | SersicUtil._x_reduced | def _x_reduced(self, x, y, n_sersic, r_eff, center_x, center_y):
"""
coordinate transform to normalized radius
:param x:
:param y:
:param center_x:
:param center_y:
:return:
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 ... | python | def _x_reduced(self, x, y, n_sersic, r_eff, center_x, center_y):
"""
coordinate transform to normalized radius
:param x:
:param y:
:param center_x:
:param center_y:
:return:
"""
x_ = x - center_x
y_ = y - center_y
r = np.sqrt(x_**2 ... | [
"def",
"_x_reduced",
"(",
"self",
",",
"x",
",",
"y",
",",
"n_sersic",
",",
"r_eff",
",",
"center_x",
",",
"center_y",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",
".",
"sqrt",
"(",
"x_",
"**",
"2"... | coordinate transform to normalized radius
:param x:
:param y:
:param center_x:
:param center_y:
:return: | [
"coordinate",
"transform",
"to",
"normalized",
"radius",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"center_x",
":",
":",
"param",
"center_y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sersic_utils.py#L39-L56 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic_utils.py | SersicUtil._alpha_eff | def _alpha_eff(self, r_eff, n_sersic, k_eff):
"""
deflection angle at r_eff
:param r_eff:
:param n_sersic:
:param k_eff:
:return:
"""
b = self.b_n(n_sersic)
alpha_eff = n_sersic * r_eff * k_eff * b**(-2*n_sersic) * np.exp(b) * special.gamma(2*n_ser... | python | def _alpha_eff(self, r_eff, n_sersic, k_eff):
"""
deflection angle at r_eff
:param r_eff:
:param n_sersic:
:param k_eff:
:return:
"""
b = self.b_n(n_sersic)
alpha_eff = n_sersic * r_eff * k_eff * b**(-2*n_sersic) * np.exp(b) * special.gamma(2*n_ser... | [
"def",
"_alpha_eff",
"(",
"self",
",",
"r_eff",
",",
"n_sersic",
",",
"k_eff",
")",
":",
"b",
"=",
"self",
".",
"b_n",
"(",
"n_sersic",
")",
"alpha_eff",
"=",
"n_sersic",
"*",
"r_eff",
"*",
"k_eff",
"*",
"b",
"**",
"(",
"-",
"2",
"*",
"n_sersic",
... | deflection angle at r_eff
:param r_eff:
:param n_sersic:
:param k_eff:
:return: | [
"deflection",
"angle",
"at",
"r_eff",
":",
"param",
"r_eff",
":",
":",
"param",
"n_sersic",
":",
":",
"param",
"k_eff",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sersic_utils.py#L58-L68 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic_utils.py | SersicUtil.density | def density(self, x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0):
"""
de-projection of the Sersic profile based on
Prugniel & Simien (1997)
:return:
"""
raise ValueError("not implemented! Use a Multi-Gaussian-component decomposition.") | python | def density(self, x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0):
"""
de-projection of the Sersic profile based on
Prugniel & Simien (1997)
:return:
"""
raise ValueError("not implemented! Use a Multi-Gaussian-component decomposition.") | [
"def",
"density",
"(",
"self",
",",
"x",
",",
"y",
",",
"n_sersic",
",",
"r_eff",
",",
"k_eff",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"\"not implemented! Use a Multi-Gaussian-component decomposition.\"",
")... | de-projection of the Sersic profile based on
Prugniel & Simien (1997)
:return: | [
"de",
"-",
"projection",
"of",
"the",
"Sersic",
"profile",
"based",
"on",
"Prugniel",
"&",
"Simien",
"(",
"1997",
")",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sersic_utils.py#L110-L116 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic_utils.py | SersicUtil._total_flux | def _total_flux(self, r_eff, I_eff, n_sersic):
"""
computes total flux of a Sersic profile
:param r_eff: projected half light radius
:param I_eff: surface brightness at r_eff (in same units as r_eff)
:param n_sersic: Sersic index
:return: integrated flux to infinity
... | python | def _total_flux(self, r_eff, I_eff, n_sersic):
"""
computes total flux of a Sersic profile
:param r_eff: projected half light radius
:param I_eff: surface brightness at r_eff (in same units as r_eff)
:param n_sersic: Sersic index
:return: integrated flux to infinity
... | [
"def",
"_total_flux",
"(",
"self",
",",
"r_eff",
",",
"I_eff",
",",
"n_sersic",
")",
":",
"bn",
"=",
"self",
".",
"b_n",
"(",
"n_sersic",
")",
"return",
"I_eff",
"*",
"r_eff",
"**",
"2",
"*",
"2",
"*",
"np",
".",
"pi",
"*",
"n_sersic",
"*",
"np",... | computes total flux of a Sersic profile
:param r_eff: projected half light radius
:param I_eff: surface brightness at r_eff (in same units as r_eff)
:param n_sersic: Sersic index
:return: integrated flux to infinity | [
"computes",
"total",
"flux",
"of",
"a",
"Sersic",
"profile"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/sersic_utils.py#L118-L128 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.function | def function(self, x, y, theta_E, gamma, 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 float
... | python | def function(self, x, y, theta_E, gamma, 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 float
... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"gamma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"gamma",
"=",
"self",
".",
"_gamma_limit",
"(",
"gamma",
")",
"x_",
"=",
"x",
"-",
"center_x",
"y_",... | :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/spp.py#L16-L41 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.rho2theta | def rho2theta(self, rho0, gamma):
"""
converts 3d density into 2d projected density parameter
:param rho0:
:param gamma:
:return:
"""
fac = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * 2 / (3 - gamma) * rho0
#fac = t... | python | def rho2theta(self, rho0, gamma):
"""
converts 3d density into 2d projected density parameter
:param rho0:
:param gamma:
:return:
"""
fac = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * 2 / (3 - gamma) * rho0
#fac = t... | [
"def",
"rho2theta",
"(",
"self",
",",
"rho0",
",",
"gamma",
")",
":",
"fac",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
"*",
"special",
".",
"gamma",
"(",
"1.",
"/",
"2",
"*",
"(",
"-",
"1",
"+",
"gamma",
")",
")",
"/",
"special",
"... | converts 3d density into 2d projected density parameter
:param rho0:
:param gamma:
:return: | [
"converts",
"3d",
"density",
"into",
"2d",
"projected",
"density",
"parameter",
":",
"param",
"rho0",
":",
":",
"param",
"gamma",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L98-L109 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.theta2rho | def theta2rho(self, theta_E, gamma):
"""
converts projected density parameter (in units of deflection) into 3d density parameter
:param theta_E:
:param gamma:
:return:
"""
fac1 = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * 2... | python | def theta2rho(self, theta_E, gamma):
"""
converts projected density parameter (in units of deflection) into 3d density parameter
:param theta_E:
:param gamma:
:return:
"""
fac1 = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * 2... | [
"def",
"theta2rho",
"(",
"self",
",",
"theta_E",
",",
"gamma",
")",
":",
"fac1",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
"*",
"special",
".",
"gamma",
"(",
"1.",
"/",
"2",
"*",
"(",
"-",
"1",
"+",
"gamma",
")",
")",
"/",
"special",... | converts projected density parameter (in units of deflection) into 3d density parameter
:param theta_E:
:param gamma:
:return: | [
"converts",
"projected",
"density",
"parameter",
"(",
"in",
"units",
"of",
"deflection",
")",
"into",
"3d",
"density",
"parameter",
":",
"param",
"theta_E",
":",
":",
"param",
"gamma",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L111-L121 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.mass_3d | def mass_3d(self, r, rho0, gamma):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param a:
:param s:
:return:
"""
mass_3d = 4 * np.pi * rho0 /(-gamma + 3) * r ** (-gamma + 3)
return mass_3d | python | def mass_3d(self, r, rho0, gamma):
"""
mass enclosed a 3d sphere or radius r
:param r:
:param a:
:param s:
:return:
"""
mass_3d = 4 * np.pi * rho0 /(-gamma + 3) * r ** (-gamma + 3)
return mass_3d | [
"def",
"mass_3d",
"(",
"self",
",",
"r",
",",
"rho0",
",",
"gamma",
")",
":",
"mass_3d",
"=",
"4",
"*",
"np",
".",
"pi",
"*",
"rho0",
"/",
"(",
"-",
"gamma",
"+",
"3",
")",
"*",
"r",
"**",
"(",
"-",
"gamma",
"+",
"3",
")",
"return",
"mass_3... | mass enclosed a 3d sphere or radius r
:param r:
:param a:
:param s:
:return: | [
"mass",
"enclosed",
"a",
"3d",
"sphere",
"or",
"radius",
"r",
":",
"param",
"r",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L123-L132 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.mass_2d | def mass_2d(self, r, rho0, gamma):
"""
mass enclosed projected 2d sphere of radius r
:param r:
:param rho0:
:param a:
:param s:
:return:
"""
alpha = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * r ** (2 - gamma... | python | def mass_2d(self, r, rho0, gamma):
"""
mass enclosed projected 2d sphere of radius r
:param r:
:param rho0:
:param a:
:param s:
:return:
"""
alpha = np.sqrt(np.pi) * special.gamma(1. / 2 * (-1 + gamma)) / special.gamma(gamma / 2.) * r ** (2 - gamma... | [
"def",
"mass_2d",
"(",
"self",
",",
"r",
",",
"rho0",
",",
"gamma",
")",
":",
"alpha",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
"*",
"special",
".",
"gamma",
"(",
"1.",
"/",
"2",
"*",
"(",
"-",
"1",
"+",
"gamma",
")",
")",
"/",
... | mass enclosed projected 2d sphere of radius r
:param r:
:param rho0:
:param a:
:param s:
:return: | [
"mass",
"enclosed",
"projected",
"2d",
"sphere",
"of",
"radius",
"r",
":",
"param",
"r",
":",
":",
"param",
"rho0",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L145-L156 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.grav_pot | def grav_pot(self, x, y, rho0, gamma, center_x=0, center_y=0):
"""
gravitational potential (modulo 4 pi G and rho0 in appropriate units)
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return:
... | python | def grav_pot(self, x, y, rho0, gamma, center_x=0, center_y=0):
"""
gravitational potential (modulo 4 pi G and rho0 in appropriate units)
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return:
... | [
"def",
"grav_pot",
"(",
"self",
",",
"x",
",",
"y",
",",
"rho0",
",",
"gamma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",
".",
"sqrt",
"(",... | gravitational potential (modulo 4 pi G and rho0 in appropriate units)
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return: | [
"gravitational",
"potential",
"(",
"modulo",
"4",
"pi",
"G",
"and",
"rho0",
"in",
"appropriate",
"units",
")",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"rho0",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"param",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L169-L186 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.density | def density(self, r, rho0, gamma):
"""
computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return:
"""
rho = rho0 / r**gamma
return rho | python | def density(self, r, rho0, gamma):
"""
computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return:
"""
rho = rho0 / r**gamma
return rho | [
"def",
"density",
"(",
"self",
",",
"r",
",",
"rho0",
",",
"gamma",
")",
":",
"rho",
"=",
"rho0",
"/",
"r",
"**",
"gamma",
"return",
"rho"
] | computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return: | [
"computes",
"the",
"density",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"rho0",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L188-L199 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/spp.py | SPP.density_2d | def density_2d(self, x, y, rho0, gamma, center_x=0, center_y=0):
"""
projected density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return:
"""
x_ = x - center_x
y_ = y - ce... | python | def density_2d(self, x, y, rho0, gamma, center_x=0, center_y=0):
"""
projected density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return:
"""
x_ = x - center_x
y_ = y - ce... | [
"def",
"density_2d",
"(",
"self",
",",
"x",
",",
"y",
",",
"rho0",
",",
"gamma",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",
".",
"sqrt",
"(... | projected density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return: | [
"projected",
"density",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"param",
"rho0",
":",
":",
"param",
"a",
":",
":",
"param",
"s",
":",
":",
"param",
"center_x",
":",
":",
"param",
"center_y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/spp.py#L201-L217 |
sibirrer/lenstronomy | lenstronomy/GalKin/galkin.py | Galkin.vel_disp | def vel_disp(self, kwargs_mass, kwargs_light, kwargs_anisotropy, kwargs_apertur):
"""
computes the averaged LOS velocity dispersion in the slit (convolved)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light param... | python | def vel_disp(self, kwargs_mass, kwargs_light, kwargs_anisotropy, kwargs_apertur):
"""
computes the averaged LOS velocity dispersion in the slit (convolved)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light param... | [
"def",
"vel_disp",
"(",
"self",
",",
"kwargs_mass",
",",
"kwargs_light",
",",
"kwargs_anisotropy",
",",
"kwargs_apertur",
")",
":",
"sigma2_R_sum",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"_num_sampling",
")",
":",
"sigma2_R",
"=",... | computes the averaged LOS velocity dispersion in the slit (convolved)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light parameters (following lenstronomy light model conventions)
:param kwargs_anisotropy: anisotropy par... | [
"computes",
"the",
"averaged",
"LOS",
"velocity",
"dispersion",
"in",
"the",
"slit",
"(",
"convolved",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/galkin.py#L80-L99 |
sibirrer/lenstronomy | lenstronomy/GalKin/galkin.py | Galkin.sigma2_R | def sigma2_R(self, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
returns unweighted los velocity dispersion for a specified projected radius
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
... | python | def sigma2_R(self, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
returns unweighted los velocity dispersion for a specified projected radius
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
... | [
"def",
"sigma2_R",
"(",
"self",
",",
"R",
",",
"kwargs_mass",
",",
"kwargs_light",
",",
"kwargs_anisotropy",
")",
":",
"I_R_sigma2",
"=",
"self",
".",
"I_R_simga2",
"(",
"R",
",",
"kwargs_mass",
",",
"kwargs_light",
",",
"kwargs_anisotropy",
")",
"I_R",
"=",... | returns unweighted los velocity dispersion for a specified projected radius
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light parameters (following lenstronomy light mode... | [
"returns",
"unweighted",
"los",
"velocity",
"dispersion",
"for",
"a",
"specified",
"projected",
"radius"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/galkin.py#L123-L136 |
sibirrer/lenstronomy | lenstronomy/GalKin/galkin.py | Galkin.I_R_simga2 | def I_R_simga2(self, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
equation A15 in Mamon&Lokas 2005 as a logarithmic numerical integral (if option is chosen)
modulo pre-factor 2*G
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters ... | python | def I_R_simga2(self, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
equation A15 in Mamon&Lokas 2005 as a logarithmic numerical integral (if option is chosen)
modulo pre-factor 2*G
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters ... | [
"def",
"I_R_simga2",
"(",
"self",
",",
"R",
",",
"kwargs_mass",
",",
"kwargs_light",
",",
"kwargs_anisotropy",
")",
":",
"R",
"=",
"max",
"(",
"R",
",",
"self",
".",
"_min_integrate",
")",
"if",
"self",
".",
"_log_int",
"is",
"True",
":",
"min_log",
"=... | equation A15 in Mamon&Lokas 2005 as a logarithmic numerical integral (if option is chosen)
modulo pre-factor 2*G
:param R: 2d projected radius (in angular units)
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light... | [
"equation",
"A15",
"in",
"Mamon&Lokas",
"2005",
"as",
"a",
"logarithmic",
"numerical",
"integral",
"(",
"if",
"option",
"is",
"chosen",
")",
"modulo",
"pre",
"-",
"factor",
"2",
"*",
"G"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/galkin.py#L138-L162 |
sibirrer/lenstronomy | lenstronomy/GalKin/galkin.py | Galkin._integrand_A15 | def _integrand_A15(self, r, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
integrand of A15 (in log space) in Mamon&Lokas 2005
:param r: 3d radius
:param R: 2d projected radius
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
... | python | def _integrand_A15(self, r, R, kwargs_mass, kwargs_light, kwargs_anisotropy):
"""
integrand of A15 (in log space) in Mamon&Lokas 2005
:param r: 3d radius
:param R: 2d projected radius
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
... | [
"def",
"_integrand_A15",
"(",
"self",
",",
"r",
",",
"R",
",",
"kwargs_mass",
",",
"kwargs_light",
",",
"kwargs_anisotropy",
")",
":",
"k_r",
"=",
"self",
".",
"anisotropy",
".",
"K",
"(",
"r",
",",
"R",
",",
"kwargs_anisotropy",
")",
"l_r",
"=",
"self... | integrand of A15 (in log space) in Mamon&Lokas 2005
:param r: 3d radius
:param R: 2d projected radius
:param kwargs_mass: mass model parameters (following lenstronomy lens model conventions)
:param kwargs_light: deflector light parameters (following lenstronomy light model conventions)
... | [
"integrand",
"of",
"A15",
"(",
"in",
"log",
"space",
")",
"in",
"Mamon&Lokas",
"2005"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/GalKin/galkin.py#L164-L180 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic.py | Sersic.derivatives | def derivatives(self, x, y, n_sersic, R_sersic, k_eff, 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)
if isinstance(r, int) or isinstance(r, float):
r = max(self._... | python | def derivatives(self, x, y, n_sersic, R_sersic, k_eff, 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)
if isinstance(r, int) or isinstance(r, float):
r = max(self._... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"n_sersic",
",",
"R_sersic",
",",
"k_eff",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"... | 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/sersic.py#L39-L53 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/sersic.py | Sersic.hessian | def hessian(self, x, y, n_sersic, R_sersic, k_eff, 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)
if isinstance(r, int) or isinstance(r, float):
... | python | def hessian(self, x, y, n_sersic, R_sersic, k_eff, 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)
if isinstance(r, int) or isinstance(r, float):
... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"n_sersic",
",",
"R_sersic",
",",
"k_eff",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"center_x",
"y_",
"=",
"y",
"-",
"center_y",
"r",
"=",
"np",... | 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/sersic.py#L55-L77 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nie.py | NIE_simple.derivatives | def derivatives(self, x, y, theta_E, s, q):
"""
returns df/dx and df/dy of the function
"""
if q >= 1:
q = 0.999999
psi = self._psi(x, y, q, s)
f_x = theta_E / np.sqrt(1. - q ** 2) * np.arctan(np.sqrt(1. - q ** 2) * x / (psi+s))
f_y = theta_E / np.sqrt... | python | def derivatives(self, x, y, theta_E, s, q):
"""
returns df/dx and df/dy of the function
"""
if q >= 1:
q = 0.999999
psi = self._psi(x, y, q, s)
f_x = theta_E / np.sqrt(1. - q ** 2) * np.arctan(np.sqrt(1. - q ** 2) * x / (psi+s))
f_y = theta_E / np.sqrt... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"s",
",",
"q",
")",
":",
"if",
"q",
">=",
"1",
":",
"q",
"=",
"0.999999",
"psi",
"=",
"self",
".",
"_psi",
"(",
"x",
",",
"y",
",",
"q",
",",
"s",
")",
"f_x",
"="... | 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/nie.py#L133-L142 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nie.py | NIE_simple.hessian | def hessian(self, x, y, theta_E, s, q):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
alpha_ra, alpha_dec = self.derivatives(x, y, theta_E, s, q)
diff = self._diff
alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, theta_E, s, q)
... | python | def hessian(self, x, y, theta_E, s, q):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
"""
alpha_ra, alpha_dec = self.derivatives(x, y, theta_E, s, q)
diff = self._diff
alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, theta_E, s, q)
... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"theta_E",
",",
"s",
",",
"q",
")",
":",
"alpha_ra",
",",
"alpha_dec",
"=",
"self",
".",
"derivatives",
"(",
"x",
",",
"y",
",",
"theta_E",
",",
"s",
",",
"q",
")",
"diff",
"=",
"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/nie.py#L144-L157 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/nie.py | NIE_simple._psi | def _psi(self, x, y, q, s):
"""
expression after equation (8) in Keeton&Kochanek 1998
:param x:
:param y:
:param q:
:param s:
:return:
"""
return np.sqrt(q**2 * (s**2 + x**2) + y**2) | python | def _psi(self, x, y, q, s):
"""
expression after equation (8) in Keeton&Kochanek 1998
:param x:
:param y:
:param q:
:param s:
:return:
"""
return np.sqrt(q**2 * (s**2 + x**2) + y**2) | [
"def",
"_psi",
"(",
"self",
",",
"x",
",",
"y",
",",
"q",
",",
"s",
")",
":",
"return",
"np",
".",
"sqrt",
"(",
"q",
"**",
"2",
"*",
"(",
"s",
"**",
"2",
"+",
"x",
"**",
"2",
")",
"+",
"y",
"**",
"2",
")"
] | expression after equation (8) in Keeton&Kochanek 1998
:param x:
:param y:
:param q:
:param s:
:return: | [
"expression",
"after",
"equation",
"(",
"8",
")",
"in",
"Keeton&Kochanek",
"1998"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/nie.py#L159-L169 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/convergence.py | Convergence.function | def function(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
lensing potential
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: lensing potential
"""
theta, phi = param_util.cart2polar(x - ra_0, y - dec_0)
... | python | def function(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
lensing potential
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: lensing potential
"""
theta, phi = param_util.cart2polar(x - ra_0, y - dec_0)
... | [
"def",
"function",
"(",
"self",
",",
"x",
",",
"y",
",",
"kappa_ext",
",",
"ra_0",
"=",
"0",
",",
"dec_0",
"=",
"0",
")",
":",
"theta",
",",
"phi",
"=",
"param_util",
".",
"cart2polar",
"(",
"x",
"-",
"ra_0",
",",
"y",
"-",
"dec_0",
")",
"f_",
... | lensing potential
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: lensing potential | [
"lensing",
"potential"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/convergence.py#L15-L26 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/convergence.py | Convergence.derivatives | def derivatives(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
deflection angle
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: deflection angles (first order derivatives)
"""
x_ = x - ra_0
y_ = y - dec_... | python | def derivatives(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
deflection angle
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: deflection angles (first order derivatives)
"""
x_ = x - ra_0
y_ = y - dec_... | [
"def",
"derivatives",
"(",
"self",
",",
"x",
",",
"y",
",",
"kappa_ext",
",",
"ra_0",
"=",
"0",
",",
"dec_0",
"=",
"0",
")",
":",
"x_",
"=",
"x",
"-",
"ra_0",
"y_",
"=",
"y",
"-",
"dec_0",
"f_x",
"=",
"kappa_ext",
"*",
"x_",
"f_y",
"=",
"kapp... | deflection angle
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: deflection angles (first order derivatives) | [
"deflection",
"angle"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/convergence.py#L28-L41 |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/convergence.py | Convergence.hessian | def hessian(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
Hessian matrix
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: second order derivatives f_xx, f_yy, f_xy
"""
gamma1 = 0
gamma2 = 0
kappa... | python | def hessian(self, x, y, kappa_ext, ra_0=0, dec_0=0):
"""
Hessian matrix
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: second order derivatives f_xx, f_yy, f_xy
"""
gamma1 = 0
gamma2 = 0
kappa... | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"kappa_ext",
",",
"ra_0",
"=",
"0",
",",
"dec_0",
"=",
"0",
")",
":",
"gamma1",
"=",
"0",
"gamma2",
"=",
"0",
"kappa",
"=",
"kappa_ext",
"f_xx",
"=",
"kappa",
"+",
"gamma1",
"f_yy",
"=",
"... | Hessian matrix
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: second order derivatives f_xx, f_yy, f_xy | [
"Hessian",
"matrix"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/convergence.py#L43-L58 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | map_coord2pix | def map_coord2pix(ra, dec, x_0, y_0, M):
"""
this routines performs a linear transformation between two coordinate systems. Mainly used to transform angular
into pixel coordinates in an image
:param ra: ra coordinates
:param dec: dec coordinates
:param x_0: pixel value in x-axis of ra,dec = 0,0
... | python | def map_coord2pix(ra, dec, x_0, y_0, M):
"""
this routines performs a linear transformation between two coordinate systems. Mainly used to transform angular
into pixel coordinates in an image
:param ra: ra coordinates
:param dec: dec coordinates
:param x_0: pixel value in x-axis of ra,dec = 0,0
... | [
"def",
"map_coord2pix",
"(",
"ra",
",",
"dec",
",",
"x_0",
",",
"y_0",
",",
"M",
")",
":",
"x",
",",
"y",
"=",
"M",
".",
"dot",
"(",
"np",
".",
"array",
"(",
"[",
"ra",
",",
"dec",
"]",
")",
")",
"return",
"x",
"+",
"x_0",
",",
"y",
"+",
... | this routines performs a linear transformation between two coordinate systems. Mainly used to transform angular
into pixel coordinates in an image
:param ra: ra coordinates
:param dec: dec coordinates
:param x_0: pixel value in x-axis of ra,dec = 0,0
:param y_0: pixel value in y-axis of ra,dec = 0,0... | [
"this",
"routines",
"performs",
"a",
"linear",
"transformation",
"between",
"two",
"coordinate",
"systems",
".",
"Mainly",
"used",
"to",
"transform",
"angular",
"into",
"pixel",
"coordinates",
"in",
"an",
"image",
":",
"param",
"ra",
":",
"ra",
"coordinates",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L88-L100 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | array2image | def array2image(array, nx=0, ny=0):
"""
returns the information contained in a 1d array into an n*n 2d array (only works when lenght of array is n**2)
:param array: image values
:type array: array of size n**2
:returns: 2d array
:raises: AttributeError, KeyError
"""
if nx == 0 or ny ==... | python | def array2image(array, nx=0, ny=0):
"""
returns the information contained in a 1d array into an n*n 2d array (only works when lenght of array is n**2)
:param array: image values
:type array: array of size n**2
:returns: 2d array
:raises: AttributeError, KeyError
"""
if nx == 0 or ny ==... | [
"def",
"array2image",
"(",
"array",
",",
"nx",
"=",
"0",
",",
"ny",
"=",
"0",
")",
":",
"if",
"nx",
"==",
"0",
"or",
"ny",
"==",
"0",
":",
"n",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"len",
"(",
"array",
")",
")",
")",
"if",
"n",
"**",
... | returns the information contained in a 1d array into an n*n 2d array (only works when lenght of array is n**2)
:param array: image values
:type array: array of size n**2
:returns: 2d array
:raises: AttributeError, KeyError | [
"returns",
"the",
"information",
"contained",
"in",
"a",
"1d",
"array",
"into",
"an",
"n",
"*",
"n",
"2d",
"array",
"(",
"only",
"works",
"when",
"lenght",
"of",
"array",
"is",
"n",
"**",
"2",
")"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L103-L118 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | image2array | def image2array(image):
"""
returns the information contained in a 2d array into an n*n 1d array
:param array: image values
:type array: array of size (n,n)
:returns: 1d array
:raises: AttributeError, KeyError
"""
nx, ny = image.shape # find the size of the array
imgh = np.reshape... | python | def image2array(image):
"""
returns the information contained in a 2d array into an n*n 1d array
:param array: image values
:type array: array of size (n,n)
:returns: 1d array
:raises: AttributeError, KeyError
"""
nx, ny = image.shape # find the size of the array
imgh = np.reshape... | [
"def",
"image2array",
"(",
"image",
")",
":",
"nx",
",",
"ny",
"=",
"image",
".",
"shape",
"# find the size of the array",
"imgh",
"=",
"np",
".",
"reshape",
"(",
"image",
",",
"nx",
"*",
"ny",
")",
"# change the shape to be 1d",
"return",
"imgh"
] | returns the information contained in a 2d array into an n*n 1d array
:param array: image values
:type array: array of size (n,n)
:returns: 1d array
:raises: AttributeError, KeyError | [
"returns",
"the",
"information",
"contained",
"in",
"a",
"2d",
"array",
"into",
"an",
"n",
"*",
"n",
"1d",
"array"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L121-L132 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | make_grid_transformed | def make_grid_transformed(numPix, Mpix2Angle):
"""
returns grid with linear transformation (deltaPix and rotation)
:param numPix: number of Pixels
:param Mpix2Angle: 2-by-2 matrix to mat a pixel to a coordinate
:return: coordinate grid
"""
x_grid, y_grid = make_grid(numPix, deltapix=1)
r... | python | def make_grid_transformed(numPix, Mpix2Angle):
"""
returns grid with linear transformation (deltaPix and rotation)
:param numPix: number of Pixels
:param Mpix2Angle: 2-by-2 matrix to mat a pixel to a coordinate
:return: coordinate grid
"""
x_grid, y_grid = make_grid(numPix, deltapix=1)
r... | [
"def",
"make_grid_transformed",
"(",
"numPix",
",",
"Mpix2Angle",
")",
":",
"x_grid",
",",
"y_grid",
"=",
"make_grid",
"(",
"numPix",
",",
"deltapix",
"=",
"1",
")",
"ra_grid",
",",
"dec_grid",
"=",
"map_coord2pix",
"(",
"x_grid",
",",
"y_grid",
",",
"0",
... | returns grid with linear transformation (deltaPix and rotation)
:param numPix: number of Pixels
:param Mpix2Angle: 2-by-2 matrix to mat a pixel to a coordinate
:return: coordinate grid | [
"returns",
"grid",
"with",
"linear",
"transformation",
"(",
"deltaPix",
"and",
"rotation",
")",
":",
"param",
"numPix",
":",
"number",
"of",
"Pixels",
":",
"param",
"Mpix2Angle",
":",
"2",
"-",
"by",
"-",
"2",
"matrix",
"to",
"mat",
"a",
"pixel",
"to",
... | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L158-L167 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | make_grid_with_coordtransform | def make_grid_with_coordtransform(numPix, deltapix, subgrid_res=1, left_lower=False, inverse=True):
"""
same as make_grid routine, but returns the transformaton matrix and shift between coordinates and pixel
:param numPix:
:param deltapix:
:param subgrid_res:
:param left_lower: sets the zero po... | python | def make_grid_with_coordtransform(numPix, deltapix, subgrid_res=1, left_lower=False, inverse=True):
"""
same as make_grid routine, but returns the transformaton matrix and shift between coordinates and pixel
:param numPix:
:param deltapix:
:param subgrid_res:
:param left_lower: sets the zero po... | [
"def",
"make_grid_with_coordtransform",
"(",
"numPix",
",",
"deltapix",
",",
"subgrid_res",
"=",
"1",
",",
"left_lower",
"=",
"False",
",",
"inverse",
"=",
"True",
")",
":",
"numPix_eff",
"=",
"numPix",
"*",
"subgrid_res",
"deltapix_eff",
"=",
"deltapix",
"/",... | same as make_grid routine, but returns the transformaton matrix and shift between coordinates and pixel
:param numPix:
:param deltapix:
:param subgrid_res:
:param left_lower: sets the zero point at the lower left corner of the pixels
:param inverse: bool, if true sets East as left, otherwise East i... | [
"same",
"as",
"make_grid",
"routine",
"but",
"returns",
"the",
"transformaton",
"matrix",
"and",
"shift",
"between",
"coordinates",
"and",
"pixel"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L170-L204 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | grid_from_coordinate_transform | def grid_from_coordinate_transform(numPix, Mpix2coord, ra_at_xy_0, dec_at_xy_0):
"""
return a grid in x and y coordinates that satisfy the coordinate system
:param numPix:
:param Mpix2coord:
:param ra_at_xy_0:
:param dec_at_xy_0:
:return:
"""
a = np.arange(numPix)
matrix = np.d... | python | def grid_from_coordinate_transform(numPix, Mpix2coord, ra_at_xy_0, dec_at_xy_0):
"""
return a grid in x and y coordinates that satisfy the coordinate system
:param numPix:
:param Mpix2coord:
:param ra_at_xy_0:
:param dec_at_xy_0:
:return:
"""
a = np.arange(numPix)
matrix = np.d... | [
"def",
"grid_from_coordinate_transform",
"(",
"numPix",
",",
"Mpix2coord",
",",
"ra_at_xy_0",
",",
"dec_at_xy_0",
")",
":",
"a",
"=",
"np",
".",
"arange",
"(",
"numPix",
")",
"matrix",
"=",
"np",
".",
"dstack",
"(",
"np",
".",
"meshgrid",
"(",
"a",
",",
... | return a grid in x and y coordinates that satisfy the coordinate system
:param numPix:
:param Mpix2coord:
:param ra_at_xy_0:
:param dec_at_xy_0:
:return: | [
"return",
"a",
"grid",
"in",
"x",
"and",
"y",
"coordinates",
"that",
"satisfy",
"the",
"coordinate",
"system"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L207-L224 |
sibirrer/lenstronomy | lenstronomy/Util/util.py | get_axes | def get_axes(x, y):
"""
computes the axis x and y of a given 2d grid
:param x:
:param y:
:return:
"""
n=int(np.sqrt(len(x)))
if n**2 != len(x):
raise ValueError("lenght of input array given as %s is not square of integer number!" % (len(x)))
x_image = x.reshape(n,n)
y_ima... | python | def get_axes(x, y):
"""
computes the axis x and y of a given 2d grid
:param x:
:param y:
:return:
"""
n=int(np.sqrt(len(x)))
if n**2 != len(x):
raise ValueError("lenght of input array given as %s is not square of integer number!" % (len(x)))
x_image = x.reshape(n,n)
y_ima... | [
"def",
"get_axes",
"(",
"x",
",",
"y",
")",
":",
"n",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"len",
"(",
"x",
")",
")",
")",
"if",
"n",
"**",
"2",
"!=",
"len",
"(",
"x",
")",
":",
"raise",
"ValueError",
"(",
"\"lenght of input array given as %s... | computes the axis x and y of a given 2d grid
:param x:
:param y:
:return: | [
"computes",
"the",
"axis",
"x",
"and",
"y",
"of",
"a",
"given",
"2d",
"grid",
":",
"param",
"x",
":",
":",
"param",
"y",
":",
":",
"return",
":"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/util.py#L227-L241 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.