API Reference

Ducks

class tractor.Params[source]

A set of parameters that can be optimized by the Tractor.

This is a duck-type definition.

copy()[source]
getAllParams()[source]
getAllStepSizes(*args, **kwargs)[source]
getGaussianPriors()[source]

Returns a list of (index, mu, sigma) of Gaussian priors on this set of parameters.

getLogPrior()[source]

Returns the prior, evaluated at the current values of the parameters.

getLogPriorDerivatives()[source]

Returns a “chi-like” approximation to the log-prior at the current parameter values.

This will go into the least-squares fitting (each term in the prior acts like an extra “pixel” in the fit).

Returns (rowA, colA, valA, pb, mub), where:

rowA, colA, valA: describe a sparse matrix pA

pA: has shape N x numberOfParams pb: has shape N mub: has shape N

rowA: list of iterables of ints colA: list of iterables of ints valA: list of iterables of floats pb: list of iterables of floats mub: list of iterables of floats

where “N” is the number of “pseudo-pixels” or Gaussian terms. “pA” will be appended to the least-squares “A” matrix, and “pb” will be appended to the least-squares “b” vector, and the least-squares problem is minimizing

|| A * (delta-params) - b ||^2

We also require mub, which is like “pb” but not shifted relative to the current parameter values; ie, it’s the mean of the Gaussian.

This function must take frozen-ness of parameters into account (this is implied by the “numberOfParams” shape requirement).

getLowerBounds()[source]
getParamNames()[source]

Returns a list of strings: the names of the parameters.

getParams()[source]

Returns a copy of the current parameter values as an iterable (eg, list)

getStepSizes(*args, **kwargs)[source]

Returns “reasonable” step sizes for the parameters.

getUpperBounds()[source]
hashkey()[source]

Returns a tuple containing the state of this Params object for use as a cache key.

All elements must be hashable: see http://docs.python.org/glossary.html#term-hashable

numberOfParams()[source]

Returns the number of parameters (ie, number of scalar values).

setAllParams(p)[source]
setAllStepSizes(ss)[source]
setParam(i, p)[source]

Sets parameter index ‘i’ to new value ‘p’.

i: integer in the range [0, numberOfParams()). p: float

Returns the old value.

setParams(p)[source]

Sets the parameter values to the values in the given iterable p. The length of p will be equal to numberOfParams().

setStepSizes(ss)[source]
class tractor.Source[source]

This is the duck-type definition of a Source (star, galaxy, etc) that the Tractor uses.

getBrightnesses()[source]
getModelPatch(img, minsb=0.0, modelMask=None)[source]

Returns a Patch object containing a rendering of this Source into the given Image object. This will probably use the calibration information of the Image: the WCS, PSF, and photometric calibration.

minsb: the allowable approximation error per pixel; we are asking the source to render itself out to this surface brightness.

modelMask: a ModelMask object describing the rectangular
region of interest (image pixels).
getParamDerivatives(img, modelMask=None)[source]

Returns [ Patch, Patch, ... ], of length numberOfParams(), containing the derivatives in the given Image for each parameter.

getUnitFluxModelPatches(img, minval=0.0, modelMask=None)[source]

Returns a list the same length as getBrightnesses(), each containing a Patch whose sum is ~ unity.

Like getModelPatch(), but ignore the brightness of the object and just return a patch whose sum is unity. Like “minsb”, “minval” gives the allowable per-pixel value at which the profile can be truncated. The patch may therefore not sum to 1 exactly.

class tractor.Sky[source]

Duck-type definition for a sky model.

addTo(mod, scale=1.0)[source]

Add the sky to the input synthetic image mod, a 2-D numpy array.

getConstant()[source]

Returns an unspecified constant value, eg the mean, median, etc.

getParamDerivatives(tractor, img, srcs)[source]

Returns [ Patch, Patch, ... ], of length numberOfParams(), containing the derivatives in the given Image for each parameter.

shift(x0, y0)[source]

Shifts this sky model so that it applies to the subimage starting at x0,y0.

shifted(x0, y0)[source]
subtract(con)[source]

Subtracts a constant value from this sky model.

class tractor.Brightness[source]

Duck-type definition of the brightness of an astronomical source.

Only used as an input to PhotoCal. Source`s have `Brightness`es; `PhotoCal`s convert these into counts in a specific `Image.

class tractor.PhotoCal[source]

Duck-type definition of photometric calibration.

A PhotoCal belongs to an Image; it converts Brightness values into counts (“data numbers”, ADU, etc) in the data space (synthetic image) of the Image. It also contains the parameters of that conversion so they can be optimized along with everything else.

This relationship need not be linear: the Brightness could be an astronomical magnitude, for example. In general, there is a lot of freedom in the definition of the Brightness object, and PhotoCal has to be kept consistent with that.

brightnessToCounts(brightness)[source]

Converts brightness, a Brightness duck, into counts.

Returns: float

class tractor.Position[source]

Duck-type definition of the position of an astronomical object.

Only used as an input to a WCS object; Sources have Positions, and WCS objects convert them into pixel coordinates in a specific Image.

class tractor.WCS[source]

Duck-type definition of World Coordinate System.

Converts between Position objects and Image pixel coordinates.

In general, there is a lot of freedom in the definition of the Position object, and WCS has to be kept consistent with that. For instance, if the Positions used are image-based x-y positions (PixPos), then WCS has to be null (or close to that); NullWCS.

cdAtPixel(x, y)[source]

Returns a local affine relationship between Position and (x,y) pixel coordinates. This is used, for example, to convert tensor shapes of galaxies from Position space to image space.

Returns a numpy array of shape (2,2).

In FITS celestial coordinates language, this is the CD matrix at pixel x,y:

[ [ dRA/dx * cos(Dec), dRA/dy * cos(Dec) ],
[ dDec/dx , dDec/dy ] ]

in FITS these are called:

[ [ CD11 , CD12 ],
[ CD21 , CD22 ] ]

The units of these things are degrees per pixel.

cdInverseAtPixel(x, y)[source]
pixscale_at(x, y)[source]

Returns the local pixel scale at the given x,*y* pixel coords, in arcseconds per pixel.

positionToPixel(pos, src=None)[source]

Converts a tractor.Position pos into x,y pixel coordinates.

Note that the tractor.Source may be passed in; your tractor.WCS could have color-specific behavior, for example.

Returns tuple (x, y), where x and y are floats, and 0, 0 is the first pixel.

Pixels are funny things. Our convention is shifted by 1 from the FITS convention, so 0,0 is the center of the first (“zeroth”, says Hogg) pixel, if you think of pixels as little boxes. (What is the emoticon for “point and laugh”?)

shifted(dx, dy)[source]

Returns a new WCS object appropriate for the subimage starting at (dx,dy) with respect to the current WCS origin.

class tractor.PSF[source]

Duck-type definition of a point-spread function.

getPointSourcePatch(px, py, minval=0.0, modelMask=None)[source]

Returns a Patch, a rendering of a point source at the given pixel coordinates.

The returned Patch should have unit “counts”.

minval says that we are willing to accept an approximation such that pixels with counts < minval can be omitted.

modelMask describes the pixels to be evaluated. If the
modelMask includes a pixel-by-pixel mask, this overrides minval.
getRadius()[source]

Returns the size of the support of this PSF.

This is required because the Tractor has to decide what size to make the ``Patch``es.

getShifted(x0, y0)[source]

Returns a PSF model for the subimage starting at x0,y0.

Utilities

class tractor.BaseParams[source]

A basic implementation of the Params duck type.

copy()[source]
getAllParams()[source]
getAllStepSizes(*args, **kwargs)[source]
getGaussianPriors()[source]
getLogPrior()[source]

Return the prior PDF, evaluated at the current value of the paramters.

getLogPriorDerivatives()[source]
getLowerBounds()[source]
getParamNames()[source]

Returns a list containing the names of the parameters.

getParams()[source]

Returns a copy of the current parameter values as an iterable (eg, list)

getStepSizes(*args, **kwargs)[source]

Returns “reasonable” step sizes for the parameters.

getUpperBounds()[source]
hashkey()[source]
numberOfParams()[source]

Returns the number of parameters (ie, number of scalar values).

setAllParams(p)[source]
setAllStepSizes(ss)[source]
setParam(i, p)[source]

NOTE, you MUST implement either “setParams” or “setParam”, because the default implementation causes an infinite loop!

Sets parameter index i to new value p.

