Ejemplo n.º 1
0
def CODE_rapid_files(dt, prefixdir=""):
    """
        retrieve rapid CODE products for the datetime dt
        
        Examples of Rapid files:
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.EPH_R    ephemeris aka orbits
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.ERP_R    erp, earth rotation parameters
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.CLK_R    clk, clocks

    """
    server = "ftp.unibe.ch"
    remotedir = "aiub/CODE/"
    week = gpstime.gpsWeek( dt.year, dt.month, dt.day )
    dow  =  gpstime.dayOfWeek( dt.year, dt.month, dt.day )
    clk = "COD%s%s.CLK_R" % ( week,  dow )
    sp3 = "COD%s%s.EPH_R" % ( week, dow )
    erp = "COD%s%s.ERP_R" % ( week, dow )
    print "CODE rapid products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
    print "CLK = ", clk
    print "SP3 = ", sp3
    print "ERP = ", erp
    
    ftp_tools.check_dir(prefixdir + "/products/")
    localdir = prefixdir + "/products/CODE_rapid/"
    print "local dir = ", localdir
    
    #return  CODE_download(server, directory, [clk, sp3, erp], localdir)
    return  (server, "", "", remotedir, [clk, sp3, erp], localdir)
Ejemplo n.º 2
0
def write_result_file(ppp_result,
                      preamble="",
                      rapid=True,
                      tag="ppp",
                      prefixdir=""):
    """ write the ppp result out to a text file """
    ftp_tools.check_dir(prefixdir + "/results")
    ftp_tools.check_dir(prefixdir + "/results/" + ppp_result.station.name)
    first_obs = ppp_result.observations[0]
    first_obs_mjd = int(jdutil.datetime_to_mjd(first_obs.epoch))
    rapid_final = "final"
    if rapid:
        rapid_final = "rapid"
    result_file = ppp_result.station.receiver + "." + str(
        first_obs_mjd) + "." + rapid_final + "." + tag + ".txt"

    outfile = prefixdir + "/results/" + ppp_result.station.name + "/" + result_file
    with open(outfile, 'w') as f:
        datastring = "# " + result_file + " \n"
        f.write(datastring)
        for line in preamble.split('\n'):
            f.write("# %s\n" % line)

        f.write(PPP_Point.column_labels())
        for point in ppp_result.observations:
            f.write(str(point) + "\n")

    print " wrote results to ", outfile
Ejemplo n.º 3
0
def CODE_rapid_files(dt, prefixdir=""):
    """
        retrieve rapid CODE products for the datetime dt
        
        Examples of Rapid files:
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.EPH_R    ephemeris aka orbits
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.ERP_R    erp, earth rotation parameters
        ftp://ftp.unibe.ch/aiub/CODE/COD17840.CLK_R    clk, clocks

    """
    server = "ftp.unibe.ch"
    remotedir = "aiub/CODE/%s/" % (dt.year)
    week = gpstime.gpsWeek(dt.year, dt.month, dt.day)
    dow = gpstime.dayOfWeek(dt.year, dt.month, dt.day)
    clk = "COD%s%s.CLK.Z" % (week, dow)
    sp3 = "COD%s%s.EPH.Z" % (week, dow)
    erp = "COD%s7.ERP.Z" % (week)
    print("CODE rapid products for %d-%02d-%0d" % (dt.year, dt.month, dt.day))
    print("CLK = ", clk)
    print("SP3 = ", sp3)
    print("ERP = ", erp)

    ftp_tools.check_dir(prefixdir + "/products/")
    localdir = prefixdir + "/products/CODE_rapid/"
    print("local dir = ", localdir)

    #return  CODE_download(server, directory, [clk, sp3, erp], localdir)
    return (server, "anonymous", "", remotedir, [clk, sp3, erp], localdir)
Ejemplo n.º 4
0
 def get_rinex(self,dt):
     """
         Retrieve RINEX file using ftp
     """
     current_dir = os.getcwd()
     localdir = current_dir + '/stations/' + self.name + '/'
     ftp_tools.check_dir(localdir) # create directory if it doesn't exist
     return ftp_tools.ftp_download( self.ftp_server, self.ftp_username, self.ftp_password,
                      self.ftp_dir, self.rinex_filename(dt), localdir)
Ejemplo n.º 5
0
 def get_rinex(self, dt):
     """
         Retrieve RINEX file using ftp
     """
     current_dir = os.getcwd()
     localdir = current_dir + '/stations/' + self.name + '/'
     ftp_tools.check_dir(localdir)  # create directory if it doesn't exist
     return ftp_tools.ftp_download(self.ftp_server, self.ftp_username,
                                   self.ftp_password, self.ftp_dir,
                                   self.rinex_filename(dt), localdir)
Ejemplo n.º 6
0
def cddis_brdc_file(dt, prefixdir=""):
  server =   "cddis.gsfc.nasa.gov"
  remotedir = "gnss/data/daily/%d/brdc" % dt.year
  doy = dt.timetuple().tm_yday
  f = "brdc%03d0.%dn.Z" % (doy, dt.year-2000)
  #YYYY/brdc/brdcDDD0.YYn.Z
  localdir = prefixdir + "/stations/brdc/"
  ftp_tools.check_dir(localdir)
  
  ftp_tools.ftp_download( server, username="******", password="", remotedir=remotedir, remotefile=f, localdir=localdir)
  return localdir+f
