-
Notifications
You must be signed in to change notification settings - Fork 3
Add z dep #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add z dep #33
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8fedb5c
first implementation with redshift-dependent cofactors
AlexGKim 5517ade
whatever
AlexGKim 57741e8
Merge branch 'add_z_dep' into zdep
AlexGKim cf84d63
Om-gamma parameterization gives a reasonable answer. Is it correct????
AlexGKim d770b2e
Delete flip/covariance/agkim24 directory
AlexGKim 8c8cdad
editing to make consistent with upstream
AlexGKim aea36cc
works and should match upstream
AlexGKim d7a7c13
implementation of Om0-gamma model. The output looks reasonable.
AlexGKim a830aa3
calculate derivatives with wolfram.
AlexGKim 933fbd4
implement fs8 fisher
AlexGKim 319ad0f
confirmed first order (1-a) using wolfram
AlexGKim f6c98a3
more debug code.
AlexGKim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,132 @@ | ||
| import os | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| from pkg_resources import resource_filename | ||
|
|
||
| from flip import fisher, utils | ||
| from flip.covariance import covariance | ||
|
|
||
| def main(): | ||
| flip_base = resource_filename("flip", ".") | ||
| data_path = os.path.join(flip_base, "data") | ||
|
|
||
| ### Load data | ||
| sn_data = pd.read_parquet(os.path.join(data_path, "velocity_data.parquet")) | ||
|
|
||
| sn_data = sn_data[np.array(sn_data["status"]) != False] | ||
| sn_data = sn_data[np.array(sn_data["status"]) != None] | ||
| coordinates_velocity = np.array([sn_data["ra"], sn_data["dec"], sn_data["rcom_zobs"], sn_data["zobs"]]) | ||
|
|
||
| data_velocity = sn_data.to_dict("list") | ||
| for key in data_velocity.keys(): | ||
| data_velocity[key] = np.array(data_velocity[key]) | ||
| data_velocity["velocity"] = data_velocity.pop("vpec") | ||
| data_velocity["velocity_error"] = np.zeros_like(data_velocity["velocity"]) | ||
|
|
||
|
|
||
| ktt, ptt = np.loadtxt(os.path.join(data_path, "power_spectrum_tt.txt")) | ||
| kmt, pmt = np.loadtxt(os.path.join(data_path, "power_spectrum_mt.txt")) | ||
| kmm, pmm = np.loadtxt(os.path.join(data_path, "power_spectrum_mm.txt")) | ||
|
|
||
| sigmau_fiducial = 15 | ||
|
|
||
| power_spectrum_dict = {"vv": [[ktt, ptt * utils.Du(ktt, sigmau_fiducial) ** 2]]} | ||
|
|
||
| ### Compute covariance | ||
| size_batch = 10_000 | ||
| number_worker = 16 | ||
|
|
||
|
|
||
| from flip.covariance.rcrk24.flip_terms import power_spectrum_amplitude_function | ||
| covariance_fit = covariance.CovMatrix.init_from_flip( | ||
| "rcrk24", | ||
| # "agk24" | ||
| # 'carreres23', | ||
| "velocity", | ||
| power_spectrum_dict, | ||
| coordinates_velocity=coordinates_velocity, | ||
| size_batch=size_batch, | ||
| number_worker=number_worker, | ||
| power_spectrum_amplitude_function=power_spectrum_amplitude_function, | ||
| ) | ||
|
|
||
| ### Load fitter | ||
|
|
||
| fisher_properties = { | ||
| "inversion_method": "inverse", | ||
| "velocity_type": "scatter", | ||
| } | ||
|
|
||
| variant = None # can be replaced by growth_index | ||
|
|
||
| parameter_dict = { | ||
| "fs8": 0.4, | ||
| "Om0": 0.3, | ||
| "gamma": 0.55, | ||
| "sigv": 200, | ||
| "sigma_M": 0.12, | ||
| } | ||
|
|
||
| # parameter_dict = { | ||
| # "Om0": 0.3, | ||
| # "gamma": 0.55, | ||
| # "sigv": 200, | ||
| # "sigma_M": 0.12, | ||
| # } | ||
|
|
||
| Fisher = fisher.FisherMatrix.init_from_covariance( | ||
| covariance_fit, | ||
| data_velocity, | ||
| parameter_dict, | ||
| fisher_properties=fisher_properties, | ||
| ) | ||
|
|
||
| parameter_name_list, fisher_matrix = Fisher.compute_fisher_matrix( | ||
| parameter_dict, variant=variant | ||
| ) | ||
| return parameter_name_list, fisher_matrix | ||
|
|
||
| def dlnDdOm0(parameter_values_dict): | ||
| a=(1/(1+0.05)) | ||
| lna=np.log(a) | ||
| return ( | ||
| parameter_values_dict["gamma"] * parameter_values_dict["Om0"]**(parameter_values_dict["gamma"]-1) * | ||
| ( | ||
| 3 * parameter_values_dict["gamma"] * (parameter_values_dict["Om0"]-1) * (a - lna -1) + | ||
| 3 * (a-1) * parameter_values_dict["Om0"] - | ||
| 3 * np.log(a) * parameter_values_dict["Om0"] + lna | ||
| ) | ||
| ) | ||
|
|
||
| def dlnDdgamma(parameter_values_dict): | ||
| a=(1/(1+0.05)) | ||
| lna=np.log(a) | ||
| f0 = parameter_values_dict["Om0"]**parameter_values_dict["gamma"] | ||
| return ( | ||
| f0 * | ||
| ( | ||
| np.log(parameter_values_dict["Om0"]) * | ||
| ( | ||
| 3 * parameter_values_dict["gamma"] * (parameter_values_dict["Om0"]-1) * (a - lna -1) + lna | ||
| ) + | ||
| 3 * (parameter_values_dict["Om0"]-1) * (a - lna -1) | ||
| ) | ||
| ) | ||
|
|
||
| if __name__ == "__main__": | ||
| parameter_dict = { | ||
| "Om0": 0.3, | ||
| "gamma": 0.55, | ||
| "sigv": 200, | ||
| "sigma_M": 0.12, | ||
| } | ||
| parameter_name_list, fisher_matrix = main() | ||
| cov = np.linalg.inv(fisher_matrix[0:2,0:2]) | ||
|
|
||
| s80 = 0.832 | ||
| partials = s80*np.array([parameter_dict['gamma']*parameter_dict['Om0']**(parameter_dict['gamma']-1),np.log(parameter_dict['Om0'])*parameter_dict['Om0']**parameter_dict['gamma']]) | ||
| partials = partials + parameter_dict['Om0']**parameter_dict['gamma'] *s80 * np.array([dlnDdOm0(parameter_dict), dlnDdgamma(parameter_dict)]) | ||
|
|
||
| print(np.sqrt(partials.T @ cov[0:2,0:2] @ partials)) | ||
| print(1/np.sqrt(fisher_matrix[2,2])) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not very general but we can consider it to be true if we do not add the sigma_8 dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved, at least notionally? I spent the day looking for bugs and actually reimplementing to get the same answer.