astroplan icon indicating copy to clipboard operation
astroplan copied to clipboard

NonFixedTarget

Open bmorris3 opened this issue 9 years ago • 5 comments

Here take a first crack at the NonFixedTarget object.

My goal was to forge ahead towards a NonFixedTarget framework that is flexible enough to easily build on top of. This NonFixedTarget is a wrapper around some arbitrary function supplied by the user that returns SkyCoords for the target at various times (and/or locations, pressures, temperatures, etc.). The various incarnations of a particular NonFixedTarget, at different times for instance, are accessed with the at method, like so:

>>> from astroplan import NonFixedTarget
>>> from astropy.coordinates import get_sun   # This function actually does the hard work
>>> from astropy.time import Time
>>> sun = NonFixedTarget.from_function(coord_function=get_sun, name="Sun")
>>> time = Time(["1974-04-25 06:52:37", "1974-05-25 06:52:37"])
>>> print(sun.at(time))   # Supply `time` as an argument to self.coord_function to get a `SkyCoord`
<SkyCoord (GCRS: obstime=['1974-04-25 06:52:37.000' '1974-05-25 06:52:37.000'], obsgeoloc=[ 0.  0.  0.] m, obsgeovel=[ 0.  0.  0.] m / s):52:37.000' '1974-05-25 06:52:37.000'], obsgeoloc=[ 0.  0.  0.] m, obsgeovel=[ 0.  0.  0.] m / s): (ra, dec, distance) in (deg, deg, AU)
    [(33.7205577, 13.53508027, 1.00607328),
     (63.08763056, 21.13956465, 1.01292209)]>

The flexibility of the at method is clearer for our get_moon method, which requires a location and pressure,

>>> moon = NonFixedTarget.from_function(get_moon, name="Moon")
>>> print(moon.at(time, get_site("APO"), 0*u.bar))

or alternatively, if the site and pressure always remain the same and only the time changes, that can be specified in the constant_kwargs keyword argument and the at method can be called with only a time.

>>> moon = NonFixedTarget.from_function(get_moon, name="Moon", 
                     constant_kwargs=dict(location=get_site("APO"), pressure=0*u.bar))
>>> print(moon.at(time))

(right now, this won't actually work for my current implementation of get_moon, but this is the idea).

My primary motivation for starting the branch is for solar system objects, which I'm currently implementing with NonFixedTargets in a different branch, to operate like this:

>>> from astroplan.solar_system import mercury
>>> m = mercury()
>>> print(m.at(time))
<SkyCoord (GCRS: obstime=['1974-04-25 06:52:37.000' '1974-05-25 06:52:37.000'], obsgeoloc=[ 0.  0.  0.] m, obsgeovel=[ 0.  0.  0.] m / s):52:37.000' '1974-05-25 06:52:37.000'], obsgeoloc=[ 0.  0.  0.] m, obsgeovel=[ 0.  0.  0.] m / s): (ra, dec, distance) in (deg, deg, km)
    [(23.41942467, 8.08570339, 194652143.95096359),
     (83.97920488, 25.59930064, 152922527.81298986)]>

Tell me why this is a bad idea – I'm sure there are reasons.

bmorris3 avatar Aug 18 '15 07:08 bmorris3

This looks cool but I don't have a strong opinion on the best way to do this -- I'll need to think on it a bit...

adrn avatar Aug 25 '15 18:08 adrn

(Note: this should not be a 0.1 blocker)

adrn avatar Aug 25 '15 18:08 adrn

@bmorris3 – Merge conflicts, please rebase.

cdeil avatar Aug 28 '15 08:08 cdeil

Possibly relevant: http://docs.astropy.org/en/latest/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.apply_space_motion

adrn avatar May 02 '18 18:05 adrn

@bmorris3 - the milestones need a little bit of cleanup ;)

bsipocz avatar May 03 '18 01:05 bsipocz