Skip to content

Conversation

findesgh
Copy link
Contributor

@findesgh findesgh commented Aug 6, 2020

Re-implementation of the binning utilities of pyBASS using numba. I haven't quite managed to achieve the same performance as that of the original Fortran implementation, but this should not be a problem even if binning millions of spectra.

maxbriel and others added 30 commits June 2, 2020 16:43
The complex stellar population subpackage is meant to combine bpass 
variables with a stelalr formation history to generate more complex 
populations. To this end, we're implementing a stellar formation history 
class. The basic SFH class for custom SFH is implemented using scipy 
splines. This basic class is also tested.
This method allows for the calculation of the event rate at a given lookback time. It uses the BPASS binning for this. 

This method is much faster, but suffers from a lack of accuracy.
Both functions are implemented for the BPASS spectra. 
However, the method is similar to the BPASS event rate calculation, which is sub optimal for the spectra calculation. It takes an extremely long time to do the calculation. A for loop of 100000 iterations is present, because each wavelength is seen as it's own "event type". It should be possible to remove this by implementing a function to take the separate wavelengths as a single unit. It would be interesting so see the influence of putting the for loop within a numba function, but thinking about restructuring the function is probably better. 

Including a "caching" of the BPASS spectra into a pickled DataFrame. 



Additional test files are required for this to run.
Instead of requiring a scipy interpolated spline as input. These functions now take a list of functions as input for the stellar formation and metallicity history. 

This adjustment has been made by using `numpy.interp` instead of scipy.interpolate. Furthermore, instead of scipy's spline integration `numpy.trapz` is now used to calculate the mass per bin.
maxbriel and others added 14 commits August 29, 2020 11:17
* BUG: use np instead of pd in SpectraCompiler.
* BUG: fix index and make test pass.
* BUG: fix another regression bug.
* Fix further regression bug.

Authored-by: Martin Glatzle <mglatzle@mpa-garching.mpg.de>
Also includes some docstring updates
CSPSpectra now has the following functions: 
Public: 
- at_time: at time with function input
- over_time: over lb time with function input
- grid_at_time: at time with SFH grid input
- grid_over_time: over lb time with SFH grid input
Private: 
- grid_rate_calculator_at_time
- grid_rate_calculator_over_time

The grid_rate_calculators_* are numba functions that  have the grid_* around them as wrappers for the input and output
Instead of N bins being created, N-1 bin was being created.
Copy link
Owner

@HeloiseS HeloiseS left a comment

Choose a reason for hiding this comment

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

Excellent work and must apologise for the time it took me to get to this: I was taking a course on deep learning and then had to take sick leave to treat my HVS.

I've added a few comments to the files and I have one main questions: is there a reason you added these function to the utils module and not the spec module which specifically has to do with spectroscopy?

@findesgh
Copy link
Contributor Author

findesgh commented Oct 2, 2020

No worries, thanks for taking a look!

Regarding the location in utils: I used csp as a base branch for this since I need the spectra loading functionality for #46. And the spec module has not yet been merged into csp. In principle, though, feel free to move the code to where you see fit :-).

Will address the other issues as time permits.

@findesgh findesgh changed the base branch from csp to dev1.6 October 6, 2020 12:13
@findesgh
Copy link
Contributor Author

findesgh commented Oct 6, 2020

Merged dev1.6 into this and chose it as base branch as well, as that makes more sense, I suppose. Should I move the functionality to hoki/spec.py?

@HeloiseS
Copy link
Owner

HeloiseS commented Oct 8, 2020

Merged dev1.6 into this and chose it as base branch as well, as that makes more sense, I suppose. Should I move the functionality to hoki/spec.py?

great, that makes sense :)

@findesgh findesgh requested a review from HeloiseS October 8, 2020 19:33
@HeloiseS HeloiseS merged commit 6f272c1 into HeloiseS:dev1.6 Oct 8, 2020
@findesgh findesgh deleted the rebin branch October 9, 2020 00:41
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.

3 participants