; docformat = 'rst' ; ; NAME: ; sdssExtractSSO ; PURPOSE: ; Extract entries from SDSS MOC corresponding to provided list of SSOs ; ;+ ; :Description: ; Extract entries from SDSS MOC corresponding to provided list of SSOs ; ; :Categories: ; Database, Asteroid, Colors ; ; :Params: ; sso: in, required, type=string ; A list of SSO to search in SDSS MOC. ; MOC: in, optional, type=string/string ; Path to a local version of the SDSS MOC, or SDSS MOC ; structure (see sdssReadMOC documentation). ; ; :Keywords: ; ; :Returns: A reduced version of the SDSS MOC structure, with only the ; entries corresponding to the input list of SSOs. ; ; :Examples: ; ; :Uses: ; initIDL, sdssReadMOC, voSsoDNeT_resolver ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in October 2015, B. Carry (OCA) ;- function sdssExtractSSO, sso, moc ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Test Input SSO List ---------------------------------------------------------- if not keyword_set(sso) then begin message, /IOERROR, 'Syntax error: selectSDSS = sdssExtractSSO( SSO [, MOC])' return, -1 endif nbSSO = n_elements(sso) ;--I.2-- Test Input SDSS MOC ----------------------------------------------------------- ;--I.2.1-- SDSS MOC Provided as Argument if keyword_set(moc) then begin dimM = size(moc) if dimM[dimM[0]+1] eq 7 then moc = sdssReadMOC(moc) ;--I.2.2-- SDSS MOC From AstroIM Configuration endif else begin confAstroIM= initIDL() confCatalog= initIDL(confAstroIM.soft.catalog, /CATALOG) moc = sdssReadMOC(confCatalog.moc) endelse ;--I.3-- Selection Variables ---------------------------------------------------------- sel=0 nbSel=0 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Search SDSS MOC for Provided SSOs -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; for kSSO=0, nbSSO-1 do begin ;--II.1-- Get Current SSO Number and Names --------------------------------------------- id = voSsoDNeT_resolver(sso[kSSO]) dimI=size(id) if dimI[dimI[0]+1] eq 7 then begin ;--II.2-- Test SSO Number against SDSS Numbers ----------------------------------------- pNum=-1 if id.number ne 0 then begin pNum = where( id.number eq moc.ssoNum ) if pNum[0] ne -1 then begin sel = [sel, pNum[0]] nbSel++ endif endif ;--II.3-- Test SSO NameS against SDSS Name --------------------------------------------- if id.number eq 0 or pNum[0] eq -1 then begin ;--II.3.1-- SSO Name pName = where( ssoSpaceToUnderscore(id.name) eq moc.ssoName ) if pName[0] ne -1 then begin sel = [sel, pName[0]] nbSel++ ;--II.3.2-- SSO Aliases endif else begin for kName=0, id.nbAlias-1 do begin pName = where( ssoSpaceToUnderscore( (*id.alias)[kName] ) eq moc.ssoName ) if pName[0] ne -1 then begin sel = [sel, pName[0]] nbSel++ kName=id.nbAlias+1 ;-Skip end of Alias Loop endif endfor endelse endif ;--End of II.3 endif ;--Validity of SsoDNeT Results endfor ;--Loop on SSO ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Organize SDSS MOC Output & Return -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- No Match Found -> -2 Flag Returned ------------------------------------------- if nbSel lt 1 then return, -2 else begin ;--III.2-- Some Matches Found ----------------------------------------------------------- sel = sel[1:nbSel] entries = moc[sel] return, entries endelse end