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
506 columns = {
507 "bin": int,
508 "mag_min": float,
509 "mag_max": float,
510 }
511
512
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
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
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