def pick_star(g): """A task to check to see if the current star is okay, and if not, to find a new star and move to it. """ current_file = "current_object" exposure_file = "exptime" salt_lat = Angle("-32:22:32 degree") catalog = "star.lst" # ra,dec,ha,lst,alt,az,airmass,pier = status(g) alt = Angle("%s degree" % g.alt()) az = Angle("%s degree" % g.az()) pier = g.pier().strip().lower() if ( pier == "east" and airmass(alt) < 1.15 and not (alt.degree < 75.0 and 285.0 < az.degree < 300.0) and os.path.isfile(current_file) ): print "Fine to stay here" return try: sid_current = open(current_file).read().strip() except: sid_current = None print sid_current # get the best object try: # sid, ra, dec = hrstar.best_star(lst,catalog=catalog, lat=salt_lat) sid, ra, dec = hrstar_with_precess_WEST.best_star(g.lst(), int(2014), catalog=catalog, lat=salt_lat) except ValueError: print "No other acceptable candidates, so best to stay here" return # get current object if sid == sid_current: print "Current object is still best candidate" return # Move to the new best object print "Slewing to HR %s at RA=%s and Dec=%s" % (sid, ra, dec) slew(g, ra, dec) # update current value if os.path.isfile(current_file): os.remove(current_file) fout = open(current_file, "w") fout.write("%s" % sid) fout.close() # update the exposure time if os.path.isfile(exposure_file): os.remove(exposure_file) fout = open(exposure_file, "w") fout.write("3.0e-3") fout.close()
def pick_star(g): """A task to check to see if the current star is okay, and if not, to find a new star and move to it. """ current_file = 'current_object' exposure_file = 'exptime' salt_lat = Angle("-32:22:32 degree") catalog = 'star.lst' #ra,dec,ha,lst,alt,az,airmass,pier = status(g) alt = Angle('%s degree' % g.alt()) az = Angle('%s degree' % g.az()) pier = g.pier().strip().lower() if pier == 'east' and airmass(alt) < 1.15 and not ( alt.degree < 75.0 and 285.0 < az.degree < 300.0) and os.path.isfile(current_file): print 'Fine to stay here' return try: sid_current = open(current_file).read().strip() except: sid_current = None print sid_current #get the best object try: #sid, ra, dec = hrstar.best_star(lst,catalog=catalog, lat=salt_lat) sid, ra, dec = hrstar_with_precess_WEST.best_star(g.lst(), int(2014), catalog=catalog, lat=salt_lat) except ValueError: print 'No other acceptable candidates, so best to stay here' return #get current object if sid == sid_current: print 'Current object is still best candidate' return #Move to the new best object print 'Slewing to HR %s at RA=%s and Dec=%s' % (sid, ra, dec) slew(g, ra, dec) #update current value if os.path.isfile(current_file): os.remove(current_file) fout = open(current_file, 'w') fout.write('%s' % sid) fout.close() #update the exposure time if os.path.isfile(exposure_file): os.remove(exposure_file) fout = open(exposure_file, 'w') fout.write('3.0e-3') fout.close()
try: sid = open(current_file).read().strip() except Exception, e: print e return #load catalog star_dict = load_catalog(hr_file) #get ra/dec for best object ra = star_dict[sid][1] dec = star_dict[sid][2] ra = Angle(ra, unit='hour') dec = Angle(dec, unit='degree') RA_now, Dec_now = Apply_precess(ra, dec, Year_NOW) #slew telescope to position with GTO900() as g: print 'Move to: RA(2000)=%s Dec(2000)=%s - RA(NOW)=%s Dec(NOW)=%s' % ( ra, dec, RA_now, Dec_now) #slew(g, ra, dec) slew(g, RA_now, Dec_now) if __name__ == '__main__': #goto_hr() import sys goto_hr(int(sys.argv[1]), current_file='current_object', hr_file='star.lst')
def goto_hr(Year_NOW,current_file='current_object', hr_file='star.lst'): """Go to the current object""" try: sid = open(current_file).read().strip() except Exception, e: print e return #load catalog star_dict=load_catalog(hr_file) #get ra/dec for best object ra = star_dict[sid][1] dec = star_dict[sid][2] ra = Angle(ra, unit='hour') dec = Angle(dec, unit='degree') RA_now, Dec_now = Apply_precess(ra,dec,Year_NOW) #slew telescope to position with GTO900() as g: print 'Move to: RA(2000)=%s Dec(2000)=%s - RA(NOW)=%s Dec(NOW)=%s'%(ra, dec, RA_now, Dec_now) #slew(g, ra, dec) slew(g, RA_now, Dec_now) if __name__=='__main__': #goto_hr() import sys goto_hr(int(sys.argv[1]),current_file='current_object', hr_file='star.lst')