예제 #1
0
def testing_sp3(gpstime, sp3, systemsatlists, obsdata, obstypes, prntoidx,
                year, month, day, emin, emax, outputfile, up, East, North,
                recv, dec_rate, log):
    """
    inputs are gpstime( numpy array with week and sow)
    sp3 is what has been read from the sp3 file
    columsn are satNu, week, sow, x, y, z (in meters)
    log is for comments
    """
    checkD = False
    if dec_rate > 0:
        checkD = True
        log.write('You are decimating \n')
    # epoch at the beginning of the day of your RINEX file
    gweek0, gpssec0 = g.kgpsweek(year, month, day, 0, 0, 0)

    ll = 'quadratic'
    #   will store in this variable, then sort it before writing out to a file
    saveit = np.empty(shape=[0, 11])
    fout = open(outputfile, 'w+')
    NsatT = 0
    # make a dictionary for constellation name
    sname = {}
    sname['G'] = 'GPS'
    sname['R'] = 'GLONASS'
    sname['E'] = 'GALILEO'
    sname['C'] = 'BEIDOU'
    for con in ['G', 'E', 'R', 'C']:
        if con in obstypes:
            satL = len(systemsatlists[con][:])
            satS = 'Processing ' + sname[con]
            with Bar(satS, max=satL, fill='@', suffix='%(percent)d%%') as bar:
                log.write(
                    'Good news - found data for constellation {0:s} \n'.format(
                        con))
                obslist = obstypes[con][:]
                satlist = systemsatlists[con][:]
                for prn in satlist:
                    bar.next()
                    addon = g.findConstell(
                        con)  # 100,200,or 300 for R,E, and C
                    log.write(
                        'Constellation {0:1s} Satellite {1:2.0f}  Addon {2:3.0f} \n'
                        .format(con, prn, addon))
                    # window out the data for this satellite
                    m = sp3[:, 0] == prn + addon
                    x = sp3[m, 3]
                    if len(x) > 0:
                        sp3_week = sp3[m, 1]
                        sp3_sec = sp3[m, 2]
                        x = sp3[m, 3]
                        y = sp3[m, 4]
                        z = sp3[m, 5]
                        # fit the orbits for this satellite
                        t = sp3_sec
                        iX = interp1d(t,
                                      x,
                                      ll,
                                      bounds_error=False,
                                      fill_value='extrapolate')
                        iY = interp1d(t,
                                      y,
                                      ll,
                                      bounds_error=False,
                                      fill_value='extrapolate')
                        iZ = interp1d(t,
                                      z,
                                      ll,
                                      bounds_error=False,
                                      fill_value='extrapolate')
                        # get the S1 data for this satellite
                        if 'S1' in obslist:
                            s1 = obsdata[con]['S1'][:, prntoidx[con][prn]]

        # indices when there are no data for this satellite
                        ij = np.isnan(s1)
                        # indices when there are data in the RINEX file - this way you do not compute
                        # orbits unless there are data.
                        not_ij = np.logical_not(ij)
                        Tp = gpstime[
                            not_ij,
                            1]  # only use the seconds of the week for now
                        s1 = s1[not_ij]
                        #print(s1.shape)
                        emp = np.zeros(shape=[len(s1), 1], dtype=float)
                        # get the rest of the SNR data in a function
                        s2, s5, s6, s7, s8 = extract_snr(
                            prn, con, obslist, obsdata, prntoidx, not_ij, emp)
                        # make sure there are no nan values in s2 or s5

                        nepochs = len(Tp)
                        for ij in range(0, nepochs):
                            TT = 0  # default value
                            if checkD:
                                TT = Tp[ij] % dec_rate  # get the modulus
                            if TT == 0:
                                SatOrb = satorb_prop_sp3(
                                    iX, iY, iZ, recv, Tp, ij)
                                r = np.subtract(SatOrb, recv)
                                azimA = g.azimuth_angle(r, East, North)
                                eleA = g.elev_angle(up, r) * 180 / np.pi
                                if (eleA >= emin) and (eleA <= emax):
                                    fout.write(
                                        "{0:3.0f} {1:10.4f} {2:10.4f} {3:10.0f} {4:7.2f} {5:7.2f} {6:7.2f} {7:7.2f} {8:7.2f} {9:7.2f} {10:7.2f} \n"
                                        .format(prn + addon, eleA, azimA,
                                                Tp[ij] - gpssec0, 0,
                                                float(s6[ij]), s1[ij],
                                                float(s2[ij]), float(s5[ij]),
                                                float(s6[ij]), float(s7[ij])))
                    else:
                        log.write(
                            'This satellite is not in the orbit file. {0:3.0f} \n'
                            .format(prn))
        else:
            log.write('No data for constellation {0:1s} \n'.format(con))
    log.write('write SNR data to file \n')
    fout.close()