Ejemplo n.º 7
0
def CODE_download( server, username, password, remotedir, files, localdir):
    print "CODE_download start ", datetime.datetime.now()
    ftp_tools.check_dir(localdir)

    for f in files:
        local_file = localdir+f
        ftp_tools.ftp_download( server, username, password, remotedir, f, localdir)
    print "CODE_download Done ", datetime.datetime.now()
    sys.stdout.flush()
    output=[]
    for f in files:
        output.append( localdir+f)
    return output # returns list of files: [CLK, EPH, ERP]
Ejemplo n.º 8
0
def CODE_final_files(dt, prefixdir=""):
    server = "ftp.unibe.ch"
    remotedir = "aiub/CODE/%s/" % (dt.year)
    week = gpstime.gpsWeek(dt.year, dt.month, dt.day)
    dow = gpstime.dayOfWeek(dt.year, dt.month, dt.day)
    clk = "COD%s%s.CLK.Z" % (week, dow)  # clock
    sp3 = "COD%s%s.EPH.Z" % (week, dow)  # orbit
    erp = "COD%s%s.ERP.Z" % (week, dow)  # earth
    print("CODE final products for %d-%02d-%0d" % (dt.year, dt.month, dt.day))
    print("CLK = ", clk)
    print("SP3 = ", sp3)
    print("ERP = ", erp)

    ftp_tools.check_dir(prefixdir + "/products/")
    localdir = prefixdir + "/products/CODE_final/"
    print("local dir = ", localdir)
    return (server, "anonymous", "", remotedir, [clk, sp3, erp], localdir)
Ejemplo n.º 9
0
def CODE_final_files(dt, prefixdir=""):
    server = "ftp.unibe.ch"
    remotedir = "aiub/CODE/%s/" % (dt.year)
    week = gpstime.gpsWeek(   dt.year, dt.month, dt.day )
    dow  = gpstime.dayOfWeek( dt.year, dt.month, dt.day )
    clk = "COD%s%s.CLK.Z" % ( week, dow ) # clock
    sp3 = "COD%s%s.EPH.Z" % ( week, dow ) # orbit
    erp = "COD%s%s.ERP.Z" % ( week, dow ) # earth
    print "CODE final products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
    print "CLK = ", clk
    print "SP3 = ", sp3
    print "ERP = ", erp
    
    ftp_tools.check_dir(prefixdir + "/products/")
    localdir = prefixdir + "/products/CODE_final/"
    print "local dir = ", localdir
    return  (server, "", "", remotedir, [clk, sp3, erp], localdir)
Ejemplo n.º 10
0
def diff_stations(prefixdir, station1, station2, dt, products, program):
    """
    calculate clock difference between two stations
    Station1 PPP result is receive_clock_offset = IGST(rapid/final) - Station1
    Station2 PPP result is receive_clock_offset = IGST(rapid/final) - Station2

    Double difference Station1-Station2 gives:
    (IGST(rapid/final) - Station1) - (IGST(rapid/final) - Station2)
    =
    Station2 - Station1
    """
    year = dt.timetuple().tm_year
    doy = dt.timetuple().tm_yday
    mjd = jdutil.datetime_to_mjd(dt)
    # output filename
    diff_dir = prefixdir + "/results/diff/"
    ftp_tools.check_dir(diff_dir)
    fname = diff_dir + "%s.diff.%s.%d.%s.%s.txt" % (
        station1.receiver, station2.receiver, mjd, products, program)
    if os.path.exists(fname):
        print(fname, " already exists - nothing to do.")
        return  # result already exists, nothing to do

    r1 = read_result_file(station1, dt, products, program, prefixdir)
    r2 = read_result_file(station2, dt, products, program, prefixdir)
    print("diff ", station1.name, " - ", station2.name, end=' ')
    # print "diff station2 ", len(r2)
    # read_result_file( )
    # 2,x2) = bipm_ftp.COD_read_day(prefixdir, station2, year, doy, rapid)
    # print len(t1), len(t2)

    (t_diff, clock_diff) = diff(r1, r2)
    print(len(t_diff), " points")
    # print len(td), len(d)
    # print d
    # print numpy.median(d)
    # (td2,d2) = mad.remove_timeseries_outliers(td,d)
    # write_diff_file(prefixdir, station1, station2, year, doy, td2, d2)
    # print len(td2)
    return (t_diff, clock_diff)
Ejemplo n.º 11
0
def write_result_file( ppp_result ,  preamble="" , rapid=True, tag="ppp", prefixdir=""):
    """ write the ppp result out to a text file """
    ftp_tools.check_dir(prefixdir + "/results")
    ftp_tools.check_dir(prefixdir + "/results/" + ppp_result.station.name)
    first_obs = ppp_result.observations[0]
    first_obs_mjd = int(jdutil.datetime_to_mjd( first_obs.epoch ) )
    rapid_final = "final"
    if rapid:
        rapid_final = "rapid"
    result_file = ppp_result.station.receiver +"." + str(first_obs_mjd) + "." + rapid_final + "." + tag + ".txt"
    
    outfile = prefixdir + "/results/" + ppp_result.station.name + "/" + result_file
    with open(outfile,'w') as f:
        datastring = "# " + result_file + " \n"
        f.write(datastring)
        for line in preamble.split('\n'):
            f.write( "# %s\n" % line)

        f.write(PPP_Point.column_labels())
        for point in ppp_result.observations:
            f.write(str(point) + "\n")

    print " wrote results to ", outfile
