-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add individual intensities #212
Open
jvshields
wants to merge
39
commits into
tardis-sn:main
Choose a base branch
from
jvshields:add_individual_intensities
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+467
−175
Open
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
172f99f
refactor distances to work with new rays
jvshields f7a7c14
add spherical model parsing
jvshields a10f42b
hook up spherical model reader
jvshields 578fbd7
add explanatory comments
jvshields a5e4120
checkpoint
jvshields 9372ea0
blackify code
jvshields b975ff8
apply appropriate depth masks for rays
jvshields 61250ec
checkpoint
jvshields 0af69a6
checkpoint for some working spherical geometry
jvshields d3f6182
checkpoint for photosphere correction
jvshields 5609849
add single threaded implementation
jvshields 2558f0a
readability cleanup
jvshields 73f629e
add structure for intensities. Also move thetas to sampled from gauss…
jvshields 59de710
move thetas to radiation field
jvshields 7efc0fc
remove single threaded case
jvshields 76e57a9
fix tests
jvshields e05b51e
apply black
jvshields 1e4813b
simplify distances
jvshields dd77b2e
improve documentation
jvshields e824584
more documentation cleanup
jvshields d90a62f
bugfixing
jvshields bf6fd0e
move back to old weights and theta sampling
jvshields cee4e75
fix tests for old thetas
jvshields aa872dc
fix inward rays
jvshields ec52aa0
apply black
jvshields 4902a88
more informative error message when file fails to read
jvshields e1aa678
make marcs reader read whether the model is plane parallel or spherical
jvshields e894d63
fix model reading error message in line with spherical geometry being…
jvshields b13a366
cleanup unused code
jvshields 1cd79ae
fix test
jvshields 2d22a75
Merge remote-tracking branch 'upstream/main' into add_individual_inte…
jvshields 6e9572f
Merge remote-tracking branch 'upstream/main' into add_individual_inte…
jvshields 6e772c7
resolve merge conflicts
jvshields 71a7c27
small config_schema changes
jvshields eb49c03
remove individual intensity preservation w/ no radiation_field return
jvshields 0c542dc
black
jvshields 28d0881
move marcs regex patterns to new file
jvshields 5fbf7c3
Merge branch 'main' into add_individual_intensities
jvshields 8d8984c
Merge remote-tracking branch 'upstream/main' into add_individual_inte…
jvshields 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -18,7 +18,8 @@ class RadiationField(HDFWriterMixin): | |
---------- | ||
frequencies : astronopy.units.Quantity | ||
source_function : stardis.radiation_field.source_function | ||
opacities : stardis.radiation_field.opacities | ||
stellar_model : stardis.stellar_model.StellarModel | ||
num_of_thetas : int | ||
|
||
Attributes | ||
---------- | ||
|
@@ -31,16 +32,40 @@ class RadiationField(HDFWriterMixin): | |
calculate the total opacity at each frequency at each depth point. | ||
F_nu : numpy.ndarray | ||
Radiation field fluxes at each frequency at each depth point. Initialized as zeros and calculated by a solver. | ||
thetas : numpy.ndarray | ||
Theta angles for raytracing. | ||
I_nus_weights : numpy.ndarray | ||
Weights for the theta angles. | ||
I_nus : numpy.ndarray | ||
Radiation field intensity at each frequency at each depth point at each theta angle. Initialized as zeros and calculated by a solver. | ||
""" | ||
|
||
hdf_properties = ["frequencies", "opacities", "F_nu"] | ||
|
||
def __init__(self, frequencies, source_function, stellar_model): | ||
def __init__(self, frequencies, source_function, stellar_model, num_of_thetas): | ||
self.frequencies = frequencies | ||
self.source_function = source_function | ||
self.opacities = Opacities(frequencies, stellar_model) | ||
self.F_nu = np.zeros((stellar_model.no_of_depth_points, len(frequencies))) | ||
|
||
# This uses gauss-legendre quadrature to sample thetas | ||
thetas, weights = np.polynomial.legendre.leggauss(num_of_thetas) | ||
self.thetas = (thetas / 2) + 0.5 * np.pi / 2 | ||
self.I_nus_weights = weights * np.pi / 2 | ||
|
||
# This was our original theta sampling method | ||
# dtheta = (np.pi / 2) / num_of_thetas # Korg uses Gauss-Legendre quadrature here | ||
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. Does this need to be kept? If so I would put it in a test for comparison purposes. |
||
# start_theta = dtheta / 2 | ||
# end_theta = (np.pi / 2) - (dtheta / 2) | ||
# self.thetas = np.linspace(start_theta, end_theta, num_of_thetas) | ||
# self.I_nus_weights = ( | ||
# 2 * np.pi * dtheta * np.sin(self.thetas) * np.cos(self.thetas) | ||
# ) | ||
|
||
self.I_nus = np.zeros( | ||
(stellar_model.no_of_depth_points, len(frequencies), len(self.thetas)) | ||
) | ||
|
||
|
||
def create_stellar_radiation_field(tracing_nus, stellar_model, stellar_plasma, config): | ||
""" | ||
|
@@ -69,7 +94,7 @@ def create_stellar_radiation_field(tracing_nus, stellar_model, stellar_plasma, c | |
""" | ||
|
||
stellar_radiation_field = RadiationField( | ||
tracing_nus, blackbody_flux_at_nu, stellar_model | ||
tracing_nus, blackbody_flux_at_nu, stellar_model, config.no_of_thetas | ||
) | ||
logger.info("Calculating alphas") | ||
calc_alphas( | ||
|
@@ -83,7 +108,6 @@ def create_stellar_radiation_field(tracing_nus, stellar_model, stellar_plasma, c | |
raytrace( | ||
stellar_model, | ||
stellar_radiation_field, | ||
no_of_thetas=config.no_of_thetas, | ||
n_threads=config.n_threads, | ||
) | ||
|
||
|
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.
This is so long it would probably be best in its own file and imported
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.
I have done this.