id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
10,600
astropy/photutils
photutils/segmentation/core.py
SegmentationImage.remove_masked_labels
def remove_masked_labels(self, mask, partial_overlap=True, relabel=False): """ Remove labeled segments located within a masked region. Parameters ---------- mask : array_like (bool) A boolean mask, with the same shape as the segmentation ...
python
def remove_masked_labels(self, mask, partial_overlap=True, relabel=False): """ Remove labeled segments located within a masked region. Parameters ---------- mask : array_like (bool) A boolean mask, with the same shape as the segmentation ...
[ "def", "remove_masked_labels", "(", "self", ",", "mask", ",", "partial_overlap", "=", "True", ",", "relabel", "=", "False", ")", ":", "if", "mask", ".", "shape", "!=", "self", ".", "shape", ":", "raise", "ValueError", "(", "'mask must have the same shape as th...
Remove labeled segments located within a masked region. Parameters ---------- mask : array_like (bool) A boolean mask, with the same shape as the segmentation image, where `True` values indicate masked pixels. partial_overlap : bool, optional If this...
[ "Remove", "labeled", "segments", "located", "within", "a", "masked", "region", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/core.py#L1090-L1155
10,601
astropy/photutils
photutils/segmentation/core.py
SegmentationImage.outline_segments
def outline_segments(self, mask_background=False): """ Outline the labeled segments. The "outlines" represent the pixels *just inside* the segments, leaving the background pixels unmodified. Parameters ---------- mask_background : bool, optional Set ...
python
def outline_segments(self, mask_background=False): """ Outline the labeled segments. The "outlines" represent the pixels *just inside* the segments, leaving the background pixels unmodified. Parameters ---------- mask_background : bool, optional Set ...
[ "def", "outline_segments", "(", "self", ",", "mask_background", "=", "False", ")", ":", "from", "scipy", ".", "ndimage", "import", "grey_erosion", ",", "grey_dilation", "# mode='constant' ensures outline is included on the image borders", "selem", "=", "np", ".", "array...
Outline the labeled segments. The "outlines" represent the pixels *just inside* the segments, leaving the background pixels unmodified. Parameters ---------- mask_background : bool, optional Set to `True` to mask the background pixels (labels = 0) in the...
[ "Outline", "the", "labeled", "segments", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/core.py#L1157-L1213
10,602
astropy/photutils
photutils/aperture/mask.py
ApertureMask._overlap_slices
def _overlap_slices(self, shape): """ Calculate the slices for the overlapping part of the bounding box and an array of the given shape. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of array where the slices are to be applied....
python
def _overlap_slices(self, shape): """ Calculate the slices for the overlapping part of the bounding box and an array of the given shape. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of array where the slices are to be applied....
[ "def", "_overlap_slices", "(", "self", ",", "shape", ")", ":", "if", "len", "(", "shape", ")", "!=", "2", ":", "raise", "ValueError", "(", "'input shape must have 2 elements.'", ")", "xmin", "=", "self", ".", "bbox", ".", "ixmin", "xmax", "=", "self", "....
Calculate the slices for the overlapping part of the bounding box and an array of the given shape. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of array where the slices are to be applied. Returns ------- slices_large...
[ "Calculate", "the", "slices", "for", "the", "overlapping", "part", "of", "the", "bounding", "box", "and", "an", "array", "of", "the", "given", "shape", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/mask.py#L49-L93
10,603
astropy/photutils
photutils/aperture/mask.py
ApertureMask.to_image
def to_image(self, shape): """ Return an image of the mask in a 2D array of the given shape, taking any edge effects into account. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of the output array. Returns ------- ...
python
def to_image(self, shape): """ Return an image of the mask in a 2D array of the given shape, taking any edge effects into account. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of the output array. Returns ------- ...
[ "def", "to_image", "(", "self", ",", "shape", ")", ":", "if", "len", "(", "shape", ")", "!=", "2", ":", "raise", "ValueError", "(", "'input shape must have 2 elements.'", ")", "image", "=", "np", ".", "zeros", "(", "shape", ")", "if", "self", ".", "bbo...
Return an image of the mask in a 2D array of the given shape, taking any edge effects into account. Parameters ---------- shape : tuple of int The ``(ny, nx)`` shape of the output array. Returns ------- result : `~numpy.ndarray` A 2D arra...
[ "Return", "an", "image", "of", "the", "mask", "in", "a", "2D", "array", "of", "the", "given", "shape", "taking", "any", "edge", "effects", "into", "account", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/mask.py#L112-L141
10,604
astropy/photutils
photutils/aperture/mask.py
ApertureMask.cutout
def cutout(self, data, fill_value=0., copy=False): """ Create a cutout from the input data over the mask bounding box, taking any edge effects into account. Parameters ---------- data : array_like A 2D array on which to apply the aperture mask. fill_...
python
def cutout(self, data, fill_value=0., copy=False): """ Create a cutout from the input data over the mask bounding box, taking any edge effects into account. Parameters ---------- data : array_like A 2D array on which to apply the aperture mask. fill_...
[ "def", "cutout", "(", "self", ",", "data", ",", "fill_value", "=", "0.", ",", "copy", "=", "False", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "data", ")", "if", "data", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "'data must...
Create a cutout from the input data over the mask bounding box, taking any edge effects into account. Parameters ---------- data : array_like A 2D array on which to apply the aperture mask. fill_value : float, optional The value is used to fill pixels wh...
[ "Create", "a", "cutout", "from", "the", "input", "data", "over", "the", "mask", "bounding", "box", "taking", "any", "edge", "effects", "into", "account", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/mask.py#L143-L208
10,605
astropy/photutils
photutils/aperture/mask.py
ApertureMask.multiply
def multiply(self, data, fill_value=0.): """ Multiply the aperture mask with the input data, taking any edge effects into account. The result is a mask-weighted cutout from the data. Parameters ---------- data : array_like or `~astropy.units.Quantity` ...
python
def multiply(self, data, fill_value=0.): """ Multiply the aperture mask with the input data, taking any edge effects into account. The result is a mask-weighted cutout from the data. Parameters ---------- data : array_like or `~astropy.units.Quantity` ...
[ "def", "multiply", "(", "self", ",", "data", ",", "fill_value", "=", "0.", ")", ":", "cutout", "=", "self", ".", "cutout", "(", "data", ",", "fill_value", "=", "fill_value", ")", "if", "cutout", "is", "None", ":", "return", "None", "else", ":", "retu...
Multiply the aperture mask with the input data, taking any edge effects into account. The result is a mask-weighted cutout from the data. Parameters ---------- data : array_like or `~astropy.units.Quantity` The 2D array to multiply with the aperture mask. f...
[ "Multiply", "the", "aperture", "mask", "with", "the", "input", "data", "taking", "any", "edge", "effects", "into", "account", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/mask.py#L210-L241
10,606
astropy/photutils
photutils/segmentation/deblend.py
deblend_sources
def deblend_sources(data, segment_img, npixels, filter_kernel=None, labels=None, nlevels=32, contrast=0.001, mode='exponential', connectivity=8, relabel=True): """ Deblend overlapping sources labeled in a segmentation image. Sources are deblended using a combination ...
python
def deblend_sources(data, segment_img, npixels, filter_kernel=None, labels=None, nlevels=32, contrast=0.001, mode='exponential', connectivity=8, relabel=True): """ Deblend overlapping sources labeled in a segmentation image. Sources are deblended using a combination ...
[ "def", "deblend_sources", "(", "data", ",", "segment_img", ",", "npixels", ",", "filter_kernel", "=", "None", ",", "labels", "=", "None", ",", "nlevels", "=", "32", ",", "contrast", "=", "0.001", ",", "mode", "=", "'exponential'", ",", "connectivity", "=",...
Deblend overlapping sources labeled in a segmentation image. Sources are deblended using a combination of multi-thresholding and `watershed segmentation <https://en.wikipedia.org/wiki/Watershed_(image_processing)>`_. In order to deblend sources, they must be separated enough such that there is a s...
[ "Deblend", "overlapping", "sources", "labeled", "in", "a", "segmentation", "image", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/deblend.py#L18-L147
10,607
astropy/photutils
photutils/utils/_moments.py
_moments_central
def _moments_central(data, center=None, order=1): """ Calculate the central image moments up to the specified order. Parameters ---------- data : 2D array-like The input 2D array. center : tuple of two floats or `None`, optional The ``(x, y)`` center position. If `None` it wil...
python
def _moments_central(data, center=None, order=1): """ Calculate the central image moments up to the specified order. Parameters ---------- data : 2D array-like The input 2D array. center : tuple of two floats or `None`, optional The ``(x, y)`` center position. If `None` it wil...
[ "def", "_moments_central", "(", "data", ",", "center", "=", "None", ",", "order", "=", "1", ")", ":", "data", "=", "np", ".", "asarray", "(", "data", ")", ".", "astype", "(", "float", ")", "if", "data", ".", "ndim", "!=", "2", ":", "raise", "Valu...
Calculate the central image moments up to the specified order. Parameters ---------- data : 2D array-like The input 2D array. center : tuple of two floats or `None`, optional The ``(x, y)`` center position. If `None` it will calculated as the "center of mass" of the input ``da...
[ "Calculate", "the", "central", "image", "moments", "up", "to", "the", "specified", "order", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/_moments.py#L9-L44
10,608
astropy/photutils
photutils/isophote/harmonics.py
first_and_second_harmonic_function
def first_and_second_harmonic_function(phi, c): """ Compute the harmonic function value used to calculate the corrections for ellipse fitting. This function includes simultaneously both the first and second order harmonics: .. math:: f(phi) = c[0] + c[1]*\\sin(phi) + c[2]*\\cos(phi) +...
python
def first_and_second_harmonic_function(phi, c): """ Compute the harmonic function value used to calculate the corrections for ellipse fitting. This function includes simultaneously both the first and second order harmonics: .. math:: f(phi) = c[0] + c[1]*\\sin(phi) + c[2]*\\cos(phi) +...
[ "def", "first_and_second_harmonic_function", "(", "phi", ",", "c", ")", ":", "return", "(", "c", "[", "0", "]", "+", "c", "[", "1", "]", "*", "np", ".", "sin", "(", "phi", ")", "+", "c", "[", "2", "]", "*", "np", ".", "cos", "(", "phi", ")", ...
Compute the harmonic function value used to calculate the corrections for ellipse fitting. This function includes simultaneously both the first and second order harmonics: .. math:: f(phi) = c[0] + c[1]*\\sin(phi) + c[2]*\\cos(phi) + c[3]*\\sin(2*phi) + c[4]*\\cos(2*phi) ...
[ "Compute", "the", "harmonic", "function", "value", "used", "to", "calculate", "the", "corrections", "for", "ellipse", "fitting", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/harmonics.py#L23-L53
10,609
astropy/photutils
photutils/psf/matching/windows.py
_radial_distance
def _radial_distance(shape): """ Return an array where each value is the Euclidean distance from the array center. Parameters ---------- shape : tuple of int The size of the output array along each axis. Returns ------- result : `~numpy.ndarray` An array containing ...
python
def _radial_distance(shape): """ Return an array where each value is the Euclidean distance from the array center. Parameters ---------- shape : tuple of int The size of the output array along each axis. Returns ------- result : `~numpy.ndarray` An array containing ...
[ "def", "_radial_distance", "(", "shape", ")", ":", "if", "len", "(", "shape", ")", "!=", "2", ":", "raise", "ValueError", "(", "'shape must have only 2 elements'", ")", "position", "=", "(", "np", ".", "asarray", "(", "shape", ")", "-", "1", ")", "/", ...
Return an array where each value is the Euclidean distance from the array center. Parameters ---------- shape : tuple of int The size of the output array along each axis. Returns ------- result : `~numpy.ndarray` An array containing the Euclidian radial distances from the ...
[ "Return", "an", "array", "where", "each", "value", "is", "the", "Euclidean", "distance", "from", "the", "array", "center", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/matching/windows.py#L13-L36
10,610
astropy/photutils
photutils/datasets/load.py
load_spitzer_image
def load_spitzer_image(show_progress=False): # pragma: no cover """ Load a 4.5 micron Spitzer image. The catalog for this image is returned by :func:`load_spitzer_catalog`. Parameters ---------- show_progress : bool, optional Whether to display a progress bar during the download...
python
def load_spitzer_image(show_progress=False): # pragma: no cover """ Load a 4.5 micron Spitzer image. The catalog for this image is returned by :func:`load_spitzer_catalog`. Parameters ---------- show_progress : bool, optional Whether to display a progress bar during the download...
[ "def", "load_spitzer_image", "(", "show_progress", "=", "False", ")", ":", "# pragma: no cover", "path", "=", "get_path", "(", "'spitzer_example_image.fits'", ",", "location", "=", "'remote'", ",", "show_progress", "=", "show_progress", ")", "hdu", "=", "fits", "....
Load a 4.5 micron Spitzer image. The catalog for this image is returned by :func:`load_spitzer_catalog`. Parameters ---------- show_progress : bool, optional Whether to display a progress bar during the download (default is `False`). Returns ------- hdu : `~astropy.io....
[ "Load", "a", "4", ".", "5", "micron", "Spitzer", "image", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/load.py#L73-L109
10,611
astropy/photutils
photutils/datasets/load.py
load_spitzer_catalog
def load_spitzer_catalog(show_progress=False): # pragma: no cover """ Load a 4.5 micron Spitzer catalog. The image from which this catalog was derived is returned by :func:`load_spitzer_image`. Parameters ---------- show_progress : bool, optional Whether to display a progress ba...
python
def load_spitzer_catalog(show_progress=False): # pragma: no cover """ Load a 4.5 micron Spitzer catalog. The image from which this catalog was derived is returned by :func:`load_spitzer_image`. Parameters ---------- show_progress : bool, optional Whether to display a progress ba...
[ "def", "load_spitzer_catalog", "(", "show_progress", "=", "False", ")", ":", "# pragma: no cover", "path", "=", "get_path", "(", "'spitzer_example_catalog.xml'", ",", "location", "=", "'remote'", ",", "show_progress", "=", "show_progress", ")", "table", "=", "Table"...
Load a 4.5 micron Spitzer catalog. The image from which this catalog was derived is returned by :func:`load_spitzer_image`. Parameters ---------- show_progress : bool, optional Whether to display a progress bar during the download (default is `False`). Returns ------- ...
[ "Load", "a", "4", ".", "5", "micron", "Spitzer", "catalog", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/load.py#L112-L152
10,612
astropy/photutils
photutils/datasets/load.py
load_irac_psf
def load_irac_psf(channel, show_progress=False): # pragma: no cover """ Load a Spitzer IRAC PSF image. Parameters ---------- channel : int (1-4) The IRAC channel number: * Channel 1: 3.6 microns * Channel 2: 4.5 microns * Channel 3: 5.8 microns ...
python
def load_irac_psf(channel, show_progress=False): # pragma: no cover """ Load a Spitzer IRAC PSF image. Parameters ---------- channel : int (1-4) The IRAC channel number: * Channel 1: 3.6 microns * Channel 2: 4.5 microns * Channel 3: 5.8 microns ...
[ "def", "load_irac_psf", "(", "channel", ",", "show_progress", "=", "False", ")", ":", "# pragma: no cover", "channel", "=", "int", "(", "channel", ")", "if", "channel", "<", "1", "or", "channel", ">", "4", ":", "raise", "ValueError", "(", "'channel must be 1...
Load a Spitzer IRAC PSF image. Parameters ---------- channel : int (1-4) The IRAC channel number: * Channel 1: 3.6 microns * Channel 2: 4.5 microns * Channel 3: 5.8 microns * Channel 4: 8.0 microns show_progress : bool, optional Whether to d...
[ "Load", "a", "Spitzer", "IRAC", "PSF", "image", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/load.py#L155-L217
10,613
astropy/photutils
photutils/isophote/ellipse.py
Ellipse.fit_image
def fit_image(self, sma0=None, minsma=0., maxsma=None, step=0.1, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT, maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0, integrmode=BILINEAR, linear=False, maxrit=None):...
python
def fit_image(self, sma0=None, minsma=0., maxsma=None, step=0.1, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT, maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0, integrmode=BILINEAR, linear=False, maxrit=None):...
[ "def", "fit_image", "(", "self", ",", "sma0", "=", "None", ",", "minsma", "=", "0.", ",", "maxsma", "=", "None", ",", "step", "=", "0.1", ",", "conver", "=", "DEFAULT_CONVERGENCE", ",", "minit", "=", "DEFAULT_MINIT", ",", "maxit", "=", "DEFAULT_MAXIT", ...
Fit multiple isophotes to the image array. This method loops over each value of the semimajor axis (sma) length (constructed from the input parameters), fitting a single isophote at each sma. The entire set of isophotes is returned in an `~photutils.isophote.IsophoteList` instance. ...
[ "Fit", "multiple", "isophotes", "to", "the", "image", "array", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/ellipse.py#L199-L449
10,614
astropy/photutils
photutils/isophote/ellipse.py
Ellipse.fit_isophote
def fit_isophote(self, sma, step=0.1, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT, maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0, integrmode=BILINEAR, linear=False, maxrit=None, noniterate=Fals...
python
def fit_isophote(self, sma, step=0.1, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT, maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0, integrmode=BILINEAR, linear=False, maxrit=None, noniterate=Fals...
[ "def", "fit_isophote", "(", "self", ",", "sma", ",", "step", "=", "0.1", ",", "conver", "=", "DEFAULT_CONVERGENCE", ",", "minit", "=", "DEFAULT_MINIT", ",", "maxit", "=", "DEFAULT_MAXIT", ",", "fflag", "=", "DEFAULT_FFLAG", ",", "maxgerr", "=", "DEFAULT_MAXG...
Fit a single isophote with a given semimajor axis length. The ``step`` and ``linear`` parameters are not used to actually grow or shrink the current fitting semimajor axis length. They are necessary so the sampling algorithm can know where to start the gradient computation and also how...
[ "Fit", "a", "single", "isophote", "with", "a", "given", "semimajor", "axis", "length", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/ellipse.py#L451-L579
10,615
astropy/photutils
photutils/aperture/circle.py
CircularAperture.to_sky
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyCircularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wc...
python
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyCircularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wc...
[ "def", "to_sky", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "sky_params", "=", "self", ".", "_to_sky_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "SkyCircularAperture", "(", "*", "*", "sky_params", ")" ]
Convert the aperture to a `SkyCircularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformat...
[ "Convert", "the", "aperture", "to", "a", "SkyCircularAperture", "object", "defined", "in", "celestial", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/circle.py#L157-L179
10,616
astropy/photutils
photutils/aperture/circle.py
CircularAnnulus.to_sky
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyCircularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs...
python
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyCircularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs...
[ "def", "to_sky", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "sky_params", "=", "self", ".", "_to_sky_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "SkyCircularAnnulus", "(", "*", "*", "sky_params", ")" ]
Convert the aperture to a `SkyCircularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformati...
[ "Convert", "the", "aperture", "to", "a", "SkyCircularAnnulus", "object", "defined", "in", "celestial", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/circle.py#L254-L276
10,617
astropy/photutils
photutils/aperture/circle.py
SkyCircularAperture.to_pixel
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `CircularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, ...
python
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `CircularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, ...
[ "def", "to_pixel", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "pixel_params", "=", "self", ".", "_to_pixel_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "CircularAperture", "(", "*", "*", "pixel_params", ")" ]
Convert the aperture to a `CircularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformation inc...
[ "Convert", "the", "aperture", "to", "a", "CircularAperture", "object", "defined", "in", "pixel", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/circle.py#L303-L325
10,618
astropy/photutils
photutils/aperture/circle.py
SkyCircularAnnulus.to_pixel
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `CircularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, o...
python
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `CircularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, o...
[ "def", "to_pixel", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "pixel_params", "=", "self", ".", "_to_pixel_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "CircularAnnulus", "(", "*", "*", "pixel_params", ")" ]
Convert the aperture to a `CircularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformation incl...
[ "Convert", "the", "aperture", "to", "a", "CircularAnnulus", "object", "defined", "in", "pixel", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/circle.py#L364-L386
10,619
astropy/photutils
photutils/datasets/make.py
apply_poisson_noise
def apply_poisson_noise(data, random_state=None): """ Apply Poisson noise to an array, where the value of each element in the input array represents the expected number of counts. Each pixel in the output array is generated by drawing a random sample from a Poisson distribution whose expectation va...
python
def apply_poisson_noise(data, random_state=None): """ Apply Poisson noise to an array, where the value of each element in the input array represents the expected number of counts. Each pixel in the output array is generated by drawing a random sample from a Poisson distribution whose expectation va...
[ "def", "apply_poisson_noise", "(", "data", ",", "random_state", "=", "None", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "data", ")", "if", "np", ".", "any", "(", "data", "<", "0", ")", ":", "raise", "ValueError", "(", "'data must not contain an...
Apply Poisson noise to an array, where the value of each element in the input array represents the expected number of counts. Each pixel in the output array is generated by drawing a random sample from a Poisson distribution whose expectation value is given by the pixel value in the input array. P...
[ "Apply", "Poisson", "noise", "to", "an", "array", "where", "the", "value", "of", "each", "element", "in", "the", "input", "array", "represents", "the", "expected", "number", "of", "counts", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L26-L78
10,620
astropy/photutils
photutils/datasets/make.py
make_noise_image
def make_noise_image(shape, type='gaussian', mean=None, stddev=None, random_state=None): """ Make a noise image containing Gaussian or Poisson noise. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. type : {'gaussian', 'poisson'} ...
python
def make_noise_image(shape, type='gaussian', mean=None, stddev=None, random_state=None): """ Make a noise image containing Gaussian or Poisson noise. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. type : {'gaussian', 'poisson'} ...
[ "def", "make_noise_image", "(", "shape", ",", "type", "=", "'gaussian'", ",", "mean", "=", "None", ",", "stddev", "=", "None", ",", "random_state", "=", "None", ")", ":", "if", "mean", "is", "None", ":", "raise", "ValueError", "(", "'\"mean\" must be input...
Make a noise image containing Gaussian or Poisson noise. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. type : {'gaussian', 'poisson'} The distribution used to generate the random noise: * ``'gaussian'``: Gaussian distributed noise. ...
[ "Make", "a", "noise", "image", "containing", "Gaussian", "or", "Poisson", "noise", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L81-L156
10,621
astropy/photutils
photutils/datasets/make.py
make_random_models_table
def make_random_models_table(n_sources, param_ranges, random_state=None): """ Make a `~astropy.table.Table` containing randomly generated parameters for an Astropy model to simulate a set of sources. Each row of the table corresponds to a source whose parameters are defined by the column names. Th...
python
def make_random_models_table(n_sources, param_ranges, random_state=None): """ Make a `~astropy.table.Table` containing randomly generated parameters for an Astropy model to simulate a set of sources. Each row of the table corresponds to a source whose parameters are defined by the column names. Th...
[ "def", "make_random_models_table", "(", "n_sources", ",", "param_ranges", ",", "random_state", "=", "None", ")", ":", "prng", "=", "check_random_state", "(", "random_state", ")", "sources", "=", "Table", "(", ")", "for", "param_name", ",", "(", "lower", ",", ...
Make a `~astropy.table.Table` containing randomly generated parameters for an Astropy model to simulate a set of sources. Each row of the table corresponds to a source whose parameters are defined by the column names. The parameters are drawn from a uniform distribution over the specified input ranges...
[ "Make", "a", "~astropy", ".", "table", ".", "Table", "containing", "randomly", "generated", "parameters", "for", "an", "Astropy", "model", "to", "simulate", "a", "set", "of", "sources", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L159-L237
10,622
astropy/photutils
photutils/datasets/make.py
make_random_gaussians_table
def make_random_gaussians_table(n_sources, param_ranges, random_state=None): """ Make a `~astropy.table.Table` containing randomly generated parameters for 2D Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The parameters a...
python
def make_random_gaussians_table(n_sources, param_ranges, random_state=None): """ Make a `~astropy.table.Table` containing randomly generated parameters for 2D Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The parameters a...
[ "def", "make_random_gaussians_table", "(", "n_sources", ",", "param_ranges", ",", "random_state", "=", "None", ")", ":", "sources", "=", "make_random_models_table", "(", "n_sources", ",", "param_ranges", ",", "random_state", "=", "random_state", ")", "# convert Gaussi...
Make a `~astropy.table.Table` containing randomly generated parameters for 2D Gaussian sources. Each row of the table corresponds to a Gaussian source whose parameters are defined by the column names. The parameters are drawn from a uniform distribution over the specified input ranges. The output...
[ "Make", "a", "~astropy", ".", "table", ".", "Table", "containing", "randomly", "generated", "parameters", "for", "2D", "Gaussian", "sources", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L240-L363
10,623
astropy/photutils
photutils/datasets/make.py
make_model_sources_image
def make_model_sources_image(shape, model, source_table, oversample=1): """ Make an image containing sources generated from a user-specified model. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. model : 2D astropy.modeling.models object The m...
python
def make_model_sources_image(shape, model, source_table, oversample=1): """ Make an image containing sources generated from a user-specified model. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. model : 2D astropy.modeling.models object The m...
[ "def", "make_model_sources_image", "(", "shape", ",", "model", ",", "source_table", ",", "oversample", "=", "1", ")", ":", "image", "=", "np", ".", "zeros", "(", "shape", ",", "dtype", "=", "np", ".", "float64", ")", "y", ",", "x", "=", "np", ".", ...
Make an image containing sources generated from a user-specified model. Parameters ---------- shape : 2-tuple of int The shape of the output 2D image. model : 2D astropy.modeling.models object The model to be used for rendering the sources. source_table : `~astropy.table.Table...
[ "Make", "an", "image", "containing", "sources", "generated", "from", "a", "user", "-", "specified", "model", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L366-L460
10,624
astropy/photutils
photutils/datasets/make.py
make_4gaussians_image
def make_4gaussians_image(noise=True): """ Make an example image containing four 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 5 is added to the output image. Parameters ...
python
def make_4gaussians_image(noise=True): """ Make an example image containing four 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 5 is added to the output image. Parameters ...
[ "def", "make_4gaussians_image", "(", "noise", "=", "True", ")", ":", "table", "=", "Table", "(", ")", "table", "[", "'amplitude'", "]", "=", "[", "50", ",", "70", ",", "150", ",", "210", "]", "table", "[", "'x_mean'", "]", "=", "[", "160", ",", "...
Make an example image containing four 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 5 is added to the output image. Parameters ---------- noise : bool, optional Whet...
[ "Make", "an", "example", "image", "containing", "four", "2D", "Gaussians", "plus", "a", "constant", "background", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L638-L688
10,625
astropy/photutils
photutils/datasets/make.py
make_100gaussians_image
def make_100gaussians_image(noise=True): """ Make an example image containing 100 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 2 is added to the output image. Parameters ...
python
def make_100gaussians_image(noise=True): """ Make an example image containing 100 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 2 is added to the output image. Parameters ...
[ "def", "make_100gaussians_image", "(", "noise", "=", "True", ")", ":", "n_sources", "=", "100", "flux_range", "=", "[", "500", ",", "1000", "]", "xmean_range", "=", "[", "0", ",", "500", "]", "ymean_range", "=", "[", "0", ",", "300", "]", "xstddev_rang...
Make an example image containing 100 2D Gaussians plus a constant background. The background has a mean of 5. If ``noise`` is `True`, then Gaussian noise with a mean of 0 and a standard deviation of 2 is added to the output image. Parameters ---------- noise : bool, optional Wheth...
[ "Make", "an", "example", "image", "containing", "100", "2D", "Gaussians", "plus", "a", "constant", "background", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L691-L749
10,626
astropy/photutils
photutils/datasets/make.py
make_wcs
def make_wcs(shape, galactic=False): """ Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame. Parameters ---------- shape : 2-tuple of int The shape of the 2D array to be used with the output `~astropy.wcs.WCS` object. galactic : bool, optio...
python
def make_wcs(shape, galactic=False): """ Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame. Parameters ---------- shape : 2-tuple of int The shape of the 2D array to be used with the output `~astropy.wcs.WCS` object. galactic : bool, optio...
[ "def", "make_wcs", "(", "shape", ",", "galactic", "=", "False", ")", ":", "wcs", "=", "WCS", "(", "naxis", "=", "2", ")", "rho", "=", "np", ".", "pi", "/", "3.", "scale", "=", "0.1", "/", "3600.", "if", "astropy_version", "<", "'3.1'", ":", "wcs"...
Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame. Parameters ---------- shape : 2-tuple of int The shape of the 2D array to be used with the output `~astropy.wcs.WCS` object. galactic : bool, optional If `True`, then the output WCS will b...
[ "Create", "a", "simple", "celestial", "WCS", "object", "in", "either", "the", "ICRS", "or", "Galactic", "coordinate", "frame", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L752-L809
10,627
astropy/photutils
photutils/datasets/make.py
make_imagehdu
def make_imagehdu(data, wcs=None): """ Create a FITS `~astropy.io.fits.ImageHDU` containing the input 2D image. Parameters ---------- data : 2D array-like The input 2D data. wcs : `~astropy.wcs.WCS`, optional The world coordinate system (WCS) transformation to include in ...
python
def make_imagehdu(data, wcs=None): """ Create a FITS `~astropy.io.fits.ImageHDU` containing the input 2D image. Parameters ---------- data : 2D array-like The input 2D data. wcs : `~astropy.wcs.WCS`, optional The world coordinate system (WCS) transformation to include in ...
[ "def", "make_imagehdu", "(", "data", ",", "wcs", "=", "None", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "data", ")", "if", "data", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "'data must be a 2D array'", ")", "if", "wcs", "is", ...
Create a FITS `~astropy.io.fits.ImageHDU` containing the input 2D image. Parameters ---------- data : 2D array-like The input 2D data. wcs : `~astropy.wcs.WCS`, optional The world coordinate system (WCS) transformation to include in the output FITS header. Returns ...
[ "Create", "a", "FITS", "~astropy", ".", "io", ".", "fits", ".", "ImageHDU", "containing", "the", "input", "2D", "image", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/datasets/make.py#L812-L855
10,628
astropy/photutils
photutils/centroids/core.py
centroid_com
def centroid_com(data, mask=None): """ Calculate the centroid of an n-dimensional array as its "center of mass" determined from moments. Invalid values (e.g. NaNs or infs) in the ``data`` array are automatically masked. Parameters ---------- data : array_like The input n-dimens...
python
def centroid_com(data, mask=None): """ Calculate the centroid of an n-dimensional array as its "center of mass" determined from moments. Invalid values (e.g. NaNs or infs) in the ``data`` array are automatically masked. Parameters ---------- data : array_like The input n-dimens...
[ "def", "centroid_com", "(", "data", ",", "mask", "=", "None", ")", ":", "data", "=", "data", ".", "astype", "(", "np", ".", "float", ")", "if", "mask", "is", "not", "None", "and", "mask", "is", "not", "np", ".", "ma", ".", "nomask", ":", "mask", ...
Calculate the centroid of an n-dimensional array as its "center of mass" determined from moments. Invalid values (e.g. NaNs or infs) in the ``data`` array are automatically masked. Parameters ---------- data : array_like The input n-dimensional array. mask : array_like (bool), opt...
[ "Calculate", "the", "centroid", "of", "an", "n", "-", "dimensional", "array", "as", "its", "center", "of", "mass", "determined", "from", "moments", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L74-L117
10,629
astropy/photutils
photutils/centroids/core.py
gaussian1d_moments
def gaussian1d_moments(data, mask=None): """ Estimate 1D Gaussian parameters from the moments of 1D data. This function can be useful for providing initial parameter values when fitting a 1D Gaussian to the ``data``. Parameters ---------- data : array_like (1D) The 1D array. m...
python
def gaussian1d_moments(data, mask=None): """ Estimate 1D Gaussian parameters from the moments of 1D data. This function can be useful for providing initial parameter values when fitting a 1D Gaussian to the ``data``. Parameters ---------- data : array_like (1D) The 1D array. m...
[ "def", "gaussian1d_moments", "(", "data", ",", "mask", "=", "None", ")", ":", "if", "np", ".", "any", "(", "~", "np", ".", "isfinite", "(", "data", ")", ")", ":", "data", "=", "np", ".", "ma", ".", "masked_invalid", "(", "data", ")", "warnings", ...
Estimate 1D Gaussian parameters from the moments of 1D data. This function can be useful for providing initial parameter values when fitting a 1D Gaussian to the ``data``. Parameters ---------- data : array_like (1D) The 1D array. mask : array_like (1D bool), optional A boolea...
[ "Estimate", "1D", "Gaussian", "parameters", "from", "the", "moments", "of", "1D", "data", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L120-L163
10,630
astropy/photutils
photutils/centroids/core.py
fit_2dgaussian
def fit_2dgaussian(data, error=None, mask=None): """ Fit a 2D Gaussian plus a constant to a 2D image. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combination of the invalid-value masks for the ``dat...
python
def fit_2dgaussian(data, error=None, mask=None): """ Fit a 2D Gaussian plus a constant to a 2D image. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combination of the invalid-value masks for the ``dat...
[ "def", "fit_2dgaussian", "(", "data", ",", "error", "=", "None", ",", "mask", "=", "None", ")", ":", "from", ".", ".", "morphology", "import", "data_properties", "# prevent circular imports", "data", "=", "np", ".", "ma", ".", "asanyarray", "(", "data", ")...
Fit a 2D Gaussian plus a constant to a 2D image. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combination of the invalid-value masks for the ``data`` and ``error`` arrays. Parameters ---------- ...
[ "Fit", "a", "2D", "Gaussian", "plus", "a", "constant", "to", "a", "2D", "image", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L166-L247
10,631
astropy/photutils
photutils/centroids/core.py
centroid_1dg
def centroid_1dg(data, error=None, mask=None): """ Calculate the centroid of a 2D array by fitting 1D Gaussians to the marginal ``x`` and ``y`` distributions of the array. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values ...
python
def centroid_1dg(data, error=None, mask=None): """ Calculate the centroid of a 2D array by fitting 1D Gaussians to the marginal ``x`` and ``y`` distributions of the array. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values ...
[ "def", "centroid_1dg", "(", "data", ",", "error", "=", "None", ",", "mask", "=", "None", ")", ":", "data", "=", "np", ".", "ma", ".", "asanyarray", "(", "data", ")", "if", "mask", "is", "not", "None", "and", "mask", "is", "not", "np", ".", "ma", ...
Calculate the centroid of a 2D array by fitting 1D Gaussians to the marginal ``x`` and ``y`` distributions of the array. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combination of the invalid-value masks fo...
[ "Calculate", "the", "centroid", "of", "a", "2D", "array", "by", "fitting", "1D", "Gaussians", "to", "the", "marginal", "x", "and", "y", "distributions", "of", "the", "array", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L250-L322
10,632
astropy/photutils
photutils/centroids/core.py
centroid_sources
def centroid_sources(data, xpos, ypos, box_size=11, footprint=None, error=None, mask=None, centroid_func=centroid_com): """ Calculate the centroid of sources at the defined positions. A cutout image centered on each input position will be used to calculate the centroid position. T...
python
def centroid_sources(data, xpos, ypos, box_size=11, footprint=None, error=None, mask=None, centroid_func=centroid_com): """ Calculate the centroid of sources at the defined positions. A cutout image centered on each input position will be used to calculate the centroid position. T...
[ "def", "centroid_sources", "(", "data", ",", "xpos", ",", "ypos", ",", "box_size", "=", "11", ",", "footprint", "=", "None", ",", "error", "=", "None", ",", "mask", "=", "None", ",", "centroid_func", "=", "centroid_com", ")", ":", "xpos", "=", "np", ...
Calculate the centroid of sources at the defined positions. A cutout image centered on each input position will be used to calculate the centroid position. The cutout image is defined either using the ``box_size`` or ``footprint`` keyword. The ``footprint`` keyword can be used to create a non-rectang...
[ "Calculate", "the", "centroid", "of", "sources", "at", "the", "defined", "positions", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L358-L481
10,633
astropy/photutils
photutils/centroids/core.py
GaussianConst2D.evaluate
def evaluate(x, y, constant, amplitude, x_mean, y_mean, x_stddev, y_stddev, theta): """Two dimensional Gaussian plus constant function.""" model = Const2D(constant)(x, y) + Gaussian2D(amplitude, x_mean, y_mean, x_stddev, ...
python
def evaluate(x, y, constant, amplitude, x_mean, y_mean, x_stddev, y_stddev, theta): """Two dimensional Gaussian plus constant function.""" model = Const2D(constant)(x, y) + Gaussian2D(amplitude, x_mean, y_mean, x_stddev, ...
[ "def", "evaluate", "(", "x", ",", "y", ",", "constant", ",", "amplitude", ",", "x_mean", ",", "y_mean", ",", "x_stddev", ",", "y_stddev", ",", "theta", ")", ":", "model", "=", "Const2D", "(", "constant", ")", "(", "x", ",", "y", ")", "+", "Gaussian...
Two dimensional Gaussian plus constant function.
[ "Two", "dimensional", "Gaussian", "plus", "constant", "function", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L61-L68
10,634
astropy/photutils
photutils/psf/sandbox.py
DiscretePRF.evaluate
def evaluate(self, x, y, flux, x_0, y_0): """ Discrete PRF model evaluation. Given a certain position and flux the corresponding image of the PSF is chosen and scaled to the flux. If x and y are outside the boundaries of the image, zero will be returned. Parameters ...
python
def evaluate(self, x, y, flux, x_0, y_0): """ Discrete PRF model evaluation. Given a certain position and flux the corresponding image of the PSF is chosen and scaled to the flux. If x and y are outside the boundaries of the image, zero will be returned. Parameters ...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ")", ":", "# Convert x and y to index arrays", "x", "=", "(", "x", "-", "x_0", "+", "0.5", "+", "self", ".", "prf_shape", "[", "1", "]", "//", "2", ")", ".",...
Discrete PRF model evaluation. Given a certain position and flux the corresponding image of the PSF is chosen and scaled to the flux. If x and y are outside the boundaries of the image, zero will be returned. Parameters ---------- x : float x coordinate arra...
[ "Discrete", "PRF", "model", "evaluation", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/sandbox.py#L104-L145
10,635
astropy/photutils
photutils/psf/sandbox.py
Reproject._reproject
def _reproject(wcs1, wcs2): """ Perform the forward transformation of ``wcs1`` followed by the inverse transformation of ``wcs2``. Parameters ---------- wcs1, wcs2 : `~astropy.wcs.WCS` or `~gwcs.wcs.WCS` The WCS objects. Returns ------- ...
python
def _reproject(wcs1, wcs2): """ Perform the forward transformation of ``wcs1`` followed by the inverse transformation of ``wcs2``. Parameters ---------- wcs1, wcs2 : `~astropy.wcs.WCS` or `~gwcs.wcs.WCS` The WCS objects. Returns ------- ...
[ "def", "_reproject", "(", "wcs1", ",", "wcs2", ")", ":", "import", "gwcs", "forward_origin", "=", "[", "]", "if", "isinstance", "(", "wcs1", ",", "fitswcs", ".", "WCS", ")", ":", "forward", "=", "wcs1", ".", "all_pix2world", "forward_origin", "=", "[", ...
Perform the forward transformation of ``wcs1`` followed by the inverse transformation of ``wcs2``. Parameters ---------- wcs1, wcs2 : `~astropy.wcs.WCS` or `~gwcs.wcs.WCS` The WCS objects. Returns ------- result : func Function to compute...
[ "Perform", "the", "forward", "transformation", "of", "wcs1", "followed", "by", "the", "inverse", "transformation", "of", "wcs2", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/sandbox.py#L316-L363
10,636
astropy/photutils
photutils/utils/misc.py
get_version_info
def get_version_info(): """ Return astropy and photutils versions. Returns ------- result : str The astropy and photutils versions. """ from astropy import __version__ astropy_version = __version__ from photutils import __version__ photutils_version = __version__ ...
python
def get_version_info(): """ Return astropy and photutils versions. Returns ------- result : str The astropy and photutils versions. """ from astropy import __version__ astropy_version = __version__ from photutils import __version__ photutils_version = __version__ ...
[ "def", "get_version_info", "(", ")", ":", "from", "astropy", "import", "__version__", "astropy_version", "=", "__version__", "from", "photutils", "import", "__version__", "photutils_version", "=", "__version__", "return", "'astropy: {0}, photutils: {1}'", ".", "format", ...
Return astropy and photutils versions. Returns ------- result : str The astropy and photutils versions.
[ "Return", "astropy", "and", "photutils", "versions", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/misc.py#L15-L32
10,637
astropy/photutils
photutils/utils/errors.py
calc_total_error
def calc_total_error(data, bkg_error, effective_gain): """ Calculate a total error array, combining a background-only error array with the Poisson noise of sources. Parameters ---------- data : array_like or `~astropy.units.Quantity` The data array. bkg_error : array_like or `~astr...
python
def calc_total_error(data, bkg_error, effective_gain): """ Calculate a total error array, combining a background-only error array with the Poisson noise of sources. Parameters ---------- data : array_like or `~astropy.units.Quantity` The data array. bkg_error : array_like or `~astr...
[ "def", "calc_total_error", "(", "data", ",", "bkg_error", ",", "effective_gain", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "data", ")", "bkg_error", "=", "np", ".", "asanyarray", "(", "bkg_error", ")", "inputs", "=", "[", "data", ",", "bkg_err...
Calculate a total error array, combining a background-only error array with the Poisson noise of sources. Parameters ---------- data : array_like or `~astropy.units.Quantity` The data array. bkg_error : array_like or `~astropy.units.Quantity` The pixel-wise Gaussian 1-sigma backgro...
[ "Calculate", "a", "total", "error", "array", "combining", "a", "background", "-", "only", "error", "array", "with", "the", "Poisson", "noise", "of", "sources", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/errors.py#L11-L132
10,638
astropy/photutils
photutils/aperture/rectangle.py
RectangularAperture.to_sky
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyRectangularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', ...
python
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyRectangularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', ...
[ "def", "to_sky", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "sky_params", "=", "self", ".", "_to_sky_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "SkyRectangularAperture", "(", "*", "*", "sky_params", ")" ]
Convert the aperture to a `SkyRectangularAperture` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transfor...
[ "Convert", "the", "aperture", "to", "a", "SkyRectangularAperture", "object", "defined", "in", "celestial", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/rectangle.py#L200-L222
10,639
astropy/photutils
photutils/aperture/rectangle.py
RectangularAnnulus.to_sky
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyRectangularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', '...
python
def to_sky(self, wcs, mode='all'): """ Convert the aperture to a `SkyRectangularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', '...
[ "def", "to_sky", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "sky_params", "=", "self", ".", "_to_sky_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "SkyRectangularAnnulus", "(", "*", "*", "sky_params", ")" ]
Convert the aperture to a `SkyRectangularAnnulus` object defined in celestial coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transform...
[ "Convert", "the", "aperture", "to", "a", "SkyRectangularAnnulus", "object", "defined", "in", "celestial", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/rectangle.py#L354-L376
10,640
astropy/photutils
photutils/aperture/rectangle.py
SkyRectangularAperture.to_pixel
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `RectangularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'...
python
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `RectangularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'...
[ "def", "to_pixel", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "pixel_params", "=", "self", ".", "_to_pixel_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "RectangularAperture", "(", "*", "*", "pixel_params", ")" ]
Convert the aperture to a `RectangularAperture` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformation ...
[ "Convert", "the", "aperture", "to", "a", "RectangularAperture", "object", "defined", "in", "pixel", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/rectangle.py#L425-L447
10,641
astropy/photutils
photutils/aperture/rectangle.py
SkyRectangularAnnulus.to_pixel
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `RectangularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}...
python
def to_pixel(self, wcs, mode='all'): """ Convert the aperture to a `RectangularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}...
[ "def", "to_pixel", "(", "self", ",", "wcs", ",", "mode", "=", "'all'", ")", ":", "pixel_params", "=", "self", ".", "_to_pixel_params", "(", "wcs", ",", "mode", "=", "mode", ")", "return", "RectangularAnnulus", "(", "*", "*", "pixel_params", ")" ]
Convert the aperture to a `RectangularAnnulus` object defined in pixel coordinates. Parameters ---------- wcs : `~astropy.wcs.WCS` The world coordinate system (WCS) transformation to use. mode : {'all', 'wcs'}, optional Whether to do the transformation i...
[ "Convert", "the", "aperture", "to", "a", "RectangularAnnulus", "object", "defined", "in", "pixel", "coordinates", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/rectangle.py#L511-L533
10,642
astropy/photutils
photutils/psf/epsf.py
_py2intround
def _py2intround(a): """ Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0. """ data = np.asanyarray(a) value = np.where(data >= 0, np.floor(data + 0.5), np.ceil(data - 0.5)).astype(int) if not hasattr(a, '__iter__...
python
def _py2intround(a): """ Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0. """ data = np.asanyarray(a) value = np.where(data >= 0, np.floor(data + 0.5), np.ceil(data - 0.5)).astype(int) if not hasattr(a, '__iter__...
[ "def", "_py2intround", "(", "a", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "a", ")", "value", "=", "np", ".", "where", "(", "data", ">=", "0", ",", "np", ".", "floor", "(", "data", "+", "0.5", ")", ",", "np", ".", "ceil", "(", "dat...
Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0.
[ "Round", "the", "input", "to", "the", "nearest", "integer", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L845-L859
10,643
astropy/photutils
photutils/psf/epsf.py
_interpolate_missing_data
def _interpolate_missing_data(data, mask, method='cubic'): """ Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the sam...
python
def _interpolate_missing_data(data, mask, method='cubic'): """ Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the sam...
[ "def", "_interpolate_missing_data", "(", "data", ",", "mask", ",", "method", "=", "'cubic'", ")", ":", "from", "scipy", "import", "interpolate", "data_interp", "=", "np", ".", "array", "(", "data", ",", "copy", "=", "True", ")", "if", "len", "(", "data_i...
Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the same shape as the input ``data``, where a `True` value indicates t...
[ "Interpolate", "missing", "data", "as", "identified", "by", "the", "mask", "keyword", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L862-L916
10,644
astropy/photutils
photutils/psf/epsf.py
EPSFFitter._fit_star
def _fit_star(self, epsf, star, fitter, fitter_kwargs, fitter_has_fit_info, fit_boxsize): """ Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if t...
python
def _fit_star(self, epsf, star, fitter, fitter_kwargs, fitter_has_fit_info, fit_boxsize): """ Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if t...
[ "def", "_fit_star", "(", "self", ",", "epsf", ",", "star", ",", "fitter", ",", "fitter_kwargs", ",", "fitter_has_fit_info", ",", "fit_boxsize", ")", ":", "if", "fit_boxsize", "is", "not", "None", ":", "try", ":", "xcenter", ",", "ycenter", "=", "star", "...
Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if the original is needed.
[ "Fit", "an", "ePSF", "model", "to", "a", "single", "star", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L146-L238
10,645
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._init_img_params
def _init_img_params(param): """ Initialize 2D image-type parameters that can accept either a single or two values. """ if param is not None: param = np.atleast_1d(param) if len(param) == 1: param = np.repeat(param, 2) return para...
python
def _init_img_params(param): """ Initialize 2D image-type parameters that can accept either a single or two values. """ if param is not None: param = np.atleast_1d(param) if len(param) == 1: param = np.repeat(param, 2) return para...
[ "def", "_init_img_params", "(", "param", ")", ":", "if", "param", "is", "not", "None", ":", "param", "=", "np", ".", "atleast_1d", "(", "param", ")", "if", "len", "(", "param", ")", "==", "1", ":", "param", "=", "np", ".", "repeat", "(", "param", ...
Initialize 2D image-type parameters that can accept either a single or two values.
[ "Initialize", "2D", "image", "-", "type", "parameters", "that", "can", "accept", "either", "a", "single", "or", "two", "values", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L369-L380
10,646
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._create_initial_epsf
def _create_initial_epsf(self, stars): """ Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the...
python
def _create_initial_epsf(self, stars): """ Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the...
[ "def", "_create_initial_epsf", "(", "self", ",", "stars", ")", ":", "oversampling", "=", "self", ".", "oversampling", "shape", "=", "self", ".", "shape", "# define the ePSF shape", "if", "shape", "is", "not", "None", ":", "shape", "=", "np", ".", "atleast_1d...
Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the size is even along any axis, it will be made odd b...
[ "Create", "an", "initial", "EPSFModel", "object", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L382-L430
10,647
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._resample_residual
def _resample_residual(self, star, epsf): """ Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled gri...
python
def _resample_residual(self, star, epsf): """ Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled gri...
[ "def", "_resample_residual", "(", "self", ",", "star", ",", "epsf", ")", ":", "# find the integer index of EPSFStar pixels in the oversampled", "# ePSF grid", "x", "=", "epsf", ".", "_oversampling", "[", "0", "]", "*", "star", ".", "_xidx_centered", "y", "=", "eps...
Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled grid. The normalized residual image is then resampled fr...
[ "Compute", "a", "normalized", "residual", "image", "in", "the", "oversampled", "ePSF", "grid", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L432-L484
10,648
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._resample_residuals
def _resample_residuals(self, stars, epsf): """ Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Retu...
python
def _resample_residuals(self, stars, epsf): """ Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Retu...
[ "def", "_resample_residuals", "(", "self", ",", "stars", ",", "epsf", ")", ":", "shape", "=", "(", "stars", ".", "n_good_stars", ",", "epsf", ".", "shape", "[", "0", "]", ",", "epsf", ".", "shape", "[", "1", "]", ")", "star_imgs", "=", "np", ".", ...
Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Returns ------- star_imgs : 3D `~numpy.ndarray` ...
[ "Compute", "normalized", "residual", "images", "for", "all", "the", "input", "stars", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L486-L509
10,649
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._smooth_epsf
def _smooth_epsf(self, epsf_data): """ Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` ...
python
def _smooth_epsf(self, epsf_data): """ Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` ...
[ "def", "_smooth_epsf", "(", "self", ",", "epsf_data", ")", ":", "from", "scipy", ".", "ndimage", "import", "convolve", "if", "self", ".", "smoothing_kernel", "is", "None", ":", "return", "epsf_data", "elif", "self", ".", "smoothing_kernel", "==", "'quartic'", ...
Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` The smoothed (convolved) ePSF data.
[ "Smooth", "the", "ePSF", "array", "by", "convolving", "it", "with", "a", "kernel", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L511-L571
10,650
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._recenter_epsf
def _recenter_epsf(self, epsf_data, epsf, centroid_func=centroid_com, box_size=5, maxiters=20, center_accuracy=1.0e-4): """ Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ----...
python
def _recenter_epsf(self, epsf_data, epsf, centroid_func=centroid_com, box_size=5, maxiters=20, center_accuracy=1.0e-4): """ Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ----...
[ "def", "_recenter_epsf", "(", "self", ",", "epsf_data", ",", "epsf", ",", "centroid_func", "=", "centroid_com", ",", "box_size", "=", "5", ",", "maxiters", "=", "20", ",", "center_accuracy", "=", "1.0e-4", ")", ":", "# Define an EPSFModel for the input data. This...
Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. epsf : `EPSFModel` object The ePSF model. ...
[ "Calculate", "the", "center", "of", "the", "ePSF", "data", "and", "shift", "the", "data", "so", "the", "ePSF", "center", "is", "at", "the", "center", "of", "the", "ePSF", "data", "array", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L573-L671
10,651
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._build_epsf_step
def _build_epsf_step(self, stars, epsf=None): """ A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not inpu...
python
def _build_epsf_step(self, stars, epsf=None): """ A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not inpu...
[ "def", "_build_epsf_step", "(", "self", ",", "stars", ",", "epsf", "=", "None", ")", ":", "if", "len", "(", "stars", ")", "<", "1", ":", "raise", "ValueError", "(", "'stars must contain at least one EPSFStar or '", "'LinkedEPSFStar object.'", ")", "if", "epsf", ...
A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not input, then the ePSF will be built from scratch. ...
[ "A", "single", "iteration", "of", "improving", "an", "ePSF", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L673-L755
10,652
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder.build_epsf
def build_epsf(self, stars, init_epsf=None): """ Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If ...
python
def build_epsf(self, stars, init_epsf=None): """ Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If ...
[ "def", "build_epsf", "(", "self", ",", "stars", ",", "init_epsf", "=", "None", ")", ":", "iter_num", "=", "0", "center_dist_sq", "=", "self", ".", "center_accuracy_sq", "+", "1.", "centers", "=", "stars", ".", "cutout_center_flat", "n_stars", "=", "stars", ...
Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If not input, then the ePSF will be built from scratch. ...
[ "Iteratively", "build", "an", "ePSF", "from", "star", "cutouts", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L757-L842
10,653
astropy/photutils
photutils/psf/models.py
FittableImageModel._set_oversampling
def _set_oversampling(self, value): """ This is a private method because it's used in the initializer by the ``oversampling`` """ try: value = np.atleast_1d(value).astype(float) if len(value) == 1: value = np.repeat(value, 2) excep...
python
def _set_oversampling(self, value): """ This is a private method because it's used in the initializer by the ``oversampling`` """ try: value = np.atleast_1d(value).astype(float) if len(value) == 1: value = np.repeat(value, 2) excep...
[ "def", "_set_oversampling", "(", "self", ",", "value", ")", ":", "try", ":", "value", "=", "np", ".", "atleast_1d", "(", "value", ")", ".", "astype", "(", "float", ")", "if", "len", "(", "value", ")", "==", "1", ":", "value", "=", "np", ".", "rep...
This is a private method because it's used in the initializer by the ``oversampling``
[ "This", "is", "a", "private", "method", "because", "it", "s", "used", "in", "the", "initializer", "by", "the", "oversampling" ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L234-L249
10,654
astropy/photutils
photutils/psf/models.py
FittableImageModel.evaluate
def evaluate(self, x, y, flux, x_0, y_0, use_oversampling=True): """ Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the ...
python
def evaluate(self, x, y, flux, x_0, y_0, use_oversampling=True): """ Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the ...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ",", "use_oversampling", "=", "True", ")", ":", "if", "use_oversampling", ":", "xi", "=", "self", ".", "_oversampling", "[", "0", "]", "*", "(", "np", ".", "...
Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the model pixel indices. The default is `True`, which means the inpu...
[ "Evaluate", "the", "model", "on", "some", "input", "variables", "and", "provided", "model", "parameters", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L453-L486
10,655
astropy/photutils
photutils/psf/models.py
GriddedPSFModel._find_bounds_1d
def _find_bounds_1d(data, x): """ Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters -------...
python
def _find_bounds_1d(data, x): """ Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters -------...
[ "def", "_find_bounds_1d", "(", "data", ",", "x", ")", ":", "idx", "=", "np", ".", "searchsorted", "(", "data", ",", "x", ")", "if", "idx", "==", "0", ":", "idx0", "=", "0", "elif", "idx", "==", "len", "(", "data", ")", ":", "# pragma: no cover", ...
Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters ---------- data : 1D `~numpy.ndarray` ...
[ "Find", "the", "index", "of", "the", "lower", "bound", "where", "x", "should", "be", "inserted", "into", "a", "to", "maintain", "order", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L582-L612
10,656
astropy/photutils
photutils/psf/models.py
GriddedPSFModel._bilinear_interp
def _bilinear_interp(xyref, zref, xi, yi): """ Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D...
python
def _bilinear_interp(xyref, zref, xi, yi): """ Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D...
[ "def", "_bilinear_interp", "(", "xyref", ",", "zref", ",", "xi", ",", "yi", ")", ":", "if", "len", "(", "xyref", ")", "!=", "4", ":", "raise", "ValueError", "(", "'xyref must contain only 4 (x, y) pairs'", ")", "if", "zref", ".", "shape", "[", "0", "]", ...
Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D `~numpy.ndarray` A 3D `~numpy.ndarray` of shape ``...
[ "Perform", "bilinear", "interpolation", "of", "four", "2D", "arrays", "located", "at", "points", "on", "a", "regular", "grid", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L651-L706
10,657
astropy/photutils
photutils/psf/models.py
GriddedPSFModel.evaluate
def evaluate(self, x, y, flux, x_0, y_0): """ Evaluate the `GriddedPSFModel` for the input parameters. """ # NOTE: this is needed because the PSF photometry routines input # length-1 values instead of scalars. TODO: fix the photometry # routines. if not np.issca...
python
def evaluate(self, x, y, flux, x_0, y_0): """ Evaluate the `GriddedPSFModel` for the input parameters. """ # NOTE: this is needed because the PSF photometry routines input # length-1 values instead of scalars. TODO: fix the photometry # routines. if not np.issca...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ")", ":", "# NOTE: this is needed because the PSF photometry routines input", "# length-1 values instead of scalars. TODO: fix the photometry", "# routines.", "if", "not", "np", ".",...
Evaluate the `GriddedPSFModel` for the input parameters.
[ "Evaluate", "the", "GriddedPSFModel", "for", "the", "input", "parameters", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L708-L742
10,658
astropy/photutils
photutils/psf/models.py
IntegratedGaussianPRF.evaluate
def evaluate(self, x, y, flux, x_0, y_0, sigma): """Model function Gaussian PSF model.""" return (flux / 4 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqr...
python
def evaluate(self, x, y, flux, x_0, y_0, sigma): """Model function Gaussian PSF model.""" return (flux / 4 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqr...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ",", "sigma", ")", ":", "return", "(", "flux", "/", "4", "*", "(", "(", "self", ".", "_erf", "(", "(", "x", "-", "x_0", "+", "0.5", ")", "/", "(", "n...
Model function Gaussian PSF model.
[ "Model", "function", "Gaussian", "PSF", "model", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L819-L826
10,659
astropy/photutils
photutils/psf/models.py
PRFAdapter.evaluate
def evaluate(self, x, y, flux, x_0, y_0): """The evaluation function for PRFAdapter.""" if self.xname is None: dx = x - x_0 else: dx = x setattr(self.psfmodel, self.xname, x_0) if self.xname is None: dy = y - y_0 else: ...
python
def evaluate(self, x, y, flux, x_0, y_0): """The evaluation function for PRFAdapter.""" if self.xname is None: dx = x - x_0 else: dx = x setattr(self.psfmodel, self.xname, x_0) if self.xname is None: dy = y - y_0 else: ...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ")", ":", "if", "self", ".", "xname", "is", "None", ":", "dx", "=", "x", "-", "x_0", "else", ":", "dx", "=", "x", "setattr", "(", "self", ".", "psfmodel"...
The evaluation function for PRFAdapter.
[ "The", "evaluation", "function", "for", "PRFAdapter", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L895-L915
10,660
astropy/photutils
photutils/isophote/isophote.py
_isophote_list_to_table
def _isophote_list_to_table(isophote_list): """ Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Re...
python
def _isophote_list_to_table(isophote_list): """ Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Re...
[ "def", "_isophote_list_to_table", "(", "isophote_list", ")", ":", "properties", "=", "OrderedDict", "(", ")", "properties", "[", "'sma'", "]", "=", "'sma'", "properties", "[", "'intens'", "]", "=", "'intens'", "properties", "[", "'int_err'", "]", "=", "'intens...
Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Returns ------- result : `~astropy.table.QTable` ...
[ "Convert", "an", "~photutils", ".", "isophote", ".", "IsophoteList", "instance", "to", "a", "~astropy", ".", "table", ".", "QTable", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L730-L768
10,661
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_fluxes
def _compute_fluxes(self): """ Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the se...
python
def _compute_fluxes(self): """ Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the se...
[ "def", "_compute_fluxes", "(", "self", ")", ":", "# Compute limits of square array that encloses circle.", "sma", "=", "self", ".", "sample", ".", "geometry", ".", "sma", "x0", "=", "self", ".", "sample", ".", "geometry", ".", "x0", "y0", "=", "self", ".", "...
Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the semimajor axis length and with the length of the ...
[ "Compute", "integrated", "flux", "inside", "ellipse", "as", "well", "as", "inside", "a", "circle", "defined", "with", "the", "same", "semimajor", "axis", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L176-L221
10,662
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_deviations
def _compute_deviations(self, sample, n): """ Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data. """ try: coeffs = fit_first_and_second_...
python
def _compute_deviations(self, sample, n): """ Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data. """ try: coeffs = fit_first_and_second_...
[ "def", "_compute_deviations", "(", "self", ",", "sample", ",", "n", ")", ":", "try", ":", "coeffs", "=", "fit_first_and_second_harmonics", "(", "self", ".", "sample", ".", "values", "[", "0", "]", ",", "self", ".", "sample", ".", "values", "[", "2", "]...
Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data.
[ "Compute", "deviations", "from", "a", "perfect", "ellipse", "based", "on", "the", "amplitudes", "and", "errors", "for", "harmonic", "n", ".", "Note", "that", "we", "first", "subtract", "the", "first", "and", "second", "harmonics", "from", "the", "raw", "data...
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L223-L257
10,663
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_errors
def _compute_errors(self): """ Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2. """ try: coeffs = fit_first_and_second_harmonics(self.sample.values[0], ...
python
def _compute_errors(self): """ Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2. """ try: coeffs = fit_first_and_second_harmonics(self.sample.values[0], ...
[ "def", "_compute_errors", "(", "self", ")", ":", "try", ":", "coeffs", "=", "fit_first_and_second_harmonics", "(", "self", ".", "sample", ".", "values", "[", "0", "]", ",", "self", ".", "sample", ".", "values", "[", "2", "]", ")", "covariance", "=", "c...
Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2.
[ "Compute", "parameter", "errors", "based", "on", "the", "diagonal", "of", "the", "covariance", "matrix", "of", "the", "four", "harmonic", "coefficients", "for", "harmonics", "n", "=", "1", "and", "n", "=", "2", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L259-L295
10,664
astropy/photutils
photutils/isophote/isophote.py
Isophote.fix_geometry
def fix_geometry(self, isophote): """ Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless s...
python
def fix_geometry(self, isophote): """ Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless s...
[ "def", "fix_geometry", "(", "self", ",", "isophote", ")", ":", "self", ".", "sample", ".", "geometry", ".", "eps", "=", "isophote", ".", "sample", ".", "geometry", ".", "eps", "self", ".", "sample", ".", "geometry", ".", "pa", "=", "isophote", ".", "...
Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless situation. This is not a problem in itself when...
[ "Fix", "the", "geometry", "of", "a", "problematic", "isophote", "to", "be", "identical", "to", "the", "input", "isophote", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L297-L318
10,665
astropy/photutils
photutils/isophote/isophote.py
IsophoteList.get_closest
def get_closest(self, sma): """ Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- is...
python
def get_closest(self, sma): """ Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- is...
[ "def", "get_closest", "(", "self", ",", "sma", ")", ":", "index", "=", "(", "np", ".", "abs", "(", "self", ".", "sma", "-", "sma", ")", ")", ".", "argmin", "(", ")", "return", "self", ".", "_list", "[", "index", "]" ]
Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- isophote : `~photutils.isophote.Isophote` instance...
[ "Return", "the", "~photutils", ".", "isophote", ".", "Isophote", "instance", "that", "has", "the", "closest", "semimajor", "axis", "length", "to", "the", "input", "semimajor", "axis", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L468-L485
10,666
astropy/photutils
photutils/utils/interpolation.py
interpolate_masked_data
def interpolate_masked_data(data, mask, error=None, background=None): """ Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for sing...
python
def interpolate_masked_data(data, mask, error=None, background=None): """ Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for sing...
[ "def", "interpolate_masked_data", "(", "data", ",", "mask", ",", "error", "=", "None", ",", "background", "=", "None", ")", ":", "if", "data", ".", "shape", "!=", "mask", ".", "shape", ":", "raise", "ValueError", "(", "'data and mask must have the same shape'"...
Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for single, isolated masked pixels (e.g. hot/warm pixels). Parameters ---------- ...
[ "Interpolate", "over", "masked", "pixels", "in", "data", "and", "optional", "error", "or", "background", "images", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/interpolation.py#L289-L370
10,667
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.ThreadsWithRunningExecServers
def ThreadsWithRunningExecServers(self): """Returns a list of tids of inferior threads with open exec servers.""" socket_dir = '/tmp/pyringe_%s' % self.inferior.pid if os.path.isdir(socket_dir): return [int(fname[:-9]) for fname in os.listdir(socket_dir) if fname.endswith('...
python
def ThreadsWithRunningExecServers(self): """Returns a list of tids of inferior threads with open exec servers.""" socket_dir = '/tmp/pyringe_%s' % self.inferior.pid if os.path.isdir(socket_dir): return [int(fname[:-9]) for fname in os.listdir(socket_dir) if fname.endswith('...
[ "def", "ThreadsWithRunningExecServers", "(", "self", ")", ":", "socket_dir", "=", "'/tmp/pyringe_%s'", "%", "self", ".", "inferior", ".", "pid", "if", "os", ".", "path", ".", "isdir", "(", "socket_dir", ")", ":", "return", "[", "int", "(", "fname", "[", ...
Returns a list of tids of inferior threads with open exec servers.
[ "Returns", "a", "list", "of", "tids", "of", "inferior", "threads", "with", "open", "exec", "servers", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L46-L53
10,668
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.SendToExecSocket
def SendToExecSocket(self, code, tid=None): """Inject python code into exec socket.""" response = self._SendToExecSocketRaw(json.dumps(code), tid) return json.loads(response)
python
def SendToExecSocket(self, code, tid=None): """Inject python code into exec socket.""" response = self._SendToExecSocketRaw(json.dumps(code), tid) return json.loads(response)
[ "def", "SendToExecSocket", "(", "self", ",", "code", ",", "tid", "=", "None", ")", ":", "response", "=", "self", ".", "_SendToExecSocketRaw", "(", "json", ".", "dumps", "(", "code", ")", ",", "tid", ")", "return", "json", ".", "loads", "(", "response",...
Inject python code into exec socket.
[ "Inject", "python", "code", "into", "exec", "socket", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L55-L58
10,669
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.CloseExecSocket
def CloseExecSocket(self, tid=None): """Send closing request to exec socket.""" response = self._SendToExecSocketRaw('__kill__', tid) if response != '__kill_ack__': logging.warning('May not have succeeded in closing socket, make sure ' 'using execsocks().')
python
def CloseExecSocket(self, tid=None): """Send closing request to exec socket.""" response = self._SendToExecSocketRaw('__kill__', tid) if response != '__kill_ack__': logging.warning('May not have succeeded in closing socket, make sure ' 'using execsocks().')
[ "def", "CloseExecSocket", "(", "self", ",", "tid", "=", "None", ")", ":", "response", "=", "self", ".", "_SendToExecSocketRaw", "(", "'__kill__'", ",", "tid", ")", "if", "response", "!=", "'__kill_ack__'", ":", "logging", ".", "warning", "(", "'May not have ...
Send closing request to exec socket.
[ "Send", "closing", "request", "to", "exec", "socket", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L79-L84
10,670
google/pyringe
pyringe/plugins/read_only.py
ReadonlyPlugin.Backtrace
def Backtrace(self, to_string=False): """Get a backtrace of the current position.""" if self.inferior.is_running: res = self.inferior.Backtrace() if to_string: return res print res else: logging.error('Not attached to any process.')
python
def Backtrace(self, to_string=False): """Get a backtrace of the current position.""" if self.inferior.is_running: res = self.inferior.Backtrace() if to_string: return res print res else: logging.error('Not attached to any process.')
[ "def", "Backtrace", "(", "self", ",", "to_string", "=", "False", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "res", "=", "self", ".", "inferior", ".", "Backtrace", "(", ")", "if", "to_string", ":", "return", "res", "print", "res", ...
Get a backtrace of the current position.
[ "Get", "a", "backtrace", "of", "the", "current", "position", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/read_only.py#L52-L60
10,671
google/pyringe
pyringe/plugins/read_only.py
ReadonlyPlugin.ListThreads
def ListThreads(self): """List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process. """ if self.inferior.is_running: return self.inferior.threads logging.error('Not attached to any process.')...
python
def ListThreads(self): """List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process. """ if self.inferior.is_running: return self.inferior.threads logging.error('Not attached to any process.')...
[ "def", "ListThreads", "(", "self", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "return", "self", ".", "inferior", ".", "threads", "logging", ".", "error", "(", "'Not attached to any process.'", ")", "return", "[", "]" ]
List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process.
[ "List", "the", "currently", "running", "python", "threads", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/read_only.py#L86-L96
10,672
google/pyringe
pyringe/payload/gdb_service.py
PyFrameObjectPtr.extract_filename
def extract_filename(self): """Alternative way of getting the executed file which inspects globals.""" globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT) global_dict = libpython.PyDictObjectPtr(globals_gdbval) for key, value in global_dict.iteritems(): if str(key.proxyval(set())) == '_...
python
def extract_filename(self): """Alternative way of getting the executed file which inspects globals.""" globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT) global_dict = libpython.PyDictObjectPtr(globals_gdbval) for key, value in global_dict.iteritems(): if str(key.proxyval(set())) == '_...
[ "def", "extract_filename", "(", "self", ")", ":", "globals_gdbval", "=", "self", ".", "_gdbval", "[", "'f_globals'", "]", ".", "cast", "(", "GdbCache", ".", "DICT", ")", "global_dict", "=", "libpython", ".", "PyDictObjectPtr", "(", "globals_gdbval", ")", "fo...
Alternative way of getting the executed file which inspects globals.
[ "Alternative", "way", "of", "getting", "the", "executed", "file", "which", "inspects", "globals", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L157-L163
10,673
google/pyringe
pyringe/payload/gdb_service.py
GdbService._UnserializableObjectFallback
def _UnserializableObjectFallback(self, obj): """Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new sty...
python
def _UnserializableObjectFallback(self, obj): """Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new sty...
[ "def", "_UnserializableObjectFallback", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "libpython", ".", "PyInstanceObjectPtr", ")", ":", "# old-style classes use 'classobj'/'instance'", "# get class attribute dictionary", "in_class", "=", "obj", ...
Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new style classes) Args: obj: The object to Json-s...
[ "Handles", "sanitizing", "of", "unserializable", "objects", "for", "Json", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L208-L271
10,674
google/pyringe
pyringe/payload/gdb_service.py
GdbService._AcceptRPC
def _AcceptRPC(self): """Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists. """ request =...
python
def _AcceptRPC(self): """Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists. """ request =...
[ "def", "_AcceptRPC", "(", "self", ")", ":", "request", "=", "self", ".", "_ReadObject", "(", ")", "if", "request", "[", "'func'", "]", "==", "'__kill__'", ":", "self", ".", "ClearBreakpoints", "(", ")", "self", ".", "_WriteObject", "(", "'__kill_ack__'", ...
Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists.
[ "Reads", "RPC", "request", "from", "stdin", "and", "processes", "it", "writing", "result", "to", "stdout", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L293-L311
10,675
google/pyringe
pyringe/payload/gdb_service.py
GdbService._UnpackGdbVal
def _UnpackGdbVal(self, gdb_value): """Unpacks gdb.Value objects and returns the best-matched python object.""" val_type = gdb_value.type.code if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM: return int(gdb_value) if val_type == gdb.TYPE_CODE_VOID: return None if val_t...
python
def _UnpackGdbVal(self, gdb_value): """Unpacks gdb.Value objects and returns the best-matched python object.""" val_type = gdb_value.type.code if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM: return int(gdb_value) if val_type == gdb.TYPE_CODE_VOID: return None if val_t...
[ "def", "_UnpackGdbVal", "(", "self", ",", "gdb_value", ")", ":", "val_type", "=", "gdb_value", ".", "type", ".", "code", "if", "val_type", "==", "gdb", ".", "TYPE_CODE_INT", "or", "val_type", "==", "gdb", ".", "TYPE_CODE_ENUM", ":", "return", "int", "(", ...
Unpacks gdb.Value objects and returns the best-matched python object.
[ "Unpacks", "gdb", ".", "Value", "objects", "and", "returns", "the", "best", "-", "matched", "python", "object", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L313-L326
10,676
google/pyringe
pyringe/payload/gdb_service.py
GdbService.EnsureGdbPosition
def EnsureGdbPosition(self, pid, tid, frame_depth): """Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUna...
python
def EnsureGdbPosition(self, pid, tid, frame_depth): """Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUna...
[ "def", "EnsureGdbPosition", "(", "self", ",", "pid", ",", "tid", ",", "frame_depth", ")", ":", "position", "=", "[", "pid", ",", "tid", ",", "frame_depth", "]", "if", "not", "pid", ":", "return", "if", "not", "self", ".", "IsAttached", "(", ")", ":",...
Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUnavailableException: If the requested process, thread or fram...
[ "Make", "sure", "our", "position", "matches", "the", "request", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L335-L378
10,677
google/pyringe
pyringe/payload/gdb_service.py
GdbService.IsSymbolFileSane
def IsSymbolFileSane(self, position): """Performs basic sanity check by trying to look up a bunch of symbols.""" pos = [position[0], None, None] self.EnsureGdbPosition(*pos) try: if GdbCache.DICT and GdbCache.TYPE and GdbCache.INTERP_HEAD: # pylint: disable=pointless-statement tsta...
python
def IsSymbolFileSane(self, position): """Performs basic sanity check by trying to look up a bunch of symbols.""" pos = [position[0], None, None] self.EnsureGdbPosition(*pos) try: if GdbCache.DICT and GdbCache.TYPE and GdbCache.INTERP_HEAD: # pylint: disable=pointless-statement tsta...
[ "def", "IsSymbolFileSane", "(", "self", ",", "position", ")", ":", "pos", "=", "[", "position", "[", "0", "]", ",", "None", ",", "None", "]", "self", ".", "EnsureGdbPosition", "(", "*", "pos", ")", "try", ":", "if", "GdbCache", ".", "DICT", "and", ...
Performs basic sanity check by trying to look up a bunch of symbols.
[ "Performs", "basic", "sanity", "check", "by", "trying", "to", "look", "up", "a", "bunch", "of", "symbols", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L392-L433
10,678
google/pyringe
pyringe/payload/gdb_service.py
GdbService.Detach
def Detach(self): """Detaches from the inferior. If not attached, this is a no-op.""" # We have to work around the python APIs weirdness :\ if not self.IsAttached(): return None # Gdb doesn't drain any pending SIGINTs it may have sent to the inferior # when it simply detaches. We can do this b...
python
def Detach(self): """Detaches from the inferior. If not attached, this is a no-op.""" # We have to work around the python APIs weirdness :\ if not self.IsAttached(): return None # Gdb doesn't drain any pending SIGINTs it may have sent to the inferior # when it simply detaches. We can do this b...
[ "def", "Detach", "(", "self", ")", ":", "# We have to work around the python APIs weirdness :\\", "if", "not", "self", ".", "IsAttached", "(", ")", ":", "return", "None", "# Gdb doesn't drain any pending SIGINTs it may have sent to the inferior", "# when it simply detaches. We ca...
Detaches from the inferior. If not attached, this is a no-op.
[ "Detaches", "from", "the", "inferior", ".", "If", "not", "attached", "this", "is", "a", "no", "-", "op", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L449-L467
10,679
google/pyringe
pyringe/payload/gdb_service.py
GdbService.Call
def Call(self, position, function_call): """Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuin...
python
def Call(self, position, function_call): """Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuin...
[ "def", "Call", "(", "self", ",", "position", ",", "function_call", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "None", ",", "None", ")", "if", "not", "gdb", ".", "selected_thread", "(", ")", ".", "is_stopped", "(", ...
Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuing it after the call is the responsibility of...
[ "Perform", "a", "function", "call", "in", "the", "inferior", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L492-L511
10,680
google/pyringe
pyringe/payload/gdb_service.py
GdbService.ExecuteRaw
def ExecuteRaw(self, position, command): """Send a command string to gdb.""" self.EnsureGdbPosition(position[0], None, None) return gdb.execute(command, to_string=True)
python
def ExecuteRaw(self, position, command): """Send a command string to gdb.""" self.EnsureGdbPosition(position[0], None, None) return gdb.execute(command, to_string=True)
[ "def", "ExecuteRaw", "(", "self", ",", "position", ",", "command", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "None", ",", "None", ")", "return", "gdb", ".", "execute", "(", "command", ",", "to_string", "=", "True"...
Send a command string to gdb.
[ "Send", "a", "command", "string", "to", "gdb", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L513-L516
10,681
google/pyringe
pyringe/payload/gdb_service.py
GdbService._GetGdbThreadMapping
def _GetGdbThreadMapping(self, position): """Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate b...
python
def _GetGdbThreadMapping(self, position): """Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate b...
[ "def", "_GetGdbThreadMapping", "(", "self", ",", "position", ")", ":", "if", "len", "(", "gdb", ".", "selected_inferior", "(", ")", ".", "threads", "(", ")", ")", "==", "1", ":", "# gdb's output for info threads changes and only displays PID. We cheat.", "return", ...
Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate between these two, we have to execute 'info th...
[ "Gets", "a", "mapping", "from", "python", "tid", "to", "gdb", "thread", "num", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L518-L545
10,682
google/pyringe
pyringe/payload/gdb_service.py
GdbService._Inject
def _Inject(self, position, call): """Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame...
python
def _Inject(self, position, call): """Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame...
[ "def", "_Inject", "(", "self", ",", "position", ",", "call", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "position", "[", "1", "]", ",", "None", ")", "self", ".", "ClearBreakpoints", "(", ")", "self", ".", "_AddTh...
Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame gdb constructs for us, and will most ...
[ "Injects", "evaluation", "of", "call", "in", "a", "safe", "location", "in", "the", "inferior", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L557-L587
10,683
google/pyringe
pyringe/payload/gdb_service.py
GdbService._BacktraceFromFramePtr
def _BacktraceFromFramePtr(self, frame_ptr): """Assembles and returns what looks exactly like python's backtraces.""" # expects frame_ptr to be a gdb.Value frame_objs = [PyFrameObjectPtr(frame) for frame in self._IterateChainedList(frame_ptr, 'f_back')] # We want to output tracebacks ...
python
def _BacktraceFromFramePtr(self, frame_ptr): """Assembles and returns what looks exactly like python's backtraces.""" # expects frame_ptr to be a gdb.Value frame_objs = [PyFrameObjectPtr(frame) for frame in self._IterateChainedList(frame_ptr, 'f_back')] # We want to output tracebacks ...
[ "def", "_BacktraceFromFramePtr", "(", "self", ",", "frame_ptr", ")", ":", "# expects frame_ptr to be a gdb.Value", "frame_objs", "=", "[", "PyFrameObjectPtr", "(", "frame", ")", "for", "frame", "in", "self", ".", "_IterateChainedList", "(", "frame_ptr", ",", "'f_bac...
Assembles and returns what looks exactly like python's backtraces.
[ "Assembles", "and", "returns", "what", "looks", "exactly", "like", "python", "s", "backtraces", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L597-L615
10,684
google/pyringe
pyringe/inferior.py
GdbProxy.Kill
def Kill(self): """Send death pill to Gdb and forcefully kill it if that doesn't work.""" try: if self.is_running: self.Detach() if self._Execute('__kill__') == '__kill_ack__': # acknowledged, let's give it some time to die in peace time.sleep(0.1) except (TimeoutError, P...
python
def Kill(self): """Send death pill to Gdb and forcefully kill it if that doesn't work.""" try: if self.is_running: self.Detach() if self._Execute('__kill__') == '__kill_ack__': # acknowledged, let's give it some time to die in peace time.sleep(0.1) except (TimeoutError, P...
[ "def", "Kill", "(", "self", ")", ":", "try", ":", "if", "self", ".", "is_running", ":", "self", ".", "Detach", "(", ")", "if", "self", ".", "_Execute", "(", "'__kill__'", ")", "==", "'__kill_ack__'", ":", "# acknowledged, let's give it some time to die in peac...
Send death pill to Gdb and forcefully kill it if that doesn't work.
[ "Send", "death", "pill", "to", "Gdb", "and", "forcefully", "kill", "it", "if", "that", "doesn", "t", "work", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L202-L222
10,685
google/pyringe
pyringe/inferior.py
GdbProxy.Version
def Version(): """Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the...
python
def Version(): """Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the...
[ "def", "Version", "(", ")", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'gdb'", ",", "'--version'", "]", ")", ".", "split", "(", "'\\n'", ")", "[", "0", "]", "# Example output (Arch linux):", "# GNU gdb (GDB) 7.7", "# Example output (Debian...
Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the form (<major>, ...
[ "Gets", "the", "version", "of", "gdb", "as", "a", "3", "-", "tuple", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L229-L272
10,686
google/pyringe
pyringe/inferior.py
GdbProxy._JsonDecodeDict
def _JsonDecodeDict(self, data): """Json object decode hook that automatically converts unicode objects.""" rv = {} for key, value in data.iteritems(): if isinstance(key, unicode): key = self._TryStr(key) if isinstance(value, unicode): value = self._TryStr(value) elif isins...
python
def _JsonDecodeDict(self, data): """Json object decode hook that automatically converts unicode objects.""" rv = {} for key, value in data.iteritems(): if isinstance(key, unicode): key = self._TryStr(key) if isinstance(value, unicode): value = self._TryStr(value) elif isins...
[ "def", "_JsonDecodeDict", "(", "self", ",", "data", ")", ":", "rv", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "key", ",", "unicode", ")", ":", "key", "=", "self", ".", "_Try...
Json object decode hook that automatically converts unicode objects.
[ "Json", "object", "decode", "hook", "that", "automatically", "converts", "unicode", "objects", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L305-L319
10,687
google/pyringe
pyringe/inferior.py
GdbProxy._Execute
def _Execute(self, funcname, *args, **kwargs): """Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is ins...
python
def _Execute(self, funcname, *args, **kwargs): """Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is ins...
[ "def", "_Execute", "(", "self", ",", "funcname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wait_for_completion", "=", "kwargs", ".", "get", "(", "'wait_for_completion'", ",", "False", ")", "rpc_dict", "=", "{", "'func'", ":", "funcname", ",",...
Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is inspected, which decides whether to wait forever ...
[ "Send", "an", "RPC", "request", "to", "the", "gdb", "-", "internal", "python", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L325-L355
10,688
google/pyringe
pyringe/inferior.py
GdbProxy._Recv
def _Recv(self, timeout): """Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of ...
python
def _Recv(self, timeout): """Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of ...
[ "def", "_Recv", "(", "self", ",", "timeout", ")", ":", "buf", "=", "''", "# The messiness of this stems from the \"duck-typiness\" of this function.", "# The timeout parameter of poll has different semantics depending on whether", "# it's <=0, >0, or None. Yay.", "wait_for_line", "=", ...
Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of None or TIMEOUT_FOREVER means "th...
[ "Receive", "output", "from", "gdb", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L361-L429
10,689
google/pyringe
pyringe/inferior.py
Inferior.needsattached
def needsattached(func): """Decorator to prevent commands from being used when not attached.""" @functools.wraps(func) def wrap(self, *args, **kwargs): if not self.attached: raise PositionError('Not attached to any process.') return func(self, *args, **kwargs) return wrap
python
def needsattached(func): """Decorator to prevent commands from being used when not attached.""" @functools.wraps(func) def wrap(self, *args, **kwargs): if not self.attached: raise PositionError('Not attached to any process.') return func(self, *args, **kwargs) return wrap
[ "def", "needsattached", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrap", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "attached", ":", "raise", "PositionError", "...
Decorator to prevent commands from being used when not attached.
[ "Decorator", "to", "prevent", "commands", "from", "being", "used", "when", "not", "attached", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L458-L466
10,690
google/pyringe
pyringe/inferior.py
Inferior.Reinit
def Reinit(self, pid, auto_symfile_loading=True): """Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process ...
python
def Reinit(self, pid, auto_symfile_loading=True): """Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process ...
[ "def", "Reinit", "(", "self", ",", "pid", ",", "auto_symfile_loading", "=", "True", ")", ":", "self", ".", "ShutDownGdb", "(", ")", "self", ".", "__init__", "(", "pid", ",", "auto_symfile_loading", ",", "architecture", "=", "self", ".", "arch", ")" ]
Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process auto_symfile_loading: whether the symbol file should...
[ "Reinitializes", "the", "object", "with", "a", "new", "pid", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L472-L484
10,691
google/pyringe
pyringe/plugins/inject.py
InjectPlugin.InjectString
def InjectString(self, codestring, wait_for_completion=True): """Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed. """ if self.inferior.is_runnin...
python
def InjectString(self, codestring, wait_for_completion=True): """Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed. """ if self.inferior.is_runnin...
[ "def", "InjectString", "(", "self", ",", "codestring", ",", "wait_for_completion", "=", "True", ")", ":", "if", "self", ".", "inferior", ".", "is_running", "and", "self", ".", "inferior", ".", "gdb", ".", "IsAttached", "(", ")", ":", "try", ":", "self", ...
Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed.
[ "Try", "to", "inject", "python", "code", "into", "current", "thread", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject.py#L40-L57
10,692
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.field
def field(self, name): ''' Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined...
python
def field(self, name): ''' Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined...
[ "def", "field", "(", "self", ",", "name", ")", ":", "if", "self", ".", "is_null", "(", ")", ":", "raise", "NullPyObjectPtr", "(", "self", ")", "if", "name", "==", "'ob_type'", ":", "pyo_ptr", "=", "self", ".", "_gdbval", ".", "cast", "(", "PyObjectPt...
Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined so that "ob_type" and (for a var o...
[ "Get", "the", "gdb", ".", "Value", "for", "the", "given", "field", "within", "the", "PyObject", "coping", "with", "some", "python", "2", "versus", "python", "3", "differences", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L131-L163
10,693
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.write_repr
def write_repr(self, out, visited): ''' Write a string representation of the value scraped from the inferior process to "out", a file-like object. ''' # Default implementation: generate a proxy value and write its repr # However, this could involve a lot of work for compl...
python
def write_repr(self, out, visited): ''' Write a string representation of the value scraped from the inferior process to "out", a file-like object. ''' # Default implementation: generate a proxy value and write its repr # However, this could involve a lot of work for compl...
[ "def", "write_repr", "(", "self", ",", "out", ",", "visited", ")", ":", "# Default implementation: generate a proxy value and write its repr", "# However, this could involve a lot of work for complicated objects,", "# so for derived classes we specialize this", "return", "out", ".", ...
Write a string representation of the value scraped from the inferior process to "out", a file-like object.
[ "Write", "a", "string", "representation", "of", "the", "value", "scraped", "from", "the", "inferior", "process", "to", "out", "a", "file", "-", "like", "object", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L262-L270
10,694
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.from_pyobject_ptr
def from_pyobject_ptr(cls, gdbval): ''' Try to locate the appropriate derived class dynamically, and cast the pointer accordingly. ''' try: p = PyObjectPtr(gdbval) cls = cls.subclass_from_type(p.type()) return cls(gdbval, cast_to=cls.get_gdb_ty...
python
def from_pyobject_ptr(cls, gdbval): ''' Try to locate the appropriate derived class dynamically, and cast the pointer accordingly. ''' try: p = PyObjectPtr(gdbval) cls = cls.subclass_from_type(p.type()) return cls(gdbval, cast_to=cls.get_gdb_ty...
[ "def", "from_pyobject_ptr", "(", "cls", ",", "gdbval", ")", ":", "try", ":", "p", "=", "PyObjectPtr", "(", "gdbval", ")", "cls", "=", "cls", ".", "subclass_from_type", "(", "p", ".", "type", "(", ")", ")", "return", "cls", "(", "gdbval", ",", "cast_t...
Try to locate the appropriate derived class dynamically, and cast the pointer accordingly.
[ "Try", "to", "locate", "the", "appropriate", "derived", "class", "dynamically", "and", "cast", "the", "pointer", "accordingly", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L340-L353
10,695
google/pyringe
pyringe/payload/libpython.py
HeapTypeObjectPtr.proxyval
def proxyval(self, visited): ''' Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors ''' # Guard against infinite loops: if self.as_address() in visited: ...
python
def proxyval(self, visited): ''' Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors ''' # Guard against infinite loops: if self.as_address() in visited: ...
[ "def", "proxyval", "(", "self", ",", "visited", ")", ":", "# Guard against infinite loops:", "if", "self", ".", "as_address", "(", ")", "in", "visited", ":", "return", "ProxyAlreadyVisited", "(", "'<...>'", ")", "visited", ".", "add", "(", "self", ".", "as_a...
Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors
[ "Support", "for", "new", "-", "style", "classes", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L459-L479
10,696
google/pyringe
pyringe/payload/libpython.py
PyCodeObjectPtr.addr2line
def addr2line(self, addrq): ''' Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt ''' co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) # Initialize lineno to co_firstline...
python
def addr2line(self, addrq): ''' Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt ''' co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) # Initialize lineno to co_firstline...
[ "def", "addr2line", "(", "self", ",", "addrq", ")", ":", "co_lnotab", "=", "self", ".", "pyop_field", "(", "'co_lnotab'", ")", ".", "proxyval", "(", "set", "(", ")", ")", "# Initialize lineno to co_firstlineno as per PyCode_Addr2Line", "# not 0, as lnotab_notes.txt ha...
Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt
[ "Get", "the", "line", "number", "for", "a", "given", "bytecode", "offset" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L592-L611
10,697
google/pyringe
pyringe/payload/libpython.py
PyFrameObjectPtr.current_line
def current_line(self): '''Get the text of the current source line as a string, with a trailing newline character''' if self.is_optimized_out(): return '(frame information optimized out)' with open(self.filename(), 'r') as f: all_lines = f.readlines() ...
python
def current_line(self): '''Get the text of the current source line as a string, with a trailing newline character''' if self.is_optimized_out(): return '(frame information optimized out)' with open(self.filename(), 'r') as f: all_lines = f.readlines() ...
[ "def", "current_line", "(", "self", ")", ":", "if", "self", ".", "is_optimized_out", "(", ")", ":", "return", "'(frame information optimized out)'", "with", "open", "(", "self", ".", "filename", "(", ")", ",", "'r'", ")", "as", "f", ":", "all_lines", "=", ...
Get the text of the current source line as a string, with a trailing newline character
[ "Get", "the", "text", "of", "the", "current", "source", "line", "as", "a", "string", "with", "a", "trailing", "newline", "character" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L889-L897
10,698
google/pyringe
pyringe/payload/libpython.py
Frame.select
def select(self): '''If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot''' if not hasattr(self._gdbframe, 'select'): print ('Unabl...
python
def select(self): '''If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot''' if not hasattr(self._gdbframe, 'select'): print ('Unabl...
[ "def", "select", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ".", "_gdbframe", ",", "'select'", ")", ":", "print", "(", "'Unable to select frame: '", "'this build of gdb does not expose a gdb.Frame.select method'", ")", "return", "False", "self", "."...
If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot
[ "If", "supported", "select", "this", "frame", "and", "return", "True", ";", "return", "False", "if", "unsupported" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1173-L1183
10,699
google/pyringe
pyringe/payload/libpython.py
Frame.get_index
def get_index(self): '''Calculate index of frame, starting at 0 for the newest frame within this thread''' index = 0 # Go down until you reach the newest frame: iter_frame = self while iter_frame.newer(): index += 1 iter_frame = iter_frame.newer() ...
python
def get_index(self): '''Calculate index of frame, starting at 0 for the newest frame within this thread''' index = 0 # Go down until you reach the newest frame: iter_frame = self while iter_frame.newer(): index += 1 iter_frame = iter_frame.newer() ...
[ "def", "get_index", "(", "self", ")", ":", "index", "=", "0", "# Go down until you reach the newest frame:", "iter_frame", "=", "self", "while", "iter_frame", ".", "newer", "(", ")", ":", "index", "+=", "1", "iter_frame", "=", "iter_frame", ".", "newer", "(", ...
Calculate index of frame, starting at 0 for the newest frame within this thread
[ "Calculate", "index", "of", "frame", "starting", "at", "0", "for", "the", "newest", "frame", "within", "this", "thread" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1185-L1194