i: integer in the range [0, numberOfParams()). p: float

Returns the old value.

setParams(p)[source]

NOTE, you MUST implement either “setParams” or “setParam”, because the default implementation causes an infinite loop!

Sets the parameter values to the values in the given iterable p. The base class implementation just calls setParam for each element.

setStepSizes(ss)[source]
class tractor.NamedParams[source]

A mix-in class for Params subclassers.

Allows names to be attached to parameters.

Also allows parameters to be set “Active” or “Inactive”.

addNamedParams(**d)[source]

d: dict of (string, int) parameter names->indices

addParamAliases(**d)[source]
freezeAllBut(*args)[source]
freezeAllParams()[source]
freezeParam(paramname)[source]
freezeParams(*args)[source]
freezeParamsRecursive(*pnames)[source]
getAllParams()[source]

Returns all params, regardless of thawed/frozen status.

getAllStepSizes(*args, **kwargs)[source]

Returns “reasonable” step sizes for the parameters, ignoring frozen/thawed state.

getFrozenParamIndices()[source]
getFrozenParams()[source]
getLiquidIndex(paramname)[source]

Returns the index, among the thawed parameters, of the given named parameter. Returns -1 if the parameter is frozen. Raises KeyError if the parameter is not found.

For example, if names ‘a’,’c’, and ‘e’ are thawed,

getLiquidIndex(‘c’) returns 1 getLiquidIndex(‘b’) returns -1

getLiquidIndexOfIndex(i)[source]

Return the index, among the thawed parameters, of the given parameter index (in all parameters). Returns -1 if the parameter is frozen.

getNamedParamIndex(name)[source]
getNamedParamName(ii)[source]
static getNamedParams()[source]

Returns a dict of name->index mappings.

getParamStateRecursive()[source]
getStepSizes(*args, **kwargs)[source]
getThawedParamIndices()[source]
getThawedParams()[source]
isParamFrozen(paramname)[source]
isParamThawed(paramname)[source]
setAllParams(p)[source]

Returns all params, regardless of thawed/frozen status.

setAllStepSizes(ss)[source]
setStepSizes(ss)[source]
thawAllParams()[source]
thawParam(paramname)[source]
thawParams(*args)[source]
thawParamsRecursive(*pnames)[source]
thawPathsTo(*pnames)[source]

This is a (non-recursive) basic implementation

unfreezeAllParams()
unfreezeParam(paramname)
unfreezeParams(*args)
class tractor.ScalarParam(val=0)[source]

Implementation of “Params” for a single scalar (float) parameter, stored in self.val

copy()[source]
getLowerBounds()[source]
getParamNames()[source]
getParams()[source]
getStepSizes(*args, **kwargs)[source]
getUpperBounds()[source]
getValue()[source]
numberOfParams()[source]
setParam(i, p)[source]
setParams(p)[source]
setStepSizes(ss)[source]
setValue(v)[source]
stepsize = 1.0
strformat = '%g'
class tractor.ParamList(*args)[source]

An implementation of Params that holds values in a list.

class ParamListIter(pl)[source]
next()[source]
ParamList.copy()[source]
ParamList.getAllParams()[source]
ParamList.getFormatString(i)[source]
ParamList.getLowerBounds()[source]
ParamList.getParam(i)[source]
ParamList.getParamNames()[source]
ParamList.getParams()[source]

Returns a copy of the current active parameter values (list)

ParamList.getUpperBounds()[source]
ParamList.numberOfParams()[source]
ParamList.setAllParams(p)[source]
ParamList.setParam(i, val)[source]
ParamList.setParams(p)[source]
class tractor.MultiParams(*args)[source]

An implementation of Params that combines component sub-Params.

append(x)[source]
copy()[source]
extend(x)[source]
freezeAllRecursive()[source]
freezeParamsRecursive(*pnames)[source]
getAllParams()[source]
getAllStepSizes(*args, **kwargs)[source]
getGaussianPriors()[source]
getLogPrior()[source]
getLogPriorDerivatives()[source]

Return prior formatted so that it can be used in least square fitting

getLowerBounds()[source]
getParamNames()[source]
getParamStateRecursive()[source]
getParams()[source]

Returns a copy of the current active parameter values (as a flat list)

getStepSizes(*args, **kwargs)[source]
getUpperBounds()[source]
hashkey()[source]
index(x)[source]
numberOfParams()[source]

