def draw_chart(obs_loc, t, alpha=0.3): lon, lat = obs_loc df = pd.read_csv(StringIO(hip_stars)).set_index('hip') marker_size = (0.5 + 7 - df['Vmag'].values)**2.0 t = t.isoformat()[:19].replace('T', ' ') alt, az = radec_to_altaz(lon=lon, lat=lat, ra=df['ra'], dec=df['dec'], t=t) new_df = pd.DataFrame({ 'hip': df.index.values, 'az': az, 'alt': alt, 'Vmag': df['Vmag'].values }) new_df = new_df.set_index('hip') bright_df = new_df[new_df['Vmag'] < 5] xy1 = new_df[['az', 'alt']].loc[edge1].values xy2 = new_df[['az', 'alt']].loc[edge2].values xy1[:, 0] = xy1[:, 0] * (np.pi / 180) xy2[:, 0] = xy2[:, 0] * (np.pi / 180) lines_xy = np.array([*zip(xy1, xy2)]) ax = plot_altaz(bright_df['az'], bright_df['alt'], mag=bright_df['Vmag']) ax.add_collection(LineCollection(lines_xy, alpha=alpha)) plt.show()
def planet(body, obs_loc, t=None): if t is None: t = datetime.utcnow() body = body.lower() if not body in solar_system_ephemeris.bodies: raise Exception("Body not available!") if type(obs_loc) == str and obs_loc in cities.keys(): lon, lat = cities[obs_loc][:-1] elif isinstance(obs_loc, tuple): if len(obs_loc) == 2: lon, lat = obs_loc else: raise Exception("obs_loc should be in the format: (lon, lat)") else: raise Exception( "obs_loc should be a city name or geographic coordiantes.") loc = EarthLocation(lon=lon, lat=lat) with solar_system_ephemeris.set('jpl'): crd = get_body(body, Time(t), loc) ra = crd.ra.value dec = crd.dec.value r = crd.distance.value x, y, z = radec_to_cartesian(ra, dec, r) alt, az = radec_to_altaz(lon=lon, lat=lat, ra=ra, dec=dec, t=t) return (x, y, z), (ra, dec, r), (az, alt)
def planets(body, loc, t, tt): with solar_system_ephemeris.set('jpl'): crd = get_body(body, tt, loc) ra = crd.ra.value dec = crd.dec.value r = crd.distance.value x, y, z = radec_to_cartesian(ra, dec, r) alt, az = radec_to_altaz(lon=lon, lat=lat, ra=ra, dec=dec, t=t) return (x, y, z), (ra, dec, r), (az, alt)
#======================================== import matplotlib.pyplot as plt from matplotlib.collections import LineCollection from hypatie.plots import plot_radec, plot_altaz from hypatie.transform import radec_to_altaz from hypatie.data import cities lon, lat = cities['strasbourg'][:2] marker_size = (0.5 + 7 - df['Vmag'].values)**2.0 t = t.utc_datetime().isoformat()[:19].replace('T', ' ') alt, az = radec_to_altaz(lon=lon, lat=lat, ra=df['ra'], dec=df['dec'], t=t) new_df = pd.DataFrame({ 'hip': df.index.values, 'az': az, 'alt': alt, 'Vmag': df['Vmag'].values }) new_df = new_df.set_index('hip') xy1 = new_df[['az', 'alt']].loc[edges_star1].values xy2 = new_df[['az', 'alt']].loc[edges_star2].values #lines_xy = np.rollaxis(np.array([xy1, xy2]), 1) xy1[:, 0] = xy1[:, 0] * (np.pi / 180) xy2[:, 0] = xy2[:, 0] * (np.pi / 180) lines_xy = np.array([*zip(xy1, xy2)])
ra, dec = radec_to_tete(RA, DEC, t) ha = get_ha(ra, dec, (lon, lat), t) from astropy.coordinates import SkyCoord, EarthLocation, AltAz, HADec from astropy.time import Time from astropy import units as u tt = Time(t) c = SkyCoord(ra=ra, dec=dec, unit='deg') #c = c.tete me = EarthLocation(lon=lon, lat=lat) hadec = HADec(location=me, obstime=tt) cc = c.transform_to(hadec) print('Behrouz Hour angle:', ha) print('Astropy Hour angle:', cc.ha.deg) from hypatie.transform import radec_to_altaz az, alt = radec_to_altaz(ra, dec, (lon, lat), t) print(az, alt) aa = AltAz(location=me, obstime=tt) ccc = c.transform_to(aa) print(ccc.az.value, ccc.alt.value) #=================================================== ast_ha = cc.ha.deg ast_az_alt = (ccc.az.value, ccc.alt.value)