def get_observer_look(sat_lon, sat_lat, sat_alt, utc_time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ utc_time: Observation time (datetime object) lon: Longitude of observer position on ground in degrees east lat: Latitude of observer position on ground in degrees north alt: Altitude above sea-level (geoid) of observer position on ground in km Return: (Azimuth, Elevation) """ (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = astronomy.observer_position( utc_time, sat_lon, sat_lat, sat_alt) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(utc_time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(utc_time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + \ sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + \ cos_lat * sin_theta * ry + sin_lat * rz az_ = np.arctan(-top_e / top_s) if has_xarray and isinstance(az_, xr.DataArray): az_data = az_.data else: az_data = az_ if has_dask and isinstance(az_data, da.Array): az_data = da.where(top_s > 0, az_data + np.pi, az_data) az_data = da.where(az_data < 0, az_data + 2 * np.pi, az_data) else: az_data[np.where(top_s > 0)] += np.pi az_data[np.where(az_data < 0)] += 2 * np.pi if has_xarray and isinstance(az_, xr.DataArray): az_.data = az_data else: az_ = az_data rg_ = np.sqrt(rx * rx + ry * ry + rz * rz) el_ = np.arcsin(top_z / rg_) return np.rad2deg(az_), np.rad2deg(el_)
def get_observer_look(sat_lon, sat_lat, sat_alt, utc_time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ :utc_time: Observation time (datetime object) :lon: Longitude of observer position on ground in degrees east :lat: Latitude of observer position on ground in degrees north :alt: Altitude above sea-level (geoid) of observer position on ground in km :return: (Azimuth, Elevation) """ (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = astronomy.observer_position( utc_time, sat_lon, sat_lat, sat_alt) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(utc_time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(utc_time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + \ sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + \ cos_lat * sin_theta * ry + sin_lat * rz az_ = np.arctan(-top_e / top_s) if has_xarray and isinstance(az_, xr.DataArray): az_data = az_.data else: az_data = az_ if has_dask and isinstance(az_data, da.Array): az_data = da.where(top_s > 0, az_data + np.pi, az_data) az_data = da.where(az_data < 0, az_data + 2 * np.pi, az_data) else: az_data[np.where(top_s > 0)] += np.pi az_data[np.where(az_data < 0)] += 2 * np.pi if has_xarray and isinstance(az_, xr.DataArray): az_.data = az_data else: az_ = az_data rg_ = np.sqrt(rx * rx + ry * ry + rz * rz) el_ = np.arcsin(top_z / rg_) return np.rad2deg(az_), np.rad2deg(el_)
def get_observer_look(sat_lon, sat_lat, sat_alt, utc_time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ utc_time: Observation time (datetime object) lon: Longitude of observer position on ground in degrees east lat: Latitude of observer position on ground in degrees north alt: Altitude above sea-level (geoid) of observer position on ground in km Return: (Azimuth, Elevation) """ utc_time = dt2np(utc_time) (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = astronomy.observer_position( utc_time, sat_lon, sat_lat, sat_alt) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(utc_time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(utc_time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + \ sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + \ cos_lat * sin_theta * ry + sin_lat * rz az_ = np.arctan(-top_e / top_s) az_ = np.where(top_s > 0, az_ + np.pi, az_) az_ = np.where(az_ < 0, az_ + 2 * np.pi, az_) rg_ = np.sqrt(rx * rx + ry * ry + rz * rz) el_ = np.arcsin(top_z / rg_) return np.rad2deg(az_), np.rad2deg(el_)
def getDistance(self, satID, time, lat, lon, alt): (lon2, lat2, alt2) = self.orbByID[satID].get_lonlatalt(time) (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = astronomy.observer_position(time, lon2, lat2, alt2) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(time, lon, lat, alt) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z vx = vel_x - ovel_x vy = vel_y - ovel_y vz = vel_z - ovel_z r = math.sqrt(rx * rx + ry * ry + rz * rz) v = math.sqrt(vx * vx + vy * vy + vz * vz) return (alt2, r, v)
def get_observer_look(self, time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ time: Observation time (datetime object) lon: Longitude of observer position on ground lat: Latitude of observer position on ground alt: Altitude above sea-level (geoid) of observer position on ground Return: (Azimuth, Elevation) """ (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = self.get_position(time, normalize=False) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z rvx = vel_x - ovel_x rvy = vel_y - ovel_y rvz = vel_z - ovel_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + cos_lat * sin_theta * ry + sin_lat * rz az = np.arctan(-top_e / top_s) if top_s > 0: az = az + np.pi if az < 0: az = az + 2 * np.pi rg = np.sqrt(rx * rx + ry * ry + rz * rz) el = np.arcsin(top_z / rg) w = (rx * rvx + ry * rvy + rz * rvz) / rg return np.rad2deg(az), np.rad2deg(el)
def get_observer_look(self, utc_time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ utc_time: Observation time (datetime object) lon: Longitude of observer position on ground in degrees east lat: Latitude of observer position on ground in degrees north alt: Altitude above sea-level (geoid) of observer position on ground in km Return: (Azimuth, Elevation) """ utc_time = dt2np(utc_time) (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = self.get_position( utc_time, normalize=False) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(utc_time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(utc_time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + \ sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + \ cos_lat * sin_theta * ry + sin_lat * rz az_ = np.arctan(-top_e / top_s) az_ = np.where(top_s > 0, az_ + np.pi, az_) az_ = np.where(az_ < 0, az_ + 2 * np.pi, az_) rg_ = np.sqrt(rx * rx + ry * ry + rz * rz) el_ = np.arcsin(top_z / rg_) return np.rad2deg(az_), np.rad2deg(el_)
def get_observer_look(self, time, lon, lat, alt): """Calculate observers look angle to a satellite. http://celestrak.com/columns/v02n02/ time: Observation time (datetime object) lon: Longitude of observer position on ground lat: Latitude of observer position on ground alt: Altitude above sea-level (geoid) of observer position on ground Return: (Azimuth, Elevation) """ (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = self.get_position(time, normalize=False) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(time, lon, lat, alt) lon = np.deg2rad(lon) lat = np.deg2rad(lat) theta = (astronomy.gmst(time) + lon) % (2 * np.pi) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z rvx = vel_x - ovel_x rvy = vel_y - ovel_y rvz = vel_z - ovel_z sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * rx + sin_lat * sin_theta * ry - cos_lat * rz top_e = -sin_theta * rx + cos_theta * ry top_z = cos_lat * cos_theta * rx + cos_lat * sin_theta * ry + sin_lat * rz az = np.arctan(-top_e / top_s) if top_s > 0: az = az + np.pi if az < 0: az = az + 2 * np.pi rg = np.sqrt(rx * rx + ry * ry + rz * rz) el = np.arcsin(top_z / rg) w = (rx * rvx + ry * rvy + rz * rvz) / rg return np.rad2deg(az), np.rad2deg(el)
def getDistance(self, satID, time, lat, lon, alt): # Get satellite position (lat/lon/altitude) (lon2, lat2, alt2) = self.orbByID[satID].get_lonlatalt(time) (pos_x, pos_y, pos_z), (vel_x, vel_y, vel_z) = \ self.orbByID[satID].get_position(time, normalize=False) (opos_x, opos_y, opos_z), (ovel_x, ovel_y, ovel_z) = \ astronomy.observer_position(time, lon, lat, alt) rx = pos_x - opos_x ry = pos_y - opos_y rz = pos_z - opos_z vx = vel_x - ovel_x vy = vel_y - ovel_y vz = vel_z - ovel_z r = math.sqrt(rx * rx + ry * ry + rz * rz) v = math.sqrt(vx * vx + vy * vy + vz * vz) v_r = (rx * vx + ry * vy + rz * vz) / (r) # Radial projection return (alt2, r, v, v_r)
def findtask(norad_id, observation_time, LAT, LONG, ALT): id = norad_id id = id.rjust(5) counter = 0 with open('3le.txt', 'r') as TLEs: for line in TLEs: if line[2:7] == id and counter == 0: # print(line) line1 = line counter = 1 elif line[2:7] == id and counter == 1: line2 = line # print(line) break R_site_ECI, V_site_ECI = observer_position(observation_time, LONG, LAT, ALT) sat = satellite.get_sat(line1, line2) R_sat_ECI, V_sat_ECI = sat.propagate(observation_time.year, observation_time.month, observation_time.day, observation_time.hour, observation_time.minute, (observation_time.second + observation_time.microsecond * 10 ** (-6))) delta_R = np.array([[R_sat_ECI[0] - R_site_ECI[0]], [R_sat_ECI[1] - R_site_ECI[1]], [R_sat_ECI[2] - R_site_ECI[2]]]) delta_V = np.array([[V_sat_ECI[0] - V_site_ECI[0]], [V_sat_ECI[1] - V_site_ECI[1]], [V_sat_ECI[2] - V_site_ECI[2]]]) utc_time = dt2np(observation_time) lon = np.deg2rad(LONG) lat = np.deg2rad(LAT) theta = (astronomy.gmst(utc_time) + lon) % (2 * np.pi) sin_lat = np.sin(lat) cos_lat = np.cos(lat) sin_theta = np.sin(theta) cos_theta = np.cos(theta) top_s = sin_lat * cos_theta * delta_R[0] + \ sin_lat * sin_theta * delta_R[1] - cos_lat * delta_R[2] top_e = -sin_theta * delta_R[0] + cos_theta * delta_R[1] top_z = cos_lat * cos_theta * delta_R[0] + \ cos_lat * sin_theta * delta_R[1] + sin_lat * delta_R[2] az_ = np.arctan(-top_e / top_s) az_ = np.where(top_s > 0, az_ + np.pi, az_) az_ = np.where(az_ < 0, az_ + 2 * np.pi, az_) rg_ = np.sqrt(top_s * top_s + top_e * top_e + top_z * top_z) el_ = np.arcsin(top_z / rg_) AZ = np.rad2deg(az_) EL = np.rad2deg(el_) mag_delta_R = math.sqrt(delta_R[0] ** 2 + delta_R[1] ** 2 + delta_R[2] ** 2) unit_delta_R = np.array([delta_R[0] / mag_delta_R, delta_R[1] / mag_delta_R, delta_R[2] / mag_delta_R]) V_orth_R_ECI = logical_cross(logical_cross(unit_delta_R, delta_V), unit_delta_R) total_look_angular_rate = (math.sqrt(V_orth_R_ECI[0] ** 2 + V_orth_R_ECI[1] ** 2 + V_orth_R_ECI[2] ** 2) / \ math.sqrt(delta_R[0] ** 2 + delta_R[1] ** 2 + delta_R[2] ** 2)) * (180.0 / math.pi) exposure_time = 0.955/total_look_angular_rate if exposure_time > 10: exposure_time = 10 return [AZ[0], EL[0], total_look_angular_rate, exposure_time]