-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
[TEP006] Aggregate TARDIS restructure and configuration system cleanup #652
[TEP006] Aggregate TARDIS restructure and configuration system cleanup #652
Conversation
1585d7f
to
a12700b
Compare
@@ -14,11 +14,11 @@ | |||
class BasePlasma(object): | |||
|
|||
outputs_dict = {} | |||
def __init__(self, plasma_properties, **kwargs): | |||
def __init__(self, plasma_properties, property_args=None, **kwargs): |
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.
@ftsamis that looks awesome! I'm wondering if we should call this property_kwargs
? But if you think args
is better let's go with this.
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.
You are right, property_kwargs
is a better name. Done
5a1b4de
to
7e443d6
Compare
7e443d6
to
81ee84c
Compare
81ee84c
to
48ceb8c
Compare
@tardis-sn/tardis-core I would like to have as many collaboration members as possible look over this. This is a major change, but seemingly has passed all the tests for now. |
ca2684c
to
5640c5f
Compare
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Radial1DModel(object): |
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.
missing documentation. This needs to be fixed here or as an issue
it's not clear what the different attributes are and how the class works.
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.
Fixed.
from tardis.util import quantity_linspace | ||
|
||
|
||
class HomologousDensity(object): |
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.
same here - documentation missing and explanation.
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.
Fixed.
self.density_0 = density_0 | ||
self.time_0 = time_0 | ||
|
||
def after_time(self, time_explosion): |
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.
not clear if this function name is clear - @tardis-sn/tardis-core ?
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 agree with @wkerzendorf
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.
Propose an alternative.
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.
calculate_density_evolution
? @chvogl If no other alternative in the next hour just use that and we are done!!
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 think something like calculate_density_at_time_of_simulation would be more comprehensible.
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 really don't like long names, but done.
time_explosion).cgs | ||
|
||
@classmethod | ||
def from_config(cls, config): |
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.
documentation missing
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.
Fixed. Also for all other from_config
classmethods.
@@ -110,29 +120,30 @@ def legacy_update_spectrum(self, no_of_virtual_packets): | |||
self.spectrum_virtual.update_luminosity( | |||
self.montecarlo_virtual_luminosity) | |||
|
|||
def run(self, model, no_of_packets, no_of_virtual_packets=0, nthreads=1,last_run=False): | |||
def run(self, model, plasma, no_of_packets, no_of_virtual_packets=0, nthreads=1,last_run=False): |
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.
We should fix the documentation here.
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.
Fixed.
exptau = 1 - np.exp(- | ||
runner.line_lists_tau_sobolevs.reshape(-1, | ||
runner.j_estimator.shape[0]) ) | ||
model.Edotlu = Edotlu_norm_factor*exptau*runner.Edotlu_estimator | ||
runner.Edotlu = Edotlu_norm_factor*exptau*runner.Edotlu_estimator |
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.
PEP 8 violation
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.
Out of scope for this PR. Introduced in #595.
|
||
mean_densities = mean_densities[inner_boundary_index:outer_boundary_index] | ||
|
||
time_of_model,velocity, unscaled_mean_densities = file_parsers[filetype](filename) |
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.
PEP8 Violation
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.
Fixed!
self.density_0 = density_0 | ||
self.time_0 = time_0 | ||
|
||
def after_time(self, time_explosion): |
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 agree with @wkerzendorf
if d_conf.type == 'branch85_w7': | ||
density_0 = calculate_power_law_density(v_middle, d_conf.w7_v_0, | ||
d_conf.w7_rho_0, -7) | ||
return cls(density_0, d_conf.w7_time_0) |
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 think it would be nicer to have the returns outside the if statements. Just set time_0 equal to d_conf.w7_time_0 for this case and move the return to the end.
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 agree. Fixed.
def calculate_power_law_density(velocities, velocity_0, rho_0, exponent): | ||
""" | ||
|
||
This function computes a descret exponential density profile. |
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.
Typo
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.
Out of scope for this PR, introduced in #26.
self.packet_source = packet_source.BlackBodySimpleSource(seed) | ||
self.spectrum_frequency = spectrum_frequency | ||
self.virtual_spectrum_range = virtual_spectrum_range # TODO: linspace handling |
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.
If this is still relevant it would be nice to make an issue out of this. Otherwise just remove the TODO.
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 closely related to #644. I removed the TODO comment for now. Fixed.
def from_config(cls, config): | ||
if config.plasma.disable_electron_scattering: | ||
logger.warn('Disabling electron scattering - this is not physical') | ||
sigma_thomson = 1e-200 / (u.cm ** 2) |
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.
Cross sections have units of (length)**2.
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.
The logic was actually copied as-is from current master:
tardis/tardis/io/config_reader.py
Line 948 in 60d1d1d
validated_config_dict['montecarlo']['sigma_thomson'] = 6.652486e-25 / (u.cm ** 2) |
Since I don't really know what sigma_thomson or cross sections are in this context, I'd like a confirmation on if we should change that. @wkerzendorf?
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.
After some digging in the code, it seems that the unit of sigma_thomson is completely ignored afterwards, since cmontecarlo uses just its value. So, neither the wrong unit, neither correcting it would affect the computations in any way, which means it is probably safe to fix this by directly using, as @chvogl proposed, the astropy.constants.sigma_T
.
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.
Fixed as proposed.
sigma_thomson = 1e-200 / (u.cm ** 2) | ||
else: | ||
logger.debug("Electron scattering switched on") | ||
sigma_thomson = 6.652486e-25 / (u.cm ** 2) |
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.
Same as above.
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.
Maybe we should use the Thomson scattering cross-section from astropy (astropy.constants.sigma_T) instead of hardcoding the value.
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.
Same answer as above. @wkerzendorf. On your second comment, if there is a constant for that it seems perfectly reasonable to use it as far as I am concerned.
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.
Fixed as proposed.
|
||
return cls(seed=config.montecarlo.seed, | ||
spectrum_frequency=spectrum_frequency, | ||
# TODO: Linspace handling for virtual_spectrum_range |
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.
Maybe make an issue out of this.
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.
Removed the TODO comment. Fixed.
…y_at_time_of_simulation
…d of in every 'if'.
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.
Had a very quick look at it - looks very impressive to me, good job @ftsamis! Apart from the legacy support thing (the violation of which I am ok with), nothing stuck out. I am all for merging and closing this chapter.
|
||
return radial1d_mdl | ||
return simulation |
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 will break existing scripts which expect that radial1d_mdl is returned by run_tardis.
I am tempted to swallow this and will update e.g. tardisanalysis.
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 true, although having the entire simulation object returned is much more useful and takes the need to duplicate information, which we heavily did until now, i.e. copying various stuff to model.
So, swallowing this would be a fair trade-off, I believe. ☺
@ftsamis undo the last change. this breaks the tests - we shouldn't do this in this PR. |
…also fixing its unit." This reverts commit 136f667.
Edit: I had converted sigma_T to cgs. No idea what caused the tests to fail. |
@ftsamis congratulations - I'm merging this now. |
This is an aggregate of:
LegacyPlasmaArray
with a function - Replace LegacyPlasmaArray with a function #635MontecarloRunner
- Restructure the MontecarloRunner #636Simulation
- Restructure the Simulation #645config_reader
module - Cleanup of the config_reader module. #623