Skip to content
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

NonFixedTarget #63

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

NonFixedTarget #63

wants to merge 4 commits into from

Conversation

bmorris3
Copy link
Contributor

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.

@adrn
Copy link
Member

adrn commented Aug 25, 2015

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
Copy link
Member

adrn commented Aug 25, 2015

(Note: this should not be a 0.1 blocker)

@cdeil cdeil added this to the 0.2 release milestone Aug 25, 2015
@cdeil
Copy link
Member

cdeil commented Aug 28, 2015

@bmorris3 – Merge conflicts, please rebase.

@adrn
Copy link
Member

adrn commented May 2, 2018

@bsipocz
Copy link
Member

bsipocz commented May 3, 2018

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

@michaelbaisch michaelbaisch mentioned this pull request Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants