APSF //- This script searches a selected constellation for two or more objects //- in the same field of view of a given eyepiece/telescope/aid combination //- Paul Rodman, July 2006 //- //- V1.1 3 Aug 2007 //- If the selected telescope is actually binoculars, then the binocular //- FOV will be used, and the eyepiece and visual aid ignored. dim i,j,k,l,Objects(-1) as integer, VAid(-1),s(-1) as string, fov,sep,maxsep,minmag as double, search as APSearch dim scope as TelescopeResource, ep as EyepieceResource, aid as VisualAidResource dim a,b,amax,bmax,pairs(-1,-1),mult(-1) as APCatalogObject, hits(-1) as string, list,n,m,npairs,WhatToSave as integer dim p as APPlanObject, npair,nmulti,iscope,ipiece,iaid, imaxsrch, iconst, icat as integer dim rconstellation, rcatalogue as boolean sub Eliminate(a as APCatalogObject) // Eliminate duplicate objects dim i,j as integer for i=0 to ubound(pairs,1) for j=0 to 1 if pairs(i,j)<>nil and pairs(i,j).ID=a.ID then pairs(i,j)=nil next next end sub function AverageRA(ra1 as double, ra2 as double) as double // Find the average of two RAs dim r,r1,r2 as double if abs(ra1-ra2)<12.0 then return (ra1+ra2)*0.5 r1=min(ra1,ra2)+24.0 r2=max(ra1,ra2) r=(r1+r2)*0.5 if r<24.0 then return r else return r-24.0 end function // Get parameters // Some default objects redim Objects(29) Objects(5)=1 Objects(21)=1 Objects(27)=1 Objects(29)=1 iscope=RestoreIntegerValue("Telescope",0) ipiece=RestoreIntegerValue("Eyepiece",0) iaid=RestoreIntegerValue("Aid",0) imaxsrch=RestoreIntegerValue("imaxsrch",10000) rconstellation=RestoreBooleanValue("RConst",true) rcatalogue=RestoreBooleanValue("RCat",true) iconst=RestoreIntegerValue("Const",0) icat=RestoreIntegerValue("Cat",0) WhatToSave=RestoreIntegerValue("WhatToSave",0) Objects=RestoreIntegerValue("Objects",Objects) 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) SetIntegerParameter(true,"Max. search hits",imaxsrch,1,100000) SetBooleanParameter("Restrict to constellation",rconstellation) SetBooleanParameter(true,"Restrict to catalogue",rcatalogue) SetPopupParameter("Constellation",iconst,Constellations) SetPopupParameter(true,"Catalogue",icat,Catalogs) SetCheckListParameter("Object Types (select at least one)",Objects,AllTypeNames,true) SetChoiceParameter(true,"Results",WhatToSave,"List only","Add pairs to plan","Add multiples to plan","Add pairs and multiples to plan") if not EditParameters("Close Objects") 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") Objects=GetCheckListParameter("Object Types (select at least one)") search = new APSearch rconstellation=GetBooleanParameter("Restrict to constellation") iconst=GetPopupParameter("Constellation") if rconstellation then search.AddConstellation(ConstellationAbbreviation(iconst)) rcatalogue=GetBooleanParameter("Restrict to catalogue") icat=GetPopupParameter("Catalogue") if rcatalogue then search.SetCatalog(icat+1) j=0 for i=0 to ubound(Objects) if Objects(i)<>0 then search.AddType(i+1) j=j+1 end if next if j<=0 then print "You must specify at least one object type!" return end if imaxsrch=GetIntegerParameter("Max. search hits") search.MaxResults=imaxsrch if not search.Search then print search.Error return end if n=search.nObjects list=NewList("Objects closer than "+format(fov,"0.0##")+DegreeSymbol) ListHeading(list,1,"Objects") ListHeading(list,2,"Separation",2) m=1 // Find pairs of objects StartProgress("Looking for pairs less than "+format(fov,"0.00")+DegreeSymbol+" apart",true,n) AddToList(list,m,1,"Pairs of Objects in FOV:") m=m+1 npairs=0 npair=1 for i=1 to n-1 // Check for user cancel if UpdateProgress(i) then StopProgress return end if a=search.GetObject(i) for j=i+1 to n b=search.GetObject(j) // If declination difference is > FOV, then no chance if abs(a.Dec-b.Dec)0.001 and sepnil then mult.Append pairs(i,0) if pairs(i,1)<>nil then mult.Append pairs(i,1) for j=0 to ubound(mult) Eliminate(mult(j)) next for j=i+1 to n a=pairs(j,0) b=pairs(j,1) if a<>nil then for k=0 to ubound(mult) if AngleBetween(a.RA,a.Dec,mult(k).RA,mult(k).Dec)>fov then a=nil exit end if next if a<>nil then mult.Append a Eliminate(a) end if end if if b<>nil then for k=0 to ubound(mult) if AngleBetween(b.RA,b.Dec,mult(k).RA,mult(k).Dec)>fov then b=nil exit end if next if b<>nil then mult.Append b Eliminate(b) end if end if next if ubound(mult)>1 then // Multiple found. Add to list. redim s(-1) for k=0 to ubound(mult) s.Append mult(k).ID next AddToList(list,m,1,Join(s,", ")) // Find widest separation, and brightes component maxsep=0.0 minmag=99.0 for j=0 to ubound(mult)-1 a=mult(j) if a.Magnitudemaxsep then maxsep=sep amax=a bmax=b end if next next AddToList(list,m,2,format(maxsep,"0.0##")+DegreeSymbol) m=m+1 if WhatToSave=2 or WhatToSave=3 then // Add to plan a=mult(0) p=a.AddToPlan p.ID="Multi"+str(nmulti) p.Name=Join(s,", ") p.RA=AverageRA(amax.RA,bmax.RA) p.Dec=(amax.Dec+bmax.Dec)*0.5 p.Type="" p.Magnitude=minmag p.Magnitude2=99 p.Separation=0 p.PosAngle=0 p.Catalog="" p.Notes=str(ubound(s)+1)+" objects: "+p.Name+". Greatest separation: "+format(maxsep,"0.0##")+DegreeSymbol p.Size=format(maxsep*60,"0.00")+"x"+format(maxsep*60,"0.00") nmulti=nmulti+1 end if end if next StopProgress SaveIntegerValue("Telescope",iscope) SaveIntegerValue("Eyepiece",ipiece) SaveIntegerValue("Aid",iaid) SaveIntegerValue("imaxsrch",imaxsrch) SaveBooleanValue("RConst",rconstellation) SaveBooleanValue("RCat",rcatalogue) SaveIntegerValue("Const",iconst) SaveIntegerValue("Cat",icat) SaveIntegerValue("WhatToSave",WhatToSave) SaveIntegerValue("Objects",Objects) Bleep