'wettemp', 'datetime']) else: wrtm = CsvWriter(name='met', fname=cr.json['met_wr'], filt=['id', 'temp', 'pressure', 'humidity', 'wettemp', 'datetime'], mode='a') data = {'id': cr.json['station_id'], 'temp': temp, 'pressure': pres, 'humidity': humi, 'wettemp': wet} if wrtm.WriteData(data) == -1: logging.error('Met data write failed') # get station coordinates print("Loading station coords...") if re.search('^http[s]?://', cr.json['coo_rd']): rd_st = HttpReader(url=cr.json['coo_rd'], ptys=['STA'], \ filt=['id', 'east', 'north', 'elev']) else: rd_st = GeoReader(fname=cr.json['coo_rd'], \ filt=['id', 'east', 'north', 'elev']) w = rd_st.Load() st_coord = [x for x in w if x['id'] == cr.json['station_id']] if not st_coord: logging.fatal("Station not found: %s", cr.json['station_id']) sys.exit(-1) # coordinate writer fmt = '.%df' % cr.json['decimals'] if re.search('^http[s]?://', cr.json['coo_wr']): wrt = HttpWriter(url=cr.json['coo_wr'], mode='POST', dist=fmt) elif re.search('^sqlite:', cr.json['coo_wr']): wrt = SqLiteWriter(db=cr.json['coo_wr'][7:], dist=fmt, table='monitoring_coo', filt=['id', 'east', 'north', 'elev', 'datetime']) else: wrt = GeoWriter(fname=cr.json['coo_wr'], mode='a', dist=fmt)
""" import sys import re sys.path.append('../pyapi/') from georeader import GeoReader from sqlitewriter import SqLiteWriter if len(sys.argv) < 3: print("Usage {} file.geo database.sqlite".format(sys.argv[0])) exit(0) fn = sys.argv[1][:-4] coo_rdr = GeoReader(fname=fn+'.coo') geo_rdr = GeoReader(fname=fn+'.geo') coo_wrt = SqLiteWriter(db=sys.argv[2], table='monitoring_coo', filt=['id', 'east', 'north', 'elev', 'datetime']) geo_wrt = SqLiteWriter(db=sys.argv[2], table='monitoring_obs', filt=['id', 'hz', 'v', 'distance', 'crossincline', 'lengthincline', 'datetime']) buf = coo_rdr.Load() for b in buf: coo_wrt.WriteData(b) buf = geo_rdr.Load() for b in buf: geo_wrt.WriteData(b)
import sys from georeader import GeoReader fname = "/home/siki/GeoEasy_old/data/freestation.geo" gama_path = '/home/siki/GeoEasy/src/gama-local' if len(sys.argv) > 1: fname = sys.argv[1] if fname[-4:] != '.geo' and fname[-4:] != '.coo': fname += '.geo' if not os.path.isfile(fname): print("File not found: " + fname) exit(-1) fn = fname[:-4] # remove extension g = GamaIface(gama_path, 3, 0.95, 1, 1, 1.5) # load coordinates coo = GeoReader(fname=fn + '.coo') while True: w = coo.GetNext() if w is None or len(w) == 0: break if 'id' in w: if w['id'] == '1': g.add_point(w, 'ADJ') else: g.add_point(w, 'FIX') obs = GeoReader(fname=fn + '.geo') # load observations while True: w = obs.GetNext() if w is None or len(w) == 0: break
if __name__ == '__main__': from serialiface import SerialIface from georeader import GeoReader from csvreader import CsvReader logging.getLogger().setLevel(logging.WARNING) if len(sys.argv) > 1: ifname = sys.argv[1] else: #ifname = 'test.geo' print("Usage: blindorientation.py input_file totalstation port") sys.exit(-1) if ifname[-4:] != '.dmp' and ifname[-4:] != '.geo': ifname += '.geo' if ifname[-4:] == '.geo': g = GeoReader(fname=ifname) else: g = CsvReader(fname=ifname) data = g.Load() stationtype = '1100' if len(sys.argv) > 2: stationtype = sys.argv[2] port = '/dev/ttyUSB0' if len(sys.argv) > 3: port = sys.argv[3] if re.search('120[0-9]$', stationtype): from leicatps1200 import LeicaTPS1200 mu = LeicaTPS1200() elif re.search('110[0-9]$', stationtype): from leicatcra1100 import LeicaTCRA1100 mu = LeicaTCRA1100()
print( "Usage: freestation.py input_file gama_path station_id station_height" ) sys.exit(-1) if fname[-4:] not in ['.geo', '.coo', '.dmp', '.csv']: fname += '.geo' if len(sys.argv) > 2: gama_path = sys.argv[2] else: gama_path = '/home/siki/GeoEasy/gama-local' # load observations and coordinates fn = fname[:-4] # remove extension ext = fname[-4:] if ext in ['.geo', '.coo']: obs = GeoReader(fname=fn + '.geo') else: obs = CsvReader(fname=fn + '.dmp') # load observations observations = obs.Load() # load coordinates and add to adjustment if ext in ['.geo', '.coo']: coo = GeoReader(fname=fn + '.coo') else: coo = CsvReader(fname=fn + '.csv') n = 0 # number of points st = False # station found coords = coo.Load() f = Freestation(observations, coords, gama_path) print(f.Adjustment())
sys.exit(-1) # logging #TODO if the log file does not exist, it causes an error message logging.basicConfig(format=cr.json['log_format'], filename=cr.json['log_file'], \ filemode='w', level=cr.json['log_level']) # load reference coordinates of points if re.search('^http[s]?://', cr.json['coo_ref']): rd_st = HttpReader(url=cr.json['coo_ref'], ptys=['STA'], \ filt=['id', 'east', 'north', 'elev']) elif re.search('^sqlite:', cr.json['coo_ref']): rd_st = SqLiteReader(db=cr.json['coo_ref'][7:], \ filt=['id', 'east', 'north', 'elev']) else: rd_st = GeoReader(fname=cr.json['coo_ref'], \ filt=['id', 'east', 'north', 'elev']) w = rd_st.Load() logging.info('%d rows read from %s' % (len(w), cr.json['coo_ref'])) #transform into system of reference line if len(cr.json['ref_line_points']) == 2: logging.info( 'ref line points: %s, %s' % (cr.json['ref_line_points'][0], cr.json['ref_line_points'][1])) # A point coordinates in reference line try: iA = filter(lambda pp: pp['id'] == cr.json['ref_line_points'][0], w)[0] except IndexError: iA = None logging.error('No A point of reference line found: %s ' %
met = sys.argv[7].upper() elif not config: met = None if len(sys.argv) > 8: met_addr = sys.argv[8] elif not config: met_addr = None if len(sys.argv) > 9: met_par = sys.argv[9] elif not config: met_par = None # load input data set coo_filt = ['id', 'east', 'north', 'elev'] if ifname[-4:] in ('.geo', '.coo'): g = GeoReader(fname=ifname[:-4] + '.geo') f = GeoReader(fname=ifname[:-4] + '.coo', filt=coo_filt) else: g = CsvReader(fname=ifname[:-4] + '.dmp') f = CsvReader(fname=ifname[:-4] + '.csv', filt=coo_filt) directions = g.Load() coordinates = f.Load() # writers if ofname[-4:] == '.dmp' or ofname[-4:] == '.csv' or ofname == 'stdout': # dmp/csv file or console output if ofname[-4:] == '.dmp' or ofname[-4:] == '.csv': ofname1 = ofname[:-4] + '.dmp' ofname2 = ofname[:-4] + '.csv' else: ofname1 = ofname2 = ofname
exit(-1) #ifname = "test.coo" if len(sys.argv) > 2: ofname = sys.argv[2] else: ofname = 'stdout' station_id = None if len(sys.argv) > 3: station_id = sys.argv[3] station_ih = 0 if len(sys.argv) > 4: station_ih = float(sys.argv[4]) # load input data set if ifname[-4:] == '.coo': g = GeoReader(fname=ifname, filt=['id', 'east', 'north', 'elev']) else: g = CsvReader(fname=ifname, filt=['id', 'east', 'north', 'elev']) data = g.Load() if ofname[-4:] == '.geo': geo_wrt = GeoWriter(dist = '.4f', angle = 'RAD', fname = ofname, \ filt = ['station', 'id', 'hz', 'v', 'distance', 'faces', 'ih', \ 'code'], mode = 'w') else: geo_wrt = CsvWriter(dist = '.4f', angle = 'RAD', fname = ofname, \ header = True, mode = 'w', \ filt = ['station', 'id', 'hz', 'v', 'distance', 'faces', 'ih', \ 'code']) og = ObsGen(data, station_id, station_ih) if og.station_east is None or og.station_north is None or og.station_elev is None: print "station coordinates not found: ", station_id