Ejemplo n.º 12
0
def glab_run(station, dt, rapid=True, prefixdir=""):
    dt_start = datetime.datetime.utcnow()

    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex( dt )

    (clk, eph, erp) = igs_ftp.get_CODE_rapid(dt, prefixdir)

    run_log  = " run start: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_start.year, dt_start.month, dt_start.day, dt_start.hour, dt_start.minute, dt_start.second)
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % dt.year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date:  %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk
    run_log += "       EPH: %s\n" % eph
    run_log += "       ERP: %s\n" % erp
    print run_log

    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir( tempdir )
    ftp_tools.delete_files(tempdir) # empty the temp directory

    # copy files to tempdir
    files_to_copy = [ rinex, clk, eph, eph, erp ]
    copied_files = []
    for f in files_to_copy:
        shutil.copy2( f, tempdir )
        (tmp,fn ) = os.path.split(f)
        copied_files.append( tempdir + fn )

    # unzip zipped files, if needed
    for f in copied_files:
        if f[-1] == "Z" or f[-1] == "z": # compressed .z or .Z file
            cmd ='/bin/gunzip'
            cmd = cmd + " -f " + f # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # TODO: if the RINEX file is hatanaka-compressed, uncompress it
    # this requires the CRX2RNX binary
    """
    if rinexfile[-3] == "d" or rinexfile[-3] == "D":
        hata_file = moved_files[0]
        cmd = "CRX2RNX " + hata_file[:-2]
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()
    """

    # figure out the rinex file name
    (tmp,rinexfile ) = os.path.split(rinex)
    inputfile = rinexfile[:-2] # strip off ".Z"

    # now ppp itself:
    os.chdir( tempdir )

    antfile = prefixdir + "/common/igs08.atx"
    outfile = tempdir + "out.txt"
    
    cmd =  glab_binary # must have this executable in path
    # see doc/glab_options.txt
    options = [ " -input:obs %s" % inputfile,
                " -input:clk %s" % clk,
                " -input:orb %s" % eph,
                " -input:ant %s" % antfile,
                " -model:recphasecenter no", # USNO receiver antenna is not in igs08.atx (?should it be?)
                " -output:file %s" % outfile,
                " -pre:dec 30", # rinex data is at 30s intervals, don't decimate
                " -pre:elevation 10", # elevation mask
                " --print:input", # discard unnecessary output
                " --print:model",
                " --print:prefit",
                " --print:postfit",
                " --print:satellites" ]

    for opt in options:
        cmd += opt
    p = subprocess.Popen(cmd, shell=True, cwd = tempdir )
    p.communicate() # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end-dt_start
    run_log2  = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute, dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds+delta.microseconds/1.0e6)
    print run_log2

    # here we may parse the output and store it to file somewhere
    ppp_result = glab_parse_result(outfile, station)
    ppp_common.write_result_file( ppp_result=ppp_result, preamble=run_log+run_log2, rapid=rapid, tag=glab_tag, prefixdir=prefixdir )
