Пример #1
0
def main():
    [city_name, latitude, longitude, tz] = sys.argv[1:5]
    year = int(sys.argv[5])

    compute_lagnams = False  # Default
    scripts = [sanscript.DEVANAGARI]  # Default language is devanagari
    fmt = 'hh:mm'

    if len(sys.argv) == 9:
        compute_lagnams = True
        fmt = sys.argv[7]
        scripts = sys.argv[6].split(",")
    elif len(sys.argv) == 8:
        scripts = sys.argv[6].split(",")
        fmt = sys.argv[7]
        compute_lagnams = False
    elif len(sys.argv) == 7:
        scripts = sys.argv[6].split(",")
        compute_lagnams = False

    city = City(city_name, latitude, longitude, tz)

    panchaanga = jyotisha.panchaanga.spatio_temporal.annual.get_panchaanga_for_civil_year(
        city=city, year=year)

    emit(panchaanga, scripts=scripts)
Пример #2
0
def test_get_samvatsara():
    city = City.get_city_from_db('Bangalore')
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2019, month=9, day=10))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.LUNAR_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "विकारी"
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2020, month=2, day=10))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.LUNAR_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "विकारी"
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2020, month=4, day=10))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.LUNAR_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "शार्वरी"
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2020, month=4, day=10))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.TROPICAL_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "शार्वरी"
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2020, month=4, day=10))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.SIDEREAL_SOLAR_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "विकारी"
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2020, month=4, day=20))
    assert panchaanga.get_samvatsara(
        month_type=RulesRepo.SIDEREAL_SOLAR_MONTH_DIR).get_name(
            script=sanscript.DEVANAGARI) == "शार्वरी"
Пример #3
0
def main():
    [city_name, latitude, longitude, tz] = sys.argv[1:5]
    year = int(sys.argv[5])

    if len(sys.argv) == 8:
        all_tags = False
    else:
        all_tags = True  # Default assume detailed ICS with name_to_rule tags

    if len(sys.argv) >= 7:
        scripts = sys.argv[6].split(",")
    else:
        scripts = [sanscript.IAST
                   ]  # Default script is IAST for writing calendar

    city = City(city_name, latitude, longitude, tz)

    panchaanga = jyotisha.panchaanga.spatio_temporal.annual.get_panchaanga_for_civil_year(
        city=city, year=year)
    panchaanga.update_festival_details()

    ics_calendar = compute_calendar(panchaanga)
    output_file = os.path.expanduser(
        '%s/%s-%d-%s.ics' % ("~/Documents/jyotisha", city.name, year, scripts))
    write_to_file(ics_calendar, output_file)
Пример #4
0
def main():
    [city_name, latitude, longitude, tz] = sys.argv[1:5]
    year = int(sys.argv[5])

    compute_lagnams = False  # Default
    script = sanscript.DEVANAGARI  # Default script is devanagari
    fmt = 'hh:mm'
    lagnasuff = ''

    if len(sys.argv) == 9:
        compute_lagnams = True
        lagnasuff = '-lagna'
        fmt = sys.argv[7]
        script = sys.argv[6]
    elif len(sys.argv) == 8:
        script = sys.argv[6]
        fmt = sys.argv[7]
        compute_lagnams = False
    elif len(sys.argv) == 7:
        script = sys.argv[6]
        compute_lagnams = False

    city = City(city_name, latitude, longitude, tz)

    panchaanga = annual.get_panchaanga_for_civil_year(city=city, year=year)

    panchaanga.update_festival_details()

    city_name_en = jyotisha.custom_transliteration.romanise(
        jyotisha.custom_transliteration.tr(city.name, sanscript.IAST)).title()
    output_file = os.path.expanduser(
        '%s/%s-%d-%s-daily%s.md' % ("~/Documents/jyotisha/jyotisha/txt/daily",
                                    city_name_en, year, script, lagnasuff))
    os.makedirs(os.path.dirname(output_file), exist_ok=True)
    writeDailyText(panchaanga, compute_lagnams, open(output_file, 'w'))