Count unpinned (active) params.

prepend(x)[source]
printThawedParams()[source]
remove(x)[source]
setAllParams(p)[source]
setAllStepSizes(ss)[source]
setParam(i, p)[source]
setParams(p)[source]
setStepSizes(ss)[source]
thawAllRecursive()[source]
thawParamsRecursive(*pnames)[source]
thawPathsTo(*pnames)[source]

Core Tractor routines

class tractor.Tractor(images=[], catalog=[], optimizer=None)[source]

Heavy farm machinery.

As you might guess from the name, this is the main class of the Tractor framework. A Tractor has a set of Images and a set of Sources, and has methods to optimize the parameters of those Images and Sources.

  • images: list of Image objects (data)
  • catalog: list of Source objects
addImage(img)[source]
addSource(src)[source]
addSources(srcs)[source]
getCatalog()[source]
getChiImage(imgi=-1, img=None, srcs=None, minsb=0.0)[source]
getChiImages()[source]
getDerivs()[source]

Computes model-image derivatives for each parameter.

Returns a nested list of tuples:

allderivs: [
(param0:) [ (deriv, img), (deriv, img), ... ], (param1:) [], (param2:) [ (deriv, img), ],

]

Where the derivs are Patch objects and imgs are Image objects.

getImage(imgi)[source]
getImages()[source]
getLogLikelihood()[source]
getLogProb()[source]

Return the posterior log PDF, evaluated at the current parameters.

getModelImage(img, srcs=None, sky=True, minsb=None)[source]

Create a model image for the given “tractor image”, including the sky level. If “srcs” is specified (a list of sources), then only those sources will be rendered into the image. Otherwise, the whole catalog will be.

getModelImages(**kwargs)[source]
getModelPatch(img, src, **kwargs)[source]
getNImages()[source]
static getName()[source]
static getNamedParams()[source]
optimize(**kwargs)[source]

Performs one step of optimization.

(Exactly what that entails depends on the optimizer; by default (LsqrOptimizer) it means one linearized least-squares + line search iteration.)

Returns (delta-logprob, parameter update X, alpha stepsize)

If variance=True,

Returns (delta-logprob, parameter update X, alpha stepsize, variance)

If just_variance=True, Returns variance.

optimize_forced_photometry(**kwargs)[source]

Returns an “OptResult” duck with fields:

.ims0, .ims1 (if wantims=True) .IV (if variance=True) .fitstats (if fitstats=True)

ims0, ims1: [ (img_data, mod, ie, chi, roi), ... ]

ASSUMES linear brightnesses!

ASSUMES all source parameters except brightness are frozen.

If sky=False, ASSUMES image parameters are frozen. If sky=True, ASSUMES only the sky parameters are unfrozen

ASSUMES the PSF and Sky models are position-independent!!

PRIORS probably don’t work because we don’t setParams() when evaluating likelihood or prior!

optimize_loop(**kwargs)[source]

Performs multiple steps of optimization until convergence.

Returns a dict of results (exact contents varying by optimizer).

removeSource(src)[source]
setCatalog(srcs)[source]
setImages(ims)[source]
setModelMasks(masks, assumeMasks=True)[source]

A “model mask” is used to define the pixels that are evaluated when computing the model patch for a source in an image. This allows for consistent computation of derivatives and optimization, without introducing errors due to approximating the profiles differently given different parameter settings.

masks: if None, this masking is disabled, and normal approximation rules apply.

Otherwise, masks must be a list, with length equal to the number of images. Each list element must be a dictionary with Source objects for keys and ModelMask objects for values. Sources that do not touch the image should not exist in the dictionary; all the ModelMask objects should be non-None and non-empty.

class tractor.Catalog(*args)[source]

A list of Source objects. This class allows the Tractor to treat a set of astronomical sources as a single object with a bunch of parameters. Most of the functionality comes from the base class.

Constructor syntax:

cat = Catalog(src1, src2, src3)

so if you have a list of sources,

srcs = [src1, src2, src3] cat = Catalog(*srcs)

deepcopy()
getFrozenSources()[source]
getNamedParamName(j)[source]
getThawedSources()[source]
printLong()[source]
class tractor.Images(*args)[source]

