LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Functions | Variables
lsst.pipe.tasks.diff_matched_tract_catalog Namespace Reference

Classes

class  DiffMatchedTractCatalogConfig
 
class  DiffMatchedTractCatalogConnections
 
class  DiffMatchedTractCatalogTask
 
class  MatchedCatalogFluxesConfig
 
class  MatchType
 
class  MeasurementType
 
class  MeasurementTypeInfo
 
class  Median
 
class  Percentile
 
class  SigmaIQR
 
class  SigmaMAD
 
class  SourceType
 
class  SourceTypeInfo
 
class  Statistic
 

Functions

 is_sequence_set (Sequence x)
 
 is_percentile (str x)
 
 _get_stat_name (*args)
 
 _get_column_name (band, *args)
 
 compute_stats (values_ref, values_target, errors_target, row, stats, suffixes, prefix, skip_diff=False)
 
 _get_columns (Dict bands_columns, Dict suffixes, Dict suffixes_flux, Dict suffixes_mag, Dict stats, ComparableCatalog target, str column_dist)
 

Variables

dict DiffMatchedTractCatalogBaseTemplates
 

Function Documentation

◆ _get_column_name()

lsst.pipe.tasks.diff_matched_tract_catalog._get_column_name ( band,
* args )
protected

Definition at line 401 of file diff_matched_tract_catalog.py.

401def _get_column_name(band, *args):
402 return f"{band}_{_get_stat_name(*args)}"
403
404

◆ _get_columns()

lsst.pipe.tasks.diff_matched_tract_catalog._get_columns ( Dict bands_columns,
Dict suffixes,
Dict suffixes_flux,
Dict suffixes_mag,
Dict stats,
ComparableCatalog target,
str column_dist )
protected
Get column names for a table of difference statistics.

Parameters
----------
bands_columns : `Dict` [`str`,`MatchedCatalogFluxesConfig`]
    Dict keyed by band of flux column configuration.
suffixes, suffixes_flux, suffixes_mag : `Dict` [`MeasurementType`, `str`]
    Dict of suffixes for each `MeasurementType` type, for general columns (e.g.
    coordinates), fluxes and magnitudes, respectively.
stats : `Dict` [`str`, `Statistic`]
    Dict of suffixes for each `Statistic` type.
target : `ComparableCatalog`
    A target catalog with coordinate column names.
column_dist : `str`
    The name of the distance column.

Returns
-------
columns : `Dict` [`str`, `type`]
    Dictionary of column types keyed by name.
n_models : `int`
    The number of models measurements will be made for.

Notes
-----
Presently, models must be identical for each band.

Definition at line 476 of file diff_matched_tract_catalog.py.

477 stats: Dict, target: ComparableCatalog, column_dist: str):
478 """Get column names for a table of difference statistics.
479
480 Parameters
481 ----------
482 bands_columns : `Dict` [`str`,`MatchedCatalogFluxesConfig`]
483 Dict keyed by band of flux column configuration.
484 suffixes, suffixes_flux, suffixes_mag : `Dict` [`MeasurementType`, `str`]
485 Dict of suffixes for each `MeasurementType` type, for general columns (e.g.
486 coordinates), fluxes and magnitudes, respectively.
487 stats : `Dict` [`str`, `Statistic`]
488 Dict of suffixes for each `Statistic` type.
489 target : `ComparableCatalog`
490 A target catalog with coordinate column names.
491 column_dist : `str`
492 The name of the distance column.
493
494 Returns
495 -------
496 columns : `Dict` [`str`, `type`]
497 Dictionary of column types keyed by name.
498 n_models : `int`
499 The number of models measurements will be made for.
500
501 Notes
502 -----
503 Presently, models must be identical for each band.
504 """
505 # Initial columns
506 columns = {
507 "bin": int,
508 "mag_min": float,
509 "mag_max": float,
510 }
511
512 # pre-assign all of the columns with appropriate types
513 n_models = 0
514
515 bands = list(bands_columns.keys())
516 n_bands = len(bands)
517
518 for idx, (band, config_flux) in enumerate(bands_columns.items()):
519 columns_suffix = [
520 ('flux', suffixes_flux),
521 ('mag', suffixes_mag),
522 ]
523 if idx == 0:
524 n_models = len(config_flux.columns_target_flux)
525 if (idx > 0) or (n_bands > 2):
526 columns_suffix.append((f'color_{bands[idx - 1]}_m_{band}', suffixes))
527 n_models_flux = len(config_flux.columns_target_flux)
528 n_models_err = len(config_flux.columns_target_flux_err)
529
530 # TODO: Do equivalent validation earlier, in the config
531 if (n_models_flux != n_models) or (n_models_err != n_models):
532 raise RuntimeError(f'{config_flux} len(columns_target_flux)={n_models_flux} and'
533 f' len(columns_target_flux_err)={n_models_err} must equal {n_models}')
534
535 for sourcetype in SourceType:
536 label = sourcetype.value.label
537 # Totals would be redundant
538 if sourcetype != SourceType.ALL:
539 for item in (f'n_{itype}_{mtype.value}' for itype in ('ref', 'target')
540 for mtype in MatchType):
541 columns[_get_column_name(band, label, item)] = int
542
543 for item in (target.column_coord1, target.column_coord2, column_dist):
544 for suffix in suffixes.values():
545 for stat in stats.keys():
546 columns[_get_column_name(band, label, item, suffix, stat)] = float
547
548 for item in config_flux.columns_target_flux:
549 for prefix_item, suffixes_col in columns_suffix:
550 for suffix in suffixes_col.values():
551 for stat in stats.keys():
552 columns[_get_column_name(band, label, prefix_item, item, suffix, stat)] = float
553
554 return columns, n_models
555
556

