Example #1
0
    def _doBodyEphem(self, mess, args, unic_symb, body, with_constell_mag=True, rising_first=True):
        """ Return next rise/setting for specified body.
        """
        body.compute()

        jid, loc, dt = self._parseJidLocTime(mess, args)
        next_rising, next_setting, riset = self._getNextRiseSetting(jid, body, dt=dt, loc=loc, horizon='0.0')

        if riset == SkybberBot.RISET_OK:
            if rising_first:
                result = unic_symb + ' ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(next_rising) + '  ' + SkybberBot.UNICODE_SET + utils.formatLocalTime(next_setting)
            else:
                result = unic_symb + ' ' + SkybberBot.UNICODE_SET + utils.formatLocalTime(next_setting) + '  ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(next_rising)
        else:
            result = self._fmtRiSetFailMsg(body, riset)
        if with_constell_mag:
            result += '  ' + str(body.mag) + 'm'
            result += '  [ ' +  ephem.constellation(body)[1] + ' ]'
        return result
Example #2
0
    def _doInnerBodyEphem(self, mess, args, unic_symb, body, with_constell_mag=True):
        body.compute()

        elong = math.degrees(body.elong)

        jid, loc, dt = self._parseJidLocTime(mess, args)
        next_rising, next_setting, riset = self._getNextRiseSetting(jid, body, dt=dt, loc=loc, horizon='0.0')

        if riset == SkybberBot.RISET_OK:
            if elong > 0.0:
                result = unic_symb + ' ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(next_setting)
            else:
                result = unic_symb + ' ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(next_rising)
        else:
            result = self._fmtRiSetFailMsg(body, riset)

        result += '  Elong ' + ("%0.2f" % elong)

        if with_constell_mag:
            result += '  ' + str(body.mag) + 'm'
            result += '  [ ' +  ephem.constellation(body)[1] + ' ]'
        return result
Example #3
0
    def tw(self, mess, args):
        """tw [date] [location]  - show begin/end of current twilight
        """
        jid, loc, dt = self._parseJidLocTime(mess, args)

        # Set noon of if date is set
        if dt != None:
            dt = self._getNoonDateTimeFrom6To6ByDate(dt)

        next_rising, next_setting, riset = self._getNextRiseSetting(jid, ephem.Sun(), dt=dt, loc=loc, horizon='-18.0')

        if riset == SkybberBot.RISET_OK:
            reply = SkybberBot.UNICODE_SET + utils.formatLocalTime(next_setting) + '  -  ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(next_rising)
        elif riset == SkybberBot.NEVER_SETTING:
            reply = SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT
        else:
            reply = SkybberBot.MSG_FULL_ASTRONOMICAL_NIGHT
        return reply
Example #4
0
 def format(self):
     result = utils.magMeter(self.mag, -8.0, 0.0, 1.0) + '   ' + utils.formatLocalTime(self.tm) + '  ' + \
         utils.formatSign(self.mag) + 'm  [ ' + utils.formatSign(self.alt) + ' / ' + utils.formatSign(self.az) + ' ]\n'
     return result
Example #5
0
    def night(self, mess, args):
        """night [date] [location] - show the real night, taking into consideration the Moon rising/setting
        """
        jid, loc, dt = self._parseJidLocTime(mess, args)

        # Set noon of if date is set
        if dt != None:
            dt = self._getNoonDateTimeFrom6To6ByDate(dt)

        next_sun_rising, next_sun_setting, riset_sun = self._getNextRiseSetting(jid, ephem.Sun(), dt=dt, loc=loc, horizon='-18.0')
        next_moon_rising, next_moon_setting, riset_moon = self._getNextRiseSetting(jid, ephem.Moon(), dt=dt, loc=loc)

        if riset_sun == SkybberBot.NEVER_SETTING:
            return SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT

        full_night = False

        if riset_sun == SkybberBot.NEVER_SETTING:
            # TODO :
            # tw_start = start day time
            # tw_end = end day time
            full_night = True
            pass
        else:
            tw_start = next_sun_setting
            tw_end = next_sun_rising

        tw_middle_end = None
        tw_middle_start = None

        if riset_moon == SkybberBot.RISET_OK:
            if next_moon_rising < next_moon_setting:
                if next_moon_rising < next_sun_setting:
                    if next_moon_setting > next_sun_setting:
                        if next_moon_setting < next_sun_rising:
                            tw_start = next_moon_setting # MR - SS - MS - SR
                        else:
                            return SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT # MR - SS - SR - MS
                    else:
                        pass  # MR - MS - SS - SR
                else:
                    if next_moon_rising < next_sun_rising:
                        if next_moon_setting < next_sun_rising:
                            # SS - MR - MS - SR
                            tw_middle_end = next_moon_rising
                            tw_middle_start = next_moon_rising
                        else:
                            tw_end = next_moon_rising # SS - MR - SR - MS
                    else:
                        pass  # SS - SR - MR - MS
            else:
                if next_moon_setting < next_sun_setting:
                    if next_moon_rising > next_sun_setting:
                        if next_moon_rising < next_sun_rising:
                            tw_end = next_moon_rising # MS - SS - MR - SR
                        else:
                            pass # MS - SS - SR - MR
                    else:
                        return SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT # MS - MR - SS - SR
                else:
                    if next_moon_setting < next_sun_rising:
                        if next_moon_rising < next_sun_rising:
                            # SS - MS - MR - SR
                            tw_start = next_moon_setting
                            tw_end = next_moon_rising
                        else:
                            tw_start = next_moon_setting # SS - MS - SR - MR
                    else:
                        return SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT # SS - SR - MS - MR
        else:
            if riset_moon == SkybberBot.NEVER_SETTING:
                return SkybberBot.MSG_NO_ASTRONOMICAL_NIGHT
            elif full_night:
                return SkybberBot.MSG_FULL_ASTRONOMICAL_NIGHT

        if tw_middle_start is None:
            reply = SkybberBot.UNICODE_SET + utils.formatLocalTime(tw_start) + '  -  ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(tw_end)
        else:
            reply = SkybberBot.UNICODE_SET + utils.formatLocalTime(tw_start) + '  -  ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(tw_middle_end) + ' , ' + \
                    SkybberBot.UNICODE_SET + utils.formatLocalTime(tw_middle_end) + '  -  ' + SkybberBot.UNICODE_RISE + utils.formatLocalTime(tw_end)

        return reply
Example #6
0
 def format(self):
     result = utils.formatLocalTime(self.tm) + "  [ " + self.alt + " / " + self.az + " ]"
     return result