def computeHoFromImage(starList): # the leading theory is that this approximation will only work when the stars are closeby # that is, the small angle approximation works pixScale = 24.1 # 5 # arcsec/pixel pixDegrees = pixScale / 3600 K = 3600 / 24.2 imageWidth = 3872 # pix imageHeight = 2592 # pix xc = imageWidth / 2 yc = imageHeight / 2 naturalBias = -4.9399 # -11.0701857994#-5.25 #calc from lyra_oct9 basic optimum # naturalBias =-4.7598 #this is teh TRUE # naturalBias =-3.3920 # naturalBias = -4.9749 # naturalBias = -5.2764 # PITCH CALIBRATION SUPER IMPORTANT pitch = 62.62 # 39.76#62.62 #deg # i'll need to get the correct roll value from the IMU roll = -0.54 # 1.9 #-0.32-1.9056-3.19+4444#-0.5 # -2.4#-0.54 rollOffset = -4.7598 # basic optimal point # rollOffset = 0.4523 #this one is the TRUE # rollOffset = 10.4774 # rollOffset = -5.2764 # strip 'annotations' # starList = starList['annotations'] shortList = [] # make a short list of the stars we're really interested in for star in starList: # if the star has an alternate name its probably big or bright or both # if len(star['names'])>1: # pixel offsets star["newx"] = star["pixelx"] * ST.cosd(roll + rollOffset) + star["pixely"] * ST.sind(roll + rollOffset) star["newy"] = -star["pixelx"] * ST.sind(roll + rollOffset) + star["pixely"] * ST.cosd(roll + rollOffset) star["xOff"] = star["pixelx"] - xc star["yOff"] = yc - star["pixely"] # rotation will go here # compute offset from roll angle # i think the order we do the roll and pitch operations is kind of important # star['ho'] = pitch + star['yOff']*pixDegrees + naturalBias # i feel like its plus and the matlab is actually whats wrong star["ho"] = -pixDegrees * star["xOff"] * ST.sind(roll + rollOffset) + ( pixDegrees * star["yOff"] + (pitch + naturalBias) ) * ST.cosd(roll + rollOffset) # shortList.append(star) print star # print "\n\n\n shortList \n\n\n" %shortList return [starList, pitch, roll]
# testing the nautical almanac values import ST as ST p = [0.0231, 0.3058, -0.4001] Z = [267.2721, 151.6809, 358.9823] ans = [] [ans.append(p[i]*ST.sind(Z[i])) for i in range(0, len(p))] ans = sum(ans) print ans