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

CPL added #159

Merged
merged 9 commits into from Jun 11, 2021
Merged

CPL added #159

merged 9 commits into from Jun 11, 2021

Conversation

anastasia-tsvetkova
Copy link
Contributor

Cutoff PL parameterized via Ep added

@grburgess
Copy link
Contributor

@anastasia-tsvetkova you will need to run the script in /scripts/ python generate_test_data.py

and move the newly created table to astromodels/data and update that table in the git

Copy link
Contributor

@grburgess grburgess left a comment

Choose a reason for hiding this comment

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

Thank you for the addition. However, I'm curious if it is not easier to compute Ep after a fit via error propagation. This parameterization introduces functional correlations.

@@ -343,6 +343,83 @@ def evaluate(self, x, K, piv, index, xc):

return result * unit_


class CPL(Function1D, metaclass=FunctionMeta):
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of CPL could be confusing as there is already a cutoff power law function. Moreover, we typically spell out the function name to be clear for users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed: CPL -> Cutoff_powerlaw_Ep


A power law multiplied by an exponential cutoff parametrized via Ep

latex : $ K~\frac{x}{piv}^{index}~\exp{-x/xp} $
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the correct formula?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, thanks, fixed

unit_ = 1.0
K_, piv_, x_, index_, xp_ = K, piv, x, index, xp

result = nb_func.cplaw_eval(x_, K_, xp_, index_, piv_)
Copy link
Contributor

Choose a reason for hiding this comment

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

There was a new numba function cpp_eval created but it is not called here. However, there is really no need as you can write xc = xp (2+index) and pass this to cplaw_eval without the need for extra code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -67,6 +67,20 @@ def cplaw_eval(x, K, xc, index, piv):
return out


@nb.njit(fastmath=True, cache=True)
def cpl_eval(x, K, xp, index, piv):
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

@grburgess grburgess merged commit bc43245 into threeML:master Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants