-
Notifications
You must be signed in to change notification settings - Fork 39
Splitting plot functions away from calculations/themis_observation.py #448
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
Open
lassejsc
wants to merge
7
commits into
fmihpc:master
Choose a base branch
from
lassejsc:themis_fix
base: master
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.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b20a9f5
Moving themis obs to plot
lassejsc 18acbc3
removed get_dv in favor of already defined get_velocity_mesh_dv
lassejsc 05f31f2
removed unsused imports from plot_themis_observation
lassejsc a950267
Init file setups for the themis plot and new virtual_observations in
lassejsc 0941fd2
Moved some functions from former themis_observations to
lassejsc 9fb8070
Fixed imports and function calls
lassejsc e00e466
Added output to file for the plots
lassejsc 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
|
|
||
| import numpy as np | ||
| def simulation_to_spacecraft_frame(spinvector, detector_axis, phi=0): | ||
| ''' Builds a matrix to transform coordinates from simulation frame into spaceraft frame | ||
| :param spinvector Spacecraft spin axis, in simulation coordinates | ||
| :param detector_axis Detector plane normal axis | ||
| :param phi Rotate spacecraft around spin axis after setting up coordinate system | ||
| ''' | ||
| # TODO: Normalize vectors? | ||
| y = np.cross(detector_axis,spinvector) | ||
| z = np.cross(spinvector, y) | ||
| yr = np.cos(phi)*y - np.sin(phi)*z | ||
| zr = np.sin(phi)*y + np.cos(phi)*z | ||
| m = np.array([spinvector, yr, zr]) | ||
|
|
||
| return m | ||
|
|
||
| def spacecraft_to_simulation_frame(spinvector, detector_axis, phi=0): | ||
| ''' Builds a matrix to transform coordinates from spaceraft frame back to simulation frame | ||
| :param spinvector Spacecraft spin axis, in simulation coordinates | ||
| :param detector_axis Detector plane normal axis | ||
| :param phi Rotate spacecraft around spin axis after setting up coordinate system | ||
| ''' | ||
| return simulation_to_spacecraft_frame(spinvector,detector_axis,phi).T | ||
|
|
||
| def simulation_to_observation_frame(x_axis,y_axis): | ||
| ''' Builds a 3x3 matrix to transform velocities into an observation plane | ||
| :param x_axis: x-axis of the observation plane (in simulation coordinates) | ||
| :param y_axis: y-axis of the observation plane (gets orthonormalized) | ||
| ''' | ||
| xn = np.linalg.norm(x_axis) | ||
| x_axis /= xn | ||
| p = x_axis.dot(y_axis) | ||
| y_axis -= p*x_axis | ||
| yn = np.linalg.norm(y_axis) | ||
| y_axis /= yn | ||
| z_axis = np.cross(x_axis,y_axis) | ||
| return np.array([x_axis,y_axis,z_axis]) | ||
|
|
||
|
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the change here, shading flat complained about the input shapes for this function and vmin,vmax complained about already being in the
norminput, this made it plot with least amount of effort.