Пример #5
0
    def get(self, latitude, longitude, year):
        args = self.get_parser.parse_args()
        city = City("", latitude, longitude, args['timezone'])
        panchaanga = annual.get_panchaanga_for_civil_year(city=city,
                                                          year=int(year))

        return panchaanga.to_json_map()
def main():
    [city_name, latitude, longitude, tz] = sys.argv[1:5]
    year = int(sys.argv[5])

    compute_lagnams = False  # Default
    script = sanscript.DEVANAGARI  # Default script is devanagari
    fmt = 'hh:mm'

    if len(sys.argv) == 9:
        compute_lagnams = True
        fmt = sys.argv[7]
        script = sys.argv[6]
    elif len(sys.argv) == 8:
        script = sys.argv[6]
        fmt = sys.argv[7]
        compute_lagnams = False
    elif len(sys.argv) == 7:
        script = sys.argv[6]
        compute_lagnams = False

    city = City(city_name, latitude, longitude, tz)

    panchaanga = jyotisha.panchaanga.spatio_temporal.annual.get_panchaanga_for_civil_year(
        city=city, year=year)

    panchaanga.update_festival_details()

    ics_calendar = writeDailyICS(panchaanga)
    city_name_en = jyotisha.custom_transliteration.romanise(
        jyotisha.custom_transliteration.tr(city.name, sanscript.IAST)).title()
    output_file = os.path.expanduser(
        '%s/%s-%d-%s-daily.ics' % ("../ics/daily", city_name_en, year, script))
    write_to_file(ics_calendar, output_file)
    print('Output ICS written to %s' % output_file, file=sys.stderr)
Пример #7
0
def test_jd_start_orinda_ca():
    city = City('Orinda', '37:51:38', '-122:10:59', 'America/Los_Angeles')
    assert daily.DailyPanchaanga.from_city_and_julian_day(
        city=city,
        julian_day=2458551.8333333335).julian_day_start == 2458551.8333333335
    assert daily.DailyPanchaanga.from_city_and_julian_day(
        city=city,
        julian_day=2458552.8333333335).julian_day_start == 2458552.8333333335
Пример #8
0
 def get(self, latitude, longitude, year, month, day):
     args = self.get_parser.parse_args()
     city = City("", latitude, longitude, args['timezone'])
     panchaanga = daily.DailyPanchaanga(city=city,
                                        date=Date(year=int(year),
                                                  month=int(month),
                                                  day=int(day)))
     return panchaanga.day_length_based_periods.to_json_map()
Пример #9
0
def test_timing(caplog):
    # A separate function for convenient profiling.
    # See data/timing_snapshot* for results/ progression.
    caplog.set_level(logging.INFO)
    city = City('Chennai', "13:05:24", "80:16:12", "Asia/Calcutta")
    annual.get_panchaanga_for_civil_year(city=city,
                                         year=2018,
                                         allow_precomputed=False)
    timebudget.report(reset=True)
Пример #10
0
def test_tb_muhuurta_blr():
    city = City.get_city_from_db('Bangalore')
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2019, month=9, day=10))
    assert len(panchaanga.day_length_based_periods.fifteen_fold_division.
               tb_muhuurtas) == 15
    assert panchaanga.day_length_based_periods.fifteen_fold_division.tb_muhuurtas[
        0].jd_start == panchaanga.jd_sunrise
    for muhurta in panchaanga.day_length_based_periods.fifteen_fold_division.tb_muhuurtas:
        logging.info(muhurta.to_localized_string(city=city))
Пример #11
0
def test_adhika_maasa_computations_2009():
    city = City('Chennai', "13:05:24", "80:16:12", "Asia/Calcutta")
    panchaanga_2009 = annual.get_panchaanga_for_civil_year(
        city=city, year=2009, allow_precomputed=False)
    expected_lunar_months_2009 = [7] + [8] * 29 + [9] * 30 + [10] * 15
    assert expected_lunar_months_2009 == [
        x.lunar_month_sunrise.index
        for x in panchaanga_2009.daily_panchaangas_sorted()
        [panchaanga_2009.duration_prior_padding +
         290:panchaanga_2009.duration_prior_padding + 365]
    ]
Пример #12
0
def dump_bengaluru_history():
    city = City.get_city_from_db(name="sahakAra nagar, bengaLUru")
    # dump_summary(year=1797, city=maisUru)
    # for year in range(1950, 2020):
    #   dump_summary(year=year, city=city)
    for year in range(2010, 2023):
        dump_summary(year=year,
                     city=city,
                     computation_system=temporal.
                     get_kauNdinyAyana_bhAskara_gRhya_computation_system(),
                     allow_precomputed=False)
Пример #13
0
def no_fest_chennai_panchaanga(year):
    city = City('Chennai', "13:05:24", "80:16:12", "Asia/Calcutta")
    computation_system = copy.deepcopy(
        ComputationSystem.MULTI_NEW_MOON_SIDEREAL_MONTH_ADHIKA__CHITRA_180)
    computation_system.festival_options.repos = []
    panchaanga = annual.get_panchaanga_for_civil_year(
        city=city,
        year=year,
        allow_precomputed=False,
        computation_system=computation_system)
    return panchaanga
Пример #14
0
def test_adhika_maasa_computations_2018():
    city = City('Chennai', "13:05:24", "80:16:12", "Asia/Calcutta")
    panchaanga_2018 = annual.get_panchaanga_for_civil_year(
        city=city, year=2018, allow_precomputed=False)
    expected_lunar_months_2018 = [2] + [2.5] * 29 + [3] * 30 + [4]
    assert expected_lunar_months_2018 == [
        x.lunar_month_sunrise.index
        for x in panchaanga_2018.daily_panchaangas_sorted()
        [panchaanga_2018.duration_prior_padding +
         134:panchaanga_2018.duration_prior_padding + 195]
    ]
Пример #15
0
def test_orinda_ca_dst_2019():
    city = City('Orinda', '37:51:38', '-122:10:59', 'America/Los_Angeles')
    panchaanga = periodical.Panchaanga(city=city,
                                       start_date=Date(2019, 1, 1),
                                       end_date=Date(2019, 5, 1))
    # March 10 is the 69th day of the year (70th in leap years) in the Gregorian calendar.
    # Sunrise on that day is around 7:27 AM according to Google, which is JD 2458553.14375 according to https://ssd.jpl.nasa.gov/tc.cgi#top .
    # We use the index 70 below as the annual panchaanga object seems to use the index d + 1.
    assert round(
        panchaanga.daily_panchaangas_sorted()[panchaanga.duration_prior_padding
                                              + 69].jd_sunrise,
        ndigits=4) == round(2458554.104348237,
                            ndigits=4)  # 2019-Mar-10 07:30:15.68
Пример #16
0
def test_get_lagna_data():
    city = City.get_city_from_db('Chennai')
    from jyotisha.panchaanga.temporal import zodiac
    actual = daily.DailyPanchaanga.from_city_and_julian_day(
        city=city, julian_day=2458222.5208333335).get_lagna_data(
            ayanaamsha_id=zodiac.Ayanamsha.CHITRA_AT_180)
    expected = [(12, 2458222.5214310056), (1, 2458222.596420153),
                (2, 2458222.6812926503), (3, 2458222.772619788),
                (4, 2458222.8624254186), (5, 2458222.9478168003),
                (6, 2458223.0322211445), (7, 2458223.1202004547),
                (8, 2458223.211770839), (9, 2458223.3000455885),
                (10, 2458223.3787625884), (11, 2458223.4494649624),
                (12, 2458223.518700759)]
    numpy.testing.assert_allclose(actual, expected, rtol=1e-4)
