Skip to content

Commit 7e923dc

Browse files
photoz modes: adding option to not degauss certain z bins
1 parent f27003d commit 7e923dc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

modules_desy6/photoz_uz/module.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ params:
2525
meaning: Number of modes to use
2626
type: int
2727
default: 0
28+
no_degaussbins:
29+
meaning: List of redshift bins for which not apply degaussianization
30+
type: str
31+
default: ""
2832
inputs:
2933
wl_number_density:
3034
nbin:

modules_desy6/photoz_uz/photoz_uz.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def setup(options):
3131
`n_modes`: Number of compressed modes to use (per redshift bin, if each
3232
bin has its own compression). If omitted or set to <=0, all modes
3333
in the `basis_file` will be used.
34+
`no_degaussbins` List of redshift bins for which not to apply degaussianization.
3435
3536
The `basis_file` should contain the following arrays:
3637
`U`: An array of shape (n_modes, n_bins, n_z) giving the basis vectors (across n_z redshifts)
@@ -58,6 +59,7 @@ def setup(options):
5859
sample = options.get_string(option_section, "sample", "")
5960
basis_file = options.get_string(option_section, "basis_file", "")
6061
n_modes = options.get_int(option_section, "n_modes", 0)
62+
no_degaussbins = options.get_string(option_section, "no_degaussbins", "")
6163

6264
# Read the basis vectors and record sizes
6365
npzfile = np.load(basis_file)
@@ -101,6 +103,7 @@ def setup(options):
101103
"basis":U,
102104
"degauss":degauss,
103105
"n_modes":n_modes,
106+
"no_degaussbins":no_degaussbins,
104107
"n_bins":n_bins,
105108
"perbin":perbin}
106109

@@ -111,6 +114,7 @@ def execute(block, config):
111114
U = config['basis']
112115
degauss = config['degauss']
113116
n_modes = config['n_modes']
117+
no_degaussbins = config['no_degaussbins']
114118
perbin = config['perbin']
115119
# Read z values from pz block
116120
nbin = block[pz, "nbin"]
@@ -127,13 +131,17 @@ def execute(block, config):
127131
# Read u values
128132
uvals = config['bias_section']
129133
u_ = np.zeros((nbin,n_modes))
134+
# transform string with zbins not to be degauss to numpy array
135+
no_degaussbins = np.fromstring(no_degaussbins, sep=' ', dtype=int)
130136
for i in range(nbin):
131137
if perbin:
132138
u_[i,:] = np.array([block[uvals, "u_{0}_{1}".format(i,j) ] for j in range(n_modes)])
133139
# Apply the degaussianization, if any:
134-
if degauss:
140+
if degauss and i not in no_degaussbins:
135141
for j in range(n_modes):
136142
u_[i,j] = degauss[i][j](u_[i,j])
143+
else:
144+
print(f'Not applying degauss to z-bin {i}')
137145
else:
138146
u_[i,:] = np.array([block[uvals, "u_{0}".format(j) ] for j in range(n_modes)])
139147
if degauss:

0 commit comments

Comments
 (0)