def doPlotSetup(self, koi, filt): 
		offra0, offdec0 = self.getHeaderOffsets(ao.getDataDir(koi)+self.frame0)
		offra1, offdec1 = self.getHeaderOffsets(ao.getDataDir(koi)+self.frame1)
		offra2, offdec2 = self.getHeaderOffsets(ao.getDataDir(koi)+self.frame2)
		deltaRA10 = offra1-offra0
		deltaRA12 = offra1-offra2
		deltaDec10 = offdec1-offdec0
		deltaDec12 = offdec1-offdec2
		self.arrowDeltaX12 = self.nextX1-self.nextX2
		self.arrowDeltaY12 = self.nextY1-self.nextY2
		self.arrowDeltaX10 = self.nextX1-self.nextX0
		self.arrowDeltaY10 = self.nextY1-self.nextY0
		if self.rotation[2] == True:
			self.arrowDeltaX12 = -self.arrowDeltaX12
			self.arrowDeltaX10 = -self.arrowDeltaX10
		if self.rotation[1] == True:
		#	print "Flipping up-down "
			self.arrowDeltaY12 = -self.arrowDeltaY12
			self.arrowDeltaY10 = -self.arrowDeltaY10
			
		plateScale= ao.getPlateScaleFromHeader(ao.getDataDir(koi)+self.frame0)
#		print "Star 1-0:  RA delta is ",deltaRA10,", dec delta is ",deltaDec10,", x delta is ",arrowDeltaX10*plateScale,", y delta is ",arrowDeltaY10*plateScale
#		print "Star 1-2:  RA delta is ",deltaRA12,", dec delta is ",deltaDec12,", x delta is ",arrowDeltaX12*plateScale,", y delta is ",arrowDeltaY12*plateScale
		## Now read in coordinates of our target
		coords = open(self.fitsDir+self.cooFile)
		lines = coords.readlines()
		targetCoords = lines[0].split(" ")
		coords.close()
		self.zoomedBoxHalfSize = int(self.zoomedBoxHalfSizeArcsec / plateScale)
#		print plateScale, " arcsec per pixel means boxes are ", zoomedBoxHalfSize
		ctrX=eval(targetCoords[0])
		ctrY=eval(targetCoords[1])
		self.lowerX=round(ctrX)-self.zoomedBoxHalfSize
		self.lowerY=round(ctrY)-self.zoomedBoxHalfSize
		self.upperX=round(ctrX)+self.zoomedBoxHalfSize
		self.upperY=round(ctrY)+self.zoomedBoxHalfSize
		### Read in data
		f = pyfits.open(self.fitsDir+self.fitsFile) 
#		self.scidata = f[0].data
		self.scidata = np.array( f[0].data ) + self.artificialBoostToAvoidZeroBkg
		self.scidataZoomed = self.scidata[self.lowerY:self.upperY,self.lowerX:self.upperX]
		## [number of times to rotate 90 deg, flip x, flip y], done in reverse order
		if self.rotation==[0,False,False]:
			foo = 1
		else:
			if  self.rotation[2] == True:
				self.scidataZoomed = np.fliplr(self.scidataZoomed)
			if  self.rotation[1] == True:
				self.scidataZoomed = np.flipud(self.scidataZoomed)
		self.scidataZoomed = np.rot90(self.scidataZoomed, self.rotation[0])
#		print self.scidataZoomed[1]
		## Number of pixels, peak counts
		self.numY=len(self.scidata)
		self.numX=len(self.scidata[0])
		peakCounts= self.scidata[round(ctrY),round(ctrX)]
		self.scaleMin = self.peakScaleFactor[0]+self.artificialBoostToAvoidZeroBkg#*minVal
		self.scaleMax = self.peakScaleFactor[1]#*maxVal
#		print koi, "scale min, max",self.scaleMin, self.scaleMax
		
		self.numYarcsec = self.numY * plateScale
		self.numXarcsec = self.numX * plateScale
		### Figure out sign ickiness
		## If the change in RA is of larger magnitude between stars 1-0, it is moving E-W 
		if abs(deltaRA10) > abs(deltaRA12):
			self.dir10 ="E"
			self.dir12 ="N"	
			if deltaRA10 > 0: # ie, if the arrow is really W, make it E by flipping
#				print "1-0 axis is W; ", deltaRA10, deltaRA12
				self.arrowDeltaX10 = -self.arrowDeltaX10
				self.arrowDeltaY10 = -self.arrowDeltaY10
#			else:
#				print "1-0 axis is E; ", deltaRA10, deltaRA12
			if deltaDec12 > 0: # ie, if the arrow is really S, make it N by flipping
#				print "1-2 axis is S; ", deltaDec10, deltaDec12
				self.arrowDeltaX12 = -self.arrowDeltaX12
				self.arrowDeltaY12 = -self.arrowDeltaY12
#			else:
#				print "1-2 axis is N; ", deltaDec10, deltaDec12
		## Otherwise 1-2 is the E-W axis
		else:
			self.dir10 ="N"	
			self.dir12 ="E"
			if deltaRA12 > 0:   # ie, if the arrow is really S, make it N by flipping
#				print "1-0 axis is S; ", deltaDec10, deltaDec12
				self.arrowDeltaX12 = -self.arrowDeltaX12
				self.arrowDeltaY12 = -self.arrowDeltaY12
#			else:
#				print "1-0 axis is N; ", deltaDec10, deltaDec12
			if deltaDec10 > 0:  # ie, if the arrow is really W, make it E by flipping
