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

Evolving MMBulge Amplitude #94

Merged
merged 15 commits into from
Feb 6, 2024
Merged

Evolving MMBulge Amplitude #94

merged 15 commits into from
Feb 6, 2024

Conversation

CayenneMatt
Copy link
Collaborator

Description

This update allows usage of "...Redshift..." versions of MMBulge functions in relations.py
Previously evolving relations only worked if shape=N, now they run for shape=None

The biggest change was to mass_stellar() in sam.py
Previously the output of this function was reshaped after call, now arrays are reshaped in the function and returned with shape (M, Q, Z)

Todos

Notable points that this PR has either accomplished or will accomplish.

  • Next step is to implement scatter evolution

Questions

  • None

Status

  • Ready to go as long as this pull request doesn't fail any tests

Rewrite mass_stellar() to reshape arrays within the function rather than afterwords. Also changed lines in static_binary_density() and gwb_ideal() to remove reshaping of arrays after mass_stellar() is called since it is now performed in the function
Added redz argument to non-evolving versions of the MMBulge scaling relations. Default is redz=1, since redz is not used in the non-evolving versions of the functions it doesn't matter what the default/input is
Added redz argument to instance of mbh_from_host(). Default is redz=1
Added missing redz argument to mbh_from_host
Removed line defining redz in the wrong location
Added try except statement to handle array shaping in redshift-dependent version of mbh_from_mbulge. There may be a better way to do it, but this certainly works
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Merging #94 (704d62a) into dev (18b20db) will decrease coverage by 3.28%.
Report is 57 commits behind head on dev.
The diff coverage is 92.59%.

Additional details and impacted files

@CayenneMatt
Copy link
Collaborator Author

@lzkelley All the tests passed so I believe this is now good to go. I did add a try-except statement in right at the last minute to fix an issue that was popping up in the host-relations notebook. I don't know if that was the most efficient way to solve that issue (maybe the notebook was wrong?), so feel free to change it if it's obvious or want me to take some more time to think about a more clever solution let me know.

Copy link
Member

@lzkelley lzkelley left a comment

Choose a reason for hiding this comment

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

See inline comments.

@@ -600,7 +600,7 @@ class PM_Mass_Reset(_Population_Modifier):
"""Reset the masses of a target population based on a given M-Host relation.
"""

def __init__(self, mhost, scatter=True):
def __init__(self, mhost, redz=1, scatter=True):
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this redz parameter is unused. What's the purpose of including it here, and setting to a default of 1?

@@ -633,7 +633,7 @@ def modify(self, pop):
# Store old version
pop._mass = pop.mass
# if `scatter` is `True`, then it is set to the value in `mhost.SCATTER_DEX`
pop.mass = self.mhost.mbh_from_host(pop, scatter)
pop.mass = self.mhost.mbh_from_host(pop, redz=pop.redz, scatter=scatter)
Copy link
Member

Choose a reason for hiding this comment

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

Because the whole pop instance is being passed to the function, the function itself can always grab pop.redz. Why include it as an argument also?

@@ -351,7 +351,7 @@ def mbh_from_mstar(self, mstar, scatter):
mbulge = self.mbulge_from_mstar(mstar)
Copy link
Member

Choose a reason for hiding this comment

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

The redz parameter should be passed through here also, into the mbulge_from_mstar and mbh_from_mbulge functions, right?

@@ -191,7 +191,7 @@ def shape(self):
self._shape = tuple([len(ee) for ee in self.edges])
return self._shape

def mass_stellar(self):
def mass_stellar(self, redz):
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but it would probably be a little cleaner to just grab the redz values within this function, instead of passing them in. i.e. within this function:

redz = self.redz[np.newaxis, np.newaxis, :]

The motivation being that there are no other redshift values that would be used (at least not that I can think of).

mstar_rat = mstar_tot / mstar_pri
# M = m1 + m2
mstar_tot = mstar_pri + mstar_tot

Copy link
Member

Choose a reason for hiding this comment

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

Nice, I like moving all of this into the mass_stellar() function!

Calculate redz in mass_stellar() rather than calling as argument
Changed all instances of redz=1 to redz=None. Also updated mbh_from_host() to determine redz from pop rather than from an argument
Removed redz as arguments in two functions since they were unused.
Fixing redz arguments, removed something that was added in error
Removed argument redz from mbh_from_host() in line 107
@lzkelley lzkelley self-requested a review February 6, 2024 18:33
@lzkelley lzkelley merged commit c4c407b into dev Feb 6, 2024
8 checks passed
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.

2 participants