Repository navigation
Description
I created a stackoverflow question for this here.
I have event tuples of (azimuth, altitude, time) in horizontal coordinates, which I store as 2 numpy arrays azimuth and altitude, and a list(datetime). I also have an EarthLocation where these events are observed. The number of events is on the order of 100k.
Now I'd like to transform these to galactic coordinates. I tried
my_loc = EarthLocation.from_geodetic(...)
my_frame = AltAz(my_loc, obstime=times)
evt = SkyCoord(
alt=my_altitude*rad,
az=my_azimuth*rad,
frame=my_frame,
)
evt_gal = evt.galactic
But each of these events apparently use the same observation time. (Judging from plots where all events are suspiciously neatly sitting on a curve).
Looking at a single event, it seems that each event has multiple observation times associated to it, which is not quite what I want.
e = evt[1]
print(e.frame)
<AltAz Coordinate (obstime=[datetime.datetime(2015, 5, 17, 16, 58, 17)
datetime.datetime(2015, 12, 14, 0, 15, 26)
datetime.datetime(2015, 9, 25, 4, 16) ...,
datetime.datetime(2015, 9, 27, 6, 5, 9)
datetime.datetime(2015, 2, 5, 1, 31, 8)
datetime.datetime(2015, 12, 21, 13, 15, 49)], location=...>
Supplying the obstimes directly to SkyCoord yields identical results.
evt = SkyCoord(
alt=df_cscd['altitude_cscd'] * rad,
az=df_cscd['azimuth_random'] * rad,
location=my_earth_loc,
obstime=my_times,)
The next idea was to not pass the observation times to the frame, but to the SkyCoord:
frame_without_time = AltAz(location=my_location)
evt = SkyCoord(
alt=df_cscd['altitude_cscd'] * rad,
az=df_cscd['azimuth_random'] * rad,
frame=frame_without_time,
obstime=my_times,
)
But this raises a
ValueError: cannot specify frame attribute 'obstime' directly in SkyCoord since a frame instance was passed in
It works perfectly fine if I have just a single time, e.g. astropy.time.Time.now(). But looping over 100k events and creating a SkyCoord instance for each of them is incredibly slow, obviously.
I don't have a pull request for this, since I wonder if there is a built-in better way to do this?
What do you think?
Activity
mhvk commentedon Sep 28, 2016
I fear this may need #5254...
astrofrog commentedon Oct 31, 2016
@mhvk - just to be clear, since #5254 is merged, do you mean this should work with the latest developer version?
mhvk commentedon Oct 31, 2016
I think it should work, but haven't really tried multi-d explicitly. @moritz-lotze - would you be able to try? Or alternatively give an explicit example that currently does not work, so we can check? (i.e., something we can just copy and paste)
mhvk commentedon Nov 1, 2016
@moritz-lotze - great to hear that it works! Do raise other issues as you find them, or send PRs with possible improvements -- this is how astropy gets better!