Пример #17
0
def main():
  [city_name, latitude, longitude, tz] = sys.argv[1:5]
  year = int(sys.argv[5])

  scripts = [sanscript.DEVANAGARI]  # Default language is devanagari

  if len(sys.argv) == 7:
    scripts = sys.argv[6].split(",")

  # logging.debug(language)

  city = City(city_name, latitude, longitude, tz)
  panchaanga = annual.get_panchaanga_for_civil_year(city=city, year=year)

  panchaanga.update_festival_details()

  write_monthly_tex(panchaanga)
Пример #18
0
def main():
    [city_name, latitude, longitude, tz] = sys.argv[1:5]
    year = int(sys.argv[5])
    if len(sys.argv) >= 7:
        scripts = sys.argv[6].split(",")
    else:
        scripts = [sanscript.IAST
                   ]  # Default language is IAST for writing calendar

    city = City(city_name, latitude, longitude, tz)

    panchaanga = jyotisha.panchaanga.spatio_temporal.annual.get_panchaanga_for_civil_year(
        city=city, year=year)

    ics_calendar = compute_calendar(panchaanga)
    output_file = os.path.expanduser(
        '%s/%s-%d-%s.ics' % ("~/Documents/jyotisha", city.name, year, scripts))
    write_to_file(ics_calendar, output_file)
Пример #19
0
def main():
    [json_file, city_name, latitude, longitude, tz] = sys.argv[1:6]
    if not os.path.isfile(json_file):
        raise IOError('File %s not found!' % json_file)

    year = int(sys.argv[6])

    if len(sys.argv) == 8:
        script = sys.argv[7]
    else:
        script = 'iast'  # Default script is IAST for writing calendar

    city = City(city_name, latitude, longitude, tz)

    panchaanga = jyotisha.panchaanga.spatio_temporal.annual.get_panchaanga_for_civil_year(
        city=city, year=year)
    panchaanga.update_festival_details()

    cal_file_name = '%s-%s-%s' % (
        city_name, year, os.path.basename(json_file).replace('.json', '.ics'))
    emit_ics_calendar(panchaanga, cal_file_name)
    print('Wrote ICS file to %s' % cal_file_name)
Пример #20
0
def test_moonrise_time():
    city = City.get_city_from_db(name="Bangalore")
    from jyotisha.panchaanga.temporal.body import Graha
    assert city.get_rising_time(julian_day_start=2459107.33,
                                body=Graha.MOON) == 2459107.4297038973
Пример #21
0
def dump_pune_history():
  city = City.get_city_from_db(name="Pune")
  # dump_summary(year=1797, city=maisUru)
  for year in range(1625, 1850):
    dump_summary(year=year, city=city)
Пример #22
0
def dump_hampi_history():
  city = City.get_city_from_db(name="Hampi")
  # dump_summary(year=1797, city=maisUru)
  for year in range(1300, 1625):
    dump_summary(year=year, city=city)
Пример #23
0
def dump_bengaluru_history():
  city = City.get_city_from_db(name="sahakAra nagar, bengaLUru")
  # dump_summary(year=1797, city=maisUru)
  for year in range(1950, 2020):
    dump_summary(year=year, city=city)
Пример #24
0
                    body.longitude_difference(jd=self.jd_next_sunrise,
                                              body1=sun,
                                              body2=graha)
                ]
            else:
                amauDhyas[graha_id] = [
                    body.longitude_difference(jd=self.jd_sunrise,
                                              body1=sun,
                                              body2=graha),
                    body.longitude_difference(jd=self.jd_next_sunrise,
                                              body1=sun,
                                              body2=graha)
                ]

        if len(mauDhyas) > 0:
            self.mauDhyas = mauDhyas
        if len(amauDhyas) > 0:
            self.amauDhyas = amauDhyas


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

if __name__ == '__main__':
    panchaanga = DailyPanchaanga.from_city_and_julian_day(
        city=City('Chennai', '13:05:24', '80:16:12', 'Asia/Calcutta'),
        julian_day=2457023.27)
    panchaanga.compute_tb_muhuurtas()
    logging.debug(str(panchaanga))
