forked from joezuntz/cosmosis-standard-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added interpolate module for P(k) (cosmic emu needed this...)
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from cosmosis.datablock import option_section, names | ||
from scipy.interpolate import interp2d | ||
import numpy as np | ||
|
||
def setup(options): | ||
config=0 | ||
return config | ||
|
||
def execute(block, config): | ||
test = config | ||
|
||
P0 = block['matter_power_nl','p_k'] | ||
k0 = block['matter_power_nl','k_h'] | ||
z0 = block['matter_power_nl','z'] | ||
|
||
P1 = block['matter_power_lin','p_k'] | ||
k1 = block['matter_power_lin','k_h'] | ||
z1 = block['matter_power_lin','z'] | ||
|
||
I = interp2d(np.log10(k0),z0,np.log10(P0)) | ||
|
||
P_nl_interp = 10**I(np.log10(k1),z1) | ||
|
||
|
||
block.replace_double_array_1d('matter_power_nl','k_h',k1) | ||
block.replace_double_array_1d('matter_power_nl','z',z1) | ||
block.replace_double_array_nd('matter_power_nl','p_k',P_nl_interp) | ||
|
||
#import pdb ; pdb.set_trace() | ||
|
||
return 0 |