예제 #2
0
def test_sp3(gpstime, sp3, systemsatlists, obsdata, obstypes, prntoidx, year,
             month, day, emin, emax, outputfile, up, East, North, recv,
             dec_rate):
    """
    inputs are gpstime( numpy array with week and sow)
    sp3 is what has been read from the sp3 file
    columsn are satNu, week, sow, x, y, z (in meters)
    """
    checkD = False
    if dec_rate > 0:
        checkD = True
        print('decimating')
    # epoch at the beginning of the day of your RINEX file
    gweek0, gpssec0 = g.kgpsweek(year, month, day, 0, 0, 0)

    ll = 'quadratic'
    #   will store in this variable, then sort it before writing out to a file
    saveit = np.empty(shape=[0, 11])
    fout = open(outputfile, 'w+')
    for con in ['G', 'E', 'R', 'C']:
        if con in obstypes:
            print('good news - found data for constellation ', con)
            obslist = obstypes[con][:]
            satlist = systemsatlists[con][:]
            print(satlist)
            for prn in satlist:
                addon = g.findConstell(con)  # 100,200,or 300 for R,E, and C
                print('Constellation ', con, ' satellite ', prn, addon)
                # window out the data for this satellite
                m = sp3[:, 0] == prn + addon
                x = sp3[m, 3]
                if len(x) > 0:
                    sp3_week = sp3[m, 1]
                    sp3_sec = sp3[m, 2]
                    x = sp3[m, 3]
                    y = sp3[m, 4]
                    z = sp3[m, 5]
                    # fit the orbits for this satellite
                    t = sp3_sec
                    iX = interp1d(t,
                                  x,
                                  ll,
                                  bounds_error=False,
                                  fill_value='extrapolate')
                    iY = interp1d(t,
                                  y,
                                  ll,
                                  bounds_error=False,
                                  fill_value='extrapolate')
                    iZ = interp1d(t,
                                  z,
                                  ll,
                                  bounds_error=False,
                                  fill_value='extrapolate')
                    # get the S1 data for this satellite
                    if 'S1' in obslist:
                        s1 = obsdata[con]['S1'][:, prntoidx[con][prn]]

        # indices when there are no data for this satellite
                    ij = np.isnan(s1)
                    # indices when there are data in the RINEX file - this way you do not compute
                    # orbits unless there are data.
                    not_ij = np.logical_not(ij)
                    Tp = gpstime[not_ij,
                                 1]  # only use the seconds of the week for now
                    s1 = s1[not_ij]
                    #print(s1.shape)
                    emp = np.zeros(shape=[len(s1), 1], dtype=float)
                    # get the rest of the SNR data in a function
                    s2, s5, s6, s7, s8 = extract_snr(prn, con, obslist,
                                                     obsdata, prntoidx, not_ij,
                                                     emp)

                    # make sure there are no nan values in s2 or s5

                    nepochs = len(Tp)
                    for ij in range(0, nepochs):
                        TT = 0  # default value
                        if checkD:
                            TT = Tp[ij] % dec_rate  # get the modulus
                        if TT == 0:
                            SatOrb = satorb_prop_sp3(iX, iY, iZ, recv, Tp, ij)
                            r = np.subtract(SatOrb, recv)
                            azimA = g.azimuth_angle(r, East, North)
                            eleA = g.elev_angle(up, r) * 180 / np.pi
                            if (eleA >= emin) and (eleA <= emax):
                                fout.write(
                                    "{0:3.0f} {1:10.4f} {2:10.4f} {3:10.0f} {4:7.2f} {5:7.2f} {6:7.2f} {7:7.2f} {8:7.2f} {9:7.2f} {10:7.2f} \n"
                                    .format(prn + addon, eleA,
                                            azimA, Tp[ij] - gpssec0, 0,
                                            float(s6[ij]), s1[ij],
                                            float(s2[ij]), float(s5[ij]),
                                            float(s6[ij]), float(s7[ij])))
                else:
                    print('this satellite is not in the orbit file.', prn)
        else:
            print('no data for constellation ', con)
    # print('sort by time')
    # tried saving to variable but it was very slow
    #ne = np.array([prn,eleA,azimA,Tp[ij],0,0,s1[ij],s2[ij],s5[ij],0,0])
    #saveit = np.vstack((saveit,ne))
    #i = np.argsort(saveit[:,3])
    # apply that sort to variable with shorter name
    #s = saveit[i,:]
    print('write to file')
    fout.close()