APSF //############################################################################## // Name : NEDQuery // Purpose : Retrieve information from the NED database // Requires: AP v1.5.3 or later // Author : Robin Lauryssen-Mitchell // Date : 01Aug2006 // Modified: Owen Brazell & Paul Rodman (based on SIMBADQuery) // Version : 1.0 // Status : Production // History : 20060801 - 0.1 - Internal testing only // 20060801 - 1.0 - Production release // 20060801 - 1.1 - Minor update (insert Object.ID at head of list) // 20060801 - 2.0 - Added search by RA/Dec feature // 20061026 - 3.0 - Modified for NED, Mac/Windows compatibility // 20061026 - 3.0 - Added Search radius // 20061026 - 3.1 - Fixed Windows incompatibility // Issues : Has not been tested with objects that have no Name/s //############################################################################## //============================================================================== // Declarations //============================================================================== //------------------------------------------------------------------------------ // Const declarations //------------------------------------------------------------------------------ const cArrayMinIndex = 0 const cWinBrowserPath = "C:\Program Files\Internet Explorer\iexplore.exe" const cMacBrowserPath = "open -a Safari " const cNoSelectedObject = -1 const cURLPrefix = "http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?objname=" const cImagestamp = "&extend=no&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=RA+or+Longitude&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES" const cURLPrefix2 = "http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?in_csys=Equatorial&in_equinox=J2000.0" const cImagestamp2 = "&radius={radius}&search_type=Near+Position+Search&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=Distance+to+search+center&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES&z_constraint=Unconstrained&z_value1=&z_value2=&z_unit=z&ot_include=ANY&nmp_op=ANY" const cSrchRadiusLabel = "Search radius (minutes)" //------------------------------------------------------------------------------ // Var declarations //------------------------------------------------------------------------------ dim ObjectName as string //Name of the object for Simbad to search for dim ShellText as string //Text returned by Shell command (should be none!) dim CommandString as string, srchRadius as double //============================================================================== // Subs and Functions //============================================================================== //------------------------------------------------------------------------------ //Name : GetPrefix //Purpose : If the object has a name, return it to use as a prefix //Requires: //Returns : Dialogue cancel flag //Notes : Lifted and modified from RAS_Gen where it serves a slightly // different purpose //------------------------------------------------------------------------------ function GetPrefix (ObjectID as double, byref Prefix as string, byref pfx as string, byref sfx as string) as boolean const cDelim = "," const cNoName = "" const cDefaultPopUpSelection = 0 const cPrefixLabel = "Name" const cRADecLabel = "Use RA/Dec" dim Flag as boolean dim NameText as string dim SelList(-1) as string NameText = Obj(ObjectID).Name if NameText <> cNoName then SelList = split(NameText, cDelim) end if SelList.insert cArrayMinIndex, Obj(ObjectID).ID //Local mod SetPopupParameter (cPrefixLabel, cDefaultPopUpSelection, SelList) SetBooleanParameter (cRADecLabel, false) SetDoubleParameter(cSrchRadiusLabel,srchRadius,1.0,100.0) ParameterDependency(cSrchRadiusLabel,cRADecLabel) if EditParameters ("Select object name " + Obj(ObjectID).ID) then srchRadius=GetDoubleParameter(cSrchRadiusLabel) if GetBooleanParameter(cRADecLabel) then Prefix = NEDRADec (Obj(ObjectID).RA, Obj(ObjectID).Dec) pfx=cURLPrefix2 sfx=cImagestamp2 else Prefix = SelList(GetPopupParameter(cPrefixLabel)) pfx=cURLPrefix sfx=cImagestamp end if Flag = true else Prefix = "" Flag = false end if return Flag end function //------------------------------------------------------------------------------ //Name : NEDRADec //Purpose : Take the object RA/Dec and convert into a form NED can use //Requires: Object RA and Dec as doubles //Returns : RA/Dec in Simbad format //------------------------------------------------------------------------------ function NEDRADec (RA as double, Dec as double) as string const cRAFormat = "hms+" //This format appears to be undocumented const cDecFormat = "dms+" //This format appears to be undocumented const cExtended = true const cURLplus = "%2B" // &lon=1+2+3&lat=4+5+6 return "&lon="+FormatRA(RA, cExtended, cRAFormat)+_ "&lat="+_ FormatDec(Dec, cExtended, cDecFormat) end function //============================================================================== // Main code //============================================================================== dim pfx,sfx as string srchRadius=10.0 if SelectedObject = cNoSelectedObject then //MUST have an object selected print "ERROR: You must select an object in the plan" else if GetPrefix(SelectedObject, ObjectName, pfx,sfx) then //If more than one name, choose one CommandString = pfx+trim(ObjectName)+sfx CommandString = ReplaceAll(CommandString,"{radius}",str(srchRadius)) select case Platform case platform_Windows CommandString = ReplaceAll(CommandString,"&","^&") ShellText = Shell(cWinBrowserPath, CommandString) //Go find else CommandString = ReplaceAll(CommandString,"&","\&") ShellText = Shell(cMacBrowserPath, CommandString) //Go find end select else //or abandon :) print "INFO: User cancelled" end if end if