This is a class for holding a list of Image objects, each which contains data and metadata. This class allows the Tractor to treat a list of `Image`s as a single object that has a set of parameters. Basically all the functionality comes from the base class.

getNamedParamName(j)[source]
class tractor.Image(data=None, invvar=None, inverr=None, psf=None, wcs=None, sky=None, photocal=None, name=None, time=None, **kwargs)[source]

An image plus its calibration information. An Image has pixels, inverse-variance map, WCS, PSF, photometric calibration information, and sky level. All these things are Params instances, and Image is a MultiParams so that the Tractor can optimize them.

Args:
  • data: numpy array: the image pixels
  • invvar: numpy array: the image inverse-variance
  • inverr: numpy array: the image inverse-error
  • psf: a tractor.PSF duck
  • wcs: a tractor.WCS duck
  • sky: a tractor.Sky duck
  • photocal: a tractor.PhotoCal duck
  • name: string name of this image.
  • zr: plotting range (“vmin”/”vmax” in matplotlib.imshow)

Only one of invvar and inverr should be given. If both are given, inverr takes precedent.

If wcs is not given, assumes pixel space.

If sky is not given, assumes zero sky.

If photocal is not given, assumes count units.

getFitsHeader(header=None, prefix='')[source]
getHeight()[source]
getImage()[source]
getInvError()[source]
getInvvar()[source]
getModelShape()[source]
static getNamedParams()[source]
getParamDerivatives(tractor, srcs)[source]

Returns a list of Patch objects, one per numberOfParams(). Note that this means you have to pay attention to the frozen/thawed state.

Can return None for no derivative, or False if you want the Tractor to compute the derivatives for you.

getPhotoCal()[source]
getPsf()[source]
getShape()[source]
getSky()[source]
getStandardFitsHeader(header=None)[source]
getTime()[source]
getWcs()[source]
getWidth()[source]
hashkey()[source]
invvar
numberOfPixels()[source]
static readFromFits(fits, prefix='')[source]
setImage(img)[source]
setInvvar(iv)[source]
setPsf(psf)[source]
setSky(sky)[source]
shape
subimage(x0, x1, y0, y1)[source]
toFits(fits, prefix='', primheader=None, imageheader=None, invvarheader=None)[source]
class tractor.Patch(x0, y0, patch)[source]

An image patch; a subimage. In the Tractor we use these to hold synthesized (ie, model) images. The patch is a rectangular grid of pixels and it knows its offset (2-d position) in some larger image.

This class overloads arithmetic operations (like add and multiply) relevant to synthetic image patches.

addTo(img, scale=1.0)[source]
clipTo(W, H)[source]
clipToRoi(x0, x1, y0, y1)[source]
copy()[source]
getExtent(margin=0)[source]

Return (x0, x1, y0, y1) of the region covered by this patch; NON-inclusive upper bounds, ie, [x0, x1), [y0, y1).

getImage()[source]
getName()[source]
getNonZeroMask()[source]
getOrigin()[source]
getPatch()[source]
getPixelIndices(parent)[source]
getSlice(parent=None)[source]
getSlices(shape)[source]

shape = (H,W).

Returns (spatch, sparent), slices that yield the overlapping regions in this Patch and the given image.

getX0()[source]
getY0()[source]
hasBboxOverlapWith(other)[source]
hasNonzeroOverlapWith(other)[source]
overlapsBbox(bbox)[source]
performArithmetic(other, opname, otype=<type 'float'>)[source]
plotnum = 0
set(other)[source]
setName(name)[source]
trimToNonZero()[source]
x1
y1

Galaxies

This file is part of the Tractor project. Copyright 2011, 2012, 2013 Dustin Lang and David W. Hogg. Licensed under the GPLv2; see the file COPYING for details.

galaxy.py

Exponential and deVaucouleurs galaxy model classes.

These use the slightly modified versions of the exp and dev profiles from the SDSS /Photo/ software; we use multi-Gaussian approximations of these.

class tractor.galaxy.CompositeGalaxy(pos, brightnessExp, shapeExp, brightnessDev, shapeDev)[source]

A galaxy with Exponential and deVaucouleurs components.

The two components share a position (ie the centers are the same), but have different brightnesses and shapes.

getBrightness()[source]

This makes some assumptions about the Brightness / PhotoCal and should be treated as approximate.