Ejemplo n.º 13
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP run using RTKLib rnx2rtkp
    
    """
    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow()

    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex(dt)  # doenload rinex file

    # GET NAV file
    navfile = igs_ftp.cddis_brdc_file(dt, prefixdir)

    # download IGS products
    (clk, eph, erp) = igs_ftp.get_CODE_rapid(dt, prefixdir)

    # log input files, for writing to the result file
    run_log = " run start: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_start.year, dt_start.month, dt_start.day, dt_start.hour,
        dt_start.minute, dt_start.second)
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % dt.year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date:  %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk
    run_log += "       EPH: %s\n" % eph
    run_log += "       ERP: %s\n" % erp
    print run_log

    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir(tempdir)
    ftp_tools.delete_files(tempdir)  # empty the temp directory

    # copy files to tempdir

    files_to_copy = [rinex, clk, eph, eph, erp, navfile]
    copied_files = []
    for f in files_to_copy:
        shutil.copy2(f, tempdir)
        (tmp, fn) = os.path.split(f)
        copied_files.append(tempdir + fn)

    # unzip zipped files, if needed
    for f in copied_files:
        if f[-1] == "Z" or f[-1] == "z":  # compressed .z or .Z file
            cmd = '/bin/gunzip'
            cmd = cmd + " -f " + f  # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # Hatanaka uncompress - if needed
    #rinexfile = copied_files[0] # the first file is the unzipped RINEX, in the temp dir
    if rinex[-3] == "d" or rinex[-3] == "D":
        hata_file = copied_files[0]
        hata_file = hata_file[:-2]  # strip off ".Z"
        #print "hata ", hata_file
        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()

    # figure out the rinex file name
    (tmp, rinexfile) = os.path.split(rinex)
    inputfile = rinexfile[:-2]  # strip off ".Z"
    if inputfile[-1] == "d" or rinex[-3] == "D":
        # if hatanaka compressed, we already uncompressed, so change to "O"
        inputfile = inputfile[:-1] + "O"

    # now ppp itself:
    os.chdir(tempdir)

    antfile = prefixdir + "/common/igs08.atx"
    outfile = tempdir + "out.txt"

    clk = copied_files[1]
    # RKLib wants eph files to be named sp3
    # from CODE they end .CLK_R
    clk_new = clk[:-6] + ".clk"
    cmd = "cp " + clk + " " + clk_new
    #print cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()
    clk = clk_new
    print clk
    # RKLib wants eph files to be named sp3
    # from CODE they end .CLK_R
    eph = copied_files[2]
    eph_new = eph[:-6] + ".sp3"
    cmd = "cp " + eph + " " + eph_new
    #print cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()
    eph = eph_new
    print eph

    navfile = copied_files[5]
    navfile = navfile[:-2]  # strip off ".Z"

    inputfile = tempdir + inputfile
    print "input ", inputfile
    print "nav ", navfile
    print "clk ", clk
    print "eph ", eph
    cmd = rtklib_binary  # must have this executable in path

    conf_file = prefixdir + "/common/rtklib_opts1.conf"
    options = [
        " -k %s" % conf_file,
        #" -p 7",               # mode 7:ppp-static
        #" -t", # lat/lon/height time output
        #" -u", # UTC time Don't use it, we get epochs of min:11 and min:41 instead of min:00 and min:00
        #" -d %d" % 12, # number of decimals in time output
        " -o %s" % outfile,
        #" -m 10",                       # elevation mask
        #" -c", # combined forward/backward solutions
        #" -y 1", # state output
        #" -h", # fix and hold for integer ambiguity resolution [off]
        #" -f 2", # 2:L1+L2
        #" -x 2", # debug level
        " %s" % eph,
        " %s" % clk,
        " %s" % inputfile,  # RINEX file
        " %s" % navfile,  # brdc NAV file
        #" %s" % (prefixdir + "/common/igs08.atx")
    ]

    for opt in options:
        cmd += opt
    p = subprocess.Popen(cmd, shell=True, cwd=tempdir)
    p.communicate()  # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end - dt_start
    run_log2 = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute,
        dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds +
                                          delta.microseconds / 1.0e6)
    print run_log2

    # here we may parse the output and store it to file somewhere
    ppp_result = parse_result(outfile, station)
    result_file = ppp_common.write_result_file(ppp_result=ppp_result,
                                               preamble=run_log + run_log2,
                                               rapid=rapid,
                                               tag=rtklib_tag,
                                               prefixdir=prefixdir)
    os.chdir(original_dir)  # change back to original directory
Ejemplo n.º 14
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP run using ESA gLAB
    
    """
    print "ESA gLAB PPP-run"
    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow()

    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex(dt)  # download rinex file

    print "getting IGS products:"
    # download IGS products
    (clk, eph, erp) = igs_ftp.get_CODE_rapid(dt, prefixdir)
    print "IGS products done."
    print "-------------------"

    # log input files, for writing to the result file
    run_log = " run start: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_start.year, dt_start.month, dt_start.day, dt_start.hour,
        dt_start.minute, dt_start.second)
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % dt.year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date:  %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk
    run_log += "       EPH: %s\n" % eph
    run_log += "       ERP: %s\n" % erp
    print run_log
    print "-------------------"

    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir(tempdir)
    ftp_tools.delete_files(tempdir)  # empty the temp directory

    # copy files to tempdir
    files_to_copy = [rinex, clk, eph, eph, erp]
    copied_files = []
    for f in files_to_copy:
        shutil.copy2(f, tempdir)
        (tmp, fn) = os.path.split(f)
        copied_files.append(tempdir + fn)

    # unzip zipped files, if needed
    for f in copied_files:
        if f[-1] == "Z" or f[-1] == "z":  # compressed .z or .Z file
            cmd = '/bin/gunzip'
            cmd = cmd + " -f " + f  # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # Hatanaka uncompress - if needed
    #rinexfile = copied_files[0] # the first file is the unzipped RINEX, in the temp dir
    if rinex[-3] == "d" or rinex[-3] == "D" or rinex[
            -4] == "D":  # can end .z, .Z, or .gz - so the "d" is in position -3 or -4
        hata_file = copied_files[0]
        hata_file = hata_file[:-2]  # strip off ".Z"
        if rinex[-4] == "D":
            hata_file = hata_file[:-1]  # stip off more
        #print "hata ", hata_file
        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()

    # figure out the rinex file name
    (tmp, rinexfile) = os.path.split(rinex)
    inputfile = rinexfile[:-2]  # strip off ".Z"

    if inputfile[-1] == ".":  # ends in a dot
        inputfile = inputfile[:-1]  # strip off

    if inputfile[-1] == "d" or inputfile[-1] == "D":
        # if hatanaka compressed, we already uncompressed, so change to "O"
        inputfile = inputfile[:-1] + "O"

    # now ppp itself:
    os.chdir(tempdir)

    antfile = prefixdir + "/common/igs08.atx"
    outfile = tempdir + "out.txt"
    eph = copied_files[2]
    clk = copied_files[1]
    inputfile = tempdir + inputfile

    print "inputfile for gLAB is: ", inputfile

    cmd = glab_binary  # must have this executable in path
    # see doc/glab_options.txt
    options = [
        " -input:obs %s" % inputfile,  # RINEX observation file
        " -input:clk %s" % clk,
        " -input:orb %s" % eph,  # SP3 Orbits
        " -input:ant %s" % antfile,
        # " -model:recphasecenter ANTEX",
        # " -model:recphasecenter no",
        " -model:trop",  # correct for troposphere
        #" -model:iono FPPP",
        " -output:file %s" % outfile,
        " -pre:dec 30",  # rinex data is at 30s intervals, don't decimate
        " -pre:elevation 10",  # elevation mask
        " -pre:availf G12"  # GPS frequencies L1 and L2
        " -filter:trop",
        " -filter:backward",  # runs filter both FWD and BWD
        " --print:input",  # discard unnecessary output
        " --print:model",
        " --print:prefit",
        " --print:postfit",
        " --print:satellites"
    ]
    if station.antex:
        options.append(" -model:recphasecenter ANTEX")
    else:
        options.append(
            " -model:recphasecenter no"
        )  # USNO receiver antenna is not in igs08.atx (?should it be?)

    for opt in options:
        cmd += opt
    p = subprocess.Popen(cmd, shell=True, cwd=tempdir)
    p.communicate()  # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end - dt_start
    run_log2 = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute,
        dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds +
                                          delta.microseconds / 1.0e6)
    print run_log2
    print "-------------------"

    # here we may parse the output and store it to file somewhere
    ppp_result = glab_parse_result(outfile, station)
    ppp_common.write_result_file(ppp_result=ppp_result,
                                 preamble=run_log + run_log2,
                                 rapid=rapid,
                                 tag=glab_tag,
                                 prefixdir=prefixdir)
    os.chdir(original_dir)
