4

Is there a way to use PyEphem to calculate rise/set values for a list of targets? I have an astropy.tableof coordinates (in RA & Dec) for my targets and I would like to use PyEphem (or another package) to produce a further two columns with Rise & Set times for each object in the observers reference frame.

I know PyEphem has a catalog of pre-installed objects such as bright stars and planets but what I want to do is utilise its location.next_setting(ephem.Object()) and location.next_rising(ephem.Object()) functions to calculate when my list of targets will be observable, not just the bright stars and planets.

I know there are alternatives to PyEphem out there, so far I have tried to install Astroplan without success (not sure if this is stable yet), and I have looked into Skyfield but I dont see any extra capabilities on top of PyEphem just yet.

This is similar to how my table looks now, with the last two columns added on as an example of how I want it to become.

RA              Dec             Apparent Magnitude  Rise Time   Set Time
deg             deg 
float64         float64         float64
0.0             90.0            20.1080708665       06:04:34    22:43:17
18.9473684211   80.5263157895   22.7223534546       06:25:01    22:21:56
37.8947368421   71.0526315789   19.4416167208
56.8421052632   61.5789473684   20.7207435685
75.7894736842   52.1052631579   19.9318711443
94.7368421053   42.6315789474   23.8544483535
113.684210526   33.1578947368   15.8981196334
132.631578947   23.6842105263   24.2866475431
151.578947368   14.2105263158   15.9503148326
170.526315789   4.73684210526   16.5505303858
189.473684211   -4.73684210526  24.194771397
Dean
  • 259
  • 3
  • 10

1 Answers1

4

You did mention that you might also be interested in alternatives to PyEphem so I'll give you a way to do it with astroplan:

The only obstacle here is that You have to setup your coordinates differently because astroplan can handle a list of SkyCoords but not a SkyCoord containing an array ...

# What to look at
coordinates = SkyCoord(ra=np.linspace(0, 360, 20) *u.degree,
                       dec=np.linspace(-60, 60, 20) *u.degree)
# Replace these by you table-columns, e.g. ra=table['RA']

# Where is it observed
observer_location = Observer.at_site('lapalma') # Just as example

# When to observe
time = Time(['2016-03-18 01:00:00']) # Today ... there probably is even a convenience for this

# The ugly part... with the list comprehension
coordinates2 = [i for i in coordinates]
# Calculate the time of rise/set
rise = observer_location.target_rise_time(time, coordinates2, which='next')
set = observer_location.target_set_time(time, coordinates2, which='next')

and looking at the times it seems somehow reasonably even though the last step printed multiple WARNINGS about the limited precision...

print(rise.iso)
array(['2016-03-18 12:11:40.396', '2016-03-18 11:54:31.989',
       '2016-03-18 12:23:42.034', '2016-03-18 13:07:22.969',
       '2016-03-18 13:58:27.418', '2016-03-18 14:53:52.965',
       '2016-03-18 15:52:03.338', '2016-03-18 16:51:58.965',
       '2016-03-18 17:52:59.172', '2016-03-18 18:54:34.040',
       '2016-03-18 19:56:18.074', '2016-03-18 20:57:47.969',
       '2016-03-18 21:58:38.462', '2016-03-18 22:58:20.275',
       '2016-03-18 23:56:14.195', '2016-03-19 00:51:22.408',
       '2016-03-18 01:46:02.343', '2016-03-18 02:29:20.391',
       '2016-03-18 02:57:54.607', '2016-03-18 02:37:40.890'], 
      dtype='<U23')

The rest will probably be just a matter of setting up the coordinates/time/site and inserting two new columns to your table.

MSeifert
  • 145,886
  • 38
  • 333
  • 352
  • Okay thanks for that, I had trouble installing Astroplan yesterday when I tried it, both using pip and git clone methods. I was kind of hoping there would be a solution in PyEphem as Astroplan isn't stable yet but I can always try installing it again and try your method if it works. – Dean Mar 18 '16 at 14:44