@@ -2,6 +2,7 @@ module SourceWindows
2
2
use precision
3
3
use Classes
4
4
use MpiUtils
5
+ use Interpolation, only : TCubicSpline, TInterpGrid2D
5
6
implicit none
6
7
7
8
integer , parameter :: window_21cm = 1 , window_counts = 2 , window_lensing = 3
@@ -31,12 +32,14 @@ module SourceWindows
31
32
Type, extends(TSourceWindow) :: TSplinedSourceWindow
32
33
Type (TCubicSpline), allocatable :: Window
33
34
Type (TCubicSpline), allocatable :: Bias_z
35
+ Type (TInterpGrid2D), allocatable :: Bias_zk
34
36
real (dl) :: maxwin
35
37
contains
36
38
procedure , nopass :: SelfPointer = > TSplinedSourceWindow_SelfPointer
37
39
procedure :: count_obs_window_z = > TSplinedSourceWindow_count_obs_window_z
38
40
procedure :: GetScales = > TSplinedSourceWindow_GetScales
39
41
procedure :: SetTable = > TSplinedSourceWindow_SetTable
42
+ procedure :: SetTable2DBias = > TSplinedSourceWindow_SetTable2DBias
40
43
procedure :: GetBias = > TSplinedSourceWindow_GetBias
41
44
end Type TSplinedSourceWindow
42
45
@@ -215,7 +218,18 @@ real(dl) function TSplinedSourceWindow_GetBias(this,k,a)
215
218
class(TSplinedSourceWindow) :: this
216
219
real (dl), intent (in ) :: k,a
217
220
real (dl) z
218
- if (allocated (this% bias_z)) then
221
+ integer error
222
+
223
+ if (allocated (this% bias_zk)) then
224
+ z = 1 / a-1
225
+ if (z > this% Window% X(this% Window% n) .or. z < this% Window% X(1 )) then
226
+ TSplinedSourceWindow_GetBias = 0
227
+ else
228
+ error = 0
229
+ TSplinedSourceWindow_GetBias = this% bias_zk% value(z, k, error)
230
+ if (error /= 0 ) TSplinedSourceWindow_GetBias = 0
231
+ end if
232
+ elseif (allocated (this% bias_z)) then
219
233
z = 1 / a-1
220
234
if (z > this% Window% X(this% Window% n) .or. z < this% Window% X(1 )) then
221
235
TSplinedSourceWindow_GetBias = 0
@@ -242,21 +256,42 @@ subroutine TSplinedSourceWindow_SetTable(this, n, z, W, bias_z)
242
256
end if
243
257
if (present (bias_z)) then
244
258
if (allocated (this% Bias_z)) deallocate (this% Bias_z)
259
+ if (allocated (this% Bias_zk)) deallocate (this% Bias_zk)
245
260
if (n> 0 ) then
246
261
allocate (this% Bias_z)
247
262
call this% Bias_z% Init(z,bias_z)
248
263
end if
249
264
end if
250
-
251
265
end subroutine TSplinedSourceWindow_SetTable
252
266
267
+ subroutine TSplinedSourceWindow_SetTable2DBias (this , n , nk , z , k , W , bias_zk )
268
+ class(TSplinedSourceWindow) :: this
269
+ integer , intent (in ) :: n, nk
270
+ real (dl), intent (in ) :: z(n), W(n), k(nk)
271
+ real (dl), intent (in ) :: bias_zk(n,nk)
272
+
273
+ if (allocated (this% Window)) deallocate (this% Window)
274
+ if (n> 0 ) then
275
+ allocate (this% Window)
276
+ call this% Window% Init(z,W)
277
+ this% maxwin = maxval (this% Window% F)
278
+ end if
279
+ if (allocated (this% Bias_zk)) deallocate (this% Bias_zk)
280
+ if (n> 0 .and. nk> 0 ) then
281
+ allocate (this% Bias_zk)
282
+ call this% Bias_zk% Init(z,k,bias_zk)
283
+ end if
284
+
285
+ end subroutine TSplinedSourceWindow_SetTable2DBias
286
+
287
+
253
288
function TSplinedSourceWindow_count_obs_window_z (this , z , winamp )
254
289
! distribution function W(z) for the observed sources, used for lensing and number count spectrum
255
290
! Winamp is amplitude normalized to 1 so the code can tell when the window is very small
256
291
! note this is the total count distribution observed, not a fractional selection function on an underlying distribution
257
292
class(TSplinedSourceWindow) :: this
258
293
real (dl), intent (in ) :: z
259
- real (dl) TSplinedSourceWindow_count_obs_window_z, dz, winamp
294
+ real (dl) TSplinedSourceWindow_count_obs_window_z, winamp
260
295
261
296
if (z > this% Window% X(this% Window% n) .or. z < this% Window% X(1 )) then
262
297
TSplinedSourceWindow_count_obs_window_z = 0
@@ -270,7 +305,7 @@ end function TSplinedSourceWindow_count_obs_window_z
270
305
subroutine TSplinedSourceWindow_GetScales (this , zpeak , sigma_z , zpeakstart , zpeakend )
271
306
class(TSplinedSourceWindow) :: this
272
307
real (dl), intent (out ) :: zpeak, sigma_z, zpeakstart, zpeakend
273
- integer ix, i, j
308
+ integer i, j
274
309
real (dl) z1, zstart, zend, targ
275
310
276
311
associate(z = > this% Window% X, W = > this% Window% F, n= >this% Window% n)
0 commit comments