How to Install Astropy Python package on iOS?

6 days ago 6
ARTICLE AD BOX

I am trying to run a Python script on my iPhone and iPad that uses the Astropy package. I have installed both Pythonista and Juno. Juno supposedly has it installed but I get errors from it. The script I am trying to run is pretty straight forward and below. It does run on a desktop so there are no bugs in it.

import astropy.units as u from astropy.coordinates import EarthLocation, SkyCoord, AltAz from astropy.time import Time import requests def get_equatorial_coords(): # 1. Define the Observer's Location: Roseville, California # Lat/Lon for Roseville, CA # location = EarthLocation(lat=38.7521*u.deg, lon=-121.2859*u.deg, height=50*u.m) try: # Use ip-api.com (free, no API key required for low volume) response = requests.get("http://ip-api.com/json/") data = response.json() if data['status'] == 'success': lat = data['lat'] lon = data['lon'] city = data['city'] region = data['regionName'] # Create the Astropy EarthLocation object # Note: height is set to 0 as IP geo usually doesn't provide altitude location = EarthLocation(lat=lat * u.deg, lon=lon * u.deg, height=0 * u.m) finally: print(f"Detected Location: {city}, {region}") print(f"Coordinates: {lat}, {lon}") # location = get_location_by_ip() # 2. Get the current system time (UTC) current_time = Time.now() print(f"--- Observation Details ---") print(f"Location: Roseville, CA") print(f"System Time (UTC): {current_time}") print("-" * 27) # 3. Request Target Input from User try: user_az = float(input("Enter azimuth 0.0 to 180.0: ")) user_alt = float(input("Enter altitude 0.0 to 90.0: ")) except ValueError: print("Invalid input. Please enter numerical values.") return # 4. Create an AltAz frame for the specific time and location altaz_frame = AltAz(obstime=current_time, location=location) # 5. Define the target in the AltAz system target_altaz = SkyCoord(az=user_az*u.deg, alt=user_alt*u.deg, frame=altaz_frame) # 6. Transform to Equatorial Coordinates (ICRS/J2000) target_icrs = target_altaz.transform_to('icrs') print(f"\n--- Results ---") print(f"Right Ascension (RA): {target_icrs.ra.to_string(unit=u.hour, sep='hms')}") print(f"Declination (Dec): {target_icrs.dec.to_string(unit=u.deg, sep='dms')}") if __name__ == "__main__": get_equatorial_coords()
Read Entire Article