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)
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' 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'))
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
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] ]
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] ]
def panchaanga_json_comparer(city, year, computation_system=ComputationSystem.TEST): expected_content_path = os.path.join(TEST_DATA_PATH, '%s-%d.json' % (city.name, year)) panchaanga = annual.get_panchaanga_for_civil_year( city=city, year=year, computation_system=computation_system, allow_precomputed=False) timebudget.report(reset=True) testing.json_compare(actual_object=panchaanga, expected_content_path=expected_content_path)
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)