#				print "1-2 axis is W; ", deltaRA10, deltaRA12
				self.arrowDeltaX10 = -self.arrowDeltaX10
				self.arrowDeltaY10 = -self.arrowDeltaY10
#			else:
#				print "1-2 axis is E; ", deltaRA10, deltaRA12
		### Work out rotation here (flips are easier done up above)
		if self.rotation[0] == 1:
			newY10 = self.arrowDeltaX10
			newY12 = self.arrowDeltaX12
			self.arrowDeltaX10 = self.arrowDeltaY10
			self.arrowDeltaY10 = -newY10
			self.arrowDeltaX12 = self.arrowDeltaY12
			self.arrowDeltaY12 = -newY12
		elif self.rotation[0] == 2:
			self.arrowDeltaX10 = -self.arrowDeltaX10
			self.arrowDeltaY10 = -self.arrowDeltaY10
			self.arrowDeltaX12 = -self.arrowDeltaX12
			self.arrowDeltaY12 = -self.arrowDeltaY12
		elif self.rotation[0] == 3:
			newY10 = self.arrowDeltaX10
			newY12 = self.arrowDeltaX12
			self.arrowDeltaX10 = -self.arrowDeltaY10
			self.arrowDeltaY10 = newY10
			self.arrowDeltaX12 = -self.arrowDeltaY12
			self.arrowDeltaY12 = newY12
			
		## Find if x or y is associated with E or N
		if abs(self.arrowDeltaX10) > abs(self.arrowDeltaY10):
			self.xDir ="E"	
			self.arrowOffsetX=cmp(self.arrowDeltaX10,0)*-.7*self.zoomedBoxHalfSize
			self.arrowOffsetY=cmp(self.arrowDeltaY12,0)*-.7*self.zoomedBoxHalfSize
		else:
			self.getExtraOffsetsxDir ="N"
			self.arrowOffsetX=cmp(self.arrowDeltaX12,0)*-.7*self.zoomedBoxHalfSize
			self.arrowOffsetY=cmp(self.arrowDeltaY10,0)*-.7*self.zoomedBoxHalfSize
		
		# Force to be perpendicular! ie, disregard half of the dither pattern so laboriously found above
		self.arrowDeltaX10 = math.copysign(self.arrowDeltaY12,self.arrowDeltaX10)
		self.arrowDeltaY10 = math.copysign(self.arrowDeltaX12,self.arrowDeltaY10)
		#print dir10,arrowDeltaX10,arrowDeltaY10,dir12,arrowDeltaX12,arrowDeltaY12,arrowOffsetX,arrowOffsetY
		## Put center of arrow in correct corner depending on direction of arrows
		extraX12,extraY12=self.findExtraOffsetsSoItLooksPrettier(self.arrowDeltaX12,self.arrowDeltaY12)
		extraX10,extraY10=self.findExtraOffsetsSoItLooksPrettier(self.arrowDeltaX10,self.arrowDeltaY10)
		self.extraX = extraX12 + extraX10
		self.extraY = extraY12 + extraY10
def setDictValues(keyword):
	# Accept the old value if it exists (though some will be superceded)
#	if oldSettings[keyword] != 'XX':
#		print "This was set to something:",keyword,oldSettings[keyword]
#	else:
#		print "nothing here:",keyword
	if (oldSettings[keyword] != "XX"):
		useValue = oldSettings[keyword]

	# Otherwise set defaults
	elif keyword == "Instrument":
		useValue = instrUsed
	elif keyword == "Night":
		try:
			useValue = aries.objectsForNight[obj] ## a dict, not a function
		except KeyError:
			print "The observing night for",obj,"was not listed in aries.objectsForNight[obj]"
			useValue = "XX"
	elif keyword == "RefFrame_J":
		useValue = "XX"
	elif keyword == "RefFrame_Ks":
		useValue = "XX"
	elif keyword == "Camera_mode":
		useValue = "XX"
	elif keyword == "Plate_scale_J":
		try:
			useValue = ao.getPlateScaleFromHeader(ao.koiFilterDir(obj,"J")+ao.finalKOIimageFile(obj,"J"),True,instrUsed)
		except:
			useValue = "XX"
	elif keyword == "Plate_scale_Ks":
		try:
			useValue = ao.getPlateScaleFromHeader(ao.koiFilterDir(obj,"Ks")+ao.finalKOIimageFile(obj,"Ks"),True,instrUsed)
		except:
			useValue = "XX"
	elif keyword == "2MASS_J":
		useValue = jMag
	elif keyword == "2MASS_H":
		useValue = hMag
	elif keyword == "2MASS_Ks":
		useValue = kMag
	elif keyword == "FrameList_J":
		useValue = obj+"_J"
	elif keyword == "FrameList_Ks":
		useValue =obj+"_Ks"
	elif keyword == "TargetPixelRange_J":
		useValue = [[500,1000],[100,500]]
	elif keyword == "TargetPixelRange_Ks":
		useValue = [[500,1000],[100,500]]
	else:
		useValue = "NA"
	# Here are the ones that get superceded
	if keyword == "KOI":
		useValue = obj
###	if keyword == "Raw_data_dir":
###		useValue = ao.dataDir+settingsDict["Night"]+"/"
		
	# Notify user if there are missing, required entries
	if useValue == "XX":
		print "Need value for: ",obj,keyword
		
	return useValue