; docformat = 'rst' ; ; NAME: ; vistaReadMOVIS ; PURPOSE: ; Read the MOVIS catalogs (Popescu et al. 2016) from ESO VISTA observations ; ;+ ; :Description: ; Read the MOVIS catalogs (Popescu et al. 2016) from ESO VISTA observations ; ; :Categories: ; Database, Asteroid, Colors ; ; :Params: ; MOVIS: in, optional, type=string ; Path to a local version of the MOVIS catalog. Optional if either ; the config keyword, or initIDL is properly set. ; ; :Keywords: ; COLOR: in, optional, type=boolean, default=1 ; Input catalog is the color catalog ; DETECTION: in, optional, type=boolean, default=0 ; Input catalog is the detection catalog ; MAGNITUDE: in, optional, type=boolean, default=0 ; Input catalog is the magnitude catalog ; config: in, optional, type=string ; A configuration file, providing catalog information. ; [Surface properties] ; movis = PATH_TO_YOUR_MOVIS_DIRECTORY ; ; :Returns: A structure. Fields are:: ; .NUM: Asteroid IAU Number ; .NAME: Asteroid Name or Provisional Designation ; ; :Examples: ; Read MOVIS-C catalog, remove unknown values, and plot Y-J vs J-K diagram ; IDL> c=vistaReadMOVIS( 'MOVIS-C.csv' ) ; IDL> valid=where( c.YmJ.val ne -99.99 and c.JmK.val ne -99.99 ) ; IDL> cgPlot, c[valid].YmJ.val, c[valid].JmK.val, psym=3 ; :Uses: ; initIDL ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in March 2016, B. Carry (OCA) ;- function vistaReadMOVIS, movis, color=color, detection=detection, magnitude=magnitude, config=config ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Set Catalog Version ---------------------------------------------------------- if not keyword_set(movis) then begin if not keyword_set(detection) and not keyword_set(magnitude) then color=1 endif else begin movis = strTrim(movis,2) spawn, 'head -n 1 '+movis, res split=strSplit(res,',',count=nbField ) color=0 & detection=0 & detection=0 case nbField of 21: color=1 25: magnitude=1 135: detection=1 else: begin message, /ioError, 'Bad input file, not a MOVIS catalog: '+movis end endcase endelse ;--I.2-- Set Input MOVIS File --------------------------------------------------------- ;--I.2.1-- MOVIS Provided as Argument if keyword_set(movis) then begin movis = strtrim(movis,2) ;--I.2.2-- MOVIS From AstroIM Configuration endif else begin if keyword_set(config) then begin confCatalog= initIDL(config, /CATALOG) endif else begin confAstroIM= initIDL() confCatalog= initIDL(confAstroIM.soft.catalog, /CATALOG) endelse movis = confCatalog.movis if keyword_set(color) then movis += '-C.csv' endelse ;--I.3-- Test if File Exist ----------------------------------------------------------- if not file_test(movis,/read) then begin message, 'MOVIS file not found: '+movis return, -1 endif ;--I.4-- Change '' Fields into -99.99 -------------------------------------------------- spawn, "sed -i 's/,,/,-99.99,/g' "+movis spawn, "sed -i 's/,,/,-99.99,/g' "+movis spawn, "sed -i 's/,,/,-99.99,/g' "+movis ;--I.5-- Open MOVIS File for Reading -------------------------------------------------- ;--I.5.1-- Number of Entries spawn, 'wc '+movis, res split=strsplit(res,' ',/extract) nbMOVIS = round(float(split[0]))-1 ;--I.5.2-- Open File openr, idIn, MOVIS, /Get_Lun ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read MOVIS-C Catalog -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if color eq 1 then begin ;--II.1-- Define Line Format --------------------------------------------------------------- fmt='(I,A,A,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F)' ;--II.2-- Output Structure ----------------------------------------------------------------- col={val:0.,unc:.0,dt:0.} empty={num:0L,name:'',dyn:'',YmJ:col, YmH:col, YmK:col, JmH:col, JmK:col, HmK:col} cat = replicate( empty, nbMOVIS ) ;--II.3-- Read and Keep! ------------------------------------------------------------------- line='' readf, idIn, line for kM=0, nbMOVIS-1 do begin ;--II.3.1-- Read Current Line readf, idIn, line ;--II.3.2-- Split Current Line split = strSplit( line, ',', /Extract, count=nbField ) ;--II.3.3-- Store Values in Structure cat[kM].num = round(float(split[0])) cat[kM].name = strTrim(split[1],2) cat[kM].dyn = strTrim(split[2],2) cat[kM].YmJ.val = float(split[3]) cat[kM].YmJ.unc = float(split[4]) cat[kM].YmJ.dt = float(split[5]) cat[kM].YmH.val = float(split[6]) cat[kM].YmH.unc = float(split[7]) cat[kM].YmH.dt = float(split[8]) cat[kM].YmK.val = float(split[9]) cat[kM].YmK.unc = float(split[10]) cat[kM].YmK.dt = float(split[11]) cat[kM].JmH.val = float(split[12]) cat[kM].JmH.unc = float(split[13]) cat[kM].JmH.dt = float(split[14]) cat[kM].JmK.val = float(split[15]) cat[kM].JmK.unc = float(split[16]) cat[kM].JmK.dt = float(split[17]) cat[kM].HmK.val = float(split[18]) cat[kM].HmK.unc = float(split[19]) if nbField eq 21 then cat[kM].HmK.dt = float(split[20]) endfor endif ;--X-- Close File and Return ----------------------------------------------------------------- close, idIn free_lun, idIn return, cat end