Пример #1
0
def nrcan_parse_result(filename, station, inputfile, bwd=False):
    nrcan_result = ppp_common.PPP_Result()
    nrcan_result.station = station
    if not os.path.exists(filename):
        print "No pos file to read!"
        assert(0)
        
    print " read results from ", filename
    with open(filename, "r") as f:
        for line in f:
            if line.startswith("FWD") or line.startswith("BWD"):
                vals = line.split(" ")
                vals = filter(None, vals)
                (year,month,day) = struct.unpack("4sx2sx2s", vals[4])
                tod = vals[5].replace(":","")
                (h,m,s) = struct.unpack("2s2s6s", tod)
                if bwd: # if we want BWD, then retain only backward solution
                    if vals[0] != "BWD":
                        continue
                
                dt = datetime.datetime( int(year),int(month),int(day),int(h),int(m),int(float(s))) 
                clk = float( vals[13] ) # receiver clock (ns)
                ztd = float( vals[14] ) # zenith trposphere delay (m)
                lat = float( vals[20] ) + float( vals[21] )/60.0 + float( vals[22] )/(3600.0) # latitude
                lon = float( vals[23] ) + float( vals[24] )/60.0 + float( vals[25] )/(3600.0) # longitude                
                height  = float( vals[26] ) # height (m)
                p = ppp_common.PPP_Point( dt, lat, lon, height, clk, ztd )
                nrcan_result.append(p)

    if bwd: # for the BWD solution, flip order
        nrcan_result.reverse()
    return nrcan_result
Пример #2
0
def nrcan_parse_result(filename, station, inputfile, bwd=False):
    # This function reads and parses the .pos file
    #
    # This is an older format:
    #
    # DIR FRAME        STN         DOY YEAR-MM-DD HR:MN:SS.SSS NSV GDOP    SDC    SDP       DLAT(m)       DLON(m)       DHGT(m)         CLK(ns)   TZD(m)  SLAT(m)  SLON(m)  SHGT(m) SCLK(ns)  STZD(m) LAT(d) LAT(m)    LAT(s) LON(d) LON(m)    LON(s)   HGT(m) NORTHING(m)  EASTING(m) ZONE SCALE_FACTOR HEMI  AM COMBINED_SCALE_FACTOR
    # FWD ITRF(IGb08) MARK 290.0003472 2013-10-17 00:00:30.000   6  3.4   0.83 0.0000         2.543        -0.205         2.830         250.994   2.3093   22.344   15.908   55.671   14.038   0.1000     64     13 58.18167     27     41  3.38254       173.566  7123137.761  533190.009   35      0.99961349 N   6 0.99958626
    #
    # This is a more recent (2015 December) format:
    #
    # 0   1             2          3   4          5              6   7       8      9           19             11            12              13       14       15       16       17         18       19     20     21      22      23      24      25        26     27    28    29    30    31       32        33           34     35     36        37        38            39            40             41
    # DIR FRAME        STN         DOY YEAR-MM-DD HR:MN:SS.SSS NSV GDOP    SDC    SDP       DLAT(m)       DLON(m)       DHGT(m)         CLK(ns)   TZD(m)   SLAT(m)  SLON(m)  SHGT(m)   SCLK(ns)  STZD(m) LAT(d) LAT(m)    LAT(s) LON(d) LON(m)    LON(s)   HGT(m)   AM GRAD1 GRAD2 SGRD1 SGRD2 WETZD(m) GLNCLK(ns) SGLNCLK(ns)  MAXNL  MAXWL  AVGNL(m)  AVGWL(m)  VTEC(.1TECU)  GPS_DP1P2(ns) GLN_DP1P2(ns)
    # FWD ITRF(IGb08) usn6 344.0000000 2015-12-10 00:00:00.000  14  2.3   0.69 0.0000         0.532        -0.960        -2.344          -4.054   2.3456    1.286    1.217     2.935     7.468   0.0999     38     55 14.05525    -77      3 58.63558        56.579 14   0.0   0.0   0.0   0.0   0.0542     33.576       8.911 0.2000 1.5000   0.0000     0.0000         100.0            0.0           0.0
    nrcan_result = ppp_common.PPP_Result()
    nrcan_result.station = station
    if not os.path.exists(filename):
        print "No pos file to read!"
        print "expexted to find ", filename
        assert (0)

    print " read results from ", filename
    with open(filename, "r") as f:
        for line in f:
            if line.startswith("FWD") or line.startswith("BWD"):
                vals = line.split(" ")
                vals = filter(None, vals)
                (year, month, day) = struct.unpack("4sx2sx2s", vals[4])
                tod = vals[5].replace(":", "")
                (h, m, s) = struct.unpack("2s2s6s", tod)
                if bwd:  # if we want BWD, then retain only backward solution
                    if vals[0] != "BWD":
                        continue

                dt = datetime.datetime(int(year), int(month), int(day), int(h),
                                       int(m), int(float(s)))
                clk = float(vals[13])  # receiver clock (ns)
                ztd = float(vals[14])  # zenith trposphere delay (m)
                lat = float(vals[20]) + float(vals[21]) / 60.0 + float(
                    vals[22]) / (3600.0)  # latitude
                lon = float(vals[23]) + float(vals[24]) / 60.0 + float(
                    vals[25]) / (3600.0)  # longitude
                height = float(vals[26])  # height (m)
                p = ppp_common.PPP_Point(dt, lat, lon, height, clk, ztd)
                nrcan_result.append(p)

    if bwd:  # for the BWD solution, flip order
        nrcan_result.reverse()
    return nrcan_result
