imaginglss.model.datarelease module

Python code to look at the imaging data, containing interfaces to deal with “bricks” and “catalogs”. This is the “highest level” interface to the imaging data and makes use of several lower level objects.

class imaginglss.model.datarelease.DataRelease(root, cache, version, dustdir)[source]

Bases: object

The highest level interface into the data for a given imaging data release. Uses several “helper” classes and has methods for looking at pixelized data or catalogs arranged in bricks.

Examples

>>> dr = DataRelease()
>>> dr.images['depth']['r']  # r band depth images.
>>> dr.images['image']['r']  # r band coadd images.
>>> dr.images['model']['r']  # r band tractor model images.

Attributes

brickindex (BrickIndex) an index object of all of the bricks (covering the entire sky)
bands (dict) a dictionary translating from band name to integer used in Tractor catalogue
catalogue (CachedCatalogue) the concatenated tractor catalogue, accessed by attributes.
extinction (array_like) an array storing the extinction coeffcients. The array matches the defination of DECAM_FLUX column of the catalogue, u, g, r, i, z, Y.
images (ImageRepo) Image repositories. These image repositories are used by py:meth:readout.
footprint (Footprint) the footprint of the data release.
create_catalogue(footprint)[source]

Create a catalogue based on the footprint.

Parameters:

footprint : Footprint

created with :py:meth`DataRelease.create_footprint`

create_footprint(extent)[source]

Create a footprint based on the extent.

Parameters:

extent : tuple, or None

RA1, RA2, DEC1, DEC2. If None the full catalogue is returned

init_from_state()[source]
read_depths(coord, bands=[])[source]

Read the depth of given bands, return as an array

Returns:array of dtype DECAM_DEPTH and DECAM_MW_TRANSMISSION.

Notes

only columns corresponding to band in the bands parameter are filled. the other columns are zeros.

readout(coord, repo, default=nan, ignore_missing=False)[source]

Readout pixels from an image.

Parameters:

coord : array_like

coordinates of the pixels, (RA, DEC)

repo : ImageRepo

the images to read from.

default : scalar

value to return if the pixel is not in the footprint.

image_missing : boolean

When ignore_missing is True, missing brick files are treated as not in the footprint.

Notes

This is here, because we want to query multiple images at the same time. It is also convenient to have it here to make use of brickindex. (ImageRepo is then just a stub with no business logic)

Otherwise it makes more sense to have readout in ImageRepo.

class imaginglss.model.datarelease.Footprint(bricks, brickindex)[source]

Bases: object

footprint of a data release.

Use indexing to construct sub-regions of the footprint, for example

Examples

>>> print datarelease.footprint[:100]
Footprint(.....)

Attributes

bricks (list of model.brick.Brick) A list of Bricks that are covered by the footprint
range ( tuple) The range of RA and DEC of all bricks (ramin, ramax, decmin, decmax)
area (float) Covered outline area in square degrees
filter(coord)[source]

Remove coordinates that are not covered by the footprint

Parameters:

coord : array_like

must be compatible with (RA, DEC)

Returns:

coord_in_footprint : array_like

items in the input coord that is in the footprint

intersect(other)[source]

Returns the intersection with another footprint.

random_sample(Npoints, rng)[source]

Generate uniformly distributed points within the boundary that lie in the footprint.

The random points are generated by first producing random points with int the ra and dec range of the footprint, then remove points that are not in any bricks.

Parameters:

Npoints : int

numpy of random points to sample

rng : numpy.random.RandomState

a random number generator

Returns:

coord : array_like (2, Npoints)

(RA, DEC) of the random points

Notes

Internally, the random points are generated in batches of 1 million points.

If the footprint is sparse in the bounding ra, dec range, this algorithm becomes extremely inefficient.

union(other)[source]

Returns the union with another footprint.

class imaginglss.model.datarelease.Lazy(calculate_function)[source]

Bases: object

Lazy initialization of object attributes.

imaginglss.model.datarelease.contains(haystack, needle)[source]

test if needle is in haystack.

Parameters:

haystack : array_like

Sorted array

needle : array_like

items to look for

Returns:

mask : array_like

mask[i] is true only if needle[i] is in haystack;

Examples

>>> contains([1, 2, 3], [2])
[True]