Update Neutron Star Section#425
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #425 +/- ##
==========================================
- Coverage 98.61% 98.61% -0.01%
==========================================
Files 104 106 +2
Lines 8030 8085 +55
==========================================
+ Hits 7919 7973 +54
- Misses 111 112 +1
🚀 New features to boost your workflow:
|
sibirrer
left a comment
There was a problem hiding this comment.
thank you very much @Zhengjingyi0823! I made some comments and requests to further polish documentation and code
| else: | ||
| raise ValueError("model should be chosen from 'BNS' or 'SNIa'") | ||
|
|
||
| def calculate_event_rate(self, z): |
There was a problem hiding this comment.
please precisely document the specific return with units
There was a problem hiding this comment.
I have added the description of the outputs of functions and their units.
There was a problem hiding this comment.
this should be in the docstrings of this definition, not the init statement
| raise ValueError("model should be chosen from 'BNS' or 'SNIa'") | ||
|
|
||
| def calculate_event_rate(self, z): | ||
| if self.model_name == "BNS": |
There was a problem hiding this comment.
if you have the definitions of the two separate classes named the same, you don't need an if/else statement here
There was a problem hiding this comment.
I added a wrapper function called calculate_event_rate in supernovae_pop.py so that we don’t need to change old code which calls the calculate_SNIa_rate and can simplify code in event_pop.py at the same time.
| ft_d = 1 / (t_d * (np.log(self.t_d_max / self.t_d_min))) | ||
| return ft_d | ||
|
|
||
| def z_from_time(self, t): |
There was a problem hiding this comment.
this is a very generic definition that deserves to be at a different place where it can be re-used. This routine is not specific of what the BNSMerger_pop class is about
There was a problem hiding this comment.
I moved delay_time_destribution out of the class BNSMergerRate. Since it is normalized, I renamed it as norm_delay_time_distribution.
There was a problem hiding this comment.
this does not addresses your comment. This comment was about z_from_time(t)
| self.t_d_max = 13.8 # Gyr, Hubble time approximately | ||
|
|
||
| def calculate_star_formation_rate(self, z): | ||
| """Calculates the binary formation rate. (Eq 3 - Kuwahara et al. 2025) |
There was a problem hiding this comment.
is this star formation or binary formation?
There was a problem hiding this comment.
I originally kept the name for consistency with the supernova population code. Since this function is mainly used within the BNS merger model and only externally called in the BNS merger notebook, I renamed it to calculate_binary_formation_rate for clarity.
| """Calculates the binary formation rate. (Eq 3 - Kuwahara et al. 2025) | ||
|
|
||
| :param z: redshift (z>=0) | ||
| :param z_m: peak-related redshift parameter |
There was a problem hiding this comment.
this does not seem to be an input
There was a problem hiding this comment.
I moved the fixed model parameters nu, a, b, and z_m out of the :param: section and rewrote their explanation in the correct format.
|
|
||
| :param t_d: time delay (t_d>=0) in [Gyr] | ||
| :param t_d_min: minimum of t_d in [Gyr], assumed as 20 Myr | ||
| :param t_d_max: maximum of t_d in [Gyr], assumed as Hubble time |
There was a problem hiding this comment.
this is not an input here. I would make this either a default-valued input or better document it in the class initialization what it means
| (Eq 4 - Kuwahara et al. 2025) | ||
|
|
||
| :param t_d: time delay (t>=0) | ||
| :param t: time at final integrated redshift (t>=0) |
There was a problem hiding this comment.
is there a condition that t>t_d? or something like that?
There was a problem hiding this comment.
- The condition
t_d < tis already enforced by the integration range incalculate_event_rate. To make this clearer, I added this condition as a part of comment above the code.
|
|
||
| :param z: redshift (z>=0) | ||
|
|
||
| :return: BNS merger rate R_m(z), following the unit of R_f |
There was a problem hiding this comment.
The specific unit is added.
| def calculate_event_rate(self, z): | ||
| """Calculates the rate of events, such as BNS merger. (Eq 4 - Kuwahara et al. 2025) | ||
|
|
||
| :param z: redshift (z>=0) |
There was a problem hiding this comment.
this is an array of redshifts, please specify. Do they need to be ascending/decending etc?
There was a problem hiding this comment.
I completed the description of z in function calculate_event_rate. Array z don't need to be sorted but in practice use of BNS merger model, it should be descending since it is converted from t by function z_from_time with the time-delay order from t_d_min to t_d_max.
|
|
||
| rate_array = event_pop.calculate_event_rate(self.z_array) | ||
|
|
||
| npt.assert_almost_equal(rate_array[0], 0.03081, decimal=3) |
There was a problem hiding this comment.
here I would test against the specific class instance's routine (which should be the same) instead of against a numerical answer (that is a test for the individual classes test function
There was a problem hiding this comment.
I have modified test_event_pop.py to compare the output of EventPopulation with the corresponding specific population model class.
…tion related to Event, supernova and BNSmerger
sibirrer
left a comment
There was a problem hiding this comment.
Thank you @Zhengjingyi0823 ! I still have some comments that should be addressed
| ft_d = 1 / (t_d * (np.log(self.t_d_max / self.t_d_min))) | ||
| return ft_d | ||
|
|
||
| def z_from_time(self, t): |
There was a problem hiding this comment.
this does not addresses your comment. This comment was about z_from_time(t)
| def __init__(self, model, cosmo, z_max): | ||
| """ | ||
| BNS model calls the function to calculate the rate of BNS merger. (Eq 4 - Kuwahara et al. 2025) | ||
| :return: BNS merger rate R_m(z), in (M_sol)yr^(-1)Gpc^(-3) |
There was a problem hiding this comment.
initialization do not have any returns.
You should make the two definitions to provide the same units. It's very dangerous to have different returns for different settings
| else: | ||
| raise ValueError("model should be chosen from 'BNS' or 'SNIa'") | ||
|
|
||
| def calculate_event_rate(self, z): |
There was a problem hiding this comment.
this should be in the docstrings of this definition, not the init statement
Adding function for Neutron stars.