getBrightnesses()[source]
getModelPatch(img, minsb=0.0, modelMask=None)[source]
getName()[source]
static getNamedParams()[source]
getParamDerivatives(img, modelMask=None)[source]
getUnitFluxModelPatches(img, minval=0.0, modelMask=None)[source]
class tractor.galaxy.DevGalaxy(*args, **kwargs)[source]
static getDevProfile()[source]
getName()[source]
getProfile()[source]
nre = 8.0
profile = <tractor.mixture_profiles.MixtureOfGaussians object>
class tractor.galaxy.ExpGalaxy(*args, **kwargs)[source]
static getExpProfile()[source]
getName()[source]
getProfile()[source]
nre = 4.0
profile = <tractor.mixture_profiles.MixtureOfGaussians object>
class tractor.galaxy.FixedCompositeGalaxy(pos, brightness, fracDev, shapeExp, shapeDev)[source]

A galaxy with Exponential and deVaucouleurs components where the brightnesses of the deV and exp components are defined in terms of a total brightness and a fraction of that total that goes to the deV component.

The two components share a position (ie the centers are the same), but have different shapes. The galaxy has a single brightness that is split between the components.

This is like CompositeGalaxy, but more useful for getting consistent colors from forced photometry, because one can freeze the fracDev to keep the deV+exp profile fixed.

getName()[source]
static getNamedParams()[source]
getParamDerivatives(img, modelMask=None)[source]
getRadius()[source]
class tractor.galaxy.FracDev(val=0)[source]
clipped()[source]
derivative()[source]
stepsize = 0.01
class tractor.galaxy.Galaxy(*args)[source]

Generic Galaxy profile with position, brightness, and shape.

getDName()[source]

Name used in labeling the derivative images d(Dname)/dx, eg

getName()[source]
static getNamedParams()[source]
getParamDerivatives(img, modelMask=None)[source]
getShape()[source]
getSourceType()[source]
getUnitFluxModelPatch(img, **kwargs)[source]
class tractor.galaxy.GalaxyShape(*args)[source]

A naive representation of an ellipse (describing a galaxy shape), using effective radius (in arcsec), axis ratio, and position angle.

For better ellipse parameterizations, see ellipses.py

static getName()[source]
static getNamedParams()[source]

re: arcsec ab: axis ratio, dimensionless, in [0,1] phi: deg, “E of N”, 0=direction of increasing Dec, 90=direction of increasing RA

getRaDecBasis()[source]

Returns a transformation matrix that takes vectors in r_e to delta-RA, delta-Dec vectors.

getTensor(cd)[source]
class tractor.galaxy.GaussianGalaxy(*args, **kwargs)[source]
getName()[source]
getProfile()[source]
nre = 6.0
profile = <tractor.mixture_profiles.MixtureOfGaussians object>
class tractor.galaxy.HoggGalaxy(*args)[source]
getName()[source]
getRadius()[source]
class tractor.galaxy.ProfileGalaxy[source]

A mix-in class that renders itself based on a Mixture-of-Gaussians profile.

getName()[source]
getProfile()[source]
getUnitFluxModelPatch(img, px=None, py=None, minval=0.0, modelMask=None)[source]
class tractor.galaxy.SoftenedFracDev(val=0)[source]

Implements a “softened” version of the deV-to-total fraction.

The sigmoid function is scaled and shifted so that S(0) ~ 0.1 and S(1) ~ 0.9.

Use the ‘clipped()’ function to get the un-softened fracDev clipped to [0,1].

clipped()[source]
derivative()[source]
tractor.galaxy.disable_galaxy_cache()[source]
tractor.galaxy.enable_galaxy_cache(N=10000)
tractor.galaxy.get_galaxy_cache()[source]
tractor.galaxy.set_galaxy_cache_size(N=10000)[source]

SDSS images & catalogs

This file is part of the Tractor project. Copyright 2011, 2012, 2013 Dustin Lang and David W. Hogg. Licensed under the GPLv2; see the file COPYING for details.

sdss.py

SDSS-specific implementation of Tractor elements:

  • retrieves and reads SDSS images, converting them to Tractor language
  • knows about SDSS photometric and astrometric calibration conventions
  • for DR7-specifics, see sdss_dr7.
