Exemplo n.º 1
0
 def get(self, offset, year, month, day, hour, minute, second):
   (utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second) = swe.utc_time_zone(year, month, day, hour, minute, second, float(offset))
   julday = swe.utc_to_jd(year=utc_year, month=utc_month, day=utc_day, hour=utc_hour, minutes=utc_minute, seconds=utc_second, flag=swe.GREG_CAL)[0]
   from jyotisha.panchangam import temporal
   raashi = temporal.get_solar_rashi(jd=julday)
   logging.info(raashi)
   return str(raashi)
Exemplo n.º 2
0
 def get(self, offset, year, month, day, hour, minute, second, body):
     from jyotisha import zodiac
     (utc_year, utc_month, utc_day, utc_hour, utc_minute,
      utc_second) = swe.utc_time_zone(year=year,
                                      month=month,
                                      day=day,
                                      hour=hour,
                                      minutes=minute,
                                      seconds=second,
                                      offset=float(offset))
     julday = swe.utc_to_jd(year=utc_year,
                            month=utc_month,
                            day=utc_day,
                            hour=utc_hour,
                            minutes=utc_minute,
                            seconds=utc_second,
                            flag=swe.GREG_CAL)[0]
     body_id = get_body_id(body_name=body)
     from jyotisha.panchangam import temporal
     transits = temporal.get_planet_next_transit(jd_start=julday,
                                                 jd_end=julday + 100,
                                                 planet=body_id)
     # logging.debug(transits)
     transits_utc = [(swe.jdut1_to_utc(ut=transit[0], flag=swe.GREG_CAL),
                      transit[1], transit[2]) for transit in transits]
     transits_local = [(swe.utc_time_zone(year=transit[0][0],
                                          month=transit[0][1],
                                          day=transit[0][2],
                                          hour=transit[0][3],
                                          minutes=transit[0][4],
                                          seconds=int(transit[0][5]),
                                          offset=-float(offset)),
                        transit[1], transit[2]) for transit in transits_utc]
     return str(transits_local)
Exemplo n.º 3
0
def utc_to_julian(dtime):
    """Convert UTC time to Julian date"""
    if dtime.tzinfo is not None:
        utc = local_to_utc(dtime)
    else:
        utc = dtime
    year, month, day = utc.year, utc.month, utc.day
    hour, minute, second = utc.hour, utc.minute, utc.second
    return swe.utc_to_jd(year, month, day, hour, minute, second, 1)[1]
Exemplo n.º 4
0
 def get(self, body, offset, year, month, day, hour, minute, second):
   from jyotisha import zodiac
   (utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second) = swe.utc_time_zone(year, month, day, hour, minute, second, float(offset))
   julday = swe.utc_to_jd(year=utc_year, month=utc_month, day=utc_day, hour=utc_hour, minutes=utc_minute, seconds=utc_second, flag=swe.GREG_CAL)[0]
   lahiri_nakshatra_division = zodiac.NakshatraDivision(julday=julday)
   body_id = get_body_id(body_name=body)
   if body == "moon":
     from jyotisha.panchangam import temporal
     logging.debug(temporal.get_nakshatram(julday))
   nakshatra = lahiri_nakshatra_division.get_nakshatra(body_id=body_id)
   logging.info(nakshatra)
   return str(nakshatra)
Exemplo n.º 5
0
def local_time_to_jdut1(year,
                        month,
                        day,
                        hour=0,
                        minutes=0,
                        seconds=0,
                        timezone=0.0):
    """Converts local time to JD(UT1)"""
    y, m, d, h, mnt, s = swe.utc_time_zone(year, month, day, hour, minutes,
                                           seconds, timezone)
    # BUG in pyswisseph: replace 0 by s
    jd_et, jd_ut1 = swe.utc_to_jd(y, m, d, h, mnt, 0, flag=swe.GREG_CAL)
    return jd_ut1
Exemplo n.º 6
0
    def compute(self, in_date: datetime):
        in_date = in_date.astimezone(timezone.utc)
        _, in_date_jul = swe.utc_to_jd(in_date.year, in_date.month,
                                       in_date.day, in_date.hour,
                                       in_date.minute, in_date.second,
                                       swe.GREG_CAL)
        # print(in_date_jul)

        # in_date_jul = swe.julday(in_date.year, in_date.month, in_date.day,
        #                          in_date.hour + in_date.minute / 60 + in_date.second / 3600)
        sun_pos, _ = swe.calc(in_date_jul, swe.SUN, swe.FLG_SIDEREAL)
        moon_pos, _ = swe.calc(in_date_jul, swe.MOON, swe.FLG_SIDEREAL)
        sun_pos = sun_pos[0]
        moon_pos = moon_pos[0]
        self.tithi, self.pos_deg = self._calc_tithi(sun_pos, moon_pos)
Exemplo n.º 7
0
 def local_time_to_julian_day(self, year, month, day, hours, minutes,
                              seconds):
     offset_hours = self.get_timezone_offset_hours_from_date(
         year=year,
         month=month,
         day=day,
         hour=hours,
         minute=minutes,
         seconds=seconds)
     (year_utc, month_utc, day_utc, hours_utc, minutes_utc,
      seconds_utc) = swe.utc_time_zone(year, month, day, hours, minutes,
                                       seconds, offset_hours)
     julian_dates = swe.utc_to_jd(year_utc, month_utc, day_utc, hours_utc,
                                  minutes_utc, seconds_utc, 1)
     return julian_dates[1]
Exemplo n.º 8
0
def loc_of_planet(planet, start, end, freq='1D', scale=1, fit360=False):
    """Calculate the locations of planet within a time span.

        parameters:

        planet: the planet variable in swisseph
        start, end: the time span
        freq: the calculation freq
        scale: mulitply the planet location

        return a pandas Series with planet location

    """

    results = []
    drange = pd.date_range(start, end, freq=freq, tz='utc')

    for date in drange:
        year   = date.year
        month  = date.month
        day    = date.day
        hour   = date.hour
        minute = date.minute
        second = date.second

        jd = swe.utc_to_jd(year, month, day, hour, minute, second, 1)
        ut = jd[1]

        loc = swe.calc_ut(ut, planet)

        results.append(loc[0]*scale)

    res = pd.Series(results, drange, name=swe.get_planet_name(planet))

    if scale > 1 and fit360:
        return res.apply(_fit360)

    return res
Exemplo n.º 9
0
def loc_of_planet(planet, start, end, freq='1D', scale=1, fit360=False):
    """Calculate the locations of planet within a time span.

        parameters:

        planet: the planet variable in swisseph
        start, end: the time span
        freq: the calculation freq
        scale: mulitply the planet location

        return a pandas Series with planet location

    """

    results = []
    drange = pd.date_range(start, end, freq=freq, tz='utc')

    for date in drange:
        year = date.year
        month = date.month
        day = date.day
        hour = date.hour
        minute = date.minute
        second = date.second

        jd = swe.utc_to_jd(year, month, day, hour, minute, second, 1)
        ut = jd[1]

        loc = swe.calc_ut(ut, planet)

        results.append(loc[0] * scale)

    res = pd.Series(results, drange, name=swe.get_planet_name(planet))

    if scale > 1 and fit360:
        return res.apply(_fit360)

    return res
Exemplo n.º 10
0
    def DateTime(self, year, month, date, hr, min, sec):

        return swe.utc_to_jd(year, month, date, hr, min, sec, GREG_CAL)
Exemplo n.º 11
0
        '3 %(north_pole_ra)f %(north_pole_dec)f %(boundary_ra)f %(boundary_declination)f %(south_pole_ra)f %(south_pole_dec)f 2 N%(sector_id_1)02d N%(sector_id_2)02d' % dict(
          north_pole_ra=ecliptic_north_pole_with_ra[0],
          north_pole_dec=ecliptic_north_pole_with_ra[1],
          boundary_ra=boundary_ra,
          boundary_declination=boundary_declination,
          south_pole_ra=ecliptic_south_pole_with_ra[0],
          south_pole_dec=ecliptic_south_pole_with_ra[1],
          sector_id_1=(index % 27 + 1),
          sector_id_2=((index + 1) % 27 + 1)
        ))


if __name__ == '__main__':
  # lahiri_nakshatra_division = NakshatraDivision(julday=swe.utc_to_jd(year=2017, month=8, day=19, hour=11, minutes=10, seconds=0, flag=1)[0])
  lahiri_nakshatra_division = NakshatraDivision(
    julday=swe.utc_to_jd(year=1982, month=2, day=19, hour=11, minutes=10, seconds=0, flag=1)[0])
  logging.info(lahiri_nakshatra_division.get_nakshatra(body_id=swe.MOON))
  # logging.info(lahiri_nakshatra_division)
  # logging.debug(swe.cotrans(lon=20, lat=-90, dist=9999999, obliquity=23.437404))
  lahiri_nakshatra_division.get_stellarium_nakshatra_boundaries()