◆ _get_stat_name()

lsst.pipe.tasks.diff_matched_tract_catalog._get_stat_name ( * args)
protected

Definition at line 397 of file diff_matched_tract_catalog.py.

397def _get_stat_name(*args):
398 return '_'.join(args)
399
400

◆ compute_stats()

lsst.pipe.tasks.diff_matched_tract_catalog.compute_stats ( values_ref,
values_target,
errors_target,
row,
stats,
suffixes,
prefix,
skip_diff = False )
Compute statistics on differences and store results in a row.

Parameters
----------
values_ref : `numpy.ndarray`, (N,)
    Reference values.
values_target : `numpy.ndarray`, (N,)
    Measured values.
errors_target : `numpy.ndarray`, (N,)
    Errors (standard deviations) on `values_target`.
row : `numpy.ndarray`, (1, C)
    A numpy array with pre-assigned column names.
stats : `Dict` [`str`, `Statistic`]
    A dict of `Statistic` values to measure, keyed by their column suffix.
suffixes : `Dict` [`MeasurementType`, `str`]
    A dict of measurement type column suffixes, keyed by the measurement type.
prefix : `str`
    A prefix for all column names (e.g. band).
skip_diff : `bool`
    Whether to skip computing statistics on differences. Note that
    differences will still be computed for chi statistics.

Returns
-------
row_with_stats : `numpy.ndarray`, (1, C)
    The original `row` with statistic values assigned.

Definition at line 405 of file diff_matched_tract_catalog.py.

405def compute_stats(values_ref, values_target, errors_target, row, stats, suffixes, prefix, skip_diff=False):
406 """Compute statistics on differences and store results in a row.
407
408 Parameters
409 ----------
410 values_ref : `numpy.ndarray`, (N,)
411 Reference values.
412 values_target : `numpy.ndarray`, (N,)
413 Measured values.
414 errors_target : `numpy.ndarray`, (N,)
415 Errors (standard deviations) on `values_target`.
416 row : `numpy.ndarray`, (1, C)
417 A numpy array with pre-assigned column names.
418 stats : `Dict` [`str`, `Statistic`]
419 A dict of `Statistic` values to measure, keyed by their column suffix.
420 suffixes : `Dict` [`MeasurementType`, `str`]
421 A dict of measurement type column suffixes, keyed by the measurement type.
422 prefix : `str`
423 A prefix for all column names (e.g. band).
424 skip_diff : `bool`
425 Whether to skip computing statistics on differences. Note that
426 differences will still be computed for chi statistics.
427
428 Returns
429 -------
430 row_with_stats : `numpy.ndarray`, (1, C)
431 The original `row` with statistic values assigned.
432 """
433 n_ref = len(values_ref)
434 if n_ref > 0:
435 n_target = len(values_target)
436 n_target_err = len(errors_target) if errors_target is not None else n_ref
437 if (n_target != n_ref) or (n_target_err != n_ref):
438 raise ValueError(f'lengths of values_ref={n_ref}, values_target={n_target}'
439 f', error_target={n_target_err} must match')
440
441 do_chi = errors_target is not None
442 diff = values_target - values_ref
443 chi = diff/errors_target if do_chi else diff
444 # Could make this configurable, but non-finite values/errors are not really usable
445 valid = np.isfinite(chi)
446 values_type = {} if skip_diff else {MeasurementType.DIFF: diff[valid]}
447 if do_chi:
448 values_type[MeasurementType.CHI] = chi[valid]
449
450 for suffix_type, suffix in suffixes.items():
451 values = values_type.get(suffix_type)
452 if values is not None and len(values) > 0:
453 for stat_name, stat in stats.items():
454 row[_get_stat_name(prefix, suffix, stat_name)] = stat.value(values)
455 return row
456
457
458@dataclass(frozen=True)

◆ is_percentile()

lsst.pipe.tasks.diff_matched_tract_catalog.is_percentile ( str x)

Definition at line 53 of file diff_matched_tract_catalog.py.

53def is_percentile(x: str):
54 return 0 <= Decimal(x) <= 100
55
56

◆ is_sequence_set()

lsst.pipe.tasks.diff_matched_tract_catalog.is_sequence_set ( Sequence x)

Definition at line 49 of file diff_matched_tract_catalog.py.

49def is_sequence_set(x: Sequence):
50 return len(x) == len(set(x))
51
52
daf::base::PropertySet * set
Definition fits.cc:931

Variable Documentation

◆ DiffMatchedTractCatalogBaseTemplates

dict lsst.pipe.tasks.diff_matched_tract_catalog.DiffMatchedTractCatalogBaseTemplates
Initial value:
1= {
2 "name_input_cat_ref": "truth_summary",
3 "name_input_cat_target": "objectTable_tract",
4 "name_skymap": BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
5}

Definition at line 57 of file diff_matched_tract_catalog.py.