sp_validation.run_joint_cat¶
RUN JOINT CAT.
This module implements classes to create, mask, and calibrate joint comprehensive catalogues.
- Author:
Martin Kilbinger
- class BaseCat[source]¶
Bases:
objectBase_Cat.
Basic catalogue class.
- set_params_from_command_line(args)[source]¶
Set Params From Command Line.
Only use when calling using python from command line. Does not work from ipython or jupyter.
- read_config_set_params(fpath)[source]¶
Read Config Set Params.
Read configuration file and sets class parameters.
- read_cat(load_into_memory=False, mode='r', hdu=1, name='data')[source]¶
Read Cat.
Read input catalogue, either FITS or HDF5.
- Parameters:
- Returns:
Catalogue data
- Return type:
- Raises:
IOError – If file extension is not .fits or .hd5
- write_hdf5_header(hd5file)[source]¶
Write HDF5 Header.
Write basic header information to HDF5 file.
- Parameters:
hd5file (h5py.File) – input HDF5 file
- write_hdf5_file(dat, output_path=None)[source]¶
Write HDF5 File.
Write HDF5 data to file.
- Parameters:
dat (numpy.ndarray) – input data
output_path (str, optional) – output file path; when
None(default) use self._params[‘output_path’]
- class JointCat[source]¶
Bases:
BaseCatJoint Cat.
Class to create joint weak-lensing catalogues.
- set_params_from_command_line(args)[source]¶
Set Params From Command Line.
Only use when calling using python from command line. Does not work from ipython or jupyter.
- get_patches()[source]¶
Get Patches.
Return list of patches according to option parameter value.
- Returns:
patches, list of str
- Return type:
- get_n_obj(patches, base_path, input_sub_path)[source]¶
Get N Obj.
Get number of objects from FITS file headers.
- Parameters:
patches (list) – input patches, type is str
base_path (str) – input base directory, root dir of patches
input_sub_path (str) – input file name; input path is base_path/patch/input_sub_path
Raises – ValueError: if input file canont be read
Returns –
- list
HDUs
- list
number of objects per file
- int
total number of objects
- get_col_info(dat)[source]¶
Get Col Info.
Return information of input columns.
- Parameters:
dat (numpy.ndarray) – input data
- Returns:
list – column names
list – column formats
int – number of columns
- dtype_out(name, dtype_in)[source]¶
Set output dtype.
- Parameters:
name (str) – column name
dtype_in (np.dtype) – input dtype
- Returns:
output dtype
- Return type:
np.dtype
- init_data(n_col, n_obj, ndim, dat)[source]¶
Init Data.
Initialize empty structured data.
- Parameters:
n_col (int) – number of columns
n_obj (int) – number of objects (rows)
ndim (dict) – dimension of input columns
dat (numpy.ndarray) – example data
- Returns:
combined structure data, (n_col x n_obj) array
- Return type:
- write_hdf5_file(dat_all, patches)[source]¶
Write HDF5 File.
Write data to HDF5 file.
- Parameters:
dat_all (numpy.ndarray) – input data
patches (list) – input patches, list of str
- write_hdf5_header(hd5file, patches=None)[source]¶
Write HDF5 Header.
Write header information to HDF5 file.
- Parameters:
hd5file (h5py.File) – input HDF5 file
patches (list, optional) – input patches, list of str, default is
None
- class ApplyHspMasks[source]¶
Bases:
BaseCatApply Hsp Masks.
- _labels_struct = {1: 'Faint_star_halos', 2: 'Bright_star_halos', 4: 'Stars', 8: 'Manual', 16: 'u', 32: 'g', 64: 'r', 128: 'i', 256: 'z', 512: 'Tile_RA_DEC_cut', 1024: 'Maximask', 2048: 'z2'}¶
- classmethod get_mask_col_name(bit)[source]¶
Get Mask Col Name.
Return column name of mask corresponding to input bit.
- check_params()[source]¶
Check Params.
Check whether parameter values are valid.
- Raises:
ValueError – if a parameter value is not valid
- get_paths_bit_masks()[source]¶
Get Paths Bit Masks.
Return paths of bit-coded mask files.
- Returns:
Dictionary with bit as key and path as value.
- Return type:
- get_mask(path)[source]¶
Get Mask.
Read from file and return healsparse mask.
- Parameters:
path (str) – input path
- Returns:
mask
- Return type:
hsp.HealSparseMap
- apply_mask(ra, dec, hsp_mask, label)[source]¶
Apply Mask.
Apply mask to input coordinates.
- Parameters:
hsp_mask (hsp.HealSparseMap) – input mask
ra (numpy.ndarray) – input right ascension
dec (numpy.ndarray) – input declination
- Returns:
mask values
- Return type:
- get_masks(dat=None)[source]¶
Get Masks.
Returns per-object masks for all bits.
- Parameters:
dat (numpy.ndarray, optional) – input data; if not given (default), data will be read from input file
- Returns:
masks
- Return type:
- append_masks(dat, masks)[source]¶
Append Masks.
Add mask information as columns to data.
- Parameters:
dat (numpy.ndarray) – input data
masks (dict) – mask information
- Returns:
updated data
- Return type:
- class CalibrateCat[source]¶
Bases:
BaseCatCalibrate Cat.
Class to calibrate joint catalogue.
- class Mask(col_name, label, kind=None, value=0, dat=None, verbose=False)[source]¶
Bases:
objectMask.
Class to handle masking of catalogues.
- Parameters:
col_name (str) – name of column to use for mask
label (str) – mask label
kind (str) – operation type, allowed are “equal”, “not_equal, “”greater_equal”, “smaller_equal”, “range”
value (float or list) – value(s) to be used in mask operation
dat (numpy.ndarray, optional) – input data, default is None; apply mask if given
verbose (bool, optional) – verbose output if
True; default isFalse
- print_mask_stats(num_obj, masks, mask_combined)[source]¶
Print Mask Stats.
Print mask statistics.
- Parameters:
num_obj
- get_masks_from_config(config, dat, dat_ext, masks_to_apply=None, verbose=False)[source]¶
Get Masks From Config.
Return mask information from yaml config structure.
- Parameters:
config (dict) – config information
dat (numpy.ndarray) – input data
det_ext (numpy.ndarray) – input extended data
masks_to_apply (list, optional) – masks to apply exclusively; if None (default), use all masks
verbose (bool, optional) – verbose output if
True; default isFalse
- Returns:
list – list of masks
dict – list of indices for given mask column name (label)
- compute_weights_gatti(cat_gal, g_uncorr, gal_metacal, dat, mask_combined, mask_metacal, num_bins=20, snr_min=10, snr_max=500, size_ratio_min=0.707, size_ratio_max=3)[source]¶
Compute Weights Gatti.
Compute Gatti et al. (2021) DES-like weights.
- compute_PSF_leakage(cat_gal, g_corr_mc, dat, mask_combined, mask_metacal, num_bins=20)[source]¶
Compute PSF Leakage.
- run_joint_comprehensive_cat(*args)[source]¶
Run Joint Comprehensive Cat.
Run class to create joint comprehensive catalogue from command line.