def doNcFTPDownload(logger: logging.Logger): """ doNcFTPDownload downloads remote files using 'ncftget' program """ cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored(sys._getframe().f_code.co_name, 'green') # locate 'ncftpget' program exeNCFTPGET = location.locateProg('ncftpget', logger) # create and change to download directory amc.dRTK['local']['YYDOY'] = '{YY:s}{DOY:s}'.format(YY=amc.dRTK['date']['YY'], DOY=amc.dRTK['date']['DoY']) amc.dRTK['local']['dir'] = os.path.join(amc.dRTK['local']['root'], amc.dRTK['local']['YYDOY']) amutils.mkdir_p(amc.dRTK['local']['dir']) amutils.changeDir(amc.dRTK['local']['dir']) logger.info('{func:s}: changed to local directory {dir:s}'.format(dir=amc.dRTK['local']['dir'], func=cFuncName)) for gnss in amc.dRTK['remote'].keys(): logger.info('{func:s}: downloading for {gnss:s} RINEX Nav {nav:s}'.format(gnss=gnss, nav=amc.dRTK['remote'][gnss]['rfile'], func=cFuncName)) cmdNCFTPGET = '{prog:s} -u {user:s} -p {passwd:s} -v ftp://{host:s}/{rpath}/{rfile:s}'.format(prog=exeNCFTPGET, user=amc.dRTK['ftp']['user'], passwd=amc.dRTK['ftp']['passwd'], host=amc.dRTK['ftp']['server'], rpath=amc.dRTK['remote'][gnss]['rpath'], rfile=amc.dRTK['remote'][gnss]['rfile']) logger.info('{func:s}: ... running {cmd:s}'.format(cmd=cmdNCFTPGET, func=cFuncName)) # run the program exeprogram.subProcessDisplayStdErr(cmd=cmdNCFTPGET, verbose=True)
def main(argv): """ creates a combined SBF file from hourly or six-hourly SBF files """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # treat command line options obsRnx, dirRnx, interval, logLevels = treatCmdOpts(argv) # store cli parameters amc.dRTK = {} dArgs = {} dArgs['rinexDir'] = dirRnx dArgs['obs_name'] = obsRnx dArgs['interval'] = interval amc.dRTK['args'] = dArgs # create logging for better debugging logger = amc.createLoggers(os.path.basename(__file__), dir=dirRnx, logLevels=logLevels) # locate the gfzrnx program used for execution dProgs = {} dProgs['gfzrnx'] = location.locateProg('gfzrnx', logger) amc.dRTK['progs'] = dProgs # check arguments checkArguments(logger=logger) # read the header info using gfzrnx amc.dRTK['header'] = rnx_obs_header.rnxobs_header_metadata( dArgs=amc.dRTK['args'], dProgs=amc.dRTK['progs'], logger=logger) # get list of PRNs in RINEX obs file amc.dRTK['prns'] = rnx_obs_header.rnxobs_parse_prns( dArgs=amc.dRTK['args'], dProgs=amc.dRTK['progs'], logger=logger) # extract parts of the rinex observation header rnx_obs_header.rnxobs_metadata_parser(dobs_hdr=amc.dRTK['header'], dPRNs=amc.dRTK['prns'], dArgs=amc.dRTK['args'], logger=logger) # show the information JSON structure logger.info('{func:s}: info dictionary = \n{prt!s}'.format( prt=amutils.pretty(amc.dRTK), func=cFuncName)) # store the json structure jsonName = os.path.join( amc.dRTK['args']['rinexDir'], amc.dRTK['args']['obs_name'].replace('.', '-') + '.json') print('jsonName {!s}'.format(jsonName)) with open(jsonName, 'w') as f: json.dump(amc.dRTK, f, ensure_ascii=False, indent=4, default=amutils.DT_convertor)
def process_rover(dRover, dProj, logger: logging.Logger, overwrite=False): """ process_rover processes the rover according to the settings file :params dRover: information of the rover station :type dRover: dictionary :params dProj: information about project :type dProj: dictionary """ cFuncName = amc.cBaseName + ': ' + colored(sys._getframe().f_code.co_name, 'green') # create RNX2RTKP command line options amc.dSettings['PROGS']['rnx2rtkp'] = location.locateProg('rnx2rtkp') # convert directory for the specified positioning mode and rover dRover['rtkp_dir'] = os.path.join(amc.dSettings['PROJECT']['out_dir'], dProj['posmode'], dRover['name']) amutils.mkdir_p(dRover['rtkp_dir']) dRover['rtkp_pos'] = os.path.join(dRover['rtkp_dir'], '{stat:s}-{yy:d}{doy:d}.pos'.format(stat=dRover['name'], yy=amc.dSettings['PROJECT']['iYY'], doy=amc.dSettings['PROJECT']['iDOY'])) # dRover['posfile'] = dRover script = '{cmd:s} -k {conf:s} '.format(cmd=amc.dSettings['PROGS']['rnx2rtkp'], conf=amc.dSettings['RNX2RTKP']['rtkpconf']) if dProj['posmode'].lower() == 'single': logger.info('{func:s}\n... {mode:s} processing station {stat:s}'.format(func=cFuncName, mode=colored(amc.dSettings['PROJECT']['posmode'], 'yellow'), stat=colored(dRover['name'], 'yellow'))) script += '-o {out:s} {obs:s} {nav:s}'.format(out=dRover['rtkp_pos'], obs=dRover['rinex_name'], nav=amc.dSettings['NAV']['com']) else: logger.info('{func:s}\n... {mode:s} processing station {rvr:s}, reference {base:s}'.format(func=cFuncName, mode=colored(amc.dSettings['PROJECT']['posmode'], 'yellow'), rvr=colored(dRover['name'], 'yellow'), base=colored(amc.dSettings['BASE']['site'], 'yellow'))) if dProj['posmode'].lower() in ['dgps', 'static']: script += '-o {out:s} -r {xyz:s} {obs:s} {ref:s} {nav:s}'.format(out=dRover['rtkp_pos'], obs=dRover['rinex_name'], ref=amc.dSettings['BASE']['rinex'], nav=amc.dSettings['NAV']['com_rnx3'], xyz=amc.dSettings['BASE']['cart']) else: sys.stderr.write('{func:s}\n ... wrong positioning mode for RNX2RTKP: {mode:s}'.format(func=cFuncName, mode=dProj['posmode'])) logger.info('{func:s}: executing = {script!s}'.format(script=script, func=cfunc)) sys.exit(6) # execute script exeprogram.subProcessLogStdErr(command=script, logger=logger) pass
def main(argv): """ pyRnxProc processes RINEX data using 'amrnx2rtkp' """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # pandas options pd.options.display.max_rows = 40 pd.options.display.max_columns = 36 pd.options.display.width = 2000 # limit float precision encoder.FLOAT_REPR = lambda o: format(o, '.3f') # treat command line options rootDir, roverObs, posMode, freq, cutOff, baseObs, ephemeris, gnss, typeEphem, tropo, iono, template, overwrite, logLevels = treatCmdOpts( argv) # create logging for better debugging logger = amc.createLoggers(baseName=os.path.basename(__file__), dir=rootDir, logLevels=logLevels) # store cli parameters amc.dRTK = {} amc.dRTK['rootDir'] = rootDir amc.dRTK['roverObs'] = roverObs amc.dRTK['posMode'] = posMode amc.dRTK['freq'] = [v for k, v in rtkc.dFreq.items() if k == freq][0] amc.dRTK['cutOff'] = cutOff amc.dRTK['baseObs'] = baseObs amc.dRTK['ephems'] = ephemeris amc.dRTK['GNSS'] = gnss amc.dRTK['typeEphem'] = typeEphem amc.dRTK['Tropo'] = tropo amc.dRTK['Iono'] = iono amc.dRTK['template'] = template # check validity of passed arguments retCode = checkValidityArgs(logger=logger) if retCode != amc.E_SUCCESS: logger.error('{func:s}: Program exits with code {error:s}'.format( func=cFuncName, error=colored('{!s}'.format(retCode), 'red'))) sys.exit(retCode) # create the configuration file for the GNSSs to process amc.dRTK['config'] = os.path.join( amc.dRTK['rtkDir'], '{rover:s}-{syst:s}.conf'.format( rover=amc.dRTK['roverObs'].split('.')[0], syst=amc.dRTK['GNSS'].upper())) logger.info( '{func:s}: Creating {syst:s} configuration file {conf:s}'.format( func=cFuncName, syst=colored(gnss, 'green'), conf=colored(amc.dRTK['config'], 'green'))) # create the settings used for replacing the fields in the template file template_rnx2rtkp.create_rnx2rtkp_settings(overwrite=overwrite, logger=logger) template_rnx2rtkp.create_rnx2rtkp_template(cfgFile=amc.dRTK['config'], overwrite=overwrite, logger=logger) logger.info('{func:s}: amc.dRTK = \n{json!s}'.format(func=cFuncName, json=json.dumps( amc.dRTK, sort_keys=False, indent=4))) # locate the rnx2rtkp program used for execution exeRNX2RTKP = location.locateProg('rnx2rtkp', logger) cmdRNX2RTKP = '{prog:s} -k {conf:s} -o {pos:s} {rover:s} {base:s} {nav:s}'.format( prog=exeRNX2RTKP, conf=amc.dRTK['config'], pos=amc.dRTK['filePos'], rover=amc.dRTK['roverObs'], base=amc.dRTK['baseObs'], nav=' '.join(amc.dRTK['ephems'])) logger.info('{func:s}: Running:\n{cmd:s}'.format(func=cFuncName, cmd=colored( cmdRNX2RTKP, 'green'))) # run the program if amc.dLogLevel[logLevels[0]] >= amc.dLogLevel['INFO']: exeprogram.subProcessDisplayStdErr(cmd=cmdRNX2RTKP, verbose=True) else: exeprogram.subProcessDisplayStdErr(cmd=cmdRNX2RTKP, verbose=False) # inform user logger.info('{func:s}: Created position file: {pos:s}'.format( func=cFuncName, pos=colored(amc.dRTK['filePos'], 'blue'))) logger.info('{func:s}: Created statistics file: {stat:s}'.format( func=cFuncName, stat=colored(amc.dRTK['fileStat'], 'blue')))
def main(argv): """ pyconvbin converts raw data from SBF/UBlox to RINEX """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # limit float precision encoder.FLOAT_REPR = lambda o: format(o, '.3f') # treat command line options rootDir, binFile, binType, rinexDir, crd_cart, interval, logLevels = treatCmdOpts( argv) # create logging for better debugging logger, log_name = amc.createLoggers(os.path.basename(__file__), dir=rootDir, logLevels=logLevels) # store cli parameters amc.dRTK = {} amc.dRTK['rootDir'] = rootDir amc.dRTK['binFile'] = binFile amc.dRTK['binType'] = binType amc.dRTK['rinexDir'] = rinexDir amc.dRTK['ant_crds'] = crd_cart amc.dRTK['interval'] = interval * 60 amc.dRTK['gfzrnxDir'] = os.path.join(rinexDir, 'gfzrnx') logger.info('{func:s}: arguments processed: amc.dRTK = {drtk!s}'.format( func=cFuncName, drtk=amc.dRTK)) # check validity of passed arguments retCode = checkValidityArgs(logger=logger) if retCode != amc.E_SUCCESS: logger.error('{func:s}: Program exits with code {error:s}'.format( func=cFuncName, error=colored('{!s}'.format(retCode), 'red'))) sys.exit(retCode) # locate the conversion programs SBF2RIN and CONVBIN amc.dRTK['bin'] = {} amc.dRTK['bin']['CONVBIN'] = location.locateProg('convbin', logger) amc.dRTK['bin']['SBF2RIN'] = location.locateProg('sbf2rin', logger) amc.dRTK['bin']['GFZRNX'] = location.locateProg('gfzrnx', logger) amc.dRTK['bin']['RNX2CRZ'] = location.locateProg('rnx2crz', logger) amc.dRTK['bin']['COMPRESS'] = location.locateProg('compress', logger) # convert binary file to rinex logger.info( '{func:s}: convert binary file to rinex'.format(func=cFuncName)) if amc.dRTK['binType'] == 'SBF': dRnxTmp = sbf2rinex(logger=logger) gfzrnx_ops.rnxobs_header_info(dTmpRnx=dRnxTmp, logger=logger) gfzrnx_ops.rnxobs_statistics_file(dTmpRnx=dRnxTmp, logger=logger) gfzrnx_ops.gnss_rinex_creation(dTmpRnx=dRnxTmp, logger=logger) # gfzrnx_ops.create_rnxobs_subfreq(logger=logger) # gfzrnx_ops.compress_rinex_obsnav(logger=logger) else: ubx2rinex(logger=logger) # report to the user logger.info('{func:s}: amc.dRTK =\n{json!s}'.format( func=cFuncName, json=json.dumps(amc.dRTK, sort_keys=False, indent=4, default=amutils.DT_convertor))) # store the json structure jsonName = os.path.join(amc.dRTK['rinexDir'], amc.dRTK['binFile'].replace('.', '-') + '.json') with open(jsonName, 'w') as f: json.dump(amc.dRTK, f, ensure_ascii=False, indent=4, default=amutils.DT_convertor) # remove the temporar files for file in dRnxTmp.values(): os.remove(file) # copy temp log file to the YYDOY directory copyfile(log_name, os.path.join(amc.dRTK['rinexDir'], 'pyconvbin.log')) os.remove(log_name)
def main(argv): """ creates a combined SBF file from hourly or six-hourly SBF files """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored(sys._getframe().f_code.co_name, 'green') # treat command line options obsRnx, dirRnx, obs_types, sat_systs, frequencies, prns, interval, logLevels = treatCmdOpts(argv) # store cli parameters amc.dRTK = {} dArgs = {} dArgs['rinexDir'] = dirRnx dArgs['obs_name'] = obsRnx dArgs['gnss'] = sat_systs dArgs['systyp'] = obs_types dArgs['sysfrq'] = frequencies dArgs['prns'] = prns dArgs['interval'] = interval amc.dRTK['args'] = dArgs # create logging for better debugging logger = amc.createLoggers(os.path.basename(__file__), dir=dirRnx, logLevels=logLevels) # locate the gfzrnx program used for execution dProgs = {} dProgs['gfzrnx'] = location.locateProg('gfzrnx', logger) dProgs['grep'] = location.locateProg('grep', logger) amc.dRTK['progs'] = dProgs # check arguments checkArguments(logger=logger) # read the header info using gfzrnx amc.dRTK['info']['header'] = rnx_obs_header.rnxobs_header_metadata(dArgs=amc.dRTK['args'], dProgs=amc.dRTK['progs'], logger=logger) # get list of PRNs in RINEX obs file amc.dRTK['info']['prns'] = rnx_obs_header.rnxobs_parse_prns(dArgs=amc.dRTK['args'], dProgs=amc.dRTK['progs'], logger=logger) # extract parts of the rinex observation header amc.dRTK['available'] = rnx_obs_header.rnxobs_metadata_parser(dobs_hdr=amc.dRTK['info']['header'], dPRNs=amc.dRTK['info']['prns'], dArgs=amc.dRTK['args'], logger=logger) amc.dRTK['analysed'] = rnx_obs_header.rnxobs_argument_parser(dobs_hdr=amc.dRTK['info']['header'], dPRNs=amc.dRTK['info']['prns'], dArgs=amc.dRTK['args'], logger=logger) # for each PRN selected, extract the variables of same systyp in tabular output and read in a dataframe for gnss in amc.dRTK['analysed']: logger.info('=' * 50) logger.info('{func:s}: start analysing GNSS {gnss:s}'.format(gnss=colored(gnss, 'green'), func=cFuncName)) for prn in amc.dRTK['analysed'][gnss]['prns']: logger.info('-' * 25) # create a dataframe from the rinex observation file dfPRN = rnx_obs_analyse.rnxobs_dataframe(rnx_file=dArgs['obs_name'], prn=prn, dPRNSysObs=amc.dRTK['analysed'][gnss]['sysobs'], dProgs=amc.dRTK['progs'], logger=logger) # perform analysis calculations, returned is list of ALL possible observations prn_sigobstyps = rnx_obs_analyse.rnxobs_analyse(prn=prn, dfPrn=dfPRN, dPRNSysType=amc.dRTK['analysed'][gnss]['systyp'], logger=logger) for sigtyp in amc.dRTK['analysed'][gnss]['systyp']: # plotting is done per sigtyp prn_stobs = [stobs for stobs in prn_sigobstyps if stobs.startswith(sigtyp)] cols = ['DT'] + prn_stobs # plot the observables for this specific sigtyp rnx_obs_plot.rnx_prsobs_plot(dArgs=amc.dRTK['args'], prn=prn, stobs=prn_stobs, dfPrn=dfPRN[cols], rawobs=amc.dRTK['analysed'][gnss]['sysobs'], logger=logger, showplot=True) sys.exit(11) # show the information JSON structure logger.info('{func:s}: info dictionary = \n{prt!s}'.format(prt=amutils.pretty(amc.dRTK), func=cFuncName))
def main(argv) -> bool: """ glabplotposn plots data from gLAB (v6) OUTPUT messages """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # limit float precision # encoder.FLOAT_REPR = lambda o: format(o, '.3f') # pd.options.display.float_format = "{:,.3f}".format # treat command line options dir_root, glab_cmp_out, scale_enu, center_enu, db_cvs, show_plot, log_levels = treatCmdOpts( argv) # create logging for better debugging logger, log_name = amc.createLoggers(os.path.basename(__file__), dir=dir_root, logLevels=log_levels) # store cli parameters amc.dRTK = {} amc.dRTK['dir_root'] = dir_root amc.dRTK['glab_cmp_out'] = glab_cmp_out # create sub dict for gLAB related info dgLABng = {} dgLABng['dir_glab'] = 'glabng' dgLABng['db'] = db_cvs amc.dRTK['dgLABng'] = dgLABng # check some arguments ret_val = check_arguments(logger=logger) if ret_val != amc.E_SUCCESS: sys.exit(ret_val) # open or create the database file for storing the statistics glab_updatedb.open_database(db_name=amc.dRTK['dgLABng']['db'], logger=logger) # glab_updatedb.db_update_line(db_name=amc.dRTK['dgLABng']['db'], line_id='2019,134', info_line='2019,134,new thing whole line for ', logger=logger) # get location of progs used amc.dRTK['progs'] = {} amc.dRTK['progs']['gunzip'] = location.locateProg('gunzip', logger) amc.dRTK['progs']['gzip'] = location.locateProg('gzip', logger) # uncompress the "out" file runGUNZIP = '{prog:s} -f -v {zip:s}'.format( prog=amc.dRTK['progs']['gunzip'], zip=os.path.join(amc.dRTK['dir_root'], amc.dRTK['glab_cmp_out'])) logger.info('{func:s}: Uncompressing file {cmp:s}:\n{cmd:s}'.format( func=cFuncName, cmd=colored(runGUNZIP, 'green'), cmp=colored(amc.dRTK['glab_cmp_out'], 'green'))) # run the program exeprogram.subProcessDisplayStdErr(cmd=runGUNZIP, verbose=True) # get name of uncompressed file amc.dRTK['glab_out'] = amc.dRTK['glab_cmp_out'][:-3] # split gLABs out file in parts glab_msgs = glc.dgLab['messages'][0:2] # INFO & OUTPUT messages needed dglab_tmpfiles = glab_split_outfile.split_glab_outfile( msgs=glab_msgs, glab_outfile=amc.dRTK['glab_out'], logger=logger) # read in the INFO messages from INFO temp file amc.dRTK['INFO'] = glab_parser_info.parse_glab_info( glab_info=dglab_tmpfiles['INFO'], logger=logger) # write the identification to the database file for glabng output messages # glab_updatedb.db_update_line(db_name=amc.dRTK['dgLABng']['db'], line_id=amc.dRTK['INFO']['db_lineID'], info_line=amc.dRTK['INFO']['db_lineID'], logger=logger) # read in the OUTPUT messages from OUTPUT temp file df_output = glab_parser_output.parse_glab_output( glab_output=dglab_tmpfiles['OUTPUT'], logger=logger) # save df_output as CSV file amc.dRTK['dgLABng']['pos'] = store_to_cvs(df=df_output, ext='pos', logger=logger, index=False) # compress the stored CVS file runGZIP = '{prog:s} -f -v {zip:s}'.format( prog=amc.dRTK['progs']['gzip'], zip=os.path.join(amc.dRTK['dir_root'], amc.dRTK['dgLABng']['dir_glab'], amc.dRTK['dgLABng']['pos'])) logger.info('{func:s}: Compressing file {cmp:s}:\n{cmd:s}'.format( func=cFuncName, cmd=colored(runGZIP, 'green'), cmp=colored(amc.dRTK['dgLABng']['pos'], 'green'))) # run the program exeprogram.subProcessDisplayStdErr(cmd=runGZIP, verbose=True) # calculate statitics gLAB OUTPUT messages amc.dRTK['dgLABng'][ 'stats'], dDB_crds = glab_statistics.statistics_glab_outfile( df_outp=df_output, logger=logger) for key, val in dDB_crds.items(): glab_updatedb.db_update_line( db_name=amc.dRTK['dgLABng']['db'], line_id='{id:s},{crd:s}'.format(id=amc.dRTK['INFO']['db_lineID'], crd=key), info_line='{id:s},{val:s}'.format(id=amc.dRTK['INFO']['db_lineID'], val=val), logger=logger) # sort the glab_output_db glab_updatedb.db_sort(db_name=amc.dRTK['dgLABng']['db'], logger=logger) # sys.exit(2) # plot the gLABs OUTPUT messages # - position ENU and PDOP plots glab_plot_output_enu.plot_glab_position(dfCrd=df_output, scale=scale_enu, showplot=show_plot, logger=logger) # - scatter plot of EN per dop bind glab_plot_output_enu.plot_glab_scatter(dfCrd=df_output, scale=scale_enu, center=center_enu, showplot=show_plot, logger=logger) # - scatter plot of EN per dop bind (separate) glab_plot_output_enu.plot_glab_scatter_bin(dfCrd=df_output, scale=scale_enu, center=center_enu, showplot=show_plot, logger=logger) # - plot the DOP parameters glab_plot_output_enu.plot_glab_xdop(dfCrd=df_output, showplot=show_plot, logger=logger) # - plot the ENU box plots per DOP bin glab_plot_output_stats.plot_glab_statistics( df_dopenu=df_output[glc.dgLab['OUTPUT']['XDOP'] + glc.dgLab['OUTPUT']['dENU']], scale=scale_enu, showplot=show_plot, logger=logger) # report to the user logger.info('{func:s}: Project information =\n{json!s}'.format( func=cFuncName, json=json.dumps(amc.dRTK, sort_keys=False, indent=4, default=amutils.DT_convertor))) # sort the glab_output_db glab_updatedb.db_sort(db_name=amc.dRTK['dgLABng']['db'], logger=logger) # recompress the "out" file runGZIP = '{prog:s} -f -v {zip:s}'.format(prog=amc.dRTK['progs']['gzip'], zip=os.path.join( amc.dRTK['dir_root'], amc.dRTK['glab_out'])) logger.info('{func:s}: Compressing file {cmp:s}:\n{cmd:s}'.format( func=cFuncName, cmd=colored(runGZIP, 'green'), cmp=colored(amc.dRTK['glab_out'], 'green'))) # run the program exeprogram.subProcessDisplayStdErr(cmd=runGZIP, verbose=True) # store the json structure json_out = amc.dRTK['glab_out'].split('.')[0] + '.json' with open(json_out, 'w') as f: json.dump(amc.dRTK, f, ensure_ascii=False, indent=4, default=amutils.DT_convertor) logger.info('{func:s}: created json file {json:s}'.format(func=cFuncName, json=colored( json_out, 'green'))) # copy temp log file to the YYDOY directory copyfile( log_name, os.path.join( amc.dRTK['dir_root'], '{obs:s}-{prog:s}'.format(obs=amc.dRTK['glab_out'].split('.')[0], prog='output.log'))) os.remove(log_name) return amc.E_SUCCESS
def main(argv) -> bool: """ glabplotposn plots data from gLAB (v6) OUTPUT messages """ cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # store cli parameters amc.dRTK = {} cli_opt = {} cli_opt['rxtype'], cli_opt['igs_root'], cli_opt['marker'], cli_opt[ 'year'], cli_opt['doy'], cli_opt['gnss'], cli_opt['prcodes'], cli_opt[ 'cutoff'], cli_opt['template'], log_levels = treatCmdOpts(argv) amc.dRTK['options'] = cli_opt # check some arguments # create logging for better debugging logger, log_name = amc.createLoggers(os.path.basename(__file__), dir=os.getcwd(), logLevels=log_levels) ret_val = check_arguments(logger=logger) if ret_val != amc.E_SUCCESS: sys.exit(ret_val) # locate the program used for execution amc.dRTK['progs'] = {} amc.dRTK['progs']['glabng'] = location.locateProg('glabng', logger) amc.dRTK['progs']['crz2rnx'] = location.locateProg('crz2rnx', logger) amc.dRTK['progs']['gunzip'] = location.locateProg('gunzip', logger) amc.dRTK['progs']['gzip'] = location.locateProg('gzip', logger) # uncompress RINEX files uncompress_rnx_files(logger=logger) # use the template file for creation of glab config file create_session_template(logger=logger) # run glabng using created cfg file run_glabng_session(logger=logger) # remove the decompressed RINEX files cleanup_rnx_files(logger=logger) # report to the user logger.info('{func:s}: Project information =\n{json!s}'.format( func=cFuncName, json=json.dumps(amc.dRTK, sort_keys=False, indent=4, default=amutils.DT_convertor))) # move the log file to the glab directory code_txt = '' for code in amc.dRTK['proc']['codes']: code_txt += ('_' + code) move( log_name, os.path.join( amc.dRTK['proc']['dir_glab'], 'glab_proc_{gnss:s}{prcodes:s}.log'.format(gnss=''.join( amc.dRTK['proc']['gnss']), prcodes=code_txt))) return amc.E_SUCCESS
def main(argv): """ pyconvbin converts raw data from SBF/UBlox to RINEX """ amc.cBaseName = colored(os.path.basename(__file__), 'yellow') cFuncName = colored(os.path.basename(__file__), 'yellow') + ' - ' + colored( sys._getframe().f_code.co_name, 'green') # limit float precision encoder.FLOAT_REPR = lambda o: format(o, '.3f') # dictionary of GNSS systems dGNSSSysts = { 'G': 'GPS', 'R': 'Glonass', 'E': 'Galileo', 'S': 'SBAS', 'C': 'Beidou', 'J': 'QZSS', 'I': 'IRNSS' } # treat command line options rootDir, binFile, binType, rinexDir, rinexVersion, gnssSyst, rinexNaming, overwrite, logLevels = treatCmdOpts( argv) # create logging for better debugging logger = amc.createLoggers(os.path.basename(__file__), dir=rootDir, logLevels=logLevels) # store cli parameters amc.dRTK = {} amc.dRTK['rootDir'] = rootDir amc.dRTK['binFile'] = binFile amc.dRTK['binType'] = binType amc.dRTK['rinexDir'] = rinexDir amc.dRTK['rinexVersion'] = rinexVersion amc.dRTK['gnssSyst'] = gnssSyst amc.dRTK['rinexNaming'] = rinexNaming logger.info('{func:s}: arguments processed: amc.dRTK = {drtk!s}'.format( func=cFuncName, drtk=amc.dRTK)) # check validity of passed arguments retCode = checkValidityArgs(logger=logger) if retCode != amc.E_SUCCESS: logger.error('{func:s}: Program exits with code {error:s}'.format( func=cFuncName, error=colored('{!s}'.format(retCode), 'red'))) sys.exit(retCode) # locate the conversion programs SBF2RIN and CONVBIN amc.dRTK['bin2rnx'] = {} amc.dRTK['bin2rnx']['CONVBIN'] = location.locateProg('convbin', logger) amc.dRTK['bin2rnx']['SBF2RIN'] = location.locateProg('sbf2rin', logger) # convert binary file to rinex logger.info( '{func:s}: convert binary file to rinex'.format(func=cFuncName)) if amc.dRTK['binType'] == 'SBF': sbf2rinex(logger=logger, dGnssSysts=dGNSSSysts) else: ublox2rinex(logger=logger, dGnssSysts=dGNSSSysts) # report to the user logger.info('{func:s}: amc.dRTK =\n{json!s}'.format(func=cFuncName, json=json.dumps( amc.dRTK, sort_keys=False, indent=4)))