astra.contrib.thecannon.censoring

Utilities to deal with wavelength censoring.

Module Contents

Classes

Censors A dictionary sub-class that allows for label censoring masks to be

Functions

create_mask(dispersion, censored_regions) Return a boolean censoring mask based on a structured list of (start, end)
design_matrix_mask(censors, vectorizer) Return a mask of which indices in the design matrix columns should be
class astra.contrib.thecannon.censoring.Censors(label_names, num_pixels, items=None, **kwargs)

A dictionary sub-class that allows for label censoring masks to be applied on a per-pixel basis to CannonModel objects.

Parameters:
  • label_names – A list containing the label names that form the model vectorizer.
  • num_pixels – The number of pixels per star.
  • items – [optional] A dictionary containing label names as keys and masks as values.
label_names
num_pixels
__setitem__(self, label_name, mask)

Update an entry in the pixel censoring dictionary.

Parameters:
  • label_name – The name of the label to apply the censoring to.
  • mask – A boolean mask with a size that equals the number of pixels per star. Note that a mask value of True indicates the label is censored at the given pixel, and therefore that label will not contribute to the spectral flux at that pixel.
update(self, *args, **kwargs)

D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

setdefault(self, key, value=None)

D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D

__getstate__(self)

Return the state of the censoring mask in a serializable form.

__contains__()

True if D has a key k, else False.

__delattr__()

Implement delattr(self, name).

__delitem__()

Delete self[key].

__dir__()

__dir__() -> list default dir() implementation

__eq__()

Return self==value.

__format__()

default object formatter

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__getitem__()

x.__getitem__(y) <==> x[y]

__gt__()

Return self>value.

__iter__()

Implement iter(self).

__le__()

Return self<=value.

__len__()

Return len(self).

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__sizeof__()

D.__sizeof__() -> size of D in memory, in bytes

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

clear()

D.clear() -> None. Remove all items from D.

copy()

D.copy() -> a shallow copy of D

get()

D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

items()

D.items() -> a set-like object providing a view on D’s items

keys()

D.keys() -> a set-like object providing a view on D’s keys

pop()

D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

values()

D.values() -> an object providing a view on D’s values

astra.contrib.thecannon.censoring.create_mask(dispersion, censored_regions)

Return a boolean censoring mask based on a structured list of (start, end) regions.

Parameters:
  • dispersion – An array of dispersion values.
  • censored_regions – A list of two-length tuples containing the (start, end) points of a censored region.
Returns:

A boolean mask indicating whether the pixels in the dispersion array are masked.

astra.contrib.thecannon.censoring.design_matrix_mask(censors, vectorizer)

Return a mask of which indices in the design matrix columns should be used for a given pixel.

Parameters:
  • censors – A censoring dictionary.
  • vectorizer – The model vectorizer:
Returns:

A mask of which indices in the model design matrix should be used for a given pixel.