-
Notifications
You must be signed in to change notification settings - Fork 9
BiorthBasis::Cylinder deprojection improvements #208
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
Draft
The9Cat
wants to merge
26
commits into
devel
Choose a base branch
from
Toomre
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,286
−20
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
494c619
Added a Toomre-type disk for deprojection primarily
The9Cat c7bf5ee
Added an enum and reflector for deprojection disk types and included …
The9Cat 6efc024
Addded a test routine for Abel deprojection; updated EmpCylSL for der…
22adb60
Missing source driver file
b12a1f8
Missing test class
3cf4d6c
Potential fix for pull request finding
The9Cat a03bbe6
Potential fix for pull request finding
The9Cat 4042544
Potential fix for pull request finding
The9Cat db0e02d
Potential fix for pull request finding
The9Cat dfc99f9
Potential fix for pull request finding
The9Cat 2e6fee4
Potential fix for pull request finding
The9Cat 204d43d
Add a test routine from EmpDeproj alone; fix parsing error in testEmp…
0e82cb6
Updated parsing in BiorthBasis::Cylindrical for deprojection
The9Cat cb5e150
Potential fix for pull request finding
The9Cat 5f151bc
Potential fix for pull request finding
The9Cat b761050
Potential fix for pull request finding
The9Cat 25f893d
Potential fix for pull request finding
The9Cat f9a6ae2
Potential fix for pull request finding
The9Cat 5a66623
Potential fix for pull request finding
The9Cat 4175b1e
Potential fix for pull request finding
The9Cat 31dad72
Potential fix for pull request finding
The9Cat 9c2f36f
Potential fix for pull request finding
The9Cat 22b6493
Use new sech^2 scaling
84bef8f
Merge branch 'Toomre' of github.com:EXP-code/EXP into Toomre
9439daa
Python deprojection test routine; add possibility of a separate Pytho…
1d50ae5
Fix typo in parameter assignment
The9Cat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #ifndef CUBIC_SPLINE_H | ||
| #define CUBIC_SPLINE_H | ||
|
|
||
| #include <vector> | ||
|
|
||
| namespace Deproject | ||
| { | ||
|
|
||
| class CubicSpline { | ||
| public: | ||
| CubicSpline() = default; | ||
| CubicSpline(const std::vector<double>& x_in, const std::vector<double>& y_in); | ||
|
|
||
| // set data (x must be strictly increasing) | ||
| void set_data(const std::vector<double>& x_in, const std::vector<double>& y_in); | ||
|
|
||
| // evaluate spline and its derivative (xx should lie within [xmin(), xmax()], but endpoints are clamped) | ||
| double eval(double xx) const; | ||
| double deriv(double xx) const; | ||
|
|
||
| double xmin() const; | ||
| double xmax() const; | ||
|
|
||
| private: | ||
| std::vector<double> x_, y_, y2_; | ||
| int locate(double xx) const; | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| #endif // CUBIC_SPLINE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #include <stdexcept> | ||
|
|
||
| #include "CubicSpline.H" | ||
|
|
||
| namespace Deproject | ||
| { | ||
|
|
||
| CubicSpline::CubicSpline(const std::vector<double>& x_in, const std::vector<double>& y_in) { | ||
| set_data(x_in, y_in); | ||
| } | ||
|
|
||
| void CubicSpline::set_data(const std::vector<double>& x_in, const std::vector<double>& y_in) { | ||
| x_ = x_in; | ||
| y_ = y_in; | ||
| int n = (int)x_.size(); | ||
| if (n < 2 || (int)y_.size() != n) throw std::runtime_error("CubicSpline: need at least two points and equal-sized x,y."); | ||
|
|
||
| y2_.assign(n, 0.0); | ||
| std::vector<double> u(n - 1, 0.0); | ||
|
|
||
| // natural spline boundary conditions (second derivatives at endpoints = 0) | ||
| for (int i = 1; i < n - 1; ++i) { | ||
| double sig = (x_[i] - x_[i-1]) / (x_[i+1] - x_[i-1]); | ||
| double p = sig * y2_[i-1] + 2.0; | ||
| y2_[i] = (sig - 1.0) / p; | ||
| double dY1 = (y_[i+1] - y_[i]) / (x_[i+1] - x_[i]); | ||
| double dY0 = (y_[i] - y_[i-1]) / (x_[i] - x_[i-1]); | ||
| u[i] = (6.0 * (dY1 - dY0) / (x_[i+1] - x_[i-1]) - sig * u[i-1]) / p; | ||
| } | ||
|
|
||
| for (int k = n - 2; k >= 0; --k) y2_[k] = y2_[k] * y2_[k+1] + u[k]; | ||
| } | ||
|
|
||
| int CubicSpline::locate(double xx) const { | ||
| int n = (int)x_.size(); | ||
| if (xx <= x_.front()) return 0; | ||
| if (xx >= x_.back()) return n - 2; | ||
| int lo = 0, hi = n - 1; | ||
| while (hi - lo > 1) { | ||
| int mid = (lo + hi) >> 1; | ||
| if (x_[mid] > xx) hi = mid; else lo = mid; | ||
| } | ||
| return lo; | ||
| } | ||
|
|
||
| double CubicSpline::eval(double xx) const { | ||
| int klo = locate(xx); | ||
| int khi = klo + 1; | ||
| double h = x_[khi] - x_[klo]; | ||
| if (h <= 0.0) throw std::runtime_error("CubicSpline::eval: non-increasing x."); | ||
| double A = (x_[khi] - xx) / h; | ||
| double B = (xx - x_[klo]) / h; | ||
| double val = A * y_[klo] + B * y_[khi] | ||
| + ((A*A*A - A) * y2_[klo] + (B*B*B - B) * y2_[khi]) * (h*h) / 6.0; | ||
| return val; | ||
| } | ||
|
|
||
| double CubicSpline::deriv(double xx) const { | ||
| int klo = locate(xx); | ||
| int khi = klo + 1; | ||
| double h = x_[khi] - x_[klo]; | ||
| if (h <= 0.0) throw std::runtime_error("CubicSpline::deriv: non-increasing x."); | ||
| double A = (x_[khi] - xx) / h; | ||
| double B = (xx - x_[klo]) / h; | ||
| double dy = (y_[khi] - y_[klo]) / h | ||
| + ( - (3.0*A*A - 1.0) * y2_[klo] + (3.0*B*B - 1.0) * y2_[khi] ) * (h / 6.0); | ||
| return dy; | ||
| } | ||
|
|
||
| double CubicSpline::xmin() const { return x_.front(); } | ||
| double CubicSpline::xmax() const { return x_.back(); } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.