-
Notifications
You must be signed in to change notification settings - Fork 3
Fix stellar age #138
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
Fix stellar age #138
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
46bfa5e
add metals in pynbody handler that are needed for dust computation, h…
anschaible 08dbdac
fix rotation for nihao
anschaible 62c3e21
fix rotation for nihao galaxies
anschaible 9c60c7c
fix wrong age for nihao
anschaible d5e303f
fits file saving
anschaible 131f0ec
reduce chunk size for spectral assignment
anschaible 587cd68
fix pytest for galaxy rotation
anschaible 11048d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d15ef58
update stellar age in pynbody
anschaible 915feb8
Merge branch 'main' into fix-stellar-age
anschaible a64b863
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8038901
add comment in rotation
anschaible 213b85c
Merge branch 'main' into fix-stellar-age
anschaible 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,9 +76,11 @@ def get_galaxy_rotation(config: dict): | |
| def rotate_galaxy(rubixdata: RubixData) -> RubixData: | ||
| logger.info(f"Rotating galaxy with alpha={alpha}, beta={beta}, gamma={gamma}") | ||
|
|
||
| """ | ||
| for particle_type in ["stars", "gas"]: | ||
| if particle_type in config["data"]["args"]["particle_type"]: | ||
| # Get the component (either stars or gas) | ||
| logger.info(f"Rotating {particle_type}") | ||
| component = getattr(rubixdata, particle_type) | ||
|
|
||
| # Get the inputs | ||
|
|
@@ -99,7 +101,8 @@ def rotate_galaxy(rubixdata: RubixData) -> RubixData: | |
| coords, velocities = rotate_galaxy_core( | ||
| positions=coords, | ||
| velocities=velocities, | ||
| masses=masses, | ||
| positions_stars=rubixdata.stars.coords, | ||
| masses_stars=rubixdata.stars.mass, | ||
| halfmass_radius=halfmass_radius, | ||
| alpha=alpha, | ||
| beta=beta, | ||
|
|
@@ -113,5 +116,64 @@ def rotate_galaxy(rubixdata: RubixData) -> RubixData: | |
| setattr(component, "velocity", velocities) | ||
|
|
||
| return rubixdata | ||
| """ | ||
| logger.info("Rotating galaxy for simulation: " + config["simulation"]["name"]) | ||
| # Rotate gas | ||
| if "gas" in config["data"]["args"]["particle_type"]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part looks like it can be refactored, but only minor comment |
||
| logger.info("Rotating gas") | ||
|
|
||
| # Rotate the gas component | ||
| new_coords_gas, new_velocities_gas = rotate_galaxy_core( | ||
| positions=rubixdata.gas.coords, | ||
| velocities=rubixdata.gas.velocity, | ||
| positions_stars=rubixdata.stars.coords, | ||
| masses_stars=rubixdata.stars.mass, | ||
| halfmass_radius=rubixdata.galaxy.halfmassrad_stars, | ||
| alpha=alpha, | ||
| beta=beta, | ||
| gamma=gamma, | ||
| key=config["simulation"]["name"], | ||
| ) | ||
|
|
||
| setattr(rubixdata.gas, "coords", new_coords_gas) | ||
| setattr(rubixdata.gas, "velocity", new_velocities_gas) | ||
|
|
||
| # Rotate the stellar component | ||
| new_coords_stars, new_velocities_stars = rotate_galaxy_core( | ||
| positions=rubixdata.stars.coords, | ||
| velocities=rubixdata.stars.velocity, | ||
| positions_stars=rubixdata.stars.coords, | ||
| masses_stars=rubixdata.stars.mass, | ||
| halfmass_radius=rubixdata.galaxy.halfmassrad_stars, | ||
| alpha=alpha, | ||
| beta=beta, | ||
| gamma=gamma, | ||
| key=config["simulation"]["name"], | ||
| ) | ||
|
|
||
| setattr(rubixdata.stars, "coords", new_coords_stars) | ||
| setattr(rubixdata.stars, "velocity", new_velocities_stars) | ||
|
|
||
| else: | ||
| logger.warning( | ||
| "Gas not found in particle_type, only rotating stellar component." | ||
| ) | ||
| # Rotate the stellar component | ||
| new_coords_stars, new_velocities_stars = rotate_galaxy_core( | ||
| positions=rubixdata.stars.coords, | ||
| velocities=rubixdata.stars.velocity, | ||
| positions_stars=rubixdata.stars.coords, | ||
| masses_stars=rubixdata.stars.mass, | ||
| halfmass_radius=rubixdata.galaxy.halfmassrad_stars, | ||
| alpha=alpha, | ||
| beta=beta, | ||
| gamma=gamma, | ||
| key=config["simulation"]["name"], | ||
| ) | ||
|
|
||
| setattr(rubixdata.stars, "coords", new_coords_stars) | ||
| setattr(rubixdata.stars, "velocity", new_velocities_stars) | ||
|
|
||
| return rubixdata | ||
|
|
||
| return rotate_galaxy | ||
Oops, something went wrong.
Oops, something went wrong.
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.
why this factor?