Ejemplo n.º 15
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP run using RTKLib rnx2rtkp
    
    """
    print "------------------------------"
    print "PPP run using RTKLib rnx2rtkp"

    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow()

    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex( dt ) # doenload rinex file
    
    # GET NAV file
    navfile = igs_ftp.cddis_brdc_file(dt, prefixdir)
    
    # download IGS products 
    (clk, eph, erp) = igs_ftp.get_CODE_rapid(dt, prefixdir)

    # log input files, for writing to the result file
    run_log  = " run start: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_start.year, dt_start.month, dt_start.day, dt_start.hour, dt_start.minute, dt_start.second)
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % dt.year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date:  %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk
    run_log += "       EPH: %s\n" % eph
    run_log += "       ERP: %s\n" % erp
    print run_log

    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir( tempdir )
    ftp_tools.delete_files(tempdir) # empty the temp directory

    # copy files to tempdir
    
    files_to_copy = [ rinex, clk, eph, eph, erp, navfile ]
    copied_files = []
    for f in files_to_copy:
        shutil.copy2( f, tempdir )
        (tmp,fn ) = os.path.split(f)
        copied_files.append( tempdir + fn )

    # unzip zipped files, if needed
    for f in copied_files:
        if f[-1] == "Z" or f[-1] == "z": # compressed .z or .Z file
            cmd ='/bin/gunzip'
            cmd = cmd + " -f " + f # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # Hatanaka uncompress - if needed
    #rinexfile = copied_files[0] # the first file is the unzipped RINEX, in the temp dir
    if rinex[-3] == "d" or rinex[-3] == "D" or rinex[-4] == "D":
        hata_file = copied_files[0]
        hata_file = hata_file[:-2] # strip off ".Z"
        if hata_file[-1] == ".":
            hata_file = hata_file[:-1] # stip off more
        #print "hata ", hata_file
        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()
    

    # figure out the rinex file name
    (tmp,rinexfile ) = os.path.split(rinex)
    inputfile = rinexfile[:-2] # strip off ".Z"
    if inputfile[-1] == ".": # ends in a dot
        inputfile = inputfile[:-1] # strip off
        
    if inputfile[-1] == "d" or inputfile[-1] == "D":
        # if hatanaka compressed, we already uncompressed, so change to "O"
        inputfile = inputfile[:-1]+"O"
        
    # now ppp itself:
    os.chdir( tempdir )

    antfile = prefixdir + "/common/igs08.atx"
    outfile = tempdir + "out.txt"
    
    clk = copied_files[1]
    # RKLib wants eph files to be named sp3
    # from CODE they end .CLK_R
    clk_new = clk[:-6]+".clk"
    cmd = "cp "+clk + " " + clk_new
    #print cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()
    clk = clk_new
    print clk
    # RKLib wants eph files to be named sp3
    # from CODE they end .CLK_R
    eph = copied_files[2]
    eph_new = eph[:-6]+".sp3"
    cmd = "cp "+eph + " " + eph_new
    #print cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()
    eph = eph_new
    print eph
    
    navfile = copied_files[5]
    navfile = navfile[:-2] # strip off ".Z"
    
    inputfile = tempdir+inputfile
    print "input ", inputfile
    print "nav ", navfile
    print "clk ", clk
    print "eph ", eph
    cmd =  rtklib_binary # must have this executable in path
    
    conf_file = prefixdir + "/common/rtklib_opts1.conf"
    options = [ " -k %s"%conf_file,
                #" -p 7",               # mode 7:ppp-static
                #" -t", # lat/lon/height time output
                #" -u", # UTC time Don't use it, we get epochs of min:11 and min:41 instead of min:00 and min:00
                #" -d %d" % 12, # number of decimals in time output
                " -o %s" % outfile,
                #" -m 10",                       # elevation mask
                #" -c", # combined forward/backward solutions
                #" -y 1", # state output
                #" -h", # fix and hold for integer ambiguity resolution [off]
                #" -f 2", # 2:L1+L2
                #" -x 2", # debug level
                " %s" % eph,
                " %s" % clk,
                " %s" % inputfile, # RINEX file
                " %s" % navfile,   # brdc NAV file
                #" %s" % (prefixdir + "/common/igs08.atx")
                ]

    for opt in options:
        cmd += opt
    p = subprocess.Popen(cmd, shell=True, cwd = tempdir )
    p.communicate() # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end-dt_start
    run_log2  = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute, dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds+delta.microseconds/1.0e6)
    print run_log2

    # here we may parse the output and store it to file somewhere
    ppp_result = parse_result(outfile, station)
    result_file = ppp_common.write_result_file( ppp_result=ppp_result, preamble=run_log+run_log2, rapid=rapid, tag=rtklib_tag, prefixdir=prefixdir )
    os.chdir(original_dir) # change back to original directory
Ejemplo n.º 16
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP run using ESA gLAB
    
    """
    print "ESA gLAB PPP-run"
    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow()

    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex( dt ) # download rinex file

    print "getting IGS products:"
    # download IGS products 
    (clk, eph, erp) = igs_ftp.get_CODE_rapid(dt, prefixdir)
    print "IGS products done."
    print "-------------------"

    # log input files, for writing to the result file
    run_log  = " run start: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_start.year, dt_start.month, dt_start.day, dt_start.hour, dt_start.minute, dt_start.second)
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % dt.year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date:  %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk
    run_log += "       EPH: %s\n" % eph
    run_log += "       ERP: %s\n" % erp
    print run_log
    print "-------------------"
    
    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir( tempdir )
    ftp_tools.delete_files(tempdir) # empty the temp directory

    # copy files to tempdir
    files_to_copy = [ rinex, clk, eph, eph, erp ]
    copied_files = []
    for f in files_to_copy:
        shutil.copy2( f, tempdir )
        (tmp,fn ) = os.path.split(f)
        copied_files.append( tempdir + fn )

    # unzip zipped files, if needed
    for f in copied_files:
        if f[-1] == "Z" or f[-1] == "z": # compressed .z or .Z file
            cmd ='/bin/gunzip'
            cmd = cmd + " -f " + f # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # Hatanaka uncompress - if needed
    #rinexfile = copied_files[0] # the first file is the unzipped RINEX, in the temp dir
    if rinex[-3] == "d" or rinex[-3] == "D" or rinex[-4] == "D":  # can end .z, .Z, or .gz - so the "d" is in position -3 or -4
        hata_file = copied_files[0]
        hata_file = hata_file[:-2] # strip off ".Z"
        if rinex[-4] == "D":
            hata_file = hata_file[:-1] # stip off more
        #print "hata ", hata_file
        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()
    

    # figure out the rinex file name
    (tmp,rinexfile ) = os.path.split(rinex)
    inputfile = rinexfile[:-2] # strip off ".Z"
    
    if inputfile[-1] == ".": # ends in a dot
        inputfile = inputfile[:-1] # strip off
        
    if inputfile[-1] == "d" or inputfile[-1] == "D":
        # if hatanaka compressed, we already uncompressed, so change to "O"
        inputfile = inputfile[:-1]+"O"
    
    
    # now ppp itself:
    os.chdir( tempdir )

    antfile = prefixdir + "/common/igs08.atx"
    outfile = tempdir + "out.txt"
    eph = copied_files[2]
    clk = copied_files[1]
    inputfile = tempdir + inputfile
    
    print "inputfile for gLAB is: ",inputfile
    
    cmd =  glab_binary # must have this executable in path
    # see doc/glab_options.txt
    options = [ " -input:obs %s" % inputfile,               # RINEX observation file
                " -input:clk %s" % clk,                     
                " -input:orb %s" % eph,                     # SP3 Orbits
                " -input:ant %s" % antfile,
                # " -model:recphasecenter ANTEX", 
                # " -model:recphasecenter no",                
                " -model:trop",                             # correct for troposphere
                #" -model:iono FPPP",
                " -output:file %s" % outfile,
                " -pre:dec 30",                             # rinex data is at 30s intervals, don't decimate
                " -pre:elevation 10",                       # elevation mask
                " -pre:availf G12"                          # GPS frequencies L1 and L2
                " -filter:trop",
                " -filter:backward",                        # runs filter both FWD and BWD
                " --print:input",                           # discard unnecessary output
                " --print:model",
                " --print:prefit",
                " --print:postfit",
                " --print:satellites" ]
    if station.antex:
        options.append(" -model:recphasecenter ANTEX")
    else:
        options.append(" -model:recphasecenter no") # USNO receiver antenna is not in igs08.atx (?should it be?)

    for opt in options:
        cmd += opt
    p = subprocess.Popen(cmd, shell=True, cwd = tempdir )
    p.communicate() # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end-dt_start
    run_log2  = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute, dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds+delta.microseconds/1.0e6)
    print run_log2
    print "-------------------"

    # here we may parse the output and store it to file somewhere
    ppp_result = glab_parse_result(outfile, station)
    ppp_common.write_result_file( ppp_result=ppp_result, preamble=run_log+run_log2, rapid=rapid, tag=glab_tag, prefixdir=prefixdir )
    os.chdir(original_dir)
