Commits

beroe committed 1f126ff

renamed vars_anno

Comments (0)

Files changed (2)

database/vars_annotations_by_dive.py

-#! /opt/python/bin/python
-
-# this needs the pymssql module, which needs freetds and possibly unixODBC,
-# so it is not the easiest to install. 
-# to run it on pismo, you have to use the funky path to python so it will use v2.7 instead of 2.5
-
-import pymssql
-import time
-import sys
-
-
-# change this database depending on the query...
-
-	# for expeditions
-# mydatabase = "EXPD" # "solstice.shore.mbari.org"
-
-	# for Vars data 
-mydatabase = "VARS" # "equinox.shore.mbari.org" # "134.89.12.101"
-
-	# for knowledgebase
-# mydatabase = "VARS_KB" # "equinox.shore.mbari.org" # "134.89.12.101"
-
-# a table of servers to use for each database
-
-serverlookup = {
-	"EXPD"   : "solstice.shore.mbari.org",
-	"VARS"   : "equinox.shore.mbari.org",
-	"VARS_KB": "equinox.shore.mbari.org"
-}
-
-# grab the right server name, depending on what database is being used...
-servername = serverlookup[mydatabase]
-
-username   = "everyone"
-pw         = "guest"
-
-
-# Create a list of dive numbers to cycle through...
-
-
-DiveList ={}
-
-DiveList['%Ricketts%'] = [26, 29, 329]
-DiveList['%Tiburon%']  = [131, 132, 1155] 
-
-Fields = "FileID\tDiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
-RecordedDate\tEpochSecs\tRovName\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
-VideoArchiveSetID_FK\tShipName\tObservationID_FK\tAssociations\tvideoArchiveName\tCameraDirection\t\
-ChiefScientist\tFieldWidth\tImage\tNotes\tObserver\n"
-
-
-conn = pymssql.connect(host=servername, user=username, password=pw, database=mydatabase, as_dict=False)
-cur = conn.cursor()
-
-#Write all records to one big file or write each dive to a separate file.
-
-MULTIFILE = False
-
-if MULTIFILE:
-	FileName = "CombinedDives.dat"
-	OutFile= open(FileName,'w')
-	OutFile.write(Fields)
-
-NumRecords=0
-for Vehicle in ['%Ricketts%','%Tiburon%']:
-	for Dive in DiveList.get(Vehicle):
-		ShortName = "%s%05d" % (Vehicle[1],Dive)
-		# write to individual files
-		if not MULTIFILE:
-			FileName = "Dive_"+ShortName+".dat"
-		#sys.stderr.write(FileName+"\n")
-			OutFile= open(FileName,'w')
-			OutFile.write(Fields)
-			NumRecords=0
-		
-# can add "top 10" after SELECT, to limit records... 
-
-		query=""" SELECT 
-ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
-ann.RecordedDate, ann.RovName, ann.TapeTimeCode, ann.Zoom, ann.ObservationID_FK AS obsid, ann.LinkValue, ann.linkName, 
-ann.VideoArchiveSetID_FK AS vasid, ann.ShipName, ann.Associations,ann.videoArchiveName, ann.CameraDirection,
-ann.ChiefScientist, ann.FieldWidth, ann.Image, ann.Notes, ann.Observer 
-FROM Annotations AS ann WHERE
-( (RovName like '%s') and (DiveNumber = %d ) ) """ % (Vehicle, Dive)
-
-		# print query
-
-		cur.execute(query)
-
-#timepattern = '%Y-%m-%d %H:%M:%S'
-
-		for row in cur:
-			NumRecords += 1
-			date_time = row[8]
-			try:
-				epoch= time.mktime(date_time.timetuple())
-			except: 
-				epoch = 999
-			#epoch = int(time.mktime(time.strptime(date_time, timepattern)))
-			strlist = ["%s"%(x) for x in row]
-			strlist.insert(8,str(epoch) )
-			strlist.insert(0,ShortName )
-			#print "%s\t%s\t%s" % (row[7],row[8],row[9])
-			#print "\t".join(strlist)
-			outstr = "\t".join(strlist)
-			outstr += "\n"
-			OutFile.write(outstr)
-			#print epoch
-			#print "\t".join(row)
-			#print "ID=%d, Name=%s" % (row['id'], row['name'])
-		if not MULTIFILE:
-			OutFile.close()
-		# use this line if writing to individual files	
-			sys.stderr.write("Wrote %d records to %s\n"% (NumRecords,FileName))
-if MULTIFILE:
-	sys.stderr.write("Wrote %d records to %s\n"% (NumRecords,FileName))
-	OutFile.close()
-conn.close()

