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

Refactor spectrum #729

Merged
merged 10 commits into from
Jun 7, 2017
Merged

Refactor spectrum #729

merged 10 commits into from
Jun 7, 2017

Conversation

yeganer
Copy link
Contributor

@yeganer yeganer commented Jun 3, 2017

The refactor changes the way a spectrum is handled. Instead of creating
a spectrum and updating it after each montecarlo iteration, we create a
new spectrum from the MontecarloRunner whenever it is needed.

Benefits:

  • TARDISSpectrum is now a general purpose spectrum class that is not
    linked to the Iteration sheme anymore.
  • It is now possible to save spectra for all iterations without them
    being updated each iteration.
  • This class can now also be used for spectra created by the formal
    integral approach (upcoming PR [WIP] Basic implementation of the formal integral #726)

yeganer added 2 commits June 3, 2017 15:15
The refactor changes the way a spectrum is handled. Instead of creating
a spectrum and updating it after each montecarlo iteration, we create a
new spectrum from the MontecarloRunner whenever it is needed.

Benefits:
- TARDISSpectrum is now a general purpose spectrum class that is not
linked to the Iteration sheme anymore.
- It is now possible to save spectra for all iterations without them
being updated each iteration.
- This class can now also be used for spectra created by the formal
integral approach (upcoming PR tardis-sn#726)
@wkerzendorf
Copy link
Member

@yeganer add function to calculate flux using distance.

@wkerzendorf
Copy link
Member

@yeganer add deprecation warning to flux

Copy link
Member

@wkerzendorf wkerzendorf left a comment

Choose a reason for hiding this comment

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

remove and add stuff as discussed.

@@ -37,14 +37,11 @@ def __init__(self, seed, spectrum_frequency, virtual_spectrum_range,
self.packet_source = packet_source.BlackBodySimpleSource(seed)
self.spectrum_frequency = spectrum_frequency
self.virtual_spectrum_range = virtual_spectrum_range
self.distance = distance
Copy link
Member

Choose a reason for hiding this comment

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

remove

self.spectrum_reabsorbed.update_luminosity(
montecarlo_reabsorbed_luminosity)
@property
def spectrum_virtual(self):
Copy link
Member

Choose a reason for hiding this comment

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

add warning

return TARDISSpectrum(
self.spectrum_frequency,
self.montecarlo_virtual_luminosity,
self.distance)
Copy link
Member

Choose a reason for hiding this comment

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

remove

HDF_PROPERTIES = [
'_frequency',
'luminosity',
'distance'
Copy link
Member

Choose a reason for hiding this comment

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

remove

yeganer added 2 commits June 6, 2017 12:48
This concludes the refactoring of TARDISSpectrum.

The syntax for the dummy to_hdf was slightly changed to match the syntax of pandas
to_hdf() methods. That means the 'name' parameter was removed as there
is no reason for the function do decide where it should save to and the
path is now a required argument.
@yeganer yeganer force-pushed the refactor_spectrum branch from 4297d48 to ae46cc3 Compare June 6, 2017 10:49
@yeganer
Copy link
Contributor Author

yeganer commented Jun 6, 2017

@wkerzendorf Do we still want a DeprecationWarning or is the 'hidden' functionality to add a distance to the object to allow calculation of the flux sufficient?

@wkerzendorf
Copy link
Member

@yeganer the flux should get a deprecation warning.

spec_from)


def test_creat_from_wl(spectrum):
Copy link
Contributor

Choose a reason for hiding this comment

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

You could maybe move this test into a separate section, since it does not belong into the "Load and Save" category.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I added another section.

@yeganer yeganer force-pushed the refactor_spectrum branch from aaa85b6 to c3b1a69 Compare June 6, 2017 14:23
@yeganer yeganer force-pushed the refactor_spectrum branch from c3b1a69 to 4f0e7b5 Compare June 6, 2017 14:25
@yeganer
Copy link
Contributor Author

yeganer commented Jun 6, 2017

@tardis-sn/tardis-core I'm done with this PR, if there are no further comments, this can be merged.

@wkerzendorf wkerzendorf merged commit 0703cb0 into tardis-sn:master Jun 7, 2017
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.

4 participants