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_documentation_string stringlengths 1 47.2k | 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
... | 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 | 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... | 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` | 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] | Releases sorted by version. | 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... | 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` | 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... | 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` | 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... | 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` | 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... | 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... | 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,
... | Get all local packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | 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,
... | Get all mirrored packages.
:param session: SQLAlchemy session
:type session: :class:`sqlalchemy.Session`
:return: package instances
:rtype: generator of :class:`pyshop.models.Package` | 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
... | 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... | 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... | 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` | 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... | 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... | 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... | 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
... | 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`
... | 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... | 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... | Add helpers to the template engine. | 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... | Pyramid includeme file for the :class:`pyramid.config.Configurator` | 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 | Retrieve a list of the package names registered with the package index.
Returns a list of name strings. | 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... | 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. | 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]
... | Retrieve a list of users and their attributes roles for a given
package_name. Role is either 'Maintainer' or 'Owner'. | 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) ... | Retrieve a list of [role_name, package_name] for a given username.
Role is either 'Maintainer' or 'Owner'. | 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... | Retrieve a list of files and download count for a given package and
release version. | 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
... | 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')... | 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
... | 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... | 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... | 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 ... | 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... | 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... | 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) | Create the proxy to PyPI XML-RPC Server | 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',
... | Make an xmlrpc request. | 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... | Authentification basic, Upload pyshop repository access | 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... | 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 | 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... | Download a release file.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict | 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()
... | 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 | 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') | Wrapper for b64decode, without having to struggle with bytestrings. | 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') | Wrapper for b64encode, without having to struggle with bytestrings. | 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... | 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: | 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... | returns 1d array of values in image in idex_mask
:param image:
:param idex_mask:
:return: | 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... | smaller frame that encolses all the idex_mask
:param idex_mask:
:param nx:
:param ny:
:return: | 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... | cutout the part of the image relevant for the psf convolution
:param image:
:return: | 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... | 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 | 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:... | 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: | 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, ... | 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... | 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... | 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 | 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... | 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) | 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... | 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... | 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:... | change the pixel size of a given kernel
:param kernel:
:param deltaPix_in:
:param deltaPix_out:
:return: | 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 | cut the psf properly
:param psf_data: image of PSF
:param psf_size: size of psf
:return: re-sized and re-normalized PSF | 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... | 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 | 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... | 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... | 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(... | 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: | 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... | computes the full width at half maximum of a (PSF) kernel
:param kernel: (psf) kernel, 2d numpy array
:return: fwhm in units of pixels | 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... | estimates the amplitude of a point source located at x_pos, y_pos
:param data:
:param x_pos:
:param y_pos:
:param deltaPix:
:return: | 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... | constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return: | 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... | constructs the CDF and draws from it random realizations of projected radii R
:param kwargs_list:
:return: | 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... | returns df/dx and df/dy of the function (integral of NFW) | 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... | 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 | 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... | 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... | 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 | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | 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 | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | 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 | mass enclosed a 3d sphere or radius r
:param r:
:param Ra:
:param Rs:
:return: | 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:
... | computes h()
:param X:
:return: | 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))))
... | analytic solution of the projection integral
:param x: R/Rs
:type x: float >0 | 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:
... | computes h()
:param X:
:return: | 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:
... | computes h()
:param X:
:return: | 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 | convert angle at Rs into rho0 | 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 | convert rho0 to angle at Rs
:param rho0:
:param Rs:
:return: | 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 | returns the list of all parameter names
:return: list of list of strings (for each light model separately) | 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)
... | :param x: coordinate in units of arcsec relative to the center of the image
:type x: set or single 1d numpy array | 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... | 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 | 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... | 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.
... | 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 | returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope | 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 ... | coordinate transform to normalized radius
:param x:
:param y:
:param center_x:
:param center_y:
:return: | 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... | deflection angle at r_eff
:param r_eff:
:param n_sersic:
:param k_eff:
:return: | 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.") | de-projection of the Sersic profile based on
Prugniel & Simien (1997)
:return: | 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
... | 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 | 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
... | :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... | 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... | converts 3d density into 2d projected density parameter
:param rho0:
:param gamma:
:return: | 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... | converts projected density parameter (in units of deflection) into 3d density parameter
:param theta_E:
:param gamma:
:return: | 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 | mass enclosed a 3d sphere or radius r
:param r:
:param a:
:param s:
:return: | 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... | mass enclosed projected 2d sphere of radius r
:param r:
:param rho0:
:param a:
:param s:
:return: | 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:
... | 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: | 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 | computes the density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:return: | 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... | projected density
:param x:
:param y:
:param rho0:
:param a:
:param s:
:param center_x:
:param center_y:
:return: | 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... | 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... | 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)
... | 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... | 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 ... | 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... | 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)
... | 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)
... | 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._... | returns df/dx and df/dy of the function | 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):
... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | 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... | returns df/dx and df/dy of the function | 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)
... | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy | 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) | expression after equation (8) in Keeton&Kochanek 1998
:param x:
:param y:
:param q:
:param s:
:return: | 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)
... | lensing potential
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: lensing potential | 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_... | deflection angle
:param x: x-coordinate
:param y: y-coordinate
:param kappa_ext: external convergence
:return: deflection angles (first order derivatives) | 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... | 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 | 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
... | 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... | 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 ==... | 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 | 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... | 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 | 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... | 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 | 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... | 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... | 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... | 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: | 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... | computes the axis x and y of a given 2d grid
:param x:
:param y:
:return: | 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.