How to use the ephem.degrees function in ephem

To help you get started, we’ve selected a few ephem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brandon-rhodes / pyephem / tests / test_usno.py View on Github external
def parse(fields, n):
            if len(fields) < n + 2:
                return None, None
            (timestr, anglestr) = fields[n:n+2]
            if timestr == '*****':
                return None, None
            h, m = [ int(s) for s in timestr.split(':') ]
            date = ephem.Date(midnight + h * ephem.hour + m * ephem.minute)
            angle = ephem.degrees(anglestr.strip('NS'))
            return date, angle
github brandon-rhodes / pyephem / tests / test_usno.py View on Github external
def standard_parse(line):
    """Read the date, RA, and dec from a USNO data file line."""

    fields = re.split(r'   +', line)
    dt = datetime(*strptime(fields[0][:-2], "%Y %b %d %H:%M:%S")[0:6])
    date = ephem.Date(dt)
    ra = ephem.hours(fields[1].replace(' ', ':'))
    sign, mag = fields[2].split(None, 1)
    dec = ephem.degrees(sign + mag.replace(' ', ':'))
    return date, ra, dec
github OSCAAR / OSCAAR / oscaar / extras / eph / calculateEphemerides.py View on Github external
def ingressEgressAltAz(planet,observatory,ingress,egress):
        altitudes = []
        directions = []
        for time in [ingress,egress]:
            observatory.date = list2datestr(jd2gd(time))
            star = ephem.FixedBody()
            star._ra = ephem.hours(RA(planet))
            star._dec = ephem.degrees(dec(planet))
            star.compute(observatory)
            altitudes.append(str(ephem.degrees(star.alt)).split(":")[0])
            directions.append(azToDirection(str(ephem.degrees(star.az)).split(":")[0]))
        ingressAlt,egressAlt = altitudes
        ingressDir,egressDir = directions
        return ingressAlt,ingressDir,egressAlt,egressDir
github akkana / scripts / conjunctions.py View on Github external
from __future__ import print_function

import ephem
import math

verbose = False

# How low can a planet be at sunset or midnight before it's not interesting?
# We'll half it for the moon.
min_alt = 10 * math.pi / 180.

# How close do two bodies have to be to consider it a conjunction?
max_sep = 3.5 * math.pi / 180.

# Half the moon's diameter, for checking occultations:
halfmoon = ephem.degrees('.25')

# How close does a bright planet need to be from the moon to be mentioned?
moon_sep = 25 * math.pi / 180.

# How little % illuminated do we need to consider an inner planet a crescent?
crescent_percent = 40

# Start and end times for seeing a crescent phase:
crescents = { "Mercury": [ None, None ], "Venus": [ None, None ] }

# What hour GMT corresponds to midnight here?
# Note: we're not smart about time zones. This will calculate
# a time based on the time zone offset right now, whether we're
# currently in DST or not.
# And for now we don't even calculate it, just hardwire it.
timezone = 7
github trehn / termtrack / termtrack / planets.py View on Github external
def latlon_for_planet(planet_name, date):
    planet = PLANETS[planet_name]
    obs = ephem.Observer()
    obs.date = date
    obs.lat = 0
    obs.lon = 0
    planet.compute(date)
    return degrees(planet.dec), degrees(ephem.degrees(planet.ra - obs.sidereal_time()).znorm)
github cesium-ml / cesium / mltsp / TCP / Algorithms / fitcurve / observatory_source_interface_LGC.py View on Github external
def request_noisified():
        my_obs = observatory_PTF.PTF
        # make up an object:
        vega = my_obs.create_target(ephem.hours('18:36:56.20'), ephem.degrees('38:46:59.0'), "cepheid") # coordinates of vega
        for i in range(10):
            mindiff_multiplier = i - 5
            if mindiff_multiplier < 1: 
                mindiff_multiplier = 1
            t = generic_observatory.time_series_generator()
            time_series = t.generate_time_series(vega, my_obs)
            print("mindiff_multiplier should be: ", mindiff_multiplier)
            try:
                output = my_obs.observe(target=vega, times = time_series, band = "V")
            except AssertionError as description:
                print("Failed %s times so far, because of %s" % ((i+1), description))
            else:
                return output
    return request_noisified()
github Rolf-Hempel / MoonPanoramaMaker / Source / moon_ephem.py View on Github external
print('Time (UT): ', me.location_time.date)
        print('Moon RA: %s, DE: %s, Diameter: %s' % (me.ra, me.de, ephem.degrees(me.diameter)))
        print('Astrometric libration in Latitude: ', me.astrometric_lib_lat, ", in longitude: ",
              me.astrometric_lib_long)
        print("Topocentric libration in latitude: ", degrees(me.topocentric_lib_lat),
              ", in longitude: ", degrees(me.topocentric_lib_long))
        print("Position angle of North Pole: ", degrees(me.pos_rot_north))
        print('Selenographic Co-Longitude: ', me.colong)
        print('Sunlit geographic longitudes between ', degrees(-me.colong), " and ",
              degrees(-me.colong) + 180.)
        # print 'Sun RA: %s, DE: %s' % (me.sun_ra, me.sun_de)
        print('Elongation: %s' % (ephem.degrees(me.elongation)))
        print('Phase angle: %s' % (ephem.degrees(me.phase_angle)))
        print('Sun direction: %s' % (ephem.degrees(me.pos_angle_sun)))
        print(
            ('Pos. angle pole (bright limb to the right): %s' % (ephem.degrees(me.pos_angle_pole))))

        length = 10
        ra_start = me.ra
        de_start = me.de
        end_time = date_time + datetime.timedelta(seconds=length)
        me.update(end_time)
        ra_end = me.ra
        de_end = me.de
        rate_ra = degrees((ra_end - ra_start) / length * 3600.) * 60.
        rate_de = degrees((de_end - de_start) / length * 3600.) * 60.  #
        print("rate_ra: ", rate_ra, ", rate_de: ", rate_de)
        print("")
github akkana / scripts / conjunctions.py View on Github external
def closeout(self, observer):
        """Time to figure out what we have and print it."""

        if verbose:
            print("closeout", self.start_date(), "-", self.end_date())
            print("  bodies", self.bodies)
            print("  pairs", self.pairs)

        # Find the list of minimum separations between each pair.
        startdate = ephem.date('3000/1/1')
        enddate = ephem.date('0001/1/1')
        minseps = []
        moonclose = ephem.degrees('1')
        for i, b1 in enumerate(self.bodies):
            for b2 in self.bodies[i+1:]:
                minsep = 360  # degrees
                closest_date = None
                for pair in self.pairs:
                    if pair.date < startdate:
                        startdate = pair.date
                    if pair.date > enddate:
                        enddate = pair.date
                    if b1 in pair and b2 in pair:
                        if pair.sep < minsep:
                            minsep = pair.sep
                            closest_date = pair.date

                # Not all pairs will be represented. In a triple conjunction,
                # the two outer bodies may never get close enough to register