database/vars_annotations_by_dive2.py

+#! /opt/python/bin/python
+
+# this needs the pymssql module, which needs freetds and possibly unixODBC,
+# so it is not the easiest to install. 
+# to run it on pismo, you have to use the funky path to python so it will use v2.7 instead of 2.5
+
+import pymssql
+import time
+import sys
+
+
+# change this database depending on the query...
+
+	# for expeditions
+# mydatabase = "EXPD" # "solstice.shore.mbari.org"
+
+	# for Vars data 
+mydatabase = "VARS" # "equinox.shore.mbari.org" # "134.89.12.101"
+
+	# for knowledgebase
+# mydatabase = "VARS_KB" # "equinox.shore.mbari.org" # "134.89.12.101"
+
+# a table of servers to use for each database
+
+serverlookup = {
+	"EXPD"   : "solstice.shore.mbari.org",
+	"VARS"   : "equinox.shore.mbari.org",
+	"VARS_KB": "equinox.shore.mbari.org"
+}
+
+# grab the right server name, depending on what database is being used...
+servername = serverlookup[mydatabase]
+
+username   = "everyone"
+pw         = "guest"
+
+
+# Create a list of dive numbers to cycle through...
+
+
+DiveList ={}
+
+DiveList['%Ricketts%'] = [26, 29, 329]
+DiveList['%Tiburon%']  = [131, 132, 1155] 
+
+Fields = "FileID\tDiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
+RecordedDate\tEpochSecs\tRovName\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
+VideoArchiveSetID_FK\tShipName\tObservationID_FK\tAssociations\tvideoArchiveName\tCameraDirection\t\
+ChiefScientist\tFieldWidth\tImage\tNotes\tObserver\n"
+
+
+conn = pymssql.connect(host=servername, user=username, password=pw, database=mydatabase, as_dict=False)
+cur = conn.cursor()
+
+#Write all records to one big file or write each dive to a separate file.
+
+MULTIFILE = False
+
+if MULTIFILE:
+	FileName = "CombinedDives.dat"
+	OutFile= open(FileName,'w')
+	OutFile.write(Fields)
+
+NumRecords=0
+for Vehicle in ['%Ricketts%','%Tiburon%']:
+	for Dive in DiveList.get(Vehicle):
+		ShortName = "%s%05d" % (Vehicle[1],Dive)
+		# write to individual files
+		if not MULTIFILE:
+			FileName = "Dive_"+ShortName+".dat"
+		#sys.stderr.write(FileName+"\n")
+			OutFile= open(FileName,'w')
+			OutFile.write(Fields)
+			NumRecords=0
+		
+# can add "top 10" after SELECT, to limit records... 
+
+		query=""" SELECT 
+ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
+ann.RecordedDate, ann.RovName, ann.TapeTimeCode, ann.Zoom, ann.ObservationID_FK AS obsid, ann.LinkValue, ann.linkName, 
+ann.VideoArchiveSetID_FK AS vasid, ann.ShipName, ann.Associations,ann.videoArchiveName, ann.CameraDirection,
+ann.ChiefScientist, ann.FieldWidth, ann.Image, ann.Notes, ann.Observer 
+FROM Annotations AS ann WHERE
+( (RovName like '%s') and (DiveNumber = %d ) ) """ % (Vehicle, Dive)
+
+		# print query
+
+		cur.execute(query)
+
+#timepattern = '%Y-%m-%d %H:%M:%S'
+
+		for row in cur:
+			NumRecords += 1
+			date_time = row[8]
+			try:
+				epoch= time.mktime(date_time.timetuple())
+			except: 
+				epoch = 999
+			#epoch = int(time.mktime(time.strptime(date_time, timepattern)))
+			strlist = ["%s"%(x) for x in row]
+			strlist.insert(8,str(epoch) )
+			strlist.insert(0,ShortName )
+			#print "%s\t%s\t%s" % (row[7],row[8],row[9])
+			#print "\t".join(strlist)
+			outstr = "\t".join(strlist)
+			outstr += "\n"
+			OutFile.write(outstr)
+			#print epoch
+			#print "\t".join(row)
+			#print "ID=%d, Name=%s" % (row['id'], row['name'])
+		if not MULTIFILE:
+			OutFile.close()
+		# use this line if writing to individual files	
+			sys.stderr.write("Wrote %d records to %s\n"% (NumRecords,FileName))
+if MULTIFILE:
+	sys.stderr.write("Wrote %d records to %s\n"% (NumRecords,FileName))
+	OutFile.close()
+conn.close()