def test_fraction_illuminated():
    ts = api.load.timescale()
    t0 = ts.utc(2018, 9, range(9, 19), 5)
    e = api.load('de421.bsp')
    i = almanac.fraction_illuminated(e, 'moon', t0[-1]).round(2)
    assert i == 0.62
    i = almanac.fraction_illuminated(e, 'moon', t0).round(2)
    assert (i == (0, 0, 0.03, 0.08, 0.15, 0.24, 0.33, 0.43, 0.52, 0.62)).all()
def test_fraction_illuminated():
    ts = api.load.timescale()
    t0 = ts.utc(2018, 9, range(9, 19), 5)
    e = api.load('de421.bsp')
    i = almanac.fraction_illuminated(e, 'moon', t0[-1]).round(2)
    assert i == 0.62
    i = almanac.fraction_illuminated(e, 'moon', t0).round(2)
    assert (i == (0, 0, 0.03, 0.08, 0.15, 0.24, 0.33, 0.43, 0.52, 0.62)).all()
Example #3
0
def moon_phase():
    lookup_table = [
        "NM",
        "FQ",
        "FM",
        "LQ",
    ]
    end = datetime.today().astimezone().replace(hour=23,
                                                minute=59,
                                                second=0,
                                                microsecond=0)
    t0 = ts.utc(end)

    mp = almanac.moon_phases(ephem)(t0)
    mp = lookup_table[mp]

    mf = almanac.fraction_illuminated(ephem, 'moon', t0)
    mf = math.ceil(mf * 100)

    return f"{mp}{mf:02}"
Example #4
0
def info(target, observer, pos_only=False, t=None):
    if t is None: t = now()
    name = name_from_body(target)
    astrometric = observer.at(t).observe(target)
    apparent = astrometric.apparent()
    const = pos_to_constellation(apparent)
    alt, azm, dist = apparent.altaz('standard')
    alt = round(alt.degrees, ROUNDING)
    azm = round(azm.degrees, ROUNDING)
    dist = round(dist.km * 0.6213712, ROUNDING)
    if target in [moon, mercury, venus, mars]:
        illum = almanac.fraction_illuminated(planets, name, t)
        if math.isnan(illum):
            illum = 1.0
        illum *= 100.0
    else:
        illum = None
    if pos_only:
        return name, alt, azm, dist, illum

    if target == moon or target == sun:
        rad = 0.5
    else:
        rad = 0.0

    ta, ya = almanac.find_discrete(
        day_start(t, observer), day_end(t, observer),
        risings_and_settings(planets, target, observer, radius=rad))
    culm_time, culm_alt = culmination(target, observer, t)
    rise_time = set_time = None
    for yi, ti in zip(ya, ta):
        if yi:
            rise_time = ti
        else:
            set_time = ti
    rise_time = None if rise_time is None else time_to_local_datetime(
        rise_time, observer)
    set_time = None if set_time is None else time_to_local_datetime(
        set_time, observer)
    return name, alt, azm, dist, rise_time, culm_time, set_time, culm_alt, illum, const
