### Setup Local Environment with Venv Source: https://github.com/diliprk/vedicastro/blob/main/README.md Set up a Python virtual environment using venv, activate it, and install project dependencies from requirements.txt. ```bash python -m venv astrovenv source astrovenv/bin/activate pip install --upgrade pip pip install -r requirements.txt ``` -------------------------------- ### Example Usage and Output Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/AscMotionStudy.ipynb Demonstrates how to use the calculate_daily_asc_speed function with example parameters and prints the ascendant speed for the first day. ```python # Example usage parameters year = 2024 lat = 11.020085773931049 # Example latitude lon = 76.98319647719487 # Example longitude utc = "+05:30" ayan = "Krishnamurti" house_system = "Placidus" dates, asc_speeds = calculate_daily_asc_speed(year, lat, lon, utc, ayan, house_system) print(f"Asc Speed on {dates[0]}: {asc_speeds[0]:.5f} ° per second") ``` -------------------------------- ### Install flatlib from GitHub Source: https://github.com/diliprk/vedicastro/blob/main/README.md After installing VedicAstro from PyPI, install the required flatlib package from its sidereal branch on GitHub using pip. ```bash pip install git+https://github.com/diliprk/flatlib.git@sidereal#egg=flatlib ``` -------------------------------- ### Install VedicAstro from PyPi Source: https://github.com/diliprk/vedicastro/blob/main/README.md Install the VedicAstro package using pip. This is the primary method for obtaining the library. ```bash pip install vedicastro ``` -------------------------------- ### Install Required Packages Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/AscMotionStudy.ipynb Installs plotly and nbformat. Run these commands in your virtual environment before executing the notebook. ```bash pip install plotly pip install --upgrade nbformat ``` -------------------------------- ### Setup Local Environment with Conda Source: https://github.com/diliprk/vedicastro/blob/main/README.md Set up a Python virtual environment using Conda with a specific Python version and install project dependencies. ```bash conda create -n astrovenv python=3.11 conda activate astrovenv pip install -r requirements.txt ``` -------------------------------- ### Compute Vimshottari Dasa Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/README.md Example of computing the Vimshottari Dasa periods for a given chart. The output includes start and end dates for major periods and their sub-periods (Bhuktis). ```python dasa = horoscope.compute_vimshottari_dasa(chart) # Returns: { # "Ketu": { # "start": "15-06-1990", # "end": "01-06-1998", # "bhuktis": { # "Ketu": {"start": "...", "end": "..."}, # "Venus": {"start": "...", "end": "..."}, # ... # } # }, # ... # } ``` -------------------------------- ### Get Planet Significators Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/README.md Example of how to retrieve planet significators using the get_planet_wise_significators function. This function requires pre-fetched planet and house data. ```python significators = horoscope.get_planet_wise_significators(planets_data, houses_data) # Returns: [ # {"Planet": "Sun", "A": 10, "B": 5, "C": [2, 9], "D": [3, 10]}, # ... # ] ``` -------------------------------- ### GET / Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Root endpoint that returns service information and a welcome message. ```APIDOC ## GET / ### Description Root endpoint that returns service information. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **message** (string) - Welcome message from the service. - **info** (string) - Link to the interactive API documentation. #### Response Example ```json { "message": "Welcome to VedicAstro FastAPI Service!", "info": "Visit http://127.0.0.1:8088/docs to test the API functions" } ``` ``` -------------------------------- ### Working with Nakshatras Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Illustrates how to approximate the nakshatra index from a given degree and retrieve the nakshatra name. ```python from vedicastro.VedicAstro import NAKSHATRAS # Find which nakshatra based on degree degree = 45.5 nak_index = int(degree / 13.333) # Approximate nakshatra = NAKSHATRAS[nak_index % 27] ``` -------------------------------- ### Example Usage of Aspect Mapping Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Demonstrates how to retrieve an aspect name using the ASPECT_MAPPING dictionary and flatlib constants. ```python from vedicastro.VedicAstro import ASPECT_MAPPING from flatlib import const aspect_name = ASPECT_MAPPING[const.TRINE] # Returns "Trine" ``` -------------------------------- ### CORS Configuration Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Example CORS configuration allowing all origins, credentials, methods, and headers. This is a permissive setting. ```json { "allow_origins": ["*"], "allow_credentials": true, "allow_methods": ["*"], "allow_headers": ["*"] } ``` -------------------------------- ### Converting Aspects Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Shows how to get an aspect between two objects, check if it exists, and then map its type to a human-readable name. ```python from vedicastro.VedicAstro import ASPECT_MAPPING from flatlib import aspects aspect = aspects.getAspect(obj1, obj2, const.ALL_ASPECTS) if aspect.exists(): aspect_name = ASPECT_MAPPING[int(aspect.type)] print(f"Aspect: {aspect_name}") ``` -------------------------------- ### HoraryChartInput Example JSON Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/types.md An example of a JSON payload for the HoraryChartInput model, illustrating the fields needed for KP Horary chart generation. ```json { "horary_number": 34, "year": 2024, "month": 2, "day": 5, "hour": 12, "minute": 0, "second": 0, "utc": "+5:30", "latitude": 11.02, "longitude": 76.98, "ayanamsa": "Krishnamurti", "house_system": "Placidus", "return_style": null } ``` -------------------------------- ### ChartInput Example JSON Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/types.md An example of a JSON payload for the ChartInput model, demonstrating the required and optional fields for generating a horoscope chart. ```json { "year": 1990, "month": 6, "day": 15, "hour": 14, "minute": 30, "second": 0, "utc": "+5:30", "latitude": 40.7128, "longitude": -74.0060, "ayanamsa": "Krishnamurti", "house_system": "Placidus", "return_style": null } ``` -------------------------------- ### Run VedicAstro API with FastAPI Source: https://github.com/diliprk/vedicastro/blob/main/README.md Deploy the VedicAstro package as an API service using FastAPI. This command starts the Uvicorn server. ```bash uvicorn VedicAstroAPI:app --reload --port 8088 ``` -------------------------------- ### Accessing Planet Ruler Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Demonstrates how to find the ruling planet of a zodiac sign using predefined lists for signs and their lords. ```python from vedicastro.VedicAstro import RASHIS, SIGN_LORDS # Get the ruler of Leo sign_idx = RASHIS.index("Leo") ruler = SIGN_LORDS[sign_idx] # "Sun" ``` -------------------------------- ### Mapping Ayanamsa Values Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Demonstrates creating a VedicHoroscopeData object with a specified ayanamsa and retrieving its corresponding constant. ```python from vedicastro.VedicAstro import VedicHoroscopeData, AYANAMSA_MAPPING horoscope = VedicHoroscopeData( 1990, 6, 15, 14, 30, 0, 40.7128, -74.0060, ayanamsa="Krishnamurti" ) ayanamsa_const = AYANAMSA_MAPPING[horoscope.ayanamsa] ``` -------------------------------- ### Example: Using Different House Systems Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md Shows how to initialize VedicHoroscopeData with different house systems. Different house systems will lead to variations in house cusps and planetary positions. ```python # Using different house systems horoscope_placidus = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, house_system="Placidus" ) horoscope_equal = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, house_system="Equal" ) # Different house systems produce different house cusps and planet placements ``` -------------------------------- ### VedicHoroscopeData with Auto-Detected Timezone (Example) Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md Demonstrates horoscope data creation where the timezone is automatically detected from the provided latitude and longitude. ```python # Auto-detected timezone horoscope_auto = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060 # Automatically becomes "America/New_York" ) ``` -------------------------------- ### Horary Chart Input - Example 1 Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/HoraryChartStudy.ipynb Defines the parameters for the first horary chart, including date, time, and horary number. ```python ## Chart Input - 1 # year = 2024 # month = 2 # day = 5 # hour = 9 # minute = 14 # secs = 0 # horary_number = 168 ``` -------------------------------- ### Example: Using Different Ayanamsa Systems Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md Demonstrates initializing VedicHoroscopeData with different ayanamsa systems. Note that the same birth data with different ayanamsa values will result in different sign and house placements. ```python # Using different ayanamsa systems horoscope_lahiri = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, ayanamsa="Lahiri" ) horoscope_kp = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, ayanamsa="Krishnamurti" ) # Note: Same birth data, different ayanamsa produces different sign/house placements ``` -------------------------------- ### Horary Chart Input - Example 2 Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/HoraryChartStudy.ipynb Defines the parameters for the second horary chart, including date, time, and horary number. ```python ## Chart Input - 2 year = 2024 month = 2 day = 5 hour = 15 minute = 51 secs = 0 horary_number = 140 ``` -------------------------------- ### Get Swisseph Version Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_houses.ipynb Retrieves and prints the major, minor, and patch versions of the swisseph library. ```python se_version_major, se_version_minor, se_version_patch = swe.version.split('.') print(se_version_major,'.',se_version_minor,'.',se_version_patch) ``` -------------------------------- ### VedicHoroscopeData with Lahiri Ayanamsa and Equal Houses Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md Example of configuring `VedicHoroscopeData` to use the Lahiri ayanamsa and the Equal house system. ```python horoscope = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, tz="America/New_York", ayanamsa="Lahiri", house_system="Equal" ) ``` -------------------------------- ### KP SubLord Divisions Usage Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Shows how to retrieve horary chart data, including sign and ruling planet, for a given division number. ```python from vedicastro import horary_chart horary_data = horary_chart.get_horary_ascendant_degree(34) print(horary_data['Sign']) # Zodiac sign print(horary_data['SubLord']) # Ruling planet print(horary_data['ZodiacDegreeLocation']) # Absolute degree (0-360) ``` -------------------------------- ### Get Planet in House Mapping Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Determines which house (1-12) each planet is located in. Requires chart objects for houses and planets. ```python planet_houses = horoscope.get_planet_in_house(chart, chart) print(planet_houses) # {'Sun': 1, 'Moon': 3, ...} ``` -------------------------------- ### Test Horoscope Data Endpoint with Curl Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Example curl command to send a POST request to the /get_all_horoscope_data endpoint with a JSON payload. ```bash curl -X POST http://127.0.0.1:8088/get_all_horoscope_data \ -H "Content-Type: application/json" \ -d '{ "year": 1990, "month": 6, "day": 15, "hour": 14, "minute": 30, "second": 0, "utc": "+5:30", "latitude": 40.7128, "longitude": -74.0060, "ayanamsa": "Krishnamurti", "house_system": "Placidus" }' ``` -------------------------------- ### Get Transit Details Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Captures real-time transit data for all planets at the current chart time. Returns nakshatra, lords, and retrograde status for each planet. ```python transits = horoscope.get_transit_details() for transit in transits: print(f"{transit.PlanetName}: {transit.Nakshatra}, Retrograde: {transit.isRetrograde}") ``` -------------------------------- ### cURL Example for Horary Chart Request Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Demonstrates how to make a POST request to the horary data endpoint using cURL. Includes setting the Content-Type header and providing the JSON request body. ```bash curl -X POST http://127.0.0.1:8088/get_all_horary_data \ -H "Content-Type: application/json" \ -d '{ "horary_number": 34, "year": 2024, "month": 2, "day": 5, "hour": 12, "minute": 0, "second": 0, "utc": "+5:30", "latitude": 11.02, "longitude": 76.98, "ayanamsa": "Krishnamurti", "house_system": "Placidus" }' ``` -------------------------------- ### Handle Missing Ephemeris Data Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/errors.md Use a try-except block to catch errors when setting the ephemeris path and ensure Swiss Ephemeris files are installed. ```python import swisseph as swe try: swe.set_ephe_path('./swisseph') # Ensure path is set chart = horoscope.generate_chart() except Exception as e: print(f"Ephemeris error: {e}") print("Ensure Swiss Ephemeris files are installed") ``` -------------------------------- ### Get Consolidated Chart Data Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Creates consolidated data organized by rasi (zodiac sign), combining planets and houses. Can return data grouped by rasi or as a list of dictionaries. ```python consolidated = horoscope.get_consolidated_chart_data(planets_data, houses_data) for rasi, objects in consolidated.items(): print(f"{rasi}: {list(objects.keys())}") ``` -------------------------------- ### Get Consolidated Chart Data (DataFrame Records Style) Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Retrieves consolidated astrological chart data and formats it as a list of dictionaries, similar to pandas' `to_dict(orient='records')`. This is useful for direct display or further processing. ```python consolidated_chart_data_style1 = vhd.get_consolidated_chart_data(planets_data=planets_data, houses_data=houses_data, return_style = "dataframe_records") pprint(consolidated_chart_data_style1[:3]) ``` -------------------------------- ### Initialize Birth Details for Chart Generation Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Set up the necessary variables for year, month, day, hour, minute, second, timezone, latitude, longitude, ayanamsa, and house system. ```python year = 2024 month = 1 day = 1 hour = 9 minute = 15 secs = 0 latitude, longitude, utc = 40.707013856558156, -74.01123260406254, "-5:00" ## New York ayan = "Lahiri" house_system = "Placidus" # Default House system for Krishnamurti Paddhati system ``` -------------------------------- ### compute_new_date Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/utils.md Calculates a new date by adding or subtracting a specified duration from a starting date. ```APIDOC ## Function: `compute_new_date` ### Description Compute a new date by adding or subtracting a specified duration (in years) from a starting date tuple. ### Parameters #### Path Parameters - **start_date_tuple** (tuple) - Required - The starting date as a tuple (year, month, day, hour, minute) - **duration_years** (float) - Required - The duration in years to add or subtract. - **direction** (str) - Required - 'forward' to add duration, 'backward' to subtract. ### Return Type `tuple` — The new date as a tuple (year, month, day, hour, minute). ### Example ```python from vedicastro.utils import compute_new_date start = (2024, 1, 1, 0, 0) end_date = compute_new_date(start, 1.5, "forward") # Computes date 1.5 years from start # end_date will be (2025, 7, 1, 0, 0) ``` ``` -------------------------------- ### Import necessary libraries Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/different_eph_files.ipynb Imports pandas, swisseph, and utility functions from vedicastro. ```python import pandas as pd import swisseph as swe from vedicastro.utils import * from vedicastro import VedicAstro as va ``` -------------------------------- ### VedicHoroscopeData with Explicit Timezone Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md Explicitly set the timezone for horoscope calculations. This example specifies 'America/New_York'. ```python # Explicit timezone horoscope_ny = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, tz="America/New_York" ) ``` -------------------------------- ### Initialize VedicHoroscopeData Instance Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Create an instance of VedicHoroscopeData with birth details, location, and astrological system configurations. Ensure all required parameters like year, month, day, hour, minute, second, latitude, and longitude are provided. ```python from vedicastro import VedicAstro # Create a horoscope for a birth time and location horoscope = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, tz="America/New_York", ayanamsa="Krishnamurti", house_system="Placidus" ) ``` -------------------------------- ### Complete Horary Chart Analysis Example Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/horary_chart.md This snippet demonstrates the complete workflow for horary chart analysis. It first finds the ascendant degree for a given horary number and then uses that time to generate a full horary chart, including planet data, significators, and Vimshottari Dasa. ```python from vedicastro import VedicAstro, horary_chart # Step 1: Find when ascendant matches horary number horary_number = 34 matched_time, houses_chart, houses_data = horary_chart.find_exact_ascendant_time( year=2024, month=2, day=5, utc_offset="+5:30", lat=11.02, lon=76.98, horary_number=horary_number, ayanamsa="Krishnamurti" ) if matched_time: # Step 2: Generate full horary chart data vhd = VedicAstro.VedicHoroscopeData( year=2024, month=2, day=5, hour=matched_time.hour, minute=matched_time.minute, second=matched_time.second, latitude=11.02, longitude=76.98, tz="+5:30", ayanamsa="Krishnamurti" ) planets_chart = vhd.generate_chart() planets_data = vhd.get_planets_data_from_chart(planets_chart, houses_chart) # Step 3: Analyze significators and dasa significators = vhd.get_planet_wise_significators(planets_data, houses_data) dasa = vhd.compute_vimshottari_dasa(planets_chart) ``` -------------------------------- ### Get Planet Positions within Houses Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Retrieve and print a dictionary showing which house each planet is located in. ```python planet_in_house = vhd.get_planet_in_house(houses_chart = chart, planets_chart = chart) pprint(planet_in_house) ``` -------------------------------- ### Clone VedicAstro Repository Source: https://github.com/diliprk/vedicastro/blob/main/README.md Clone the VedicAstro repository from GitHub to set up the project locally. ```bash https://github.com/diliprk/VedicAstro.git ``` -------------------------------- ### Calculate Julian Day from UTC Time Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_houses.ipynb Calculates the Julian day starting from a given UTC time, including the offset. ```python utc = swe.utc_time_zone(year, month, day, hour = hour, minutes = minute, seconds = secs, offset = utc_float) _ , jd_start = swe.utc_to_jd(*utc) ## Unpacks utc tuple current_time = jd_start ``` -------------------------------- ### Prepare DataFrames for Side-by-Side Comparison Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_planets.ipynb Selects specific columns from both Swisseph and Flatlib DataFrames and converts them to HTML for display. This is a preparatory step for visual comparison. ```python final_cols = ["Object","Rasi","LonDecDeg","SignLonDMS"] df1_html = df_swe_planets[final_cols].to_html() df2_html = df_flatlib_planets[final_cols].to_html() ``` -------------------------------- ### 422 Unprocessable Entity Error Response Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Example JSON response for a validation error. The 'detail' field indicates which fields are missing or invalid. ```json { "detail": [ { "loc": ["body", "year"], "msg": "field required", "type": "value_error.missing" } ] } ``` -------------------------------- ### Initialize VedicHoroscopeData and Generate Chart Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/README.md Instantiate the main VedicAstro class with birth details and location, then generate a horoscope chart. This is the primary entry point for astrological calculations. ```python from vedicastro import VedicAstro horoscope = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060, tz="America/New_York", ayanamsa="Krishnamurti", house_system="Placidus" ) chart = horoscope.generate_chart() planets_data = horoscope.get_planets_data_from_chart(chart) houses_data = horoscope.get_houses_data_from_chart(chart) significators = horoscope.get_planet_wise_significators(planets_data, houses_data) dasa = horoscope.compute_vimshottari_dasa(chart) aspects = horoscope.get_planetary_aspects(chart) ``` -------------------------------- ### Display help for VedicHoroscopeData Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Shows the documentation and available methods for the VedicHoroscopeData class. ```python help(VedicHoroscopeData) ``` -------------------------------- ### Get House-wise Significators Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Computes house-wise significators according to KP Astrology rules. This is useful for analyzing the significations for each house in a horoscope. ```python significators = horoscope.get_house_wise_significators(planets_data, houses_data) for sig in significators: print(f"House {sig.House}: A={sig.A}, B={sig.B}, C={sig.C}, D={sig.D}") ``` -------------------------------- ### Set Case 2 Date and Time Variables Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_planets.ipynb Initializes variables for year, month, day, hour, minute, and seconds for a specific date and time. Also sets latitude, longitude, and UTC offset for Delhi. ```python ## Case 2 year = 2000 month = 12 day = 30 hour = 22 minute = 31 secs = 59 latitude, longitude, utc_offset = 28.6334, 77.2834, "+5:30" ## Delhi ``` -------------------------------- ### Handle Missing Ephemeris Data Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/errors.md Catches exceptions that occur when Swiss Ephemeris files are not available. This typically indicates an issue with the pyswisseph installation. ```python try: horoscope = VedicAstro.VedicHoroscopeData( year=1900, month=1, day=1, hour=0, minute=0, second=0, latitude=0, longitude=0 ) chart = horoscope.generate_chart() except Exception as e: print(f"Ephemeris error: {e}") ``` -------------------------------- ### Handle Invalid Ayanamsa Error Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/README.md Example of using a try-except block to catch a TypeError when an invalid ayanamsa is provided during horoscope data initialization. ```python try: horoscope = VedicAstro.VedicHoroscopeData( 1990, 6, 15, 14, 30, 0, 40.7128, -74.0060, ayanamsa="InvalidAyanamsa" ) chart = horoscope.generate_chart() except TypeError as e: print(f"Invalid ayanamsa: {e}") ``` -------------------------------- ### Root Endpoint Information Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/endpoints.md Retrieves basic service information from the root endpoint. Use this to confirm the service is running. ```json { "message": "Welcome to VedicAstro FastAPI Service!", "info": "Visit http://127.0.0.1:8088/docs to test the API functions" } ``` -------------------------------- ### Get House-wise Significators Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Calculates and displays house-wise significators from planetary and house data. The output is a Polars DataFrame showing significators for each house. ```python house_significators_table = vhd.get_house_wise_significators(planets_data, houses_data) pl.DataFrame(house_significators_table) ``` -------------------------------- ### Get Planet-wise Significators Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Calculates and displays planet-wise significators from planetary and house data. The output is a Polars DataFrame showing significators for each planet. ```python planets_significators_table = vhd.get_planet_wise_significators(planets_data, houses_data) pl.DataFrame(planets_significators_table) ``` -------------------------------- ### Import Vedic Astro Libraries Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_planets.ipynb Imports necessary libraries for astrological calculations, including swisseph for ephemeris data and vedicastro for astrological functions. ```python import os import pandas as pd import swisseph as swe from swe_const import * from vedicastro import VedicAstro as va ``` -------------------------------- ### Get Planet-wise Significators Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Retrieves planet-wise significators based on planet and house data. Use this to understand the significations of each planet within a horoscope. ```python chart = horoscope.generate_chart() planets_data = horoscope.get_planets_data_from_chart(chart) houses_data = horoscope.get_houses_data_from_chart(chart) significators = horoscope.get_planet_wise_significators(planets_data, houses_data) for sig in significators: print(f"{sig.Planet}: A={sig.A}, B={sig.B}, C={sig.C}, D={sig.D}") ``` -------------------------------- ### House System Name to Constant Mapping Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/constants.md Maps string names of house systems (e.g., 'Placidus', 'Equal') to their corresponding constants from the flatlib library. This facilitates the selection of different house calculation methods. ```python HOUSE_SYSTEM_MAPPING = { "Placidus": const.HOUSES_PLACIDUS, "Equal": const.HOUSES_EQUAL, "Equal 2": const.HOUSES_EQUAL_2, "Whole Sign": const.HOUSES_WHOLE_SIGN, } ``` ```python from vedicastro.VedicAstro import HOUSE_SYSTEM_MAPPING system_const = HOUSE_SYSTEM_MAPPING.get("Placidus") # Returns flatlib constant for Placidus houses ``` -------------------------------- ### Get Horary Ascendant Details Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/HoraryChartStudy.ipynb Retrieves the ascendant degree and sublord for a given horary number. This is a foundational step for horary chart calculations. ```python horary_asc = horary_chart.get_horary_ascendant_degree(horary_number) desired_asc = horary_asc["ZodiacDegreeLocation"] sublord = horary_asc["SubLord"] ``` -------------------------------- ### Import necessary libraries Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Imports the required modules for Vedic astrology calculations and data handling. ```python from vedicastro.VedicAstro import VedicHoroscopeData from vedicastro.utils import pretty_data_table from pprint import pprint import polars as pl ``` -------------------------------- ### Get UTC Offset with DST Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/utils.md Retrieves the UTC offset string and timedelta for a given timezone and date, accounting for daylight saving time. ```python from vedicastro.utils import get_utc_offset from datetime import datetime tz_str, tz_delta = get_utc_offset("Asia/Kolkata", datetime(2024, 1, 1, 12, 0)) print(tz_str) # "+05:30" print(tz_delta) # 5:30:00 ny_str, ny_delta = get_utc_offset("America/New_York", datetime(2024, 7, 1, 12, 0)) print(ny_str) # "-04:00" (EDT during summer) ``` -------------------------------- ### Initialize VedicHoroscopeData and Generate Chart Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_planets.ipynb This snippet shows how to initialize the VedicHoroscopeData class with specific date, time, location, and ayanamsa details. It then generates the horoscope chart and retrieves planetary data from it. ```python vhd = va.VedicHoroscopeData(year = year, month = month, day = day, hour = hour, minute = minute, second = secs, utc = utc_offset, latitude = latitude, longitude = longitude, ayanamsa = "Krishnamurti_Senthilathiban", house_system = "Placidus") chart = vhd.generate_chart() planets_data = vhd.get_planets_data_from_chart(chart) ``` -------------------------------- ### Print Ayanamsa Flags and Values Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_planets.ipynb Demonstrates the use of different flags with the `swe.get_ayanamsa_ex_ut` function to retrieve ayanamsa values. It prints the raw flag values and the results of ayanamsa calculations with various flag combinations. ```python print(swe.FLG_SWIEPH) print(swe.FLG_SIDEREAL) print(swe.get_ayanamsa_ut(current_time)) print(swe.get_ayanamsa_ex_ut(current_time, flags = swe.FLG_SWIEPH)) print(swe.get_ayanamsa_ex_ut(current_time, flags = swe.FLG_SIDEREAL | swe.FLG_SPEED)) print(swe.get_ayanamsa_ex_ut(current_time, flags = swe.FLG_SIDEREAL + swe.FLG_SWIEPH )) print(swe.get_ayanamsa_ex_ut(current_time, flags = swe.FLG_SWIEPH | swe.FLG_SIDEREAL)[1]) ``` -------------------------------- ### Compare All Ayanamshas: SwissEPH vs Flatlib Source: https://github.com/diliprk/vedicastro/blob/main/test_suite/deg_var_check_houses.ipynb Compares all concatenated SwissEPH data with all flatlib results. Converts DataFrames to HTML and displays them side-by-side for a comprehensive overview. ```python # Convert DataFrames to HTML and concatenate them with some space in between df1_html = df_swisseph.to_html() df2_html = df_flatlib.to_html() display_side_by_side(df1_html, df2_html, localized_time, latitude, longitude, ayan = "For All") ``` -------------------------------- ### VedicHoroscopeData with Auto-Detected Timezone Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/configuration.md When `tz` is not specified, the timezone is automatically detected using TimezoneFinder based on latitude and longitude. This example uses default settings. ```python horoscope = VedicAstro.VedicHoroscopeData( year=1990, month=6, day=15, hour=14, minute=30, second=0, latitude=40.7128, longitude=-74.0060 # tz=None triggers auto-detection -> "America/New_York" ) ``` -------------------------------- ### Verify Ayanamsa and House System Settings Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Check the ayanamsa and house system attributes of the created VedicHoroscopeData object to confirm they were set correctly. ```python vhd.ayanamsa, vhd.house_system ``` -------------------------------- ### Get Vedic Planetary Aspects Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Retrieves Vedic planetary aspects and descriptive strings from planet data. Use this to analyze relationships between planets in a horoscope. ```python planets_data = horoscope.get_planets_data_from_chart(chart) vedic_aspects, descriptions = horoscope.get_planetary_aspects_vedic(planets_data) for aspect in vedic_aspects: print(f"{aspect['P1']} and {aspect['P2']} are in {aspect['Aspect']}") ``` -------------------------------- ### Import Libraries Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/AscMotionStudy.ipynb Imports necessary libraries for calculations and plotting, including flatlib, plotly, datetime, and VedicAstro. ```python from flatlib import const import plotly.graph_objects as go from datetime import datetime, timedelta from vedicastro.VedicAstro import VedicHoroscopeData ``` -------------------------------- ### Get House Data from Chart Source: https://github.com/diliprk/vedicastro/blob/main/StudyNotebooks/VedicAstroStudy.ipynb Retrieves house data for a given astrological chart and converts it into a Polars DataFrame. This is useful for analyzing the astrological houses. ```python houses_data = vhd.get_houses_data_from_chart(chart) houses_df = pl.DataFrame(houses_data) houses_df ``` -------------------------------- ### Handle Horary Charting Error Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/README.md Example of using a try-except block to catch general exceptions during horary chart analysis, such as when no matching ascendant time is found. ```python try: matched = horary_chart.find_exact_ascendant_time(...) if matched is None: print("No matching ascendant time found") except Exception as e: print(f"Horary error: {e}") ``` -------------------------------- ### Get Ayanamsa Constant Source: https://github.com/diliprk/vedicastro/blob/main/_autodocs/api-reference/VedicHoroscopeData.md Returns the ayanamsa constant from flatlib based on the configured ayanamsa string. This is useful for astrological calculations requiring specific ayanamsa systems. ```python ayanamsa_const = horoscope.get_ayanamsa() ```