autowisp.diagnostics.diagnostic_types module

Class Inheritance Diagram

Inheritance diagram of MappingProxyType

The catalogue of per-image diagnostics AutoWISP defines.

The vocabulary of diagnostic names, kept apart from the database that stores values against them. Two quite different things want it:

That second caller is the reason this module exists. The catalogue is a static list: whatever seeds one project seeds them all, so requiring an open database to discover it was a false dependency. The database module is now a consumer of the vocabulary rather than its owner.

The one thing genuinely not knowable in advance is the pixel_q* family, created at run time by calibrate rather than seeded. Those are a pattern rather than a list, and no amount of enumeration would have captured them – hence is_quantile_diagnostic(), which both the code creating those rows and the code validating expressions against them ask, so the two cannot drift apart.

Everything here is exposed as a cached function returning an immutable value rather than as a module-level constant, so that a caller cannot mutate the catalogue out from under every other caller in the process.

autowisp.diagnostics.diagnostic_types._quantile_pattern = re.compile('pixel_q\\d+\\Z')

The one diagnostic family created at run time rather than seeded. calibrate records one per configured quantile, so which exist depends on how a project was configured and cannot be listed ahead of time. Digits are required and the match anchored, so pixel_q999 is recognised while a plausible future diagnostic such as pixel_quality is not swallowed.

autowisp.diagnostics.diagnostic_types.get_photometry_id(position, has_shape_fit)[source]

Return the id recorded for the photometry at position in magfit’s arrays.

fit_magnitudes holds an image’s photometries in one array: the shape fit first, where the image has a usable one, and then every aperture. So a position is the shape fit on one image and aperture 0 on the next, and recording it would let a series pinned to one id mix photometries without saying so. The id is the same on every image instead: the aperture index, which is what the DR files number apertures by, or shapefit_photometry.

Parameters:
  • position (int) – The index into magfit’s photometry arrays.

  • has_shape_fit (bool) – Whether those arrays start with a shape fit, as get_magfit_sources decided when building them.

Returns:

The photometry id.

Return type:

int

autowisp.diagnostics.diagnostic_types.is_diagnostic(name)[source]

Whether name is a diagnostic AutoWISP can record, in any project.

The complete vocabulary, and knowable without opening a database: a diagnostic_type row can only come from standard_diagnostic_types() at project creation or from the quantile branch of ImageProcessingManager._save_image_diagnostics, which refuses every other name. So no project can hold a diagnostic this does not recognise, and validating an expression needs no project.

This is not the question of whether anything has been recorded here, which is per-project and answered by counting rows.

Parameters:

name (str) – The name to test.

Returns:

Whether the name refers to a diagnostic.

Return type:

bool

autowisp.diagnostics.diagnostic_types.is_known_quantity(name)[source]

Whether name resolves to data an expression may read.

The whole readable vocabulary: every diagnostic, plus the time. This is what tier 1 checks a referenced name against.

Parameters:

name (str) – The name to test.

Returns:

Whether the name refers to something readable.

Return type:

bool

autowisp.diagnostics.diagnostic_types.is_quantile_diagnostic(name)[source]

Whether name is one of the run-time quantile diagnostics.

The single definition of what a quantile diagnostic is called. Both the code that creates the rows and the code that validates expressions against them ask here, so the two cannot drift into disagreeing.

Parameters:

name (str) – The name to test.

Returns:

Whether calibrate would record under this name.

Return type:

bool

autowisp.diagnostics.diagnostic_types.magfit_diagnostic_names()[source]

Return the diagnostics fit_magnitudes produces.

Their values depend on the photometric reference each image was fit against, not only on the image, so a population they are read over has to be split by reference as well. Everything deciding that asks here.

Returns:

The names, a subset of

standard_diagnostic_names().

Return type:

frozenset

autowisp.diagnostics.diagnostic_types.parse_photometry_literal(literal)[source]

Return the photometry id a quoted photometry names, or None.

An expression quotes a photometry as 'shapefit' or as 'ap' followed by the aperture index, 'ap4', just as it quotes a channel by name. photometry_literal() spells an id the same way.

Parameters:

literal (str) – The quoted text.

Returns:

The id, or None if literal names no

photometry.

Return type:

int or None

autowisp.diagnostics.diagnostic_types.photometry_diagnostic_names()[source]

Return the diagnostics recorded per photometry.

Stored in photometry_diagnostics, one value per shape fit and per aperture, rather than in image_diagnostics, so an expression reads one in a photometry as well as a channel. Not the same question as magfit_diagnostic_names(), although today the same names answer both: a diagnostic fit_magnitudes recorded once per image would depend on the reference and still take no photometry.

Returns:

The names, a subset of

magfit_diagnostic_names().

Return type:

frozenset

autowisp.diagnostics.diagnostic_types.photometry_literal(photometry_id)[source]

Return how an expression quotes the photometry photometry_id.

autowisp.diagnostics.diagnostic_types.shapefit_photometry = -1

The photometry id of the shape fit. Apertures are numbered by their index, from 0, so the shape fit takes a value no aperture can have.

autowisp.diagnostics.diagnostic_types.standard_diagnostic_names()[source]

Return just the names, which is all validating an expression needs.

Returns:

The seeded diagnostic names.

Return type:

frozenset

autowisp.diagnostics.diagnostic_types.standard_diagnostic_types()[source]

Return every diagnostic seeded into a new project.

A mapping rather than a sequence of pairs because that is what the table is: DiagnosticType.name is unique, so pairs would admit duplicates that only fail later, at insert time.

Returns:

Diagnostic name to its description. Read-only,

so it is safe to hand the same object to every caller.

Return type:

MappingProxyType

autowisp.diagnostics.diagnostic_types.time_quantity = 'jd'

The name Image.jd is plotted and referenced under. Not a diagnostic – it is a column of the image row rather than an image_diagnostics value – but it is a variable in the same flat name space, and the only one that is never NaN, since the canonical image list is defined by jd IS NOT NULL. Lives here rather than in expression_series so that validating an expression needs nothing from the database tier.