Пример #3
0
def glab_parse_result(fname, station, backward=True):
    """
        parse the FILTER data fields from gLAB outuput
        to a format defined by PPP_Result
        
    """
    ppp_result = ppp_common.PPP_Result()
    ppp_result.station = station
    with open(fname) as f:
        for line in f:
            if line.startswith("FILTER"):
                fields = line.split()
                assert (fields[0] == "FILTER")
                year = int(fields[1])
                doy = int(fields[2])
                secs = float(
                    fields[3])  # seconds from start of day. GPS or UTC time??
                dt = datetime.datetime(year, 1, 1) + datetime.timedelta(
                    days=doy - 1, seconds=secs)
                x = float(fields[4])
                y = float(fields[5])
                z = float(fields[6])
                (lat, lon, height) = ppp_common.xyz2lla(x, y, z)
                clk = float(fields[7]) * (1.0e9 / 299792458.0
                                          )  # Receiver clock [ns]
                ztd = float(fields[8])  # Zenith Tropospheric Delay [m]
                p = ppp_common.PPP_Point(dt, lat, lon, height, clk, ztd)
                ppp_result.append(p)

    if backward:  # we retain data from the FILTER run backwards
        maxepoch = datetime.datetime(1900, 1, 1)
        bwd_obs = []
        #found = False
        for p in ppp_result.observations:
            if p.epoch > maxepoch:
                maxepoch = p.epoch
                maxpt = p
            else:  # we are now in the backwards data
                #if not found:
                #    print "max epoch ", maxepoch
                #    bwd_obs.append(maxpt)
                #    found = True
                bwd_obs.append(p)
        bwd_obs.reverse()  # back to chronological order
        ppp_result.observations = bwd_obs
    print len(ppp_result)
    return ppp_result
Пример #4
0
def glab_parse_result(fname, station):
    """
        parse the FILTER data fields from gLAB outuput
    """
    ppp_result = ppp_common.PPP_Result()
    ppp_result.station=station
    with open(fname) as f:
        for line in f:
            if line.startswith("FILTER"):
                fields = line.split()
                assert( fields[0] == "FILTER" )
                year = int(fields[1])
                doy = int(fields[2])
                secs = float(fields[3]) # seconds from start of day. GPS or UTC time??
                dt = datetime.datetime(year,1,1) + datetime.timedelta( days = doy-1, seconds=secs )
                x = float(fields[4])
                y = float(fields[5])
                z = float(fields[6])
                (lat, lon, height ) = ppp_common.xyz2lla( x, y, z )
                clk = float(fields[7]) * (1.0e9 / 299792458.0)   # Receiver clock [ns]
                ztd = float(fields[8]) # Zenith Tropospheric Delay [m]
                p = ppp_common.PPP_Point( dt, lat, lon, height, clk, ztd )
                ppp_result.append(p)
    return ppp_result
Пример #5
0
def parse_result(fname, station):
    """
        parse the RTKLib output
        to a format defined by PPP_Result
    """

    # tropo results are in the stats file
    stat_fname = fname + ".stat"
    tropo = []
    clock = []
    with open(stat_fname) as f:
        for line in f:
            if line.startswith("$TROP"):
                line2 = line.split(",")
                tropo.append(float(line2[5]))
            if line.startswith("$CLK"):
                line2 = line.split(",")
                clock.append(float(line2[5]))
    # has bot fwd and bwd
    clock.reverse()
    tropo.reverse()

    ppp_result = ppp_common.PPP_Result()
    ppp_result.station = station
    with open(fname) as f:
        n = 0  # line count
        for line in f:
            if line.startswith("%"):
                pass  # comments
            else:
                fields = line.split()
                #print fields
                ymd = fields[0]
                ymd = ymd.split("/")

                year = int(ymd[0])
                month = int(ymd[1])
                day = int(ymd[2])

                hms = fields[1]
                hms = hms.split(":")
                hour = int(hms[0])
                minute = int(hms[1])
                second = int(numpy.round(float(hms[2])))

                clk = clock[n]
                #(second - float(hms[2]))*1.0e9
                #print year, month, day, hour, minute, second, clk

                #secs = float(ymd[2])

                dt = datetime.datetime(year, month, day, hour, minute,
                                       0) + datetime.timedelta(seconds=second)
                #print dt
                (lat, lon,
                 height) = float(fields[2]), float(fields[3]), float(fields[4])
                #ppp_common.xyz2lla( x, y, z )
                #clk = float(fields[7]) * (1.0e9 / 299792458.0)   # Receiver clock [ns]
                ztd = tropo[n]  #??
                float(fields[8])  # Zenith Tropospheric Delay [m]
                p = ppp_common.PPP_Point(dt, lat, lon, height, clk, ztd)
                ppp_result.append(p)
                n = n + 1
    print "clk len=", len(clock)
    print "pos len=", len(ppp_result.observations)
    """
    if backward: # we retain data from the FILTER run backwards
        maxepoch=datetime.datetime(1900,1,1)
        bwd_obs = []
        #found = False
        for p in ppp_result.observations:
            if p.epoch > maxepoch:
                maxepoch = p.epoch
                maxpt = p
            else: # we are now in the backwards data
                #if not found:
                #    print "max epoch ", maxepoch
                #    bwd_obs.append(maxpt)
                #    found = True
                bwd_obs.append(p)
        bwd_obs.reverse() # back to chronological order
        ppp_result.observations = bwd_obs 
    """
    print len(ppp_result)
    return ppp_result