sacc 0.14__tar.gz → 0.15__tar.gz
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-0.14/sacc.egg-info → sacc-0.15}/PKG-INFO +1 -1
- {sacc-0.14 → sacc-0.15}/sacc/sacc.py +1 -1
- {sacc-0.14 → sacc-0.15}/sacc/tracers.py +41 -10
- {sacc-0.14 → sacc-0.15/sacc.egg-info}/PKG-INFO +1 -1
- {sacc-0.14 → sacc-0.15}/test/test_sacc2.py +12 -3
- {sacc-0.14 → sacc-0.15}/.git_archival.txt +0 -0
- {sacc-0.14 → sacc-0.15}/.gitattributes +0 -0
- {sacc-0.14 → sacc-0.15}/.github/workflows/desc-ci.yml +0 -0
- {sacc-0.14 → sacc-0.15}/.github/workflows/publish.yml +0 -0
- {sacc-0.14 → sacc-0.15}/.gitignore +0 -0
- {sacc-0.14 → sacc-0.15}/.readthedocs.yml +0 -0
- {sacc-0.14 → sacc-0.15}/LICENSE +0 -0
- {sacc-0.14 → sacc-0.15}/MANIFEST.in +0 -0
- {sacc-0.14 → sacc-0.15}/README.md +0 -0
- {sacc-0.14 → sacc-0.15}/doc/Makefile +0 -0
- {sacc-0.14 → sacc-0.15}/doc/format.md +0 -0
- {sacc-0.14 → sacc-0.15}/doc/requirements.txt +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/Makefile +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/api.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/conf.py +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/covariance.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/data_types.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/index.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/intro.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/sacc.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/tracers.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/utils.rst +0 -0
- {sacc-0.14 → sacc-0.15}/doc/source/windows.rst +0 -0
- {sacc-0.14 → sacc-0.15}/examples/.gitignore +0 -0
- {sacc-0.14 → sacc-0.15}/examples/CMB_LSS_read.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/CMB_LSS_write.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/Convert_DES_Sacc.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/Convert_KIDS_Sacc.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/Create_Sacc.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/README.md +0 -0
- {sacc-0.14 → sacc-0.15}/examples/SACC_for_clusters.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/SACC_read.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/SACC_write.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/demo_sacc_for_clusters_N+M.ipynb +0 -0
- {sacc-0.14 → sacc-0.15}/examples/example-txpipe-sacc1.sacc +0 -0
- {sacc-0.14 → sacc-0.15}/requirements.txt +0 -0
- {sacc-0.14 → sacc-0.15}/sacc/__init__.py +0 -0
- {sacc-0.14 → sacc-0.15}/sacc/covariance.py +0 -0
- {sacc-0.14 → sacc-0.15}/sacc/data_types.py +0 -0
- {sacc-0.14 → sacc-0.15}/sacc/utils.py +0 -0
- {sacc-0.14 → sacc-0.15}/sacc/windows.py +0 -0
- {sacc-0.14 → sacc-0.15}/sacc.egg-info/SOURCES.txt +0 -0
- {sacc-0.14 → sacc-0.15}/sacc.egg-info/dependency_links.txt +0 -0
- {sacc-0.14 → sacc-0.15}/sacc.egg-info/requires.txt +0 -0
- {sacc-0.14 → sacc-0.15}/sacc.egg-info/top_level.txt +0 -0
- {sacc-0.14 → sacc-0.15}/setup.cfg +0 -0
- {sacc-0.14 → sacc-0.15}/setup.py +0 -0
- {sacc-0.14 → sacc-0.15}/test/data/.gitignore +0 -0
- {sacc-0.14 → sacc-0.15}/test/make_test_data.py +0 -0
- {sacc-0.14 → sacc-0.15}/test/test_cluster_data_tracers.py +0 -0
@@ -1220,7 +1220,7 @@ class Sacc:
|
|
1220
1220
|
raise ValueError("Input bandpowers are misshapen")
|
1221
1221
|
tag_extra = range(window.nv)
|
1222
1222
|
tag_extra_name = "window_ind"
|
1223
|
-
window_use = [window for
|
1223
|
+
window_use = [window for _ in range(window.nv)]
|
1224
1224
|
else:
|
1225
1225
|
tag_extra = None
|
1226
1226
|
tag_extra_name = None
|
@@ -305,7 +305,6 @@ class MapTracer(BaseTracer, tracer_type='Map'):
|
|
305
305
|
for table in table_list:
|
306
306
|
# Read name and table type
|
307
307
|
name = table.meta['SACCNAME']
|
308
|
-
quantity = table.meta.get('SACCQTTY', 'generic')
|
309
308
|
tabtyp = table.meta['EXTNAME'].split(':')[-1]
|
310
309
|
if tabtyp not in ['beam']:
|
311
310
|
raise KeyError("Unknown table type " + table.meta['EXTNAME'])
|
@@ -317,7 +316,7 @@ class MapTracer(BaseTracer, tracer_type='Map'):
|
|
317
316
|
tr_tables[name][tabtyp] = table
|
318
317
|
|
319
318
|
# Now loop through different tracers and build them from their tables
|
320
|
-
for
|
319
|
+
for dt in tr_tables.values():
|
321
320
|
quantity = []
|
322
321
|
metadata = {}
|
323
322
|
map_unit = 'none'
|
@@ -452,7 +451,6 @@ class NuMapTracer(BaseTracer, tracer_type='NuMap'):
|
|
452
451
|
for table in table_list:
|
453
452
|
# Read name and table type
|
454
453
|
name = table.meta['SACCNAME']
|
455
|
-
quantity = table.meta.get('SACCQTTY', 'generic')
|
456
454
|
tabtyp = table.meta['EXTNAME'].split(':')[-1]
|
457
455
|
if tabtyp not in ['bandpass', 'beam']:
|
458
456
|
raise KeyError("Unknown table type " + table.meta['EXTNAME'])
|
@@ -464,7 +462,7 @@ class NuMapTracer(BaseTracer, tracer_type='NuMap'):
|
|
464
462
|
tr_tables[name][tabtyp] = table
|
465
463
|
|
466
464
|
# Now loop through different tracers and build them from their tables
|
467
|
-
for
|
465
|
+
for dt in tr_tables.values():
|
468
466
|
quantity = []
|
469
467
|
metadata = {}
|
470
468
|
nu = []
|
@@ -652,9 +650,11 @@ class NZTracer(BaseTracer, tracer_type='NZ'):
|
|
652
650
|
|
653
651
|
class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
654
652
|
"""
|
655
|
-
A Tracer type for tomographic n(z) data
|
653
|
+
A Tracer type for tomographic n(z) data represented as a `qp.Ensemble`
|
654
|
+
|
655
|
+
Takes a `qp.Ensemble` and optionally a redshift array.
|
656
656
|
|
657
|
-
|
657
|
+
Requires the `qp` and `tables_io` packages to be installed.
|
658
658
|
|
659
659
|
Parameters
|
660
660
|
----------
|
@@ -666,7 +666,7 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
666
666
|
The qp.ensemble in questions
|
667
667
|
"""
|
668
668
|
|
669
|
-
def __init__(self, name, ens, **kwargs):
|
669
|
+
def __init__(self, name, ens, z=None, **kwargs):
|
670
670
|
"""
|
671
671
|
Create a tracer corresponding to a distribution in redshift n(z),
|
672
672
|
for example of galaxies.
|
@@ -680,6 +680,11 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
680
680
|
ensemble: qp.Ensemble
|
681
681
|
The qp.ensemble in questions
|
682
682
|
|
683
|
+
z: array
|
684
|
+
Optional grid of redshift values at which to evaluate the ensemble.
|
685
|
+
If left as None then the ensemble metadata is checked for a grid.
|
686
|
+
If that is not present then no redshift grid is saved.
|
687
|
+
|
683
688
|
Returns
|
684
689
|
-------
|
685
690
|
instance: NZTracer object
|
@@ -687,7 +692,16 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
687
692
|
"""
|
688
693
|
super().__init__(name, **kwargs)
|
689
694
|
self.ensemble = ens
|
690
|
-
|
695
|
+
if z is None:
|
696
|
+
ens_meta = ens.metadata()
|
697
|
+
if 'bins' in list(ens_meta.keys()):
|
698
|
+
z = ens_meta['bins'][0]
|
699
|
+
self.z = z
|
700
|
+
if z is None:
|
701
|
+
self.nz = None
|
702
|
+
else:
|
703
|
+
self.nz = np.mean(ens.pdf(self.z),axis=0)
|
704
|
+
|
691
705
|
@classmethod
|
692
706
|
def to_tables(cls, instance_list):
|
693
707
|
"""Convert a list of NZTracers to a list of astropy tables
|
@@ -710,6 +724,16 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
710
724
|
tables = []
|
711
725
|
|
712
726
|
for tracer in instance_list:
|
727
|
+
if tracer.z is not None:
|
728
|
+
names = ['z', 'nz']
|
729
|
+
cols = [tracer.z, tracer.nz]
|
730
|
+
fid_table = Table(data=cols, names=names)
|
731
|
+
fid_table.meta['SACCTYPE'] = 'tracer'
|
732
|
+
fid_table.meta['SACCCLSS'] = cls.tracer_type
|
733
|
+
fid_table.meta['SACCNAME'] = tracer.name
|
734
|
+
fid_table.meta['SACCQTTY'] = tracer.quantity
|
735
|
+
fid_table.meta['EXTNAME'] = f'tracer:{cls.tracer_type}:{tracer.name}:fid'
|
736
|
+
|
713
737
|
table_dict = tracer.ensemble.build_tables()
|
714
738
|
ap_tables = convertToApTables(table_dict)
|
715
739
|
data_table = ap_tables['data']
|
@@ -731,6 +755,8 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
731
755
|
meta_table.meta['META_'+kk] = vv
|
732
756
|
tables.append(data_table)
|
733
757
|
tables.append(meta_table)
|
758
|
+
if tracer.z is not None:
|
759
|
+
tables.append(fid_table)
|
734
760
|
if ancil_table:
|
735
761
|
ancil_table.meta['SACCTYPE'] = 'tracer'
|
736
762
|
ancil_table.meta['SACCCLSS'] = cls.tracer_type
|
@@ -761,6 +787,7 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
761
787
|
Only contains one key/value pair for the one tracer.
|
762
788
|
"""
|
763
789
|
import qp
|
790
|
+
|
764
791
|
tracers = {}
|
765
792
|
sorted_dict = {}
|
766
793
|
for table_ in table_list:
|
@@ -772,8 +799,12 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
772
799
|
else:
|
773
800
|
sorted_dict[table_key][table_type] = table_
|
774
801
|
|
775
|
-
for
|
802
|
+
for val in sorted_dict.values():
|
776
803
|
meta_table = val['meta']
|
804
|
+
if 'fid' in val:
|
805
|
+
z = val['fid']['z']
|
806
|
+
else:
|
807
|
+
z = None
|
777
808
|
ensemble = qp.from_tables(val)
|
778
809
|
name = meta_table.meta['SACCNAME']
|
779
810
|
quantity = meta_table.meta.get('SACCQTTY', 'generic')
|
@@ -782,7 +813,7 @@ class QPNZTracer(BaseTracer, tracer_type='QPNZ'):
|
|
782
813
|
for key, value in meta_table.meta.items():
|
783
814
|
if key.startswith("META_"):
|
784
815
|
metadata[key[5:]] = value
|
785
|
-
tracers[name] = cls(name, ensemble,
|
816
|
+
tracers[name] = cls(name, ensemble, z=z,
|
786
817
|
quantity=quantity,
|
787
818
|
metadata=metadata)
|
788
819
|
return tracers
|
@@ -833,10 +833,10 @@ def test_qpnz_tracer():
|
|
833
833
|
nz_qp_interp = qp.Ensemble(qp.interp, data=dict(xvals=z, yvals=np.ones(shape=(1, 101))))
|
834
834
|
nz_qp_hist = qp.Ensemble(qp.hist, data=dict(bins=z, pdfs=np.ones(shape=(1, 100))))
|
835
835
|
|
836
|
-
T1 = sacc.BaseTracer.make('QPNZ', 'tracer1', nz_qp_interp,
|
836
|
+
T1 = sacc.BaseTracer.make('QPNZ', 'tracer1', nz_qp_interp, z,
|
837
837
|
quantity='galaxy_density',
|
838
838
|
metadata=md1)
|
839
|
-
T2 = sacc.BaseTracer.make('QPNZ', 'tracer2', nz_qp_hist,
|
839
|
+
T2 = sacc.BaseTracer.make('QPNZ', 'tracer2', nz_qp_hist, z,
|
840
840
|
quantity='galaxy_shear',
|
841
841
|
metadata=md2)
|
842
842
|
assert T1.metadata == md1
|
@@ -850,6 +850,15 @@ def test_qpnz_tracer():
|
|
850
850
|
assert T1a.metadata == md1
|
851
851
|
assert T2a.metadata == md2
|
852
852
|
|
853
|
+
# test version without saved z
|
854
|
+
T3 = sacc.BaseTracer.make('QPNZ', 'tracer3', nz_qp_interp,
|
855
|
+
quantity='galaxy_density',
|
856
|
+
metadata=md1)
|
857
|
+
tables = sacc.BaseTracer.to_tables([T3])
|
858
|
+
D = sacc.BaseTracer.from_tables(tables)
|
859
|
+
assert D['tracer3'].z is None
|
860
|
+
|
861
|
+
|
853
862
|
|
854
863
|
def test_io_qp():
|
855
864
|
s = sacc.Sacc()
|
@@ -859,7 +868,7 @@ def test_io_qp():
|
|
859
868
|
nz = np.expand_dims((z-0.5)**2/0.1**2, 0)
|
860
869
|
ens = qp.Ensemble(qp.interp, data=dict(xvals=z, yvals=nz))
|
861
870
|
ens.set_ancil(dict(modes = ens.mode(z)))
|
862
|
-
s.add_tracer('QpnZ', 'source_0', ens)
|
871
|
+
s.add_tracer('QpnZ', 'source_0', ens, z)
|
863
872
|
|
864
873
|
for i in range(20):
|
865
874
|
ee = 0.1 * i
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sacc-0.14 → sacc-0.15}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sacc-0.14 → sacc-0.15}/setup.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|