-
Notifications
You must be signed in to change notification settings - Fork 19
/
dc2_photoz_parquet.py
85 lines (65 loc) · 2.58 KB
/
dc2_photoz_parquet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
DC2 Parquet Photo-z Catalog Reader
"""
import os
import numpy as np
from .dc2_dm_catalog import DC2DMTractCatalog
__all__ = ['DC2PhotozCatalog']
class DC2PhotozCatalog(DC2DMTractCatalog):
r"""DC2 Parquet Photoz Catalog reader
Parameters
----------
file_dir (str): Directory of data files being served, required
file_pattern (str): The optional regex pattern of served data files
meta_path (str): path to yaml entries for quantities
Attributes
----------
base_dir (str): The directory of data files being served
Notes
-----
"""
# pylint: disable=too-many-instance-attributes
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
FILE_PATTERN = r'photoz_pdf_Run\d\.[0-9a-z]+_tract_\d+\.parquet$'
META_PATH = os.path.join(FILE_DIR,
'catalog_configs/_dc2_photoz_parquet.yaml')
_PDF_BIN_INFO = {
'start': 0.005,
'stop': 3.0055,
'step': 0.01,
'decimals_to_round': 3,
}
def _subclass_init(self, **kwargs):
"""
Wraps default init method to apply various corrections to the catalog.
"""
# grab bin info as kwarg, or default to run2.2i values.
self._pdf_bin_info = kwargs.get('pdf_bin_info', self._PDF_BIN_INFO)
self._pdf_bin_centers = np.round(np.arange(self._pdf_bin_info['start'],
self._pdf_bin_info['stop'],
self._pdf_bin_info['step'],
), self._pdf_bin_info['decimals_to_round'])
self._n_pdf_bins = len(self._pdf_bin_centers)
super(DC2PhotozCatalog, self)._subclass_init(**kwargs)
def _generate_modifiers(self, dm_schema_version=3):
"""Creates a dictionary relating native and homogenized column names
Args:
dm_schema_version (int): DM schema version (1, 2, or 3)
Returns:
A dictionary of the form {<homogenized name>: <native name>, ...}
"""
modifiers = {'photoz_ODDS':'ODDS',
'photoz_mode':'z_mode',
'photoz_median':'z_median',
'photoz_mean':'z_mean',
'photoz_pdf':'pdf',
'ID':'galaxy_id',
'photoz_mode_ml':'z_mode_ml',
'photoz_mode_ml_red_chi2':'z_mode_ml_red_chi2'}
return modifiers
@property
def pdf_bins(self):
return self._pdf_bin_centers
@property
def n_pdf_bins(self):
return self._n_pdf_bins