def OpenLine(infile, line, pickfile, fromcache=True): """ Start up a RatingWindow object. """ print(pickfile) if os.path.isfile(pickfile) == False: sys.stderr.write("\n\tNo pick file found for line " + str(line) + ".\n\tPress 'up' key and change line number.\n\n") exit(1) S = irlib.Survey(infile) L = S.ExtractLine(line, fromcache=fromcache) if not fromcache: try: L.FixStaticGPS() L.RemoveStationary(threshold=3.0) except irlib.LineGatherError: pass try: F = irlib.FileHandler(pickfile, L.line) dc_points, bed_points = F.GetEventVals() R = RatingWindow(L, bed_points) except irlib.FileHandlerError as err_message: print(err_message) dc_points = None bed_points = None err = 1 R = None return R, L, S
def main(): def print_syntax(): print "\t irview -f file_name [-L line_number]" return try: optlist, args = getopt.gnu_getopt(sys.argv[1:], 'f:L:') except getopt.GetoptError: print "Error collecting arguments - check syntax." print_syntax() sys.exit(1) optdict = dict(optlist) try: infile = optdict['-f'] except KeyError: print "A survey filename must be supplied:" print_syntax() sys.exit(0) line = int(optdict.get('-L', 0)) S = irlib.Survey(infile) fh5 = S.f IW, L = OpenLine(S, line, fh5) # Begin main loop print "Ice Radar Viewing Tool (IRView)" print "Press [shift+n] to digitize a feature." print "Right-click or press [shift+e] to end the feature." print "Type 'help' for additional commands." while 1: s = raw_input('>> ') IW, L = HandleCommand(s, S, IW, L)
def test_h5_add_utm_argentiere(argenfnm): stem, ext = os.path.splitext(argenfnm) utmfnm = stem + "_utm" + ext ret = subprocess.call(["h5_add_utm.py", argenfnm, utmfnm, "--swap_lon"]) assert ret == 0 S = irlib.Survey(utmfnm) L = S.ExtractLine(0) assert all(z==32 for z in L.metadata.zones) nan = numpy.nan n = numpy.array([ 346370.982676, 346370.982676, 346349.151958, 346349.15472 , 346348.999665, 346348.999665, nan, 346348.999665, 346348.41812 , 346348.41812 , nan, 346345.003619, 346343.414045, 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , 346343.5691 , nan, 346341.057314, 346341.057314, 346340.223679, 346340.223679, 346339.098926, 346339.098926, 346332.810278, 346332.810278, 346332.909735, 346332.909735, 346330.605529, 346324.740146, 346324.740146, 346323.521499, 346323.521499, 346318.935591, 346318.935591, 346316.124672, 346316.124672, nan, nan, 346308.237741, 346308.237741, 346307.511916, 346308.349951, 346308.349951, 346308.241722, 346308.241722, 346309.475826, 346309.475826, 346311.759659, 346311.759659, 346311.681825, 346311.681825, 346314.763159, 346316.892246, 346316.892246, 346316.96977 , 346316.96977 , 346316.96977 , 346316.96977 , nan, nan, 346316.96977 , 346316.96977 , 346316.892246, 346316.892246, 346316.892246, 346316.892246]) nanidx = numpy.isnan(n) assert numpy.allclose(numpy.asarray(L.metadata.eastings)[~nanidx], n[~nanidx]) return
def test_h5_consolidate(argenfnm, milnefnm): path = [os.path.split(argenfnm)[0]] path.append("test_merged.h5") mergefnm = os.path.join(*path) ret = subprocess.call(["h5_consolidate.py", argenfnm, milnefnm, "-o", mergefnm]) assert ret == 0 S = irlib.Survey(mergefnm) assert len(S.GetLines()) == 3 return
def test_h5_add_utm_milne(milnefnm): stem, ext = os.path.splitext(milnefnm) utmfnm = stem + "_utm" + ext ret = subprocess.call(["h5_add_utm.py", milnefnm, utmfnm]) assert ret == 0 S = irlib.Survey(utmfnm) L = S.ExtractLine(1) nan = numpy.nan n = numpy.array([ 9161133.36736, 9161133.36736, 9161133.36736, 9161133.36745, 9161133.36761, 9161133.36761, 9161133.36745, 9161133.36736, 9161133.3672 , 9161133.3672 , 9161133.3672 , 9161133.36704, 9161126.33162, 9161118.19976, nan, 9161105.76789, 9161100.78348, 9161097.71067, 9161095.8658 , nan, 9161093.95717, 9161094.01193, 9161094.62972, 9161096.4692 , 9161099.86058, 9161104.24245, 9161107.0551 , 9161111.66542, 9161118.3973 , 9161125.35879, 9161129.67392, 9161129.90568, 9161133.86133, 9161139.71231, 9161145.12097, 9161149.97233, 9161153.8066 , 9161156.41596, 9161159.46658, 9161159.59457, 9161163.20475, 9161167.69076, 9161171.95208, 9161173.63734, 9161173.56501, 9161175.60739, nan, 9161178.1333 , 9161180.50754, 9161182.65744, 9161185.03814, 9161188.07447, 9161191.79024, 9161194.27968, 9161198.55899, nan, 9161203.08675, 9161207.25111, 9161211.97951, nan, 9161219.97287, 9161225.04166, 9161230.32451, 9161235.93926, 9161240.99503, 9161251.44201, 9161251.89183, 9161256.72228, 9161262.00746, 9161266.84627, 9161271.5694 , nan, 9161281.12757, 9161283.16876, 9161283.73181, 9161285.64676, 9161289.67984, 9161292.93198, 9161294.72435, 9161296.62431, nan, 9161297.51707, 9161299.97351, 9161300.53191, 9161300.53191, nan, 9161303.10884, 9161306.69693, 9161310.2838 , 9161315.08688, 9161318.10779, 9161322.02093, 9161326.05301, 9161331.5344 , 9161335.79309, 9161339.72034, 9161343.99263, 9161348.4838 , 9161352.42586, 9161358.60804, 9161359.17132, 9161363.56273, 9161367.83803, 9161371.44716, 9161371.82944, 9161369.09333, nan, 9161361.14841, 9161358.84448, 9161356.77308, 9161354.48075, 9161353.75103, nan, 9161354.62899, 9161353.67833, 9161352.61849, 9161352.11253, 9161352.05144, 9161354.67132, nan, 9161357.74864, 9161358.31425, 9161358.324 , 9161359.26338, 9161360.07601, 9161365.70368, nan, 9161375.94677, 9161379.22823, 9161383.50879, 9161387.7869 , 9161391.61551, 9161394.44281]) nanidx = numpy.isnan(n) assert numpy.allclose(numpy.asarray(L.metadata.northings)[~nanidx], n[~nanidx]) assert all(z==17 for z in L.metadata.zones)
def test2(): import irlib INFILE = '../field/radar_200905/Glacier2/Glacier2_May09_utm.h5' S = irlib.Survey(INFILE) L = S.ExtractLine(1) L.DoTimeGainControl() D = L.data.copy() eastings, northings, p = L.LineProject() P = np.sqrt((eastings - eastings[0])**2 + (northings - northings[0])**2) T = np.arange(L.data.shape[0]) * 1e-8 Dmig = mig_kirchoff(D, P, T, xoffset=0.0, xwindow=10.0) plt.figure() plt.subplot(1, 2, 1) plt.imshow(D, cmap='gray') plt.subplot(1, 2, 2) plt.imshow(Dmig, cmap='gray') plt.show()
else: overwrite = False if '-q' in optdict.keys(): be_quiet = True else: be_quiet = False try: survey_fnm = sys.argv[1] outfnm = sys.argv[2] except IndexError: print_syntax() sys.exit() S = irlib.Survey(survey_fnm) lines = S.GetLines() line_dict = {} metadata_dict = {} for line in lines: line_no = line.split('_')[1] if os.path.isfile(outfnm) and not overwrite: pass else: if not be_quiet: print("Reading " + str(line)) try: L = S.ExtractLine(line_no)