moduleDir = string.replace(pipelineDir,"pipeline-analysis","modules")
sys.path.append(moduleDir) 

import ao
import grabBag as gb
import kepler
import koiPlusFilter
import catalogs

##### Read in alternate instrument directory (if not "ARIES")
args = sys.argv
if len(args)>1:
	instrUsed = str(args[1])
else:
	instrUsed = "ARIES"
objectDataDir = ao.objDirByInstr(instrUsed)
print "\nLooking for objects in directory: \n "+objectDataDir+"\n"

### Read in which objects to use
if os.path.exists("usingObjects.txt"):
	data = open("usingObjects.txt","r")
	useObjects = []
	lines = data.readlines()
	for line in lines:
		useObjects.append(line.rstrip())
else:
	print "The file does not exist. Running all objects..."
	objectDirListing=os.listdir(objectDataDir)
	useObjects = []
	for obj in objectDirListing:
		useObjects.append(obj)
#
# Put PHARO images into folders just like ARIES, so pipeline-analysis can work

import sys
import os
import string
import shutil

# User packages
pipelineDir = os.path.dirname(os.path.realpath(__file__))
moduleDir = string.replace(pipelineDir,"pipeline-analysis","modules")
sys.path.append(moduleDir) 

import ao

pharoDir = ao.objDirByInstr("PHARO")

currentSubDirs = os.listdir(pharoDir)

##### Some of the files have DUPLICATES (18, 284, 271). Here are the files we used:
filesUsedAOI = "authoritative_list_ao1.txt"
g = open(filesUsedAOI)
lines = g.readlines()
g.close()
usedThese=[]
for line in lines:
	usedThese.append(line.rstrip())

print usedThese

for dd in currentSubDirs: