APSF //- Given a field of view (defined by telescope, eyepiece, etc.), this script //- looks for objects in a catalogue (say the NGC) that will drift //- into view in an untracked telescope within a given time t after centering //- the telescope on a bright star from a second catalog (say the Bright Star //- Catalogue). //- //- Paul Rodman, August 2007 //- //- V1.0 26 Aug 2007 //- V1.1 28 Aug 2007 //- Improved performance, no flickering windows. //- V1.2 09 Sep 2007 //- Reverted some code that was accidentally added. // Note: some non-optimal programming required to get around V1.5.8 bugs function FindDriftTo(ra as double, dec as double, cat as APCatalog, mag as double, fov as double, tmax as double, byref t() as double, byref a() as APCatalogObject) as boolean dim search as APSearch, tra as double, i,n as integer, ob as APCatalogObject const DegreesToRadians = 0.017453292 redim a(-1) redim t(-1) tra = fov*0.5/(15.0*cos(dec*DegreesToRadians)) search = new APSearch search.MaxResults=5 search.SetCatalog(cat.Name) search.AddBound(item_Magnitude,rel_LT,mag) search.AddBound(item_Dec,rel_GT,dec-fov*0.48) search.AddBound(item_Dec,rel_LT,dec+fov*0.48) search.AddBound(item_RA,rel_GE,ra+tRA) search.AddBound(item_RA,rel_LT,ra+tRA+tmax/3600.0) redim t(-1) if not search.Search then print search.Error return false end if n=search.nObjects if n<1 then return false for i=1 to n ob=search.GetObject(i) a.Append ob t.Append abs(ra+tRA-ob.RA)*3600.0 next return true end function dim i,j,k,l as integer, VAid(-1),s(-1),ss,sss,id(-1),objname(-1),bid(-1),bt(-1),bids(-1),bts(-1) as string dim t(-1),fov,tmax,magstar,magdso,ra(-1),dec(-1),mag(-1) as double, search as APSearch dim scope as TelescopeResource, ep as EyepieceResource, aid as VisualAidResource dim a,b(-1) as APCatalogObject,n,m,WhatToSave as integer dim p as APPlanObject, iscope,ipiece,iaid, imax, iconst, icat, sourcecat, targetcat as integer dim list as ListWindow, srccats(-1),tcats(-1) as APCatalog // Get parameters iscope=RestoreIntegerValue("Telescope",0) ipiece=RestoreIntegerValue("Eyepiece",0) iaid=RestoreIntegerValue("Aid",0) imax=RestoreIntegerValue("imax",50) tmax=RestoreDoubleValue("tmax",3.0) magstar=RestoreDoubleValue("magstar",3.0) magdso=RestoreDoubleValue("magdso",15.0) sourcecat=RestoreIntegerValue("sourcecat",0) targetcat=RestoreIntegerValue("targetcat",0) WhatToSave=RestoreIntegerValue("WhatToSave",0) SetPopupParameter("Telescope",iscope,Telescopes) SetPopupParameter(true,"Eyepiece",ipiece,Eyepieces) VAid.Append "None" for i=1 to nVisualAids VAid.Append VisualAid(i).Name next SetPopupParameter("Visual Aid",iaid,VAid) SetDoubleParameter(true,"Maximum wait time (min)",tmax,1,24*60) srccats=CatalogsWithType(type_Star) SetPopupParameter("Source Catalogue",sourcecat,srccats) SetPopupParameter(true,"Target Catalogue",targetcat,Catalogs) SetDoubleParameter("Source Magnitude <",magstar,-1,30) SetDoubleParameter(true,"Target Magnitude <",magdso,-1,30) SetIntegerParameter("Maximum source stars",imax,1,3000) SetChoiceParameter("Results",WhatToSave,"List only","Add sources to plan (with notes)","Add sources and targets to plan") if not EditParameters("Drift To Object") then return // Get instrument parameters and work out actual FOV iscope=GetPopupParameter("Telescope") scope=Telescope(iscope+1) ipiece=GetPopupParameter("Eyepiece") ep=Eyepiece(ipiece+1) iaid=GetPopupParameter("Visual Aid") if iaid=0 then aid=nil else aid=VisualAid(iaid) if scope.IsBinocular then fov=scope.FOV else fov=ActualFOV(scope,ep,aid) end if // Get object search parameters and set up search WhatToSave=GetChoiceParameter("Results") sourcecat=GetPopupParameter("Source Catalogue") targetcat=GetPopupParameter("Target Catalogue") magstar=GetDoubleParameter("Source Magnitude <") magdso=GetDoubleParameter("Target Magnitude <") tmax=GetDoubleParameter("Maximum wait time (min)") imax=GetIntegerParameter("Maximum source stars") // Get list of bright stars as source targets search = new APSearch search.SetCatalog(srccats(sourcecat).Name) search.MaxResults=imax search.AddBound(item_Magnitude,rel_LT,magstar) if not search.Search then print search.Error return end if n=search.nObjects for i=1 to n a=search.GetObject(i) ra.Append a.RA dec.Append a.Dec mag.Append a.Magnitude ss=a.Bayer() sss=a.Name j=instr(sss,ss+",") if j>0 then sss=left(sss,j-1)+mid(sss,j+len(ss)+1) if sss<>"" then ss=ss+", "+sss objname.Append ss id.Append a.ID next search=nil list=new ListWindow("Drift to with FOV: "+format(fov,"0.0##")+DegreeSymbol) list.Heading(1)="Source Object" list.Heading(2)="Magnitude" list.Heading(3)="Target Object" list.Heading(4)="Type" list.Heading(5)="Magnitude" list.Heading(6)="Time to appear" StartProgress("Searching for drift candidates",true,n) k=1 for i=0 to ubound(ra) // Check for user cancel if UpdateProgress(i+1) then StopProgress return end if redim bids(-1) redim bts(-1) // Check for drift-to object tcats=Catalogs if FindDriftTo(ra(i),dec(i),tcats(targetcat),magdso,fov,tmax*60.0,t,b) then list.Cell(k,1)=objname(i) list.Cell(k,2)=mag(i) while ubound(b)>=0 l=0 for j=1 to ubound(b) if t(j)0 then sss=left(sss,j-1)+mid(sss,j+len(ss)+1) if sss<>"" then ss=ss+", "+sss list.Cell(k,3)=ss list.Cell(k,4)=b(l).Type list.Cell(k,5)=b(l).Magnitude if t(l)<60 then ss=str(round(t(l)))+" sec" else t(l)=t(l)/60.0 ss=str(floor(t(l)))+" min "+str(floor((t(l)-floor(t(l)))*60))+" sec" end if list.Cell(k,6)=ss bts.Append ss b.Remove l t.Remove l k=k+1 wend end if bid.Append Join(bids,chr(9)) bt.Append Join(bts,chr(9)) next StopProgress if WhatToSave>0 then StartProgress("Creating plan objects",true,ubound(id)) for i=0 to ubound(id) // Check for user cancel if UpdateProgress(i) then StopProgress exit end if if bid(i)<>"" then search = new APSearch search.SetCatalog(srccats(sourcecat).Name) search.MaxResults=1 if search.Search(id(i)) then p=search.GetObject(1).AddToPlan redim s(-1) for j=1 to CountFields(bid(i),chr(9)) s.Append NthField(bid(i),chr(9),j)+" in "+NthField(bt(i),chr(9),j) next if p.Notes<>"" then p.Notes=p.Notes+" " p.Notes=p.Notes+"[Drift: "+Join(s,", ")+"]" if WhatToSave>1 then for j=1 to CountFields(bid(i),chr(9)) search = new APSearch search.SetCatalog(tcats(targetcat).Name) search.MaxResults=1 if search.Search(NthField(bid(i),chr(9),j)) then p=search.GetObject(1).AddToPlan if p.Notes<>"" then p.Notes=p.Notes+" " p.Notes=p.Notes+"[Drift: "+NthField(bt(i),chr(9),j)+"]" end if next end if end if end if next StopProgress end if SaveIntegerValue("Telescope",iscope) SaveIntegerValue("Eyepiece",ipiece) SaveIntegerValue("Aid",iaid) SaveIntegerValue("imax",imax) SaveDoubleValue("tmax",tmax) SaveDoubleValue("magstar",magstar) SaveDoubleValue("magdso",magdso) SaveIntegerValue("sourcecat",sourcecat) SaveIntegerValue("targetcat",targetcat) SaveIntegerValue("WhatToSave",WhatToSave) Bleep