#!/usr/bin/python import sys,csv,os,cStringIO CS_BINARY = os.path.join(os.path.dirname(os.path.realpath(__file__)),"cavestats") N = 30 # Number to include in "N longest" and "N deepest" lists # Utility functions def chomp(s): if(s[-1]=="\n"): return s[:-1] else: return s # Important functions def find_effective_number(c): """Determine an appropriate number to use.""" if c["Kataster Number"]: return c["Kataster Number"] else: return c["Unofficial number"] def find_name(c): if c["Name"]: return c["Name"] elif c["Unofficial Name"]: return c["Unofficial Name"] else: return "?" def dataset_prefix(c): translations = {"2002-xx" : "quarriesd", "la11" : "lunge", "la12" : "sternloch", "la34" : "raetsel", "2001-ms-01" : "bogen" } if translations.has_key(c): return translations[c] else: return c def print_caveline(number, l, d, w, cave): dplong.write("%s" % number) if cave["Autogen file"]: # single caves dplong.write("""%s""" % (cave["Autogen file"], find_name(cave))) dplong.write("""%.1f%.1f%.1f\n""" % (l,d,w)) dump.write("%s\t%d\t%d\t%d\n" % (number, l, d, w)) else: # virtual entries for cave systems dplong.write("""%s""" % find_name(cave)) dplong.write("""%.1f%.1f%.1f\n""" % (l,d,w)) def parse_csvfile(): caveslist = [] print "Calculating SMK-system extent... ", os.popen("cavern -v7 ../loser/smk-system -o noinfo/smk-system.3d") l,d,w = map(float, chomp(os.popen(CS_BINARY + " noinfo/smk-system -c ").read()).split("\t")) caveslist.append(["", l,d,w, {"Name" : "Schwarzmooskogelhöhlensystem", "Autogen file" : ""}]) print "done\nParsing CSV file" cavetabfile = file("noinfo/CAVETAB2.CSV") fieldnames=chomp(cavetabfile.next()).replace('"','').split(",") cavetab = csv.DictReader(cavetabfile, fieldnames) # Gratuitiously complicated progress bar widget. k = 0 m = 1 L = 498 #L = len(cavetabfile.readlines()) doesn't work print "0"+50*"-"+"100%\n|", for cave in cavetab: if((50*m)/L > k): sys.stdout.write("=") sys.stdout.flush() k = k + 1 m = m + 1 if(cave["Multiple entrances"] not in ["", "yes"]): continue number = find_effective_number(cave) if((cave["Area"]=="1626") and (number not in ['LA11', 'LA12'])): continue prefix = dataset_prefix(number.lower()) stats = os.popen(CS_BINARY + " noinfo/all -cs " + prefix).read() if(stats.find("No") != -1): continue # don't trust the rather erratic data in the table #if(cave["Length"]): print number, "length:", cave["Length"] #if(cave["Depth"]): print number, "depth:", cave["Depth"] #if(cave["Extent"]): print number, "extent:", cave["Extent"] else: try: l,d,w = map(float, chomp(stats).split("\t")) caveslist.append([number,l,d,w,cave]) except: print "Error on", number raise print "|%d\nWriting output file" % m return caveslist # Main routine: # this doesn't seem to work, and is deprectaed anyway #if (not os.access('CS_BINARY', os.X_OK)): # print "%s not executable - skipping %s" % (CS_BINARY,__file__) # exit(1) caveslist = parse_csvfile() dplong = file("dplong.htm", "w") dump = file("noinfo/lengths.dat", "w") dplong.write(""" CUCC's deepest and longest caves

Lengths and depths of caves in the 1623 area

This page lists the lengths, depths and horizontal extents of those caves on the plateau for which we have survey centerline data. At present, that's only %d out of 250 or so, but the missing ones are mostly very small and obscure; the notable exceptions are some caves explored by other groups (35, LA25, BS17), and CUCC caves 71, 76, 92, 96 and 97. Of the latter 76 (by far the most significant of these) is in the process of being re-explored, and the figures in the table are for the portions revisited so far.

The eight main constitutent parts of the Schwarzmooskogel master system (40, 41, 78, 88, 115, 116, 136, 144 and 161) are listed separately in the table, although in some cases there is some ambiguity as to where to draw the lines; but for comparison I have also included the measurements of the whole system.

In these tables "length" means the total length of survey legs, not just the horizontal components, but "extent" is the maximum horizontal distance between any two survey stations. (If anyone knows a good algorithm for finding the maximum 3D spatial diameter of a set of points, and is willing to implement it, please do so!)

Deepest cavesLongest caves

""" % len(caveslist)) for cave in caveslist: print_caveline(*cave) dplong.write("""
Kat. Nr.NameLength (m)Depth (m)Extent (m)

The plateau's %d deepest caves

""" % N) dump.close() dump = cStringIO.StringIO() # just throw it away! caveslist.sort(lambda u, v: cmp(v[2],u[2])) for cave in caveslist[:N]: print_caveline(*cave) dplong.write("""
Kat. Nr.NameLength (m)Depth (m)Extent (m)

The plateau's %d longest caves

""" % N) caveslist.sort(lambda u, v: cmp(v[1],u[1])) for cave in caveslist[:N]: print_caveline(*cave) dplong.write("""
Kat. Nr.NameLength (m)Depth (m)Extent (m)

This page used to house a list of the deepest and longest caves in Austria, with ours highlighted. Rather than maintaining our own independent database, it seems much more sensible to link to the much more frequently updated list here maintained by Theo Pfarr. For comparison, Bob Gulden of the American NSS maintains a list here of the world's longest caves.


""") dump.close()