Last active
December 27, 2015 21:18
-
-
Save adrn/7390285 to your computer and use it in GitHub Desktop.
sketching out some thoughts on representing coordinates in Python
This file contains 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
position = np.array([15, 18.5, -0.7]) * u.kpc | |
c = Cartesian(position, frame=None) | |
c.transform_system(Spherical) | |
c.transform_frame(Heliocentric) # raises error - no input frame specified | |
# the system/representation classes -- e.g. Cartesian, Spherical, | |
# Cylindrical, Bispherical, etc. -- accept any Quantity object | |
velocity = np.array([10.4, 57.134, -81.124]) * u.km/u.s | |
v = Cartesian(velocity, frame=None) | |
v.transform_system(Cylindrical) | |
v = Cartesian(velocity, frame=GSR) | |
c.transform_frame(Heliocentric) | |
c.transform_system(Spherical) | |
# the more high level API would have the system/representation and | |
# frame set automatically, e.g. for ICRS | |
c = ICRS('5:10:20.52 +23:23:23.5', units=(u.hourangle, u.degree)) | |
print(c.frame) # <ICRSFrame ...> | |
print(c.system) # <Spherical ...> | |
# the kind of thing I have been dealing a lot with is dealing with | |
# simulated observations of simulation data, so somethings like | |
# this would be very nice: | |
# read in table of particle data, always in ASCII b.c. we're masochists | |
tbl = ascii.read("nbody_output.txt") | |
# this works because Table Columns will know about units, right? | |
pos = Cartesian(tbl["x","y","z"], frame=GSR) | |
vel = Cartesian(tbl["vx","vy","vz"], frame=GSR) | |
# now I need to "observe" these particles from heliocentric frame, | |
# presumably as Spherical coordinates | |
# this goes GSR to LSR, then LSR to Heliocentric. One gotcha is how do we | |
# let the user specify what circular velocity and peculiar velocity to use? | |
pos.transform_frame(Heliocentric) | |
heliocentric_pos = pos.spherical # same as pos.transform_system(Spherical)? | |
vel.transform_frame(Heliocentric) | |
heliocentric_vel = vel.spherical | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment