; docformat = 'rst' ; ; NAME: ; movisReadParam ; PURPOSE: ; Read simple configurations files for VISTA/VHS/MOVIS processing ; ;+ ; :Description: ; Read simple configurations files for VISTA/VHS/MOVIS processing ; ; :Categories: ; MOVIS, Configuration ; ; :Returns: A Structure with all the default configuration from a ; software suite (indicated by keywords) ; ; :Examples: ; ; :Params: ; file: in, required, type=string ; Path to the configuration file ; ; :Keywords: ; colorCut: in, optional, type=boolean, default=0 ; Trigger reading of the threshold on color uncertainty ; class: in, optional, type=boolean, default=0 ; Trigger reading of the definition of asteroid classes ; ; :Uses: ; readcol ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Original Version written in October 2016, B. Carry (OCA) ;- function movisReadParam, file, colorCut=colorCut, class=class ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Variables Declaration and Definition -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Validation of Inputs ----------------------------------------------------------------; if not keyword_set(file) then begin message, /ioError, 'syntax: param = movisReadParam( file [, /colorCut, /Class] )' return, -1 endif ;--I.2-- Type of Parameter File --------------------------------------------------------------; ;--I.2.1-- Check Command-Line if keyword_set(colorCut) then colorCut =1 else colorCut =0 if keyword_set(class) then class =1 else class =0 caseVec = [colorCut, class] ;--I.2.2-- Only one File at a Time if total(caseVec) ne 1 then begin print, 'movisReadPara: only one configuration file allowed at once' return, -1 endif ;--I.3-- Is Target File Readable -------------------------------------------------------------; if not file_test(file,/Read) then begin message, /INFO, 'Configuration file not found: '+strtrim(file,2) return, -1 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Threshold on Color Uncertainties -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(colorCut) then begin ;--II.1-- Output Structure -----------------------------------------------------------------; cuts={YJ:0., YH:0., YK:0., JH:0., JK:0., HK:0.} ;--II.2-- Loop Over Lines ------------------------------------------------------------------; openR, idIn, file, /Get_Lun line = ' ' section = ' ' while ~EoF(idIn) do begin ;--II.3-- Read Line & Parse --------------------------------------------------------------; readf, idIn, line split=strSplit(line, '=;', /Extract, count=nbField ) key = strTrim(split[0],2) ;--II.4-- Fill Cut Structure -------------------------------------------------------------; case key of 'YJ': cuts.YJ = float(split[1]) 'YH': cuts.YH = float(split[1]) 'YK': cuts.YK = float(split[1]) 'JH': cuts.JH = float(split[1]) 'JK': cuts.JK = float(split[1]) 'HK': cuts.HK = float(split[1]) else: endcase endwhile ;--II.5-- Free File Id and Return Cuts Structure -------------------------------------------; free_lun, idIn return, cuts endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Definition of Taxonomy Look'n'Feel -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if keyword_set(class) then begin ;--III.1-- Read Configuration CSV File -----------------------------------------------------; readcol, file, use,label, color, sSize, sSym, format='I,A,A,F,A', delimiter=',', /Silent nbClass=n_elements(use) ;--III.2-- Output Structure ----------------------------------------------------------------; empty={label:'', use:0, color:'', sym:'', size:0.} class=replicate(empty,nbClass) ;--III.3-- Fill Structure ------------------------------------------------------------------; class.use = use class.label = strTrim(label,2) class.color = strTrim(color,2) class.size = sSize class.sym = strTrim(sSym,2) ;--III.4-- Return Class Structure ----------------------------------------------------------; return, class endif end