Пример #25
0
def dump_mysore_history():
  maisUru = City.get_city_from_db(name="Mysore")
  # dump_summary(year=1797, city=maisUru)
  for year in range(1740, 1810):
    dump_summary(year=year, city=maisUru)
Пример #26
0
def test_sunrise_mtv():
    city = City.get_city_from_db('Cupertino')
    panchaanga = daily.DailyPanchaanga(city=city,
                                       date=Date(year=2018, month=11, day=11))
    panchaanga.compute_sun_moon_transitions()
    numpy.testing.assert_approx_equal(panchaanga.jd_sunrise, 2458434.11)
Пример #27
0
from jyotisha.panchaanga.spatio_temporal import City, periodical
from jyotisha.panchaanga.temporal import ComputationSystem
from jyotisha.panchaanga.temporal.time import Date

chennai = City.get_city_from_db('Chennai')


def test_daily_solar_viSukkaNi():

    computation_system = ComputationSystem.DEFAULT
    panchaanga = periodical.Panchaanga(city=chennai,
                                       start_date=Date(2018, 4, 14),
                                       end_date=Date(2018, 4, 15),
                                       computation_system=computation_system)

    assert "viSukkan2i" in panchaanga.date_str_to_panchaanga[Date(
        2018, 4, 14).get_date_str()].festival_id_to_instance
    assert "viSukkan2i" not in panchaanga.date_str_to_panchaanga[Date(
        2018, 4, 15).get_date_str()].festival_id_to_instance.keys()


def test_periodic_solar_viSukkaNi():
    computation_system = ComputationSystem.DEFAULT
    panchaanga = periodical.Panchaanga(city=chennai,
                                       start_date=Date(2018, 4, 10),
                                       end_date=Date(2018, 4, 18),
                                       computation_system=computation_system)
    assert "viSukkan2i" in panchaanga.date_str_to_panchaanga[Date(
        2018, 4, 14).get_date_str()].festival_id_to_instance
    assert "viSukkan2i" not in panchaanga.date_str_to_panchaanga[Date(
        2018, 4, 15).get_date_str()].festival_id_to_instance
Пример #28
0
def test_get_lagna_float():
    city = City.get_city_from_db('Chennai')
    numpy.testing.assert_allclose(city.get_lagna_float(2444961.7125),
                                  10.353595502472984,
                                  rtol=1e-4)
Пример #29
0
import logging

from jyotisha.panchaanga import temporal
from jyotisha.panchaanga.spatio_temporal import City
from jyotisha.panchaanga.temporal.time import Timezone

city = City.from_address_and_timezone(address="Mountain View, CA", timezone_str="America/Los_Angeles")
# time = Timezone(city.timezone).local_time_to_julian_day(year=2019, month=1, day=21, hours=18, minutes=32, seconds=0)
# logging.info(time)
# temporal.print_angas_x_ayanaamshas(jd=time)
Пример #30
0
from jyotisha.panchaanga.spatio_temporal import daily
from jyotisha.panchaanga.temporal import time
from jyotisha.panchaanga.temporal.festival.rules import RulesRepo
from jyotisha.panchaanga.temporal.interval import Interval
from jyotisha.panchaanga.temporal.time import Date
from jyotisha.panchaanga.temporal.zodiac import AngaType
from timebudget import timebudget

from sanskrit_data import testing

logging.basicConfig(
    level=logging.DEBUG,
    format="%(levelname)s: %(asctime)s {%(filename)s:%(lineno)d}: %(message)s "
)

chennai = City.get_city_from_db("Chennai")
TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), 'data')


# noinspection PyUnresolvedReferences
def panchaanga_json_comparer(city, date):
    expected_content_path = os.path.join(
        TEST_DATA_PATH, '%s-%s.json' % (city.name, date.get_date_str()))
    panchaanga = daily.DailyPanchaanga(city=city, date=date)
    timebudget.report(reset=True)
    testing.json_compare(actual_object=panchaanga,
                         expected_content_path=expected_content_path)
    return panchaanga


def test_solar_day():