sacc 1.0__py3-none-any.whl → 2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sacc/__init__.py +4 -1
- sacc/covariance.py +202 -96
- sacc/data_types.py +64 -9
- sacc/io.py +414 -0
- sacc/sacc.py +372 -149
- sacc/tracer_uncertainty/__init__.py +1 -0
- sacc/tracer_uncertainty/base.py +34 -0
- sacc/tracer_uncertainty/nz.py +287 -0
- sacc/tracers/__init__.py +6 -0
- sacc/tracers/base.py +127 -0
- sacc/tracers/clusters.py +332 -0
- sacc/tracers/maps.py +206 -0
- sacc/tracers/misc.py +87 -0
- sacc/tracers/nz.py +285 -0
- sacc/tracers/survey.py +75 -0
- sacc/utils.py +46 -2
- sacc/windows.py +116 -102
- {sacc-1.0.dist-info → sacc-2.0.dist-info}/METADATA +6 -4
- sacc-2.0.dist-info/RECORD +22 -0
- {sacc-1.0.dist-info → sacc-2.0.dist-info}/WHEEL +1 -1
- sacc/tracers.py +0 -1217
- sacc-1.0.dist-info/RECORD +0 -12
- {sacc-1.0.dist-info → sacc-2.0.dist-info}/licenses/LICENSE +0 -0
- {sacc-1.0.dist-info → sacc-2.0.dist-info}/top_level.txt +0 -0
sacc/windows.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import numpy as np
|
2
2
|
from astropy.table import Table
|
3
|
+
from .io import BaseIO, MULTIPLE_OBJECTS_PER_TABLE, ONE_OBJECT_PER_TABLE
|
3
4
|
|
4
|
-
|
5
|
-
class BaseWindow:
|
5
|
+
class BaseWindow(BaseIO):
|
6
6
|
"""Base class for window functions.
|
7
7
|
|
8
8
|
Window functions here are for 1D variables and describe
|
@@ -17,70 +17,10 @@ class BaseWindow:
|
|
17
17
|
This base class has class methods that can be used to turn
|
18
18
|
mixed lists of windows to/from astropy tables, for I/O.
|
19
19
|
"""
|
20
|
-
|
21
|
-
|
22
|
-
def __init_subclass__(cls, window_type):
|
23
|
-
# This gets called whenever a subclass is defined.
|
24
|
-
# The window_type argument is specified next to the
|
25
|
-
# base class in the subclass definition, e.g.
|
26
|
-
# window_typ='TopHat', as shown below
|
27
|
-
cls._window_classes[window_type] = cls
|
28
|
-
cls.window_type = window_type
|
29
|
-
|
30
|
-
@classmethod
|
31
|
-
def to_tables(cls, instance_list):
|
32
|
-
"""Convert a list of BaseWindos to a list of tables.
|
33
|
-
|
34
|
-
This is called when saving data to file.
|
20
|
+
_sub_classes = {}
|
35
21
|
|
36
|
-
The input instances can be different subclasses, and no
|
37
|
-
ordering is maintained.
|
38
22
|
|
39
|
-
|
40
|
-
----------
|
41
|
-
instance_list: list
|
42
|
-
List of BaseWindow subclass instances
|
43
|
-
|
44
|
-
Returns
|
45
|
-
-------
|
46
|
-
table: list
|
47
|
-
List of astropy.table.Table instances
|
48
|
-
"""
|
49
|
-
tables = []
|
50
|
-
for name, subcls in cls._window_classes.items():
|
51
|
-
# Pull out the relevant objects for this subclass.
|
52
|
-
# Note that we can't use isinstance here.
|
53
|
-
windows = [w for w in instance_list if type(w) == subcls]
|
54
|
-
if len(windows) > 0:
|
55
|
-
tables += subcls.to_tables(windows)
|
56
|
-
return tables
|
57
|
-
|
58
|
-
@classmethod
|
59
|
-
def from_tables(cls, table_list):
|
60
|
-
"""Turn a list of astropy tables into window objects
|
61
|
-
|
62
|
-
This is called when loading data from file.
|
63
|
-
|
64
|
-
Parameters
|
65
|
-
----------
|
66
|
-
instance_list: list
|
67
|
-
List of BaseWindow instances
|
68
|
-
|
69
|
-
Returns
|
70
|
-
-------
|
71
|
-
windows: dict
|
72
|
-
Dictionary of id -> Window instances
|
73
|
-
"""
|
74
|
-
windows = {}
|
75
|
-
for table in table_list:
|
76
|
-
subclass_name = table.meta['SACCCLSS']
|
77
|
-
subclass = cls._window_classes[subclass_name]
|
78
|
-
# Different subclasses can handle this differently.
|
79
|
-
windows.update(subclass.from_table(table))
|
80
|
-
return windows
|
81
|
-
|
82
|
-
|
83
|
-
class TopHatWindow(BaseWindow, window_type='TopHat'):
|
23
|
+
class TopHatWindow(BaseWindow, type_name='TopHat'):
|
84
24
|
"""A window function that is constant between two values.
|
85
25
|
|
86
26
|
The top-hat is zero elsewhere.
|
@@ -98,6 +38,7 @@ class TopHatWindow(BaseWindow, window_type='TopHat'):
|
|
98
38
|
max: int/float
|
99
39
|
The maximum value where the top-hat function equals 1
|
100
40
|
"""
|
41
|
+
storage_type = MULTIPLE_OBJECTS_PER_TABLE
|
101
42
|
def __init__(self, range_min, range_max):
|
102
43
|
"""Create a top-hat window
|
103
44
|
|
@@ -113,8 +54,35 @@ class TopHatWindow(BaseWindow, window_type='TopHat'):
|
|
113
54
|
self.min = range_min
|
114
55
|
self.max = range_max
|
115
56
|
|
57
|
+
def __eq__(self, other):
|
58
|
+
"""Equality test.
|
59
|
+
|
60
|
+
Two TopHatWindows are equal if they have the same min and max.
|
61
|
+
|
62
|
+
Parameters
|
63
|
+
----------
|
64
|
+
other: object
|
65
|
+
The other object to test for equality
|
66
|
+
"""
|
67
|
+
if not isinstance(other, type(self)):
|
68
|
+
return False
|
69
|
+
return self.min == other.min and self.max == other.max
|
70
|
+
|
71
|
+
def __hash__(self):
|
72
|
+
"""Hash function.
|
73
|
+
|
74
|
+
This uses the same attributes as __eq__ to ensure consistent
|
75
|
+
behaviour.
|
76
|
+
|
77
|
+
Returns
|
78
|
+
-------
|
79
|
+
hash: int
|
80
|
+
|
81
|
+
"""
|
82
|
+
return hash((self.min, self.max))
|
83
|
+
|
116
84
|
@classmethod
|
117
|
-
def
|
85
|
+
def to_table(cls, window_list):
|
118
86
|
"""Convert a list of Top-Hat windows to a list of astropy tables.
|
119
87
|
|
120
88
|
A single table is created for all the windows.
|
@@ -136,11 +104,7 @@ class TopHatWindow(BaseWindow, window_type='TopHat'):
|
|
136
104
|
mins = [w.min for w in window_list]
|
137
105
|
maxs = [w.max for w in window_list]
|
138
106
|
ids = [id(w) for w in window_list]
|
139
|
-
|
140
|
-
t.meta['SACCTYPE'] = 'window'
|
141
|
-
t.meta['SACCCLSS'] = cls.window_type
|
142
|
-
t.meta['EXTNAME'] = 'window:' + cls.window_type
|
143
|
-
return [t]
|
107
|
+
return Table(data=[ids, mins, maxs], names=['id', 'min', 'max'])
|
144
108
|
|
145
109
|
@classmethod
|
146
110
|
def from_table(cls, table):
|
@@ -160,17 +124,16 @@ class TopHatWindow(BaseWindow, window_type='TopHat'):
|
|
160
124
|
return {row['id']: cls(row['min'], row['max']) for row in table}
|
161
125
|
|
162
126
|
|
163
|
-
class LogTopHatWindow(TopHatWindow,
|
127
|
+
class LogTopHatWindow(TopHatWindow, type_name='LogTopHat'):
|
164
128
|
"""A window function that is log-constant between two values.
|
165
129
|
|
166
130
|
This object is the same as the TopHat form, except that in between
|
167
131
|
the min and max values it is assumed to be constant in the log of the
|
168
132
|
argument. The difference arises when this object is used elsewhere.
|
169
133
|
"""
|
170
|
-
pass
|
171
134
|
|
172
135
|
|
173
|
-
class Window(BaseWindow,
|
136
|
+
class Window(BaseWindow, type_name='Standard'):
|
174
137
|
"""The Window class defines a tabulated window function.
|
175
138
|
|
176
139
|
The class contains tabulated values of the abscissa (e.g. ell or theta) and
|
@@ -187,12 +150,41 @@ class Window(BaseWindow, window_type='Standard'):
|
|
187
150
|
The weights corresponding to each value
|
188
151
|
|
189
152
|
"""
|
153
|
+
storage_type = ONE_OBJECT_PER_TABLE
|
154
|
+
|
190
155
|
def __init__(self, values, weight):
|
191
156
|
self.values = np.array(values)
|
192
157
|
self.weight = np.array(weight)
|
193
158
|
|
194
|
-
|
195
|
-
|
159
|
+
def __eq__(self, other):
|
160
|
+
"""Equality test
|
161
|
+
|
162
|
+
Two Windows are equal if they have equivalent values and weights.
|
163
|
+
|
164
|
+
Parameters
|
165
|
+
----------
|
166
|
+
other: Window
|
167
|
+
The other Window to compare
|
168
|
+
|
169
|
+
"""
|
170
|
+
if not isinstance(other, type(self)):
|
171
|
+
return False
|
172
|
+
return np.allclose(self.values, other.values) and np.allclose(self.weight, other.weight)
|
173
|
+
|
174
|
+
def __hash__(self):
|
175
|
+
"""Hash function.
|
176
|
+
|
177
|
+
This uses the identity of the object. Caution: this is not
|
178
|
+
ideal, because it means that two windows with equivalent values and
|
179
|
+
weights may not have the same hash.
|
180
|
+
|
181
|
+
Returns
|
182
|
+
-------
|
183
|
+
hash: int
|
184
|
+
"""
|
185
|
+
return id(self)
|
186
|
+
|
187
|
+
def to_table(self):
|
196
188
|
"""Convert a list of windows to a list of astropy tables.
|
197
189
|
|
198
190
|
One table is created per window.
|
@@ -211,17 +203,10 @@ class Window(BaseWindow, window_type='Standard'):
|
|
211
203
|
table: list
|
212
204
|
List of astropy.table.Table instances
|
213
205
|
"""
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
t = Table(data=cols, names=names)
|
219
|
-
t.meta['SACCTYPE'] = 'window'
|
220
|
-
t.meta['SACCCLSS'] = cls.window_type
|
221
|
-
t.meta['SACCNAME'] = id(w)
|
222
|
-
t.meta['EXTNAME'] = 'window:' + cls.window_type
|
223
|
-
tables.append(t)
|
224
|
-
return tables
|
206
|
+
cols = [self.values, self.weight]
|
207
|
+
names = ['values', 'weight']
|
208
|
+
t = Table(data=cols, names=names)
|
209
|
+
return t
|
225
210
|
|
226
211
|
@classmethod
|
227
212
|
def from_table(cls, table):
|
@@ -238,10 +223,10 @@ class Window(BaseWindow, window_type='Standard'):
|
|
238
223
|
windows: dict
|
239
224
|
Dictionary of id -> Window instances
|
240
225
|
"""
|
241
|
-
return
|
226
|
+
return cls(table['values'], table['weight'])
|
242
227
|
|
243
228
|
|
244
|
-
class BandpowerWindow(BaseWindow,
|
229
|
+
class BandpowerWindow(BaseWindow, type_name='Bandpower'):
|
245
230
|
"""The BandpowerWindow class defines a tabulated for power
|
246
231
|
spectrum bandpowers.
|
247
232
|
|
@@ -258,6 +243,8 @@ class BandpowerWindow(BaseWindow, window_type='Bandpower'):
|
|
258
243
|
weights corresponding to each value.
|
259
244
|
|
260
245
|
"""
|
246
|
+
storage_type = ONE_OBJECT_PER_TABLE
|
247
|
+
|
261
248
|
def __init__(self, values, weight):
|
262
249
|
nl, nv = weight.shape
|
263
250
|
nell = len(values)
|
@@ -268,8 +255,42 @@ class BandpowerWindow(BaseWindow, window_type='Bandpower'):
|
|
268
255
|
self.values = np.array(values)
|
269
256
|
self.weight = np.array(weight)
|
270
257
|
|
271
|
-
|
272
|
-
|
258
|
+
def __eq__(self, other):
|
259
|
+
"""Equality test
|
260
|
+
|
261
|
+
Two BandpowerWindows are equal if they have the same values and weights.
|
262
|
+
|
263
|
+
Parameters
|
264
|
+
----------
|
265
|
+
other: BandpowerWindow
|
266
|
+
The other BandpowerWindow to compare
|
267
|
+
|
268
|
+
Returns
|
269
|
+
-------
|
270
|
+
bool
|
271
|
+
True if the windows are equal, False otherwise
|
272
|
+
"""
|
273
|
+
if not isinstance(other, type(self)):
|
274
|
+
return False
|
275
|
+
return self.nell == other.nell and \
|
276
|
+
self.nv == other.nv and \
|
277
|
+
np.allclose(self.values, other.values) and \
|
278
|
+
np.allclose(self.weight, other.weight)
|
279
|
+
|
280
|
+
def __hash__(self):
|
281
|
+
"""Hash function.
|
282
|
+
|
283
|
+
This uses the identity of the object. Caution: this is not ideal,
|
284
|
+
because it means that two windows with equivalent values and
|
285
|
+
weights may not have the same hash.
|
286
|
+
|
287
|
+
Returns
|
288
|
+
-------
|
289
|
+
hash: int
|
290
|
+
"""
|
291
|
+
return id(self)
|
292
|
+
|
293
|
+
def to_table(self):
|
273
294
|
"""Convert a list of windows to a list of astropy tables.
|
274
295
|
|
275
296
|
One table is created per window.
|
@@ -288,17 +309,10 @@ class BandpowerWindow(BaseWindow, window_type='Bandpower'):
|
|
288
309
|
table: list
|
289
310
|
List of astropy.table.Table instances
|
290
311
|
"""
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
t = Table(data=cols, names=names)
|
296
|
-
t.meta['SACCTYPE'] = 'window'
|
297
|
-
t.meta['SACCCLSS'] = cls.window_type
|
298
|
-
t.meta['SACCNAME'] = id(w)
|
299
|
-
t.meta['EXTNAME'] = 'window:' + cls.window_type
|
300
|
-
tables.append(t)
|
301
|
-
return tables
|
312
|
+
cols = [self.values, self.weight]
|
313
|
+
names = ['values', 'weight']
|
314
|
+
t = Table(data=cols, names=names)
|
315
|
+
return t
|
302
316
|
|
303
317
|
@classmethod
|
304
318
|
def from_table(cls, table):
|
@@ -315,7 +329,7 @@ class BandpowerWindow(BaseWindow, window_type='Bandpower'):
|
|
315
329
|
windows: dict
|
316
330
|
Dictionary of id -> Window instances
|
317
331
|
"""
|
318
|
-
return
|
332
|
+
return cls(table['values'], table['weight'])
|
319
333
|
|
320
334
|
def get_section(self, indices):
|
321
335
|
"""Get part of this window function corresponding to the input
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: sacc
|
3
|
-
Version:
|
3
|
+
Version: 2.0
|
4
4
|
Summary: SACC - the LSST/DESC summary statistic data format library
|
5
5
|
Author-email: LSST DESC <joezuntz@googlemail.com>
|
6
6
|
License: BSD-3-Clause
|
@@ -10,17 +10,19 @@ Classifier: Operating System :: OS Independent
|
|
10
10
|
Description-Content-Type: text/markdown
|
11
11
|
License-File: LICENSE
|
12
12
|
Requires-Dist: scipy
|
13
|
-
Requires-Dist: numpy>=
|
13
|
+
Requires-Dist: numpy>=2
|
14
14
|
Requires-Dist: astropy
|
15
15
|
Provides-Extra: all
|
16
|
-
Requires-Dist: qp-prob[all]; extra == "all"
|
16
|
+
Requires-Dist: qp-prob[all]>=1; extra == "all"
|
17
17
|
Requires-Dist: numpydoc; extra == "all"
|
18
18
|
Provides-Extra: doc
|
19
19
|
Requires-Dist: numpydoc; extra == "doc"
|
20
20
|
Provides-Extra: qp
|
21
|
-
Requires-Dist: qp-prob[all]; extra == "qp"
|
21
|
+
Requires-Dist: qp-prob[all]>=1; extra == "qp"
|
22
22
|
Dynamic: license-file
|
23
23
|
|
24
|
+
[](https://codecov.io/github/LSSTDESC/sacc)
|
25
|
+
|
24
26
|
Sacc
|
25
27
|
====
|
26
28
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
sacc/__init__.py,sha256=pcKSj7s0VizX896xmXFBl350KslJYKb3QZC3bDW5Jxs,516
|
2
|
+
sacc/covariance.py,sha256=kXviJMVeoFPVwmOD1obz_yf1zM8QtX41TIqaA-t2gjU,19414
|
3
|
+
sacc/data_types.py,sha256=fsp1UXJpsk1rYh4BIdu6Em0zhh6IEArVx7x8uWr4cdw,18261
|
4
|
+
sacc/io.py,sha256=MQsXLwyW-AvgRTIpxI68YxwBuTf9N5eRmPjrqY5o1_U,16743
|
5
|
+
sacc/sacc.py,sha256=jgksrG3GsTvJqKn-SQmZ2MkdHHBdFU06007cRTt8NM0,59030
|
6
|
+
sacc/utils.py,sha256=wRWRanAdyN9IdKVbcZLGIpi0oQgylc7qJsN_Cqmxaj0,5701
|
7
|
+
sacc/windows.py,sha256=SdRGom8ejHvDH-UEhTQBI4PpHb8dC_20SU0T3krnAvg,9910
|
8
|
+
sacc/tracer_uncertainty/__init__.py,sha256=ZH623ylPtHvBrydCYuZIUmJpebTB_ad32byKA8Xr0Dw,83
|
9
|
+
sacc/tracer_uncertainty/base.py,sha256=ecSqs-9CAFejwqPvm4XKF5El79I3KniX32e-TuxMUgw,942
|
10
|
+
sacc/tracer_uncertainty/nz.py,sha256=yitocUjN0_8SVisRauHssOPTDwfrxmJo0WyNiQF1HCk,9475
|
11
|
+
sacc/tracers/__init__.py,sha256=_HFydXF1lzymJLYwaoL9dEXllMCMapF5J0pQaAFRygc,274
|
12
|
+
sacc/tracers/base.py,sha256=2CZnj9fGgFkAffzNh3NuxEdbgMxox-5uJztl9klgR3o,4264
|
13
|
+
sacc/tracers/clusters.py,sha256=fRGqKrBE6JqgYesvrgOPtCpQ477Jivuz98z77aaHVSc,11642
|
14
|
+
sacc/tracers/maps.py,sha256=Ww6wVPnirMxtEH1WsP0wOQbgkvXftOV6iDUv7evDDVA,7382
|
15
|
+
sacc/tracers/misc.py,sha256=IbbvcB_8N2OlKWi_t6JP3fRd_956SQThb1TBXq7zOdc,2785
|
16
|
+
sacc/tracers/nz.py,sha256=oHCXnPUSUuVvQJ10Vv0prRst4Vy6X8vjqTWGCqigXlg,8604
|
17
|
+
sacc/tracers/survey.py,sha256=1HJRQxnaoraBDmol8_BW32BsNwEiAt5itPNyuRz6KFM,2568
|
18
|
+
sacc-2.0.dist-info/licenses/LICENSE,sha256=WMLhPVmrUk6KoMHcLwY1ynIJcA7id_bfU-QSSiCAxtI,1469
|
19
|
+
sacc-2.0.dist-info/METADATA,sha256=8FVuN-WubnhaUqq7E0SdMxuqgQ6JGN2QGapTQxZQoMg,2528
|
20
|
+
sacc-2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
sacc-2.0.dist-info/top_level.txt,sha256=nyd_Bzl4Ly4EGXdgYFa0MHs8CYGAOIGPG1PhQTZsSdM,5
|
22
|
+
sacc-2.0.dist-info/RECORD,,
|