catalog

This module contains functions to read, validate and make necessary changes to DESI quasar catalogs. Can be imported without a need for MPI.

_accepted_extnames = {'METADATA', 'QSO_CAT', 'ZCATALOG'}

Accepted extensions for quasar catalog.

Type:

set

_required_columns = [{'TARGETID'}, {'Z'}, {'RA', 'TARGET_RA'}, {'DEC', 'TARGET_DEC'}]

Required columns for all cases.

Type:

list(set)

_required_data_columns = [{'SURVEY'}, {'COADD_LASTNIGHT', 'LASTNIGHT', 'LAST_NIGHT'}]

Required columns for real data analysis.

Type:

list(set)

_required_tile_columns = [{'TILEID'}, {'PETAL_LOC'}]

Required columns for tile data analysis.

Type:

list(set)

_optional_columns = ['HPXPIXEL', 'PROGRAM', 'VMIN_CIV_450', 'VMAX_CIV_450', 'VMIN_CIV_2000', 'VMAX_CIV_2000']

Optional columns.

Type:

list(str)

read_quasar_catalog(filename, is_mock=False, is_tile=False, keep_surveys=None, zmin=0, zmax=100.0)[source]

Returns a quasar catalog object (ndarray).

It is sorted in the following order: 1. HPXPIXEL or TILEID 2. SURVEY or PETAL_LOC (if applicable), 3. TARGETID. BAL info included if available. It is required for BAL masking. If ‘HPXPIXEL’ column is not present, n_side is assumed 16 for mocks, 64 for data.

Parameters:
  • filename (str) – Filename to catalog.

  • is_mock (bool, default: False) – If the catalog is for mocks.

  • is_tile (bool, default: False) – If the catalog is for tiles. Duplicate TARGETIDs are allowed as long as they are in different TILEIDs.

  • keep_surveys (None or list(str), default: None) – List of surveys to subselect. None keeps all.

  • zmin (float, default: 0) – Minimum quasar redshift

  • zmax (float, default: 100) – Maximum quasar redshift

Returns:

catalog – Sorted catalog.

Return type:

ndarray

mpi_read_quasar_catalog(filename, comm=None, mpi_rank=0, is_mock=False, is_tile=False, keep_surveys=None, zmin=0, zmax=100)[source]

Returns the same quasar catalog object on all MPI ranks.

It is sorted in the following order: HPXPIXEL, SURVEY (if applicable), TARGETID. BAL info included if available. It is required for BAL masking.

Can be used without MPI by passing comm=None and mpi_rank=0.

Parameters:
  • filename (str) – Filename to catalog.

  • comm (MPI comm object or None, default: None) – MPI comm object for bcast

  • mpi_rank (int, default: 0) – Rank of the MPI process

  • is_mock (bool, default: False) – If the catalog is for mocks.

  • is_tile (bool, default: False) – If the catalog is for tiles. Duplicate TARGETIDs are allowed.

  • keep_surveys (None or list(str), default: None) – List of surveys to subselect. None keeps all.

  • zmin (float, default: 0) – Minimum quasar redshift

  • zmax (float, default: 100) – Maximum quasar redshift

Returns:

catalog – Sorted catalog on all MPI ranks.

Return type:

ndarray

Raises:

QsonicException – If error occurs while reading the catalog.

mpi_get_local_queue(filename, comm=None, mpi_rank=0, mpi_size=1, is_mock=False, is_tile=False, keep_surveys=None, zmin=0, zmax=100.0)[source]

Reads catalog on master and scatter a list of catalogs to every mpi_rank. If in tile format, sort key is ‘TILEID’.

Parameters:
  • filename (str) – Filename to catalog.

  • comm (MPI comm object or None, default: None) – MPI comm object for scatter

  • mpi_rank (int) – Rank of the MPI process

  • mpi_size (int) – Size of MPI processes

  • is_mock (bool, default: False) – If the catalog is for mocks.

  • is_tile (bool, default: False) – If the catalog is for tiles. Split key will be ‘TILEID’. Duplicate TARGETIDs are allowed.

  • keep_surveys (None or list(str), default: None) – List of surveys to subselect. None keeps all.

  • zmin (float, default: 0) – Minimum quasar redshift

  • zmax (float, default: 100) – Maximum quasar redshift

Returns:

local_queue – List of sorted catalogs.

Return type:

list(ndarray)

_check_required_columns(required_cols, colnames)[source]

Asserts all required columns are present.

Parameters:
  • required_cols (list(set)) – Required columns as list of sets.

  • colnames (list(str)) – Present column names

Raises:

Exception – If none of a required set is in colnames.

_validate_adjust_column_names(catalog, is_mock, is_tile)[source]

Validate catalog for required columns in _required_columns. ‘SURVEY’ is also required for data. ‘TARGET_{RA, DEC}’ is transformed to ‘RA’ and ‘DEC’ in return.

Parameters:
  • catalog (ndarray) – Catalog.

  • is_mock (bool) – If the catalog is for mocks, does not perform ‘SURVEY’ check.

  • is_tile (bool) – If the catalog is for tiles, duplicate TARGETIDs are allowed as long as they are in different TILEIDs.

Returns:

catalog – Catalog. No checks are performed.

Return type:

ndarray

_read(filename)[source]

Reads FITS file catalog with all columns present that are in _all_columns

Parameters:

filename (str) –

Returns:

catalog – Catalog. No checks are performed.

Return type:

ndarray

_add_healpix(catalog, n_side, keep_columns)[source]

Add ‘HPXPIXEL’ column to catalog if not present.

Parameters:
  • catalog (ndarray) – Catalog.

  • n_side (int) – Healpix nside.

  • keep_columns (list(str)) – List of surveys to subselect.

Returns:

catalog – ‘HPXPIXEL’ calculated and added catalog.

Return type:

ndarray

_prime_catalog(catalog, n_side, keep_surveys, zmin, zmax, is_tile)[source]

Returns quasar catalog object. It is sorted in the following order: sort_key (HPXPIXEL), SURVEY (if applicable), TARGETID

Parameters:
  • catalog (ndarray) – Catalog.

  • n_side (int) – Healpix nside.

  • keep_surveys (list(str)) – List of surveys to subselect.

  • zmin (float) – Minimum quasar redshift

  • zmax (float) – Maximum quasar redshift

  • is_tile (bool) – If the catalog is for tiles. Sort oder will be TILEID, PETAL_LOC.

Returns:

catalog – Sorted catalog. BAL info included if available (req. for BAL masking)

Return type:

ndarray