From 7a47eec0e39f6ab1d0a1588cb0eca1a504d101ab Mon Sep 17 00:00:00 2001 From: Martin Kilbinger Date: Wed, 26 Jul 2023 11:17:39 +0200 Subject: [PATCH] no changes --- .gitignore | 2 ++ sp_peaks/slics.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 sp_peaks/slics.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..212d545 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.ipynb_checkpoints +__pycache__ diff --git a/sp_peaks/slics.py b/sp_peaks/slics.py new file mode 100644 index 0000000..5ed43c1 --- /dev/null +++ b/sp_peaks/slics.py @@ -0,0 +1,71 @@ +"""SLICS. + +:Name: slics.py + +:Description: This package contains methods to interface with + the (Cosmo-)SLICS simulations (Hernois-Deraps et al). + +:Authors: Martin Kilbinger +""" + +col_names = [ + "RA", + "Dec", + "e1_data", + "e2_data", + "w", + "redshift_true_sim", + "gamma1_sim", + "gamma2_sim", + "kappa_sim", + "S_metacal_data", +] + +col_names_essential = [ + "RA", + "Dec", + "e1_data", + "e2_data", + "redshift_true_sim", +] + + +import os +from astropy.io import ascii + + +def read_catalogue(file_path, all_col=True): + """Read Catalogue. + + Read SLICS catalogue and return content. + + Parameters + ---------- + file_path : str + input file path + all_col : bool, optional + if True returns all columns; if False (default) only + essential columns + + Raises + ------ + IOError + if input file not found + + Returns + ------- + dict + catalogue content + + """ + if not os.path.exists(file_path): + raise IOError(f"SLICS catlogue file {file_path} does not exist") + + if all_col: + include_names = None + else: + include_names = col_names_essential + + dat = ascii.read(file_path, names=col_names, include_names=include_names) + + return dat