Ejemplo n.º 17
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP-processing with NRCan ppp.
    
    requires "gpsppp" binary
    
    """
    print "------------------------------------"

    print "PPP-processing with NRCan ppp."

    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow(
    )  # for timing how long processing takes

    year = dt.timetuple().tm_year
    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex(dt)  # this downloads RINEX over ftp, if needed

    # get GPS Products
    # nrcan ppp wants IGS products for two days.
    # if we process day N, we need products for N and N+1
    clk_files = []
    eph_files = []
    erp_file = ""  # we do not use the ERP files, for now.
    if not rapid:  # Final products
        (clk1, eph1, erp1) = igs_ftp.get_CODE_final(dt, prefixdir)
        (clk2, eph2,
         erp2) = igs_ftp.get_CODE_final(dt + datetime.timedelta(days=1),
                                        prefixdir)
        clk_files = [clk1, clk2]
        eph_files = [eph1, eph2]
        erp_file = erp1
    elif rapid:  # Rapid products
        (clk1, eph1, erp1) = igs_ftp.get_CODE_rapid(dt, prefixdir)
        (clk2, eph2,
         erp2) = igs_ftp.get_CODE_rapid(dt + datetime.timedelta(days=1),
                                        prefixdir)
        clk_files = [clk1, clk2]
        eph_files = [eph1, eph2]
        erp_file = erp1

    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir(tempdir)
    ftp_tools.delete_files(tempdir)  # empty the temp directory

    # us an existing cmd-file (doesn't change from run to run)
    cmdfile = prefixdir + "/gpsppp/1day.cmd"

    # write an INP file, corresponding to the keyboard-input required
    inp_file = nrcan_inp_file(tempdir + "run.inp", rinex, cmdfile, eph_files,
                              clk_files, rapid)

    # write a DEF file
    nrcan_def_file(prefixdir, "gpsppp.def")

    # result will be stored in a POS file:
    (rinexdir, fn) = os.path.split(rinex)
    if fn[-3:] == ".gz":
        nrcan_pos_file = tempdir + fn[:-6] + "pos"
    else:
        nrcan_pos_file = tempdir + fn[:-5] + "pos"

    run_log = ""
    run_log += " run start: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_start.year, dt_start.month, dt_start.day, dt_start.hour,
        dt_start.minute, dt_start.second)
    run_log += "   Program: %s\n" % gpsppp_version
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date: %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk_files  # allow for multiple clk-files!?
    run_log += "       EPH: %s\n" % eph_files
    run_log += "       ERP: %s\n" % erp_file
    print run_log

    # move RINEX, CLK, EPH, ERP files to temp_dir
    files_to_move = [rinex, clk1, clk2, eph1, eph2, erp_file]
    moved_files = []
    for f in files_to_move:
        shutil.copy2(f, tempdir)
        (tmp, fn) = os.path.split(f)
        moved_files.append(tempdir + fn)
    print moved_files

    # unzip zipped files. this may include the RINEX, CLK, EPH files.
    for f in moved_files:
        if f[-1] == "Z" or f[-1] == "z":  # compressed .z or .Z file
            cmd = '/bin/gunzip'
            cmd = cmd + " -f " + f  # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()

    # rename the ERP file - becase the name is fixed to gpsppp.ERP in the DEF file.
    cmd = '/bin/mv'
    gpsppp_erp = prefixdir + "/temp/gpsppp.ERP"
    (tmp, fn) = os.path.split(erp_file)  # [:-2]
    cmd = cmd + " " + tempdir + fn + " " + gpsppp_erp
    print "rename command: ", cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()

    # figure out the rinex file name
    print "rinex= ", rinex
    (tmp, rinexfile) = os.path.split(rinex)
    inputfile = rinexfile[:-2]  # strip off ".Z"
    if inputfile[-1] == ".":  # ends in a dot
        inputfile = inputfile[:-1]  # strip off

    # if the RINEX file is hatanaka-compressed, uncompress it
    if inputfile[-1] == "d" or inputfile[-1] == "D":
        hata_file = moved_files[0]
        hata_file = hata_file[:-2]  # strip off ".Z"
        if hata_file[-1] == ".":
            hata_file = hata_file[:-1]  # stip off more

        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()

    # now gpsppp itself:
    os.chdir(tempdir)
    cmd = gpsppp_binary + " < " + inp_file
    p = subprocess.Popen(cmd, shell=True, cwd=tempdir)
    p.communicate()  # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end - dt_start
    run_log2 = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % (
        dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute,
        dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds +
                                          delta.microseconds / 1.0e6)
    print run_log2
    print "---------------------------------"

    # we may now do postprocessing and store the results.
    # the result is named RINEX.pos, for example "usn63440.pos"
    ppp_result = nrcan_parse_result(nrcan_pos_file,
                                    station,
                                    inputfile,
                                    bwd=True)
    result_file = ppp_common.write_result_file(ppp_result=ppp_result,
                                               preamble=run_log + run_log2,
                                               rapid=rapid,
                                               tag=gpsppp_tag,
                                               prefixdir=prefixdir)
    os.chdir(original_dir)  # change back to original directory
    return result_file
Ejemplo n.º 18
0
def run(station, dt, rapid=True, prefixdir=""):
    """
    PPP-processing with NRCan ppp.
    
    requires "gpsppp" binary
    
    """
    print "------------------------------------"
    
    print "PPP-processing with NRCan ppp."
    
    original_dir = prefixdir
    dt_start = datetime.datetime.utcnow() # for timing how long processing takes
    
    year = dt.timetuple().tm_year
    doy = dt.timetuple().tm_yday
    rinex = station.get_rinex( dt ) # this downloads RINEX over ftp, if needed
    
    # get GPS Products
    # nrcan ppp wants IGS products for two days.
    # if we process day N, we need products for N and N+1
    clk_files =[]
    eph_files = []
    erp_file = "" # we do not use the ERP files, for now.
    if not rapid: # Final products
        (clk1, eph1, erp1) = igs_ftp.get_CODE_final(dt, prefixdir) 
        (clk2, eph2, erp2) = igs_ftp.get_CODE_final(dt+datetime.timedelta(days=1), prefixdir)
        clk_files = [ clk1, clk2 ]
        eph_files = [ eph1, eph2 ]
        erp_file = erp1
    elif rapid: # Rapid products
        (clk1, eph1, erp1) = igs_ftp.get_CODE_rapid(dt, prefixdir) 
        (clk2, eph2, erp2) = igs_ftp.get_CODE_rapid(dt+datetime.timedelta(days=1), prefixdir )
        clk_files = [ clk1, clk2 ]
        eph_files = [ eph1, eph2 ]
        erp_file = erp1
    
    # we do processing in a temp directory
    tempdir = prefixdir + "/temp/"
    ftp_tools.check_dir( tempdir )
    ftp_tools.delete_files(tempdir) # empty the temp directory
    
    # us an existing cmd-file (doesn't change from run to run)
    cmdfile = prefixdir + "/gpsppp/1day.cmd"
    
    # write an INP file, corresponding to the keyboard-input required
    inp_file = nrcan_inp_file( tempdir + "run.inp", rinex, cmdfile, eph_files, clk_files, rapid )

    # write a DEF file
    nrcan_def_file( prefixdir, "gpsppp.def")
    
    # result will be stored in a POS file:
    (rinexdir, fn ) = os.path.split(rinex)
    if fn[-3:] == ".gz":
        nrcan_pos_file = tempdir + fn[:-6] + "pos"
    else:
        nrcan_pos_file = tempdir + fn[:-5] + "pos"
    
    run_log = ""
    run_log += " run start: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_start.year, dt_start.month, dt_start.day, dt_start.hour, dt_start.minute, dt_start.second)
    run_log += "   Program: %s\n" % gpsppp_version
    run_log += "   Station: %s\n" % station.name
    run_log += "      Year: %d\n" % year
    run_log += "       DOY: %03d\n" % doy
    run_log += "      date: %d-%02d-%02d\n" % (dt.year, dt.month, dt.day)
    run_log += "     RINEX: %s\n" % rinex
    run_log += "       CLK: %s\n" % clk_files  # allow for multiple clk-files!?
    run_log += "       EPH: %s\n" % eph_files
    run_log += "       ERP: %s\n" % erp_file
    print run_log

    # move RINEX, CLK, EPH, ERP files to temp_dir
    files_to_move = [ rinex, clk1, clk2, eph1, eph2, erp_file ]
    moved_files = []
    for f in files_to_move:
        shutil.copy2( f, tempdir )
        (tmp,fn ) = os.path.split(f)
        moved_files.append( tempdir + fn )
    print moved_files
    
    # unzip zipped files. this may include the RINEX, CLK, EPH files.
    for f in moved_files:
        if f[-1] == "Z" or f[-1] == "z": # compressed .z or .Z file
            cmd ='/bin/gunzip'
            cmd = cmd + " -f " + f # -f overwrites existing file
            print "unzipping: ", cmd
            p = subprocess.Popen(cmd, shell=True)
            p.communicate()
    
    # rename the ERP file - becase the name is fixed to gpsppp.ERP in the DEF file.
    cmd ='/bin/mv'
    gpsppp_erp = prefixdir + "/temp/gpsppp.ERP"
    (tmp,fn ) = os.path.split(erp_file)  # [:-2]
    cmd = cmd + " " + tempdir + fn + " " + gpsppp_erp 
    print "rename command: ", cmd
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()
    
    # figure out the rinex file name
    print "rinex= ", rinex
    (tmp,rinexfile ) = os.path.split(rinex)
    inputfile = rinexfile[:-2] # strip off ".Z"
    if inputfile[-1] == ".": # ends in a dot
        inputfile = inputfile[:-1] # strip off
    
    # if the RINEX file is hatanaka-compressed, uncompress it
    if inputfile[-1] == "d" or inputfile[-1] == "D":
        hata_file = moved_files[0]
        hata_file = hata_file[:-2] # strip off ".Z"
        if hata_file[-1] == ".":
            hata_file = hata_file[:-1] # stip off more
            
        cmd = "CRX2RNX " + hata_file
        print "Hatanaka uncompress: ", cmd
        p = subprocess.Popen(cmd, shell=True)
        p.communicate()
    
    # now gpsppp itself:
    os.chdir( tempdir )
    cmd = gpsppp_binary + " < " + inp_file
    p = subprocess.Popen(cmd, shell=True, cwd = tempdir )
    p.communicate() # wait for processing to finish

    dt_end = datetime.datetime.utcnow()
    delta = dt_end-dt_start
    run_log2  = "   run end: %d-%02d-%02d %02d:%02d:%02d\n" % ( dt_end.year, dt_end.month, dt_end.day, dt_end.hour, dt_end.minute, dt_end.second)
    run_log2 += "   elapsed: %.2f s\n" % (delta.seconds+delta.microseconds/1.0e6)
    print run_log2
    print "---------------------------------"

    # we may now do postprocessing and store the results.
    # the result is named RINEX.pos, for example "usn63440.pos"
    ppp_result = nrcan_parse_result(nrcan_pos_file, station, inputfile, bwd=True)
    result_file = ppp_common.write_result_file( ppp_result=ppp_result, preamble=run_log+run_log2, rapid=rapid, tag=gpsppp_tag, prefixdir=prefixdir )
    os.chdir(original_dir) # change back to original directory
    return result_file