Example #5
0
                    if executeMove:
                        retVal = RCmoveToPosition(args.rotor,
                                                  int(args.rotortype),
                                                  int(args.rotorbaud), azimuth,
                                                  elevation)
                    else:
                        print(
                            '[Info] Rotor would violate user-configured limits.  No move sent.'
                        )

            print("\nAziumuth:\t%.2f degrees" % azimuth)
            print("Elevation:\t%.2f degrees" % elevation)
            print("Distance:\t%.2f miles  / %.2f km" %
                  (distance, (distance_meters / 1000.0)))
            print("Percent illumination:\t%.2f%%" %
                  (almanac.fraction_illuminated(planets, planetaryBody, t) *
                   100.0))
            print("Relative Velocity:\t%.2f m/s [- is towards, + is away]" %
                  (relativeVelocity, ))
            if args.freq != 0:
                print("\nFrequency: %.2f Hz" % float(args.freq))
                dopplerFreq = doppler_shift(float(args.freq), relativeVelocity)
                dopplerShift = dopplerFreq - float(args.freq)
                print("Doppler Shift: %.2f Hz" % dopplerShift)
                print("Doppler Frequency: %.2f Hz" % dopplerFreq)

            local_tz = get_localzone()
            # Get now in local time
            timeCheck = datetime.now(local_tz)
            # Get hour zero and end of day in local time
            startTime = newtime = timeCheck - timedelta(
Example #6
0
    def updateMoonPhase(self):
        """

        :return: true for test purpose
        """
        phasesText = {
            'New moon': {
                'range': (0, 1),
                'pic': ':/moon/new.png',
            },
            'Waxing crescent': {
                'range': (1, 23),
                'pic': ':/moon/waxing_crescent.png',
            },
            'First Quarter': {
                'range': (23, 27),
                'pic': ':/moon/first_quarter.png',
            },
            'Waxing Gibbous': {
                'range': (27, 48),
                'pic': ':/moon/waxing_gibbous.png',
            },
            'Full moon': {
                'range': (48, 52),
                'pic': ':/moon/full.png',
            },
            'Waning Gibbous': {
                'range': (52, 73),
                'pic': ':/moon/waning_gibbous.png',
            },
            'Third quarter': {
                'range': (73, 77),
                'pic': ':/moon/third_quarter.png',
            },
            'Waning crescent': {
                'range': (77, 99),
                'pic': ':/moon/waning_crescent.png',
            },
            'New moon ': {
                'range': (99, 100),
                'pic': ':/moon/new.png',
            },
        }

        # todo: is the calculation of the moon phase better separate ?
        sun = self.app.planets['sun']
        moon = self.app.planets['moon']
        earth = self.app.planets['earth']

        e = earth.at(self.app.mount.obsSite.timeJD)
        _, sunLon, _ = e.observe(sun).apparent().ecliptic_latlon()
        _, moonLon, _ = e.observe(moon).apparent().ecliptic_latlon()

        now = self.app.mount.obsSite.ts.now()
        moonPhaseIllumination = almanac.fraction_illuminated(
            self.app.planets, 'moon', now)
        moonPhaseDegree = (moonLon.degrees - sunLon.degrees) % 360.0
        moonPhasePercent = moonPhaseDegree / 360

        self.ui.moonPhaseIllumination.setText(
            f'{moonPhaseIllumination * 100:3.2f}')
        self.ui.moonPhasePercent.setText(f'{100* moonPhasePercent:3.0f}')
        self.ui.moonPhaseDegree.setText(f'{moonPhaseDegree:3.0f}')

        for phase in phasesText:
            if int(moonPhasePercent *
                   100) not in range(*phasesText[phase]['range']):
                continue
            self.ui.moonPhaseText.setText(phase)
            pixmap = PyQt5.QtGui.QPixmap(phasesText[phase]['pic']).scaled(
                60, 60)
            self.ui.moonPic.setPixmap(pixmap)
        """
        # forecast 48 hours
        ts = self.app.mount.obsSite.ts
        t0 = ts.utc(2019, 12, 1, 5)
        t1 = ts.utc(2019, 12, 31, 5)
        e = self.app.planets
        loc = self.app.mount.obsSite.location
        t, y = almanac.find_discrete(t0, t1, almanac.dark_twilight_day(e, loc))
        for ti, yi in zip(t, y):
            print(yi, ti.utc_iso())
        """

        return True
 def get_lunar_fraction_illuminated(self, dt):
     t = self._get_skyfield_time(dt)
     return almanac.fraction_illuminated(self._ephemeris, 'moon', t)
Example #8
0
def Lunar_Illumination(e, t):
    fi = almanac.fraction_illuminated(e, 'Moon', t)
    return fi
Example #9
0
                    if args.rotorelevationlimit != -1:
                        if elevation > float(args.rotorelevationlimit):
                            executeMove = False
                            
                    if executeMove:
                        retVal = RCmoveToPosition(args.rotor, int(args.rotortype),  int(args.rotorbaud),  trueAz,  elevation)
                    else:
                        print('[Info] Rotor would violate user-configured limits.  No move sent.')
                
            print("\nGeo Aziumuth:\t%.2f degrees" % azimuth)
            if azoffset != 0.0:
                print("Mag Aziumuth:\t%.2f degrees" % trueAz)
                
            print("Elevation:\t%.2f degrees" % elevation)
            print("Distance:\t%.2f miles  / %.2f km" % (distance, (distance_meters/1000.0)))
            print("Percent illumination:\t%.2f%%" % (almanac.fraction_illuminated(planets,planetaryBody,t)*100.0))
            print("Relative Velocity:\t%.2f m/s [- is towards, + is away]" % (relativeVelocity,))
            if args.freq != 0:
                print("\nFrequency: %.2f Hz" % float(args.freq))
                dopplerFreq = doppler_shift(float(args.freq),relativeVelocity)
                dopplerShift = dopplerFreq - float(args.freq)
                print("Doppler Shift: %.2f Hz" % dopplerShift)
                print("Doppler Frequency: %.2f Hz" % dopplerFreq)

            local_tz = get_localzone()
            # Get now in local time
            timeCheck = datetime.now(local_tz)
            # Get hour zero and end of day in local time
            startTime = newtime=timeCheck - timedelta(hours=timeCheck.hour) - timedelta(minutes=timeCheck.minute) - timedelta(seconds=timeCheck.second)
            endTime = newtime=startTime + timedelta(hours=23) +  timedelta(minutes=59) + timedelta(seconds=59)
            # convert to UTC
Example #10
0
File: eise.py Project: wisze/eise
        f = almanac.risings_and_settings(ephem, ephem[planets[p]], amsterdam)
        t, y = almanac.find_discrete(t0, t1, f)
        for ti, yi in zip(t, y):
            trise = ti.utc_datetime().astimezone(cet).time()
            if yi:
                opkomst = trise.strftime('%H:%M')
                print('  Opkomst om ' + opkomst)
                drawred.text((2, irise * 14),
                             symbols[p],
                             font=cmastro12,
                             fill=0)
                drawred.text((16, irise * 14), opkomst, font=font12, fill=0)
                irise = irise + 1

maanverlicht = int(100 *
                   (almanac.fraction_illuminated(ephem, 'Moon', t0) + 0.05))
venusverlicht = int(100 *
                    (almanac.fraction_illuminated(ephem, 'Venus', t0) + 0.05))
print('Maan ' + str(maanverlicht) + '% verlicht')
print('Venus ' + str(venusverlicht) + '% verlicht')
drawred.text((epd.height - 36, 14), symbols['Maan'], font=cmastro12, fill=0)
drawred.text((epd.height - 36, 28), symbols['Venus'], font=cmastro12, fill=0)
drawred.text((epd.height - 24, 14),
             str(maanverlicht) + '%',
             font=font12,
             fill=0)
drawred.text((epd.height - 24, 28),
             str(venusverlicht) + '%',
             font=font12,
             fill=0)