; docformat = 'rst' ; ; NAME: ; saiLoadConfig ; PURPOSE: ; Read a configuration file for showAoImages and return it as a structure ; ;+ ; :Description: ; Read a configuration file for showAoImages and return it as a structure ; ; :Categories: ; Disk I/O ; ; :Params: ; file: in, required, type=string ; Path to the configuration file to load ; ; :Returns: A structure containing the configuration information. If a ; structure was provided upon input, the result are merged ; ; :Uses: ; ; :Author: ; B. Carry (OCA) ; ; :History: ; Change History:: ; Original Version written in August 2016, B. Carry (OCA) ; 2017 Apr - B. Carry (OCA) - Added satellite labeling ; 2017 Nov - B. Carry (OCA) - Added panel labeling ;- function saiLoadConfig, file ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Presence of Arguments --------------------------------------------------------------- if N_params() LT 1 then begin message, /Info, ' Syntax - CONFIG = saiLoadConfig( PATH_TO_FILE )' return, -1 endif ;--I.2-- Input Configuration File ------------------------------------------------------------ if not file_test(file,/Read) then begin message, /Info, ' Configuration file cannot be read: '+strtrim(file,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Create Configuration Structure for Output -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Astrophysical Target --------------------------------------------------------------- sso = {num: 0, $ ;-SSO IAU Number name: '', $ ;-SSO Official Designation S1: '', $ ;-Identifyer for the first satellite S2: '' } ;-Identifyer for the second satellite ;--II.2-- General Graphic Parameters --------------------------------------------------------- graph = {name: 'ao.eps', $ ;-Name of the figure N:{row: 2, $ ;-Number of rows col: 5}, $ ;-Number of columns label: 0 } ;-Location of Label (-1:None, 0:All, i:stamp) ;--II.3-- General Information for All Images ------------------------------------------------ eWin={layer:-1, $ ;-Layer to display size: 30., $ ;-Size of the selected area unit: 'pix', $ ;-Unit for the window size (pix|sec|min|deg|km) track: 'sky',$ ;-Tracking mode (sky|det) CTIndex:0 , $ ;-Index of the color table min: 0., $ ;-Minimum ADU value for color bar max: 32768. } ;-Maximum ADU value for color bar eLab={panel:0, $ ;-Display the number of the panel name:0, $ ;-Display the name of the target sat: 0, $ ;-Display the position of the satellite date:0, $ ;-Display the date of observations utc: 0, $ ;-Display the UTC sop: 0, $ ;-Display the sub-observer point coordinates ssp: 0, $ ;-Display the subsolar point coordinates tel: 0, $ ;-Display the telescope name ins: 0, $ ;-Display the instrument name sky: 0, $ ;-Display the field orientation bar: {val:0., $ ;-Length of the scale bar unit:''}} ;-Unit of the scale bar (none|pix|arcsec|km) ;--II.4-- Specific Information for Each Image ----------------------------------------------- eImg={nick: '', $ ;-Image Nickname Identifier show: 0 , $ ;-Show image? target: '', $ ;-Target Name satellite:{S1:'',S2:''}, $ ;-Satellite identifiers name: '' , $ ;-FileName main: eWin, $ ;-Main image inset:eWin, $ ;-Optional Inset label:eLab } ;-Optional labels image = replicate(eImg,50) kImg=-1 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Read Input Configuration File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Open File and Loop over Lines ----------------------------------------------------- openR, inputFile, file, /GET_LUN line = ' ' section = ' ' kLine=0L while ~EOF(inputFile) do begin ;--III.2-- Read Current Line --------------------------------------------------------------- readf, inputFile, line kLine++ ;--III.3-- Selection of Section ------------------------------------------------------------ if strTrim(strMid(line,0,1),2) eq '[' then begin split = strSplit(line, '[]', /EXTRACT ) section = strLowCase(split[0]) ;--III.4-- Analysis of Section ------------------------------------------------------------- endif else begin split=strSplit(line, '=;', /EXTRACT, count=nbField ) key = strLowCase(strTrim(split[0],2)) CASE section OF ;--III.4.1-- Information on target 'target information': BEGIN CASE key OF 'number' : sso.num = round(float(split[1])) 'name' : sso.name = strTrim(split[1],2) 'satellite 1': sso.S1 = strTrim(split[1],2) 'satellite 2': sso.S2 = strTrim(split[1],2) ELSE: ENDCASE END ;--III.4.2-- General Graphic Parameters 'graphic parameters': BEGIN CASE key OF 'name': graph.name = strTrim(split[1],2) 'rows': graph.N.row = round(float(split[1])) 'columns': graph.N.col = round(float(split[1])) 'label': graph.label = round(float(split[1])) ELSE: ENDCASE END ;--III.4.3-- Common Image Parameters 'common parameters': BEGIN CASE key OF 'main.layer' : eImg.main.layer = round(float(split[1])) 'main.size' : begin sub=strSplit( strTrim(split[1],2), ' ',/Extract, count=nbSub ) eImg.main.size = float(sub[0]) if nbSub eq 2 then eImg.main.unit = strTrim(sub[1],2) end 'main.ctable' : eImg.main.CTIndex = round(float(split[1])) 'inset.layer' : eImg.inset.layer = round(float(split[1])) 'inset.size' : begin sub=strSplit( strTrim(split[1],2), ' ',/Extract, count=nbSub ) eImg.inset.size = float(sub[0]) if nbSub eq 2 then eImg.inset.unit = strTrim(sub[1],2) end 'inset.ctable': eImg.inset.CTIndex= round(float(split[1])) 'tracking' : eImg.main.track = strTrim(split[1],2) 'panelid' : eImg.label.panel = round(float(split[1])) 'target' : eImg.label.name = round(float(split[1])) 'satellite' : eImg.label.sat = round(float(split[1])) 'date' : eImg.label.date = round(float(split[1])) 'utc' : eImg.label.utc = round(float(split[1])) 'subobserver' : eImg.label.sop = round(float(split[1])) 'subSolar' : eImg.label.ssp = round(float(split[1])) 'telescope' : eImg.label.tel = round(float(split[1])) 'instrument' : eImg.label.ins = round(float(split[1])) 'compass' : eImg.label.sky = round(float(split[1])) 'scalebar' : begin sub=strSplit( strTrim(split[1],2),' ',/Extract, count=nbSub) if nbSub eq 1 then eImg.label.bar.unit = 'none' else begin eImg.label.bar.val = float(sub[0]) eImg.label.bar.unit = strTrim(sub[1],2) endelse end 'main.range': begin sub=strSplit( split[1], ',', /Extract, count=nbSub ) if nbSub ne 2 then begin message, /Informational, 'Incorrect range parameter definition in '+strTrim(file,2)+$ ' (L:'+strTrim(string(kLine),2)+'): Must contain two coma-separated elements' return, -3 endif eImg.main.min = float(sub[0]) eImg.main.max = float(sub[1]) end 'inset.range': begin sub=strSplit( split[1], ',', /Extract, count=nbSub ) if nbSub ne 2 then begin message, /Informational, 'Incorrect range parameter definition in '+strTrim(file,2)+$ ' (L:'+strTrim(string(kLine),2)+'): Must contain two coma-separated elements' return, -3 endif eImg.inset.min = float(sub[0]) eImg.inset.max = float(sub[1]) end ELSE: ENDCASE END ;--III.4.4-- Parameters for Individual Images 'list of images': BEGIN ;--II.4.4.1-- New Image with Common Parameters if nbField eq 1 then begin print, line sub = strSplit( line, '{}', /extract ) kImg++ image[kImg].nick = sub[1] image[kImg].target = sso.name if not strCmp(sso.S1,'') then image[kImg].satellite.S1 = sso.S1 if not strCmp(sso.S2,'') then image[kImg].satellite.S2 = sso.S2 image[kImg].main = eImg.main image[kImg].inset = eImg.inset image[kImg].label = eImg.label ;--II.4.4.2-- Parsing the Symbol Definition endif else begin CASE key OF 'show' : image[kImg].show = round(float(split[1])) 'name' : image[kImg].target = strTrim(split[1],2) 'panelId' : image[kImg].label.panel = round(float(split[1])) 'target' : image[kImg].label.name = round(float(split[1])) 'satellite 1' : image[kImg].satellite.S1 = strTrim(split[1],2) 'satellite 2' : image[kImg].satellite.S2 = strTrim(split[1],2) 'file' : image[kImg].name = strTrim(split[1],2) 'main.layer' : image[kImg].main.layer = round(float(split[1])) 'main.size' : begin sub=strSplit( strTrim(split[1],2), ' ',/Extract, count=nbSub ) image[kImg].main.size = float(sub[0]) if nbSub eq 2 then image[kImg].main.unit = strTrim(sub[1],2) end 'main.ctable' : image[kImg].main.CTIndex = round(float(split[1])) 'inset.layer' : image[kImg].inset.layer = round(float(split[1])) 'inset.size' : begin sub=strSplit( strTrim(split[1],2), ' ',/Extract, count=nbSub ) image[kImg].inset.size = float(sub[0]) if nbSub eq 2 then image[kImg].inset.unit = strTrim(sub[1],2) end 'inset.ctable': image[kImg].inset.CTIndex= round(float(split[1])) 'tracking' : image[kImg].main.track = strTrim(split[1],2) 'satellite' : image[kImg].label.sat = round(float(split[1])) 'date' : image[kImg].label.date = round(float(split[1])) 'utc' : image[kImg].label.utc = round(float(split[1])) 'subObserver' : image[kImg].label.sop = round(float(split[1])) 'subSolar' : image[kImg].label.ssp = round(float(split[1])) 'telescope' : image[kImg].label.tel = round(float(split[1])) 'instrument' : image[kImg].label.ins = round(float(split[1])) 'compass' : image[kImg].label.sky = round(float(split[1])) 'scalebar' : begin sub=strSplit( strTrim(split[1],2),' ',/Extract, count=nbSub) if nbSub eq 1 then eImg.label.bar.unit = 'none' else begin image[kImg].label.bar.val = float(sub[0]) image[kImg].label.bar.unit = strTrim(sub[1],2) endelse end 'main.range': begin sub=strSplit( split[1], ',', /Extract, count=nbSub ) if nbSub ne 2 then begin message, /Informational, 'Incorrect range parameter definition in '+strTrim(file,2)+$ ' (L:'+strTrim(string(kLine),2)+'): Must contain two coma-separated elements' return, -3 endif image[kImg].main.min = float(sub[0]) image[kImg].main.max = float(sub[1]) end 'inset.range': begin sub=strSplit( split[1], ',', /Extract, count=nbSub ) if nbSub ne 2 then begin message, /Informational, 'Incorrect range parameter definition in '+strTrim(file,2)+$ ' (L:'+strTrim(string(kLine),2)+'): Must contain two coma-separated elements' return, -3 endif image[kImg].inset.min = float(sub[0]) image[kImg].inset.max = float(sub[1]) end ELSE: ENDCASE endelse END ;--III.4.x-- ELSE ELSE: ENDCASE endelse endwhile ;--III.5- Trim Structure to Appropriate Length ----------------------------------------------- out = {sso:sso, $ ;-Target Information graph:graph, $ ;-Graphic Parameters image: image[0:kImg]} ;-Individual Images return, out end