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

Emissivity compiling and loading. #62

Merged
merged 74 commits into from
Oct 6, 2020
Merged

Conversation

findesgh
Copy link
Contributor

@findesgh findesgh commented Sep 9, 2020

This is a pre-requisite for the completion of #46. It does for the emissivities what is already there for the spectra in terms of compilation to npy files and loading.

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.
findesgh and others added 21 commits August 25, 2020 13:22
Small bugfix in `all_spectra`
The binary `kwarg` was not passed on to `SpectraCompiler` from `load.all_spectra`.
mass_per_bin now takes a normal python callable and a vectorized function as input. 
The latter boosts performance significantly
- CSPEventRate functions are now called:
    - calculate_rate_over_time -> over_time
    - calculate_rate_at_time -> at_time
new functions: 
    - grid_over_time: calculates the rates from a 2D SFH (per BPASS metallicity) from  time_points to time bins
     - grid_at_time: calculate the event rate at a specific moment in lookback time from a 2D SFH grid
* 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
@findesgh
Copy link
Contributor Author

@maxbriel could you please check if the changes proposed here are ok for you? I think they only affect code you "own".

@maxbriel
Copy link
Collaborator

maxbriel commented Sep 17, 2020

Hi Martin,

Thank you for your contribution! Love the abstraction and inheritance! Currently, I am rather busy, but will check the proposed changes fully before the end of next week!
Thank you for your patience!

@maxbriel maxbriel changed the base branch from csp to dev1.6 October 5, 2020 23:28
@maxbriel
Copy link
Collaborator

maxbriel commented Oct 6, 2020

Hi Martin,

I finally got around to inspecting the changes. Thank you for also cleaning up some of the doc strings! To keep consistency, we're merging csp into our dev1.6 branch first and then adding this addition to the dev1.6 branch.

For this I have merged dev1.6 into the data_loading.
I have also made the following changes:

  • Renamed the all_emissivity to emissivity_all_z r for consistency
  • Replaced try/except statement in the data_compiler to a if/else statement that checks for the existence of the compiled file.
  • Added a check for the existence of each metallicity file, when loading specta/emissivity
  • Adjusted loading for the additional "z" in BPASS_METALLICITIES

When the tests pass, it will be merged into dev1.6.

@maxbriel maxbriel merged commit 8bbe799 into HeloiseS:dev1.6 Oct 6, 2020
@findesgh findesgh deleted the data_loading branch October 6, 2020 09:50
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.

None yet

3 participants