def get_nirayana_sun_lon(jd, offset=0, debug=False):
    """Returns the nirayana longitude of the sun

      Args:
        float jd: The Julian Day at which the angam is to be computed

      Returns:
        float longitude
Exemplo n.º 12
0
def local_time_to_jdut1(year, month, day, hour = 0, minutes = 0, seconds = 0, timezone = 0.0):
  """Converts local time to JD(UT1)"""
  y, m, d, h, mnt, s = swe.utc_time_zone(year, month, day, hour, minutes, seconds, timezone)
  # BUG in pyswisseph: replace 0 by s
  jd_et, jd_ut1 = swe.utc_to_jd(y, m, d, h, mnt, 0, flag = swe.GREG_CAL)
  return jd_ut1
Exemplo n.º 13
0
    from pprint import pprint


if __name__ == "__main__":

    # This is a minimal e[phemeris].
    e = {"0": {}, "1": {}, "2": {}, "3": [], "4": []}

    # The data files, which may not be in the
    # [sin repo](https://github.com/astrolet/sin) /
    # [gravity pakage](http://search.npmjs.org/#/gravity).
    swe.set_ephe_path(re["data"])

    # Is using the Gregorian calendar flag correct?
    # If calendar type is conditional, is it easier to determine here (with the help of swe)?
    t = swe.utc_to_jd(re["ut"][0], re["ut"][1], re["ut"][2], re["ut"][3], re["ut"][4], re["ut"][5], re["ut"][6])
    # <!---
    # e["jd-ut1"] = swe.jdut1_to_utc(t[1], 1)
    # --->
    #
    # Ask for what is precious:
    #
    # 1. majors (the main things / points for astrology)
    # 2. minors (other objects - e.g. some "minor planets")
    # 3. angles (ascmc) = 8 of 10 doubles (unused 8 & 9)
    # 4. houses (cusps) = 12 of 13 doubles (unused zero)
    #

    for o in [{"what": "1", "offset": 0}, {"what": "2", "offset": 10000}]:
        iterate = re["stuff"][int(o["what"])]
        if iterate:
Exemplo n.º 14
0
                    ) in enumerate(equatorial_boundary_coordinates_with_ra):
            print(
                '3 %(north_pole_ra)f %(north_pole_dec)f %(boundary_ra)f %(boundary_declination)f %(south_pole_ra)f %(south_pole_dec)f 2 N%(sector_id_1)02d N%(sector_id_2)02d'
                % dict(north_pole_ra=ecliptic_north_pole_with_ra[0],
                       north_pole_dec=ecliptic_north_pole_with_ra[1],
                       boundary_ra=boundary_ra,
                       boundary_declination=boundary_declination,
                       south_pole_ra=ecliptic_south_pole_with_ra[0],
                       south_pole_dec=ecliptic_south_pole_with_ra[1],
                       sector_id_1=(index % 27 + 1),
                       sector_id_2=((index + 1) % 27 + 1)))


if __name__ == '__main__':
    # lahiri_nakshatra_division = NakshatraDivision(julday=swe.utc_to_jd(year=2017, month=8, day=19, hour=11, minutes=10, seconds=0, flag=1)[0])
    lahiri_nakshatra_division = NakshatraDivision(julday=swe.utc_to_jd(
        year=1982, month=2, day=19, hour=11, minutes=10, seconds=0, flag=1)[0])
    logging.info(lahiri_nakshatra_division.get_nakshatra(body_id=swe.MOON))
    # logging.info(lahiri_nakshatra_division)
    # logging.debug(swe.cotrans(lon=20, lat=-90, dist=9999999, obliquity=23.437404))
    lahiri_nakshatra_division.get_stellarium_nakshatra_boundaries()


def get_nirayana_sun_lon(jd, offset=0, debug=False):
    """Returns the nirayana longitude of the sun

      Args:
        float jd: The Julian Day at which the angam is to be computed

      Returns:
        float longitude
Exemplo n.º 15
0
if __name__ == "__main__":

    # This is a minimal e[phemeris].
    e = {"0": {}, "1": {}, "2": {}, "3": [], "4": []}

    # The data files, which may not be in the
    # [sin repo](https://github.com/astrolet/sin) /
    # [gravity pakage](http://search.npmjs.org/#/gravity).
    swe.set_ephe_path(re["data"])

    # Is using the Gregorian calendar flag correct?
    # If calendar type is conditional, is it easier to determine here (with the help of swe)?
    t = swe.utc_to_jd(re["ut"][0],
                      re["ut"][1],
                      re["ut"][2],
                      re["ut"][3],
                      re["ut"][4],
                      re["ut"][5],
                      re["ut"][6])
    # <!---
    # e["jd-ut1"] = swe.jdut1_to_utc(t[1], 1)
    # --->
    #
    # Ask for what is precious:
    #
    # 1. majors (the main things / points for astrology)
    # 2. minors (other objects - e.g. some "minor planets")
    # 3. angles (ascmc) = 8 of 10 doubles (unused 8 & 9)
    # 4. houses (cusps) = 12 of 13 doubles (unused zero)
    #