class tractor.sdss.SdssBrightPSF(real, a1, s1, a2, s2, a3, sigmap, beta)[source]
getBrightPointSourcePatch(px, py, dc)[source]
getMixtureOfGaussians(**kwargs)[source]
getPointSourcePatch(px, py, **kwargs)[source]
getRadius()[source]
class tractor.sdss.SdssPointSource(pos, bright, thresh=None, thresh2=None)[source]

Knows about the SDSS 2-Gaussian-plus-power-law PSF model and switches (smoothly) to it for bright sources.

thresh is the threshold, in COUNTS, for using the bright PSF model.

thresh2 is the lower threshold, in COUNTS, for when to start switching to the bright PSF model. We use linear interpolation for the thresh2 < b < thresh range. If not specified, defaults to factor (1./2.5) of thresh, ie, about a mag.

copy()[source]
getModelPatch(img, modelMask=None)[source]
class tractor.sdss.SdssWcs(astrans)[source]
cdAtPixel(x, y)[source]
static getNamedParams()[source]
getStepSizes(*args, **kwargs)[source]
pixelToPosition(x, y, src=None)[source]
pixelToRaDec(x, y)[source]
pixscale_at(x, y)[source]
pnames = ['a', 'b', 'c', 'd', 'e', 'f', 'drow0', 'drow1', 'drow2', 'drow3', 'dcol0', 'dcol1', 'dcol2', 'dcol3', 'csrow', 'cscol', 'ccrow', 'cccol', 'x0', 'y0']
positionToPixel(pos, src=None, color=0.0)[source]
setConstantCd(x, y)[source]
setX0Y0(x0, y0)[source]
tractor.sdss.get_tractor_image_dr8(*args, **kwargs)[source]

Creates a tractor.Image given an SDSS field identifier.

If not None, roi = (x0, x1, y0, y1) defines a region-of-interest in the image, in zero-indexed pixel coordinates. x1,y1 are NON-inclusive; roi=(0,100,0,100) will yield a 100 x 100 image.

psf can be:

“dg” for double-Gaussian “kl-gm” for SDSS KL-decomposition approximated as a Gaussian mixture

“bright-”, “” one of the above PSFs, with special handling at the bright end.

“roiradecsize” = (ra, dec, half-size in pixels) indicates that you want to grab a ROI around the given RA,Dec.

“roiradecbox” = (ra0, ra1, dec0, dec1) indicates that you want to grab a ROI containing the given RA,Dec ranges.

“invvarAtCentr” – get a scalar constant inverse-variance

“invvarAtCenterImage” – get a scalar constant inverse-variance but still make an image out of it.

Returns: (tractor.Image, dict)

dict contains useful details like:
‘sky’ ‘skysig’
tractor.sdss.get_tractor_image_dr9(*args, **kwargs)[source]
tractor.sdss.get_tractor_sources_cas_dr9(table, bandname='r', bands=None, extrabands=None, nanomaggies=False)[source]

table: filename or astrometry.util.fits.fits_table() object

tractor.sdss.get_tractor_sources_dr8(*args, **kwargs)[source]
get_tractor_sources_dr8(run, camcol, field, bandname=’r’, sdss=None,
retrieve=True, curl=False, roi=None, bands=None, badmag=25, nanomaggies=False, getobjs=False, getobjinds=False)

Creates tractor.Source objects corresponding to objects in the SDSS catalog for the given field.

bandname: “canonical” band from which to get galaxy shapes, positions, etc

tractor.sdss.get_tractor_sources_dr9(*args, **kwargs)[source]
tractor.sdss.scale_sdss_image(tim, S)[source]

Returns a rebinned “tim” by integer scale “S” (ie S=2 reduces the image size by a factor of 2x2).

The rescaling preserves intensity.

We drop remainder pixels.

CFHT images & catalogs

class tractor.cfht.CfhtLinearPhotoCal(hdr, bandname=None, scale=1.0)[source]
copy()[source]
class tractor.cfht.CfhtPhotoCal(hdr=None, bandname=None)[source]
brightnessToCounts(brightness)[source]
copy()[source]
getParamNames()[source]
getParams()[source]
getStepSizes(*args, **kwargs)[source]
hashkey()[source]
setParam(i, p)[source]
tractor.cfht.parse_head_file(fn)[source]