APSF,0 // Find interesting objects close to the one you are currently observing // Paul Rodman, 2006 (from a suggestion by Rod Mollise) // This script assumes you are connected to a telescope that is currently // pointing at a suitable object. dim ra,dec,radius,maglimit,angle,angles(-1) as double dim types(-1),cats(-1),i,stypes,scats,obn(-1),iobj as integer dim catnames(-1),ob(-1),s as string dim srch as APSearch, add,slew as boolean // Check for telescope connectivity if not IsOnLine then print "Not connected to a telescope!" return end if // Request search parameters ra=CurrentRA dec=CurrentDec redim types(type_Galaxy-1) types(type_Galaxy-1)=1 for i=1 to nCatalogs s=GetCatalog(i).Name catnames.Append s if ubound(cats)<0 and left(s,4)="NGC " then redim cats(i) cats(i)=1 end if next radius=RestoreDoubleValue("radius",5.0) maglimit=RestoreDoubleValue("maglimit",15.0) types=RestoreIntegerValue("types",types) cats=RestoreIntegerValue("cats",cats) while true SetCaptionParameter("Currently pointing at RA "+FormatRA(ra)+ _ " Dec "+FormatDec(dec),1,true,false,false,false,true) SetDoubleParameter("Search radius (degrees)",radius,0.1,20.0) SetDoubleParameter(true,"Magnitude limit",maglimit,0.0,30.0) SetCheckListParameter("Object types (choose at least one)",types,AllTypeNames,true,12) SetCheckListParameter(true,"Catalogues (choose at least one)",cats,catnames,true,12) if not EditParameters("Search Criteria") then return radius=GetDoubleParameter("Search radius (degrees)") maglimit=GetDoubleParameter("Magnitude limit") types=GetCheckListParameter("Object types (choose at least one)") cats=GetCheckListParameter("Catalogues (choose at least one)") stypes=0 for i=1 to ubound(types) stypes=stypes+types(i) next scats=0 for i=0 to ubound(cats) scats=scats+cats(i) next if stypes>0 and scats>0 then exit if stypes=0 then print "Must choose at least one object type!" if scats=0 then print "Must choose at least one catalogue!" wend SaveDoubleValue("radius",radius) SaveDoubleValue("maglimit",maglimit) SaveIntegerValue("types",types) SaveIntegerValue("cats",cats) // Set up the search bounds srch = new APSearch //srch.AddBound(item_Magnitude,rel_LE,maglimit) for i=0 to ubound(types) if types(i)=1 then srch.AddType(i+1) next for i=0 to ubound(cats) if cats(i)=1 then srch.SetCatalog(i+1) next srch.WithinDistance(radius,ra,dec) // Search for nearby objects if not srch.Search then print "Search Error: "+srch.Error return end if if srch.nObjects<=0 then print "No objects found!" return end if // Present list of objects for i=1 to srch.nObjects angle=AngleBetween(ra,dec,srch.GetObject(i).RA,srch.GetObject(i).Dec) s=srch.GetObject(i).ID+" ("+format(angle,"0.00")+DegreeSymbol+", "+ _ srch.GetObject(i).Type+")" ob.Append s angles.Append angle next SetCheckListParameter("Objects",obn,ob,true,12) SetBooleanParameter("Add selected objects to plan",false) SetBooleanParameter("Slew to closest selected object",false) if not EditParameters("Nearby Objects") then return obn=GetCheckListParameter("Objects") add=GetBooleanParameter("Add selected objects to plan") slew=GetBooleanParameter("Slew to closest selected object") // Add to plan if necessary if add then for i=0 to ubound(obn) if obn(i)=1 then call srch.GetObject(i+1).AddToPlan next end if // Slew to selected object if necessary if slew then // Find closest selected object angle=1E30 iobj=-1 for i=0 to ubound(obn) if obn(i)=1 then if angles(i)=0 then select case SlewTo(srch.GetObject(i+1).RA,srch.GetObject(i+1).Dec) case -1 print "Telescope cannot slew!" case 2 print "Below horizon!" case 3 print "Outside slewing limits!" case 4 print "Blocked by user horizon!" end select end if end if