Exemplo n.º 16
0
        minute = minute + second / 60
        second = second % 60
    if minute >= 60:
        hour = hour + minute / 60
        minute = minute % 60
    if hour >= 24:
        day = day + hour / 24
        hour = hour % 24
    from calendar import monthrange
    (_, final_day) = monthrange(year, month)
    if day > final_day:
        assert day == final_day + 1, "range not supported by this function"
        day = 1
        month = month + 1
    if month >= 13:
        year = year + (month - 1) / 12
        month = ((month - 1) % 12) + 1
    return (year, month, day, hour, minute, second)

# Essential for depickling to work.
common.update_json_class_index(sys.modules[__name__])
# logging.debug(common.json_class_index)


if __name__ == '__main__':
  # time = swe.utc_to_jd(year=1982, month=2, day=18, hour=11, minutes=10, seconds=0, flag=1)[0]
  time = swe.utc_to_jd(year=2015, month=9, day=17, hour=15, minutes=16, seconds=0, flag=1)[0]
  # time = swe.utc_to_jd(year=1986, month=8, day=24, hour=11, minutes=54, seconds=0, flag=1)[0]
  logging.info(time)
  print_angas_x_ayanamshas(jd=time)
Exemplo n.º 17
0
# ---------------------- ALL TESTS ------------------------------
def adhipati_tests():
    # nakshatra indexes counted from 0
    satabhisha, citta, aslesha = 23, 13, 8
    assert (adhipati(satabhisha) == swe.RAHU)
    assert (mahadasa[adhipati(satabhisha)] == 18)
    assert (adhipati(citta) == swe.MARS)
    assert (mahadasa[adhipati(citta)] == 7)
    assert (adhipati(aslesha) == swe.MERCURY)
    assert (mahadasa[adhipati(aslesha)] == 17)


if __name__ == "__main__":
    adhipati_tests()
    # YYYY-MM-DD 09:40 IST = 04:10 UTC
    jdut1 = swe.utc_to_jd(1985, 6, 9, 4, 10, 0, flag=swe.GREG_CAL)[1]
    tz = 5.5
    print("jdut1", jdut1)
    dashas = vimsottari_mahadasa(jdut1)
    for i in dashas:
        print(' ---------- ' + get_planet_name(i) + ' Dasa ---------- ')
        bhuktis = vimsottari_bhukti(i, dashas[i])
        for j in bhuktis:
            jd = bhuktis[j]
            y, m, d, h = swe.revjul(round(jd + tz))
            print('%8s: %04d-%02d-%02d\t%.6lf' %
                  (get_planet_name(j), y, m, d, jd))

    jd = 2456950  # Some random date, ex: current date
    i, j, antara = compute_antara_from(jd, dashas)
    print("---- JD %d falls in %s dasa/%s bhukti -----" %
Exemplo n.º 18
0
# ---------------------- ALL TESTS ------------------------------
def adhipati_tests():
    # nakshatra indexes counted from 0
    satabhisha, citta, aslesha = 23, 13, 8
    assert(adhipati(satabhisha) == swe.RAHU)
    assert(mahadasa[adhipati(satabhisha)] == 18)
    assert(adhipati(citta) == swe.MARS)
    assert(mahadasa[adhipati(citta)] == 7)
    assert(adhipati(aslesha) == swe.MERCURY)
    assert(mahadasa[adhipati(aslesha)] == 17)


if __name__ == "__main__":
    adhipati_tests()
    # YYYY-MM-DD 09:40 IST = 04:10 UTC
    jdut1 = swe.utc_to_jd(1985, 6, 9, 4, 10, 0, flag = swe.GREG_CAL)[1]
    tz = 5.5
    print("jdut1", jdut1)
    dashas = vimsottari_mahadasa(jdut1)
    for i in dashas:
        print(' ---------- ' + get_planet_name(i) + ' Dasa ---------- ')
        bhuktis = vimsottari_bhukti(i, dashas[i])
        for j in bhuktis:
            jd = bhuktis[j]
            y, m, d, h = swe.revjul(round(jd + tz))
            print('%8s: %04d-%02d-%02d\t%.6lf' % (get_planet_name(j), y, m, d, jd))

    jd = 2456950       # Some random date, ex: current date
    i, j, antara = compute_antara_from(jd, dashas)
    print("---- JD %d falls in %s dasa/%s bhukti -----" %
          (jd, get_planet_name(i), get_planet_name(j)))