Skip to content
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

New normalized_pop_mass.py file #376

Open
wants to merge 23 commits into
base: development
Choose a base branch
from

Conversation

dimsour94
Copy link
Contributor

The new normalized_pop_mass.py file estimates the underlying mass of a population based on your simulated binary fraction (as defined in your ini file) and any specified desired binary fraction you want the "nature" population to have.

@dimsour94 dimsour94 marked this pull request as draft August 29, 2024 13:04
@astroJeff
Copy link
Contributor

Update (Aug 29): This looks like a necessary and important improvement - needs to be checked carefully.

@maxbriel
Copy link
Collaborator

@dimsour94 asked me how we should pass the f_bin_nature to the calculation.
I want to make the following suggestion:

  1. When creating the main metadata when concatenating the files, we remove the calculation. Thus not having an underlying mass in the output.
  2. We add a function to the population class that will calculate the underlying mass for a given input: f_bin_nature, m_1_max, and m_2_max. If no input is given the defaults are used.

(1/(2-a1)) * ((m_1**(2-a1) - m_min**(2-a1))/(m_min**-a1))
((1/(2-a2))
* (m_1/m_min)**-a1 * ((m_2**(2-a2) - m_1**(2-a2))/(m_1**-a2)))
((1/(2-a3)) * (m_1/m_min)**-a1 * (m_2/m_1)**-a2
* ((m_max**(2-a3) - m_2**(2-a3))/(m_2**-a3))))
return mean_mass

def mean_mass_simulated(alpha3, m_a, m_b):
def mean_mass_simulated(alpha3, m_a, m_b, f_bin_simulated):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this function? Wouldn't it be better to get the mean_mass_simulated=mass_simulated/count_simulated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it's just a different approach. However, you might be right—it does seem much more straightforward to use this.

@elizabethteng elizabethteng marked this pull request as ready for review September 12, 2024 14:36
posydon/popsyn/binarypopulation.py Outdated Show resolved Hide resolved
posydon/popsyn/binarypopulation.py Outdated Show resolved Hide resolved
@maxbriel
Copy link
Collaborator

@dimsour94 I've changed how/where the calculation is done to allow for a user defined f_bin_nature, instead of doing the calculation when creating the file. I branched off your branch and implemented it here: 13ab4b0

It calculates the simulated_mass, simulated_mass_single and simulated_mass_binaries and stores those values. I removed the if statement, because np.nansum() will allow you to sum over an empty dataframe and returns 0.0. :)
I noticed there's some repeating code in synthetic_population.py and binarypopulation.py for this calculation.
This might be combined into a function and placed in another file. Not sure about this though.

The calculate_underlying_mass() function in the Population class will now allow the user to calculate the underlying mass and add it to the Population.mass_per_metallicity.

You will still have to implement the passing of f_bin_nature to the calculate_underlying_mass() function.

@maxbriel

This comment was marked as outdated.

@mkruckow

This comment was marked as outdated.

@dimsour94 dimsour94 marked this pull request as ready for review September 26, 2024 13:04
maxbriel
maxbriel previously approved these changes Oct 4, 2024
Copy link
Collaborator

@maxbriel maxbriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I tested it and it gives the simulated mass per system.
I have added that calculate_underlying_mass() save the calculated data to the Population file.

@maxbriel
Copy link
Collaborator

maxbriel commented Oct 8, 2024

Tutorials changed in PR #406 Ready for this PR to be accepted.

@maxbriel maxbriel self-requested a review October 10, 2024 15:30
Copy link
Collaborator

@mkruckow mkruckow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside a few typos, e.g. "stae" -> "star" and not always respecting the 80 characters line length, the PR looks complete now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants