def gpsTime2y_doy_hms(week, gpsTime): """ Function to convert GPS time to year, doy and hour minutes seconds """ iepy = 1980 iepd = 6 # Hour of the day ss = math.fmod(gpsTime, rtcm_ssr2osr.Constants().day_seconds) hh = np.floor(ss / 3600) # Conversion to time of year # Number of days since iepy ndy = week * 7 + np.floor( (gpsTime - ss) / rtcm_ssr2osr.Constants().day_seconds + 0.5) + iepd - 1 # Number of years since iepy ny = np.floor(ndy / 365.25) # Current year iy = np.floor(iepy + ny) # Day of the year DOY = np.floor(ndy - ny * 365.25 + 1) # Minutes ss = math.fmod(ss, 3600) mm = np.floor(ss / 60) # Seconds ss = math.fmod(ss, 60) return iy, DOY, hh, mm, ss
def ell2cart(lat, long, height): """ Coordinates transformation using WGS84 ellipsoid definition Input: - lat : ellipsoidal latitude - lon : ellipsoidal longitude - height: ellipsoidal height Output: - [x,y,z] vector of geocentric-cartesian coordinates Reference: - "Satellite Geodesy", Seeber """ h = height lat = np.radians(lat) long = np.radians(long) a = rtcm_ssr2osr.Constants().WGS84_a f = rtcm_ssr2osr.Constants().WGS84_f N_bar = a / np.sqrt(1 - f * (2 - f) * (np.sin(lat))**2) # Cartesian coordinates: x = (N_bar + h) * np.cos(lat) * np.cos(long) y = (N_bar + h) * np.cos(lat) * np.sin(long) z = (((1 - f)**2) * N_bar + h) * np.sin(lat) cart = np.array([x, y, z]) return cart
def glo_time2gps_time(glo_day, glo_time, glo_year, ls): # Moscow day -> UTC day if glo_time >= 10800.0: utc_time = glo_time - 10800.0 else: utc_time = glo_time - 10800.0 + rtcm_ssr2osr.Constants().day_seconds # compute gregorian date [day, mon, year] = glo_time2greg_day(glo_day, glo_year) # compute day of the year doy = date_to_doy(year, mon, day) # get gps week and time [gps_week, gps_time] = gps_time_from_y_doy_hms(year, doy, 0, 0, utc_time + ls) return gps_week, gps_time
def gps_time_from_y_doy_hms(year, doy, hh, mm, sec): """ Compute gps time from date as year, doy, hours, minutes, seconds """ iepy = 1980 iepd = 6 if year < 100: if year > 80: year += 1900 else: year += 2000 ndy = ((year - iepy) * 365 + doy - iepd + ((year - 1901) / 4) - ((iepy - 1901) / 4)) week = (ndy / 7) time = (round( (week - int(week)) * 7) * rtcm_ssr2osr.Constants().day_seconds + hh * 3600.0e0 + mm * 60.0e0 + sec) return int(week), time
def __init__(self, epoch, state, rec, system, ID, f1, iono): self.epoch = epoch self.sat = state[0:3] self.rec = rec self.re = rtcm_ssr2osr.Constants().re self.omega_e = rtcm_ssr2osr.Constants().omega_e # [rad/s] self.system = system self.layers = iono.n_layers for l in range(self.layers): self.height = iono.height[l] self.sh_deg = iono.degree[l] self.sh_ord = iono.order[l] self.c = iono.c[l][:] self.s = iono.s[l][:] [lat_sph, lon_sph, height_sph, el, az, psi_pp, lambda_pp, phi_pp, sf, sun_shift, lon_s, p_nm, p_cos, p_sin, m, n, vtec] = IonoComputation.compute_global_iono(self) stec = vtec * sf self.stec_corr_f1 = 40.3 * 1e16 / (f1 * f1) * stec strg = ('### SV pos/vel for SV ' + ID + ' at ' + f'{epoch}' + ': ' + '{:16.4f}'.format(state[0]) + ' ' + '{:16.4f}'.format(state[1]) + ' ' + '{:16.4f}'.format(state[2]) + ' [m]' + ' ' + '{:9.4f}'.format(state[3]) + ' ' + '{:9.4f}'.format(state[4]) + ' ' + '{:9.4f}'.format(state[5]) + ' [m/s]' + '\n' + 'PPt at t=' + f'{epoch}' + '(sun shift= ' + '{:11.8f}'.format(sun_shift * 180 / np.pi) + ' deg)' + ' \n' + 'PPt from Ref phi_R= ' + '{:11.8f}'.format(lat_sph * 180 / np.pi) + ' lam_R=' + '{:11.8f}'.format(lon_sph * 180 / np.pi) + ' rE+hR= ' + '{:10.3f}'.format(height_sph + 6370000) + '(spherical!)' + '\n' + 'PPt from Ref to SV at elev= ' + '{:11.8f}'.format(el * 180 / np.pi) + ' azim ' + '{:11.8f}'.format(az * 180 / np.pi) + '(spherical!)' + '\n' + 'PPt psi_pp= ' + '{:11.8f}'.format(psi_pp * 180 / np.pi) + ' phi_pp ' + '{:11.8f}'.format(phi_pp * 180 / np.pi) + ' lam_pp ' + '{:11.8f}'.format(lambda_pp * 180 / np.pi) + ' lon_S ' + '{:11.8f}'.format(lon_s * 180 / np.pi) + ' rE+hI: ' + '{:10.3f}'.format(self.height * 1000 + 6370000) + '\n' 'Pnm : ') # Lagrange Polynomials for o in range(len(p_nm)): m_ind = int(m[o]) n_ind = int(n[o]) strg = (strg + 'P(' + f'{n_ind}' + ',' + f'{m_ind}' + ')=' + '{:7.4f}'.format(p_nm[o]) + '; ') # Cosines strg = strg + '\n' + 'Pcos: ' for o in range(len(p_cos)): m_ind = int(m[o]) n_ind = int(n[o]) strg = (strg + 'P(' + f'{n_ind}' + ',' + f'{m_ind}' + ')=' + '{:7.4f}'.format(p_cos[o]) + '; ') # Sines strg = strg + '\n' + 'Psin: ' for o in range(len(p_sin)): m_ind = int(m[o]) n_ind = int(n[o]) strg = (strg + 'P(' + f'{n_ind}' + ',' + f'{m_ind}' + ')=' + '{:7.4f}'.format(p_sin[o]) + '; ') # Ionosphere self.strg = (strg + '\n'+ 'Sum VTEC=' + '{:6.3f}'.format(vtec) + '[TECU]' + ',' + ' sf=' + '{:6.3f}'.format(sf) + ',' + 'STEC=' + '{:6.3f}'.format(stec) + '[TECU]' + '\n' + 'SSR_VTEC: SV' + ID + ' Have SSR VTEC Iono slant influence: ' + '{:6.3f}'.format(stec) + '[TECU]' + '{:6.3f}'.format(self.stec_corr_f1) + '[m-L1]')