def test_functions(self): system = gpstk.Position.Cartesian ell = gpstk.PZ90Ellipsoid() frame = gpstk.ReferenceFrame(gpstk.ReferenceFrame.PZ90) p = gpstk.Position(10000.0, 150000.0, 200000.0, system, ell, frame) q = gpstk.Position(20000.0, 160000.0, 190000.0, system, ell, frame) self.assertAlmostEqual(1.32756277187, q.elevation(p)) self.assertAlmostEqual(86.18592516570916, p.getPhi()) self.assertAlmostEqual(57.5141089193572, p.geodeticLatitude()) self.assertAlmostEqual(10000.0, p.X())
def test_pole_tides(self): t = gpstk.CivilTime(2000).toCommonTime() p = gpstk.Position(1000.0, 2000.0, 3000.0) x = 5.0 y = 10.0 trip = gpstk.poleTides(t, p, x, y) self.assertAlmostEqual(-0.03128457731297798, trip[0])
def set_defaults(self, pTrop): # from Tropdump.cpp # trop model and weather # tropstr = "Global,20,1013,50" # use tropName instead Temp = 20.0 Press = 1013. Humid = 50. elevmin = 3.0 elevmax = 90.0 delev = 1.5 # position #refPosstr = "-740376.5046,-5457019.3545,3207315.7299" # ARL:UT, in ECEF refPosstr_x = -740376.5046 refPosstr_y = -5457019.3545 refPosstr_z = 3207315.7299 #timestr = "2017,103,0.0" doy = 103 # set up weather pTrop.setWeather(Temp,Press,Humid) # set up position refPos = gpstk.Position() refPos.setECEF(refPosstr_x, refPosstr_y, refPosstr_z) pTrop.setReceiverHeight(refPos.getHeight()) pTrop.setReceiverLatitude(refPos.getGeodeticLatitude()) pTrop.setReceiverLongitude(refPos.getLongitude()) # set up doy pTrop.setDayOfYear(doy) return pTrop, elevmin, elevmax, delev
def test_cartesian_geodetic(self): a = gpstk.PZ90Ellipsoid().a() eccSq = gpstk.PZ90Ellipsoid().eccSquared() orig = gpstk.Position(100000.0, 20000.0, 30000.0) p = gpstk.Position.convertCartesianToGeodetic(orig, a, eccSq) q = gpstk.Position.convertGeodeticToCartesian(p, a, eccSq) self.assertAlmostEqual(25.33498527029081, p[0], places=4) self.assertAlmostEqual(11.30993247402015, p[1], places=4) self.assertAlmostEqual(-6269217.08416736, p[2], places=4) self.assertAlmostEqual(99999.26269737557, q[0], places=4) self.assertAlmostEqual(19999.85253947465, q[1], places=4) self.assertAlmostEqual(29999.83821484564, q[2], places=4)
def test_geocentric_geodetic(self): a = gpstk.PZ90Ellipsoid().a() eccSq = gpstk.PZ90Ellipsoid().eccSquared() orig = gpstk.Position(40.0, 100.0, 2.5e5, gpstk.Position.Geocentric) p = gpstk.Position.convertGeocentricToGeodetic(orig, a, eccSq) q = gpstk.Position.convertGeodeticToGeocentric(p, a, eccSq) self.assertAlmostEqual(44.90696703221949, p[0], places=4) self.assertAlmostEqual(100.0, p[1], places=4) self.assertAlmostEqual(-6118405.153409380, p[2], places=4) self.assertAlmostEqual(40.00000265961031, q[0], places=4) self.assertAlmostEqual(100.0, q[1], places=4) self.assertAlmostEqual(249998.49546297366, q[2], places=4)
def main(): # Read in data, strict=True makes dataSets a list rather than a generator: header, dataSets = gpstk.readSEM('sem_data.txt', strict=True) # Write the data back to a different file (their contents should match): gpstk.writeSEM('sem_data.txt.new', header, dataSets) # Read the orbit out of the data: orbit = dataSets[0].toAlmOrbit() # alm orbit of first data point austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic) # Austin, TX starttime = gpstk.CommonTime() # iterator time to start at starttime.setTimeSystem(gpstk.TimeSystem('GPS')) endtime = gpstk.CommonTime() # end time, 1 day later (see below) endtime.setTimeSystem(gpstk.TimeSystem('GPS')) endtime.addDays(1) X = [] Y = [] # Step through a day, adding plot points: for t in gpstk.times(starttime, endtime, seconds=1000): xvt = orbit.svXvt(t) location = gpstk.Position(xvt.x) elevation = austin.elevation(location) X.append(t.getDays()) Y.append(elevation) # Make the plot fig = plt.figure() fig.suptitle('Elevation of a GPS satellite throughout the day', fontsize=14, fontweight='bold') ax = fig.add_subplot(111) ax.set_xlabel('Time (days)') ax.set_ylabel('Elevation (degrees)') plt.plot(X, Y, 'r') plt.show()
def test(self): p1 = gpstk.Position(1.5, 6.2, 3.5) p2 = gpstk.Position(1.0, 1.8, 0.5) self.assertAlmostEqual(5.348831648126533, gpstk.range(p1, p2))
def test_solid_tides(self): t = gpstk.CivilTime(2000).toCommonTime() p = gpstk.Position(1000.0, 2000.0, 3000.0) trip = gpstk.solidTides(t, p) self.assertAlmostEqual(-2.2479508782610997e-15, trip[0])
def triple2Position(x): return gpstk.Position(x[0], x[1], x[2])
def getdata(nfile, ofile, strsat=None): #one week data f1, f2 = gpstk.L1_FREQ_GPS, gpstk.L2_FREQ_GPS alfa = 1.0 / ((f1**2 / f2**2) - 1) t = [] #observation epoch on code and phase Iphase, Icode, IPPS = {}, {}, { } #dicc: key=time observer; values=iono delay and IPP VTECphase, VTECcode, ELEV = {}, {}, {} PhaseL1, PhaseL2 = {}, {} CodeL1, CodeL2 = {}, {} oheader, odata = gpstk.readRinex3Obs(ofile, strict=True) nheader, ndata = gpstk.readRinex3Nav(nfile) bcestore = gpstk.GPSEphemerisStore() for ndato in ndata: ephem = ndato.toGPSEphemeris() bcestore.addEphemeris(ephem) bcestore.SearchNear() for observation in odata: sats = [ satID for satID, datumList in observation.obs.iteritems() if str(satID).split()[0] == "GPS" ] obs_types = np.array([i for i in oheader.R2ObsTypes]) if 'C1' and 'P2' and 'L1' and 'L2' in obs_types: for sat in sats: if str(sat) == strsat: #Return for a specific satellite eph = bcestore.findEphemeris(sat, observation.time) Tgd = eph.Tgd sat_pos = eph.svXvt(observation.time) rec_pos = gpstk.Position( oheader.antennaPosition[0], oheader.antennaPosition[1], oheader.antennaPosition[2]).asECEF() elev = oheader.antennaPosition.elvAngle(sat_pos.x) azim = oheader.antennaPosition.azAngle(sat_pos.x) time = observation.time R = 6.378e6 #earth radius mapp = 1 / np.cos( np.arcsin(R / (R + 350000)) * np.sin(elev)) IPP = rec_pos.getIonosphericPiercePoint( elev, azim, 350000).asECEF() t.append(np.trunc(gpstk.YDSTime(time).sod)) if np.size(np.where(obs_types == 'C1')) > 0 and np.size( np.where(obs_types == 'P2')) > 0 and np.size( np.where(obs_types == 'L1')) > 0 and np.size( np.where(obs_types == 'L2')) > 0: C1_idx = np.where(obs_types == 'C1')[0][0] P2_idx = np.where(obs_types == 'P2')[0][0] R1 = observation.getObs(sat, C1_idx).data R2 = observation.getObs(sat, P2_idx).data L1_idx = np.where(obs_types == 'L1')[0][0] L2_idx = np.where(obs_types == 'L2')[0][0] L1 = observation.getObs( sat, L1_idx).data * gpstk.L1_WAVELENGTH_GPS L2 = observation.getObs( sat, L2_idx).data * gpstk.L2_WAVELENGTH_GPS if R2 < 3e7 and R1 < 3e7 and L2 < 3e7 and L1 < 3e7: #Distances should be in order of 1e7 meters, more than that is considered an error iono_delay_c = alfa * (R2 - R1) iono_delay_p = alfa * (L1 - L2) vtec_C = iono_delay_c / mapp vtec_P = iono_delay_p / mapp VTECcode[np.trunc( gpstk.YDSTime(time).sod)] = vtec_C VTECphase[np.trunc( gpstk.YDSTime(time).sod)] = vtec_P Icode[np.trunc( gpstk.YDSTime(time).sod)] = iono_delay_c Iphase[np.trunc( gpstk.YDSTime(time).sod)] = iono_delay_p ELEV[np.trunc(gpstk.YDSTime(time).sod)] = elev IPPS[np.trunc(gpstk.YDSTime(time).sod)] = IPP PhaseL1[np.trunc(gpstk.YDSTime(time).sod)] = L1 PhaseL2[np.trunc(gpstk.YDSTime(time).sod)] = L2 CodeL1[np.trunc(gpstk.YDSTime(time).sod)] = R1 CodeL2[np.trunc(gpstk.YDSTime(time).sod)] = R2 #stec=(iono_delay_p*f1**2)/(-40.3) #STEC delay on phase [mm] #vtec=stec/mapp #vertical delay! else: print "Needs both L1 and L2 frequencies to compute delay" break return t, Icode, Iphase, VTECphase, ELEV, IPPS, PhaseL1, PhaseL2, CodeL1, CodeL2, Tgd
python sem_plot.py """ import gpstk from matplotlib.pyplot import figure, show # Read in data, strict=True makes dataSets a list rather than a generator: header, dataSets = gpstk.readSEM("data/sem_data.txt", strict=True) # Write the data back to a different file (their contents should match): gpstk.writeSEM("sem_data.txt.new", header, dataSets) # Read the orbit out of the data: orbit = dataSets[0].toAlmOrbit() # alm orbit of first data point austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic) # Austin, TX starttime = gpstk.CommonTime() # iterator time to start at starttime.setTimeSystem(gpstk.TimeSystem("GPS")) endtime = gpstk.CommonTime() # end time, 1 day later (see below) endtime.setTimeSystem(gpstk.TimeSystem("GPS")) endtime.addDays(1) # %% Step through a day, adding plot points: d = [] el = [] for t in gpstk.times(starttime, endtime, seconds=1000): d.append(t.getDays()) xvt = orbit.svXvt(t) location = gpstk.Position(xvt.x) el.append(austin.elevation(location))