Call JPL HORIZONS website to obtain orbital elements based on the
        provided targetname, epochs, and center code and create a
        PyEphem (http://rhodesmill.org/pyephem/) object. This function
        requires PyEphem to be installed.

        :param center: str;
           center body (default: 500@10 = Sun)
        :param equinox: float;
           equinox (default: 2000.0)
        :result: list;
           list of PyEphem objects, one per epoch
        :example: >>> import callhorizons
                  >>> import numpy
                  >>> import ephem
                  >>>
                  >>> ceres = callhorizons.query('Ceres')
                  >>> ceres.set_epochrange('2016-02-23 00:00', '2016-02-24 00:00', '1h')
                  >>> ceres_pyephem = ceres.export2pyephem()
                  >>>
                  >>> nau = ephem.Observer() # setup observer site
                  >>> nau.lon = -111.653152/180.*numpy.pi
                  >>> nau.lat = 35.184108/180.*numpy.pi
                  >>> nau.elevation = 2100 # m
                  >>> nau.date = '2015/10/5 01:23' # UT
                  >>> print ('next rising: %s' % nau.next_rising(ceres_pyephem[0]))
                  >>> print ('next transit: %s' % nau.next_transit(ceres_pyephem[0]))
                  >>> print ('next setting: %s' % nau.next_setting(ceres_pyephem[0]))

def export2pyephem(self, center='500@10', equinox=2000.):
        """Call JPL HORIZONS website to obtain orbital elements based on the
        provided targetname, epochs, and center code and create a
        PyEphem (http://rhodesmill.org/pyephem/) object. This function
        requires PyEphem to be installed.

        :param center: str;
           center body (default: 500@10 = Sun)
        :param equinox: float;
           equinox (default: 2000.0)
        :result: list;
           list of PyEphem objects, one per epoch
        :example: >>> import callhorizons
                  >>> import numpy
                  >>> import ephem
                  >>>
                  >>> ceres = callhorizons.query('Ceres')
                  >>> ceres.set_epochrange('2016-02-23 00:00', '2016-02-24 00:00', '1h')
                  >>> ceres_pyephem = ceres.export2pyephem()
                  >>>
                  >>> nau = ephem.Observer() # setup observer site
                  >>> nau.lon = -111.653152/180.*numpy.pi
                  >>> nau.lat = 35.184108/180.*numpy.pi
                  >>> nau.elevation = 2100 # m
                  >>> nau.date = '2015/10/5 01:23' # UT
                  >>> print ('next rising: %s' % nau.next_rising(ceres_pyephem[0]))
                  >>> print ('next transit: %s' % nau.next_transit(ceres_pyephem[0]))
                  >>> print ('next setting: %s' % nau.next_setting(ceres_pyephem[0]))
        """

        try:
            import ephem
        except ImportError:
            raise ImportError(
                'export2pyephem requires PyEphem to be installed')

        # obtain orbital elements
        self.get_elements(center)

        objects = []
        for el in self.data:
            n = 0.9856076686/np.sqrt(el['a']**3)  # mean daily motion
            epoch_djd = el['datetime_jd']-2415020.0  # Dublin Julian date
            epoch = ephem.date(epoch_djd)
            epoch_str = "%d/%f/%d" % (epoch.triple()[1], epoch.triple()[2],
                                      epoch.triple()[0])

            # export to PyEphem
            objects.append(ephem.readdb("%s,e,%f,%f,%f,%f,%f,%f,%f,%s,%i,%f,%f" %
                                        (el['targetname'], el['incl'], el['node'],
                                         el['argper'], el['a'], n, el['e'],
                                            el['meananomaly'], epoch_str, equinox,
                                            el['H'], el['G'])))

        return objects