; docformat = 'rst' ; ; NAME: ; mp3cReadMeta ; PURPOSE: ; Read meta data in ini-style format and store it in a structure ; ;+ ; :Description: ; Read meta data in ini-style format and store it in a structure ; ; :Categories: ; MP3C ; ; :Params: ; file: in, required, type=string ; Path to the file to parse ; ; :Returns: A structure containing the meta data. Fields are:: ; id : Field unique identifier ; name : Name of the field ; desc : Description of the field ; ucd : Unified Content Descriptor (follows http://www.ivoa.net/documents/latest/UCD.html) ; unit : Unit (follows http://ivoa.net/documents/VOUnits/) ; type : Type of variable (char, int, float, ...) ; size : Number of characters coding the value ; xml : VOTable header PARAM line [returned empty here] ; ; :Keywords: ; ; :Uses: ; readcol, mp3cReadData ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Original Version written in September 2016, B. Carry (OCA) ; 2016 Nov. - B. Carry (OCA) - Changed directory tree ;- pro mp3cMeta, cwd ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Variables Declaration and Definition -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Valid Input Parameter --------------------------------------------------------------- if not keyword_set(cwd) then cwd='./' dirIn = cwd+'Descriptions/' dirMeta = cwd+'Metadata/' dirBib = cwd+'Bibliography/' suField='.field' sufBib ='.desc' sufDesc='.bib' sufXML ='.xml' ;--I.2-- Find Resources to Process ----------------------------------------------------------- readcol, dirIn+'select', resource, tag, format='(A,I)', /Silent proc = where(tag eq 1, nbRes) if proc[0] eq -1 then stop resource=resource[proc] ;--I.3-- Define VOTable Header --------------------------------------------------------------- ;--I.3.1-- VO Table - XML - Header header= ['',$ '' ] ;--I.3.2-- VO Table - Description & Information headMeta = ['MP3C - Metadata', $ ''] headBib = ['MP3C - Bibliography', $ ''] headData = ['', $ '' ] ;--I.4-- Define VOTable Footer --------------------------------------------------------------- footer = ['', $ '', $ ''] footData = ['', $ '' ] ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Convert ini-style Metadata to XML ---------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; for kRes=0, nbRes-1 do begin ;--II.1-- Read Resource Metadata File ------------------------------------------------------ nameIn = resource[kRes]+suField meta = mp3cReadMeta( dirIn+nameIn ) nbMeta=n_elements(meta.column)-1 ;--II.2-- Open File for Header PARAM line -------------------------------------------------- nameXML = resource[kRes]+sufXML openW, idEx, dirMeta+nameXML, /Get_Lun ;--II.3-- Update Header for Local Resource ------------------------------------------------- locHead = [header, headMeta, $ ;--II.3.1-- Ressource - Description & Information '', $ ; ''+meta.head.desc+' Metadata', $ ; ' ', $ ;--II.3.2-- Table - Description '', $ ''+meta.table.desc+' Metadata'] ;--II.3.3-- Write Header to XML File nbHead = n_elements(locHead) for kH=0, nbHead-1 do printf, idEx, locHead[kH] ;--II.4-- Loop over Resource Field --------------------------------------------------------- for kMeta=0, nbMeta-1 do begin ;--II.4.1-- Create VOTable Header PARAM line voHead = voFieldHead( meta.column[kMeta] ) meta.column[kMeta].xml = voHead ;--II.4.2-- Write Meta line printf, idEx, meta.column[kMeta].xml ; value balise with min max endfor ;--II.5-- Loop over Footer Lines ----------------------------------------------------------- nbFoot = n_elements(footer) for kF=0, nbFoot-1 do printf, idEx, footer[kF] free_lun, idEx ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Convert Bibliography/Acknowledgment into XML ---------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Read Resource Bibliography ------------------------------------------------------ nameIn = resource[kRes]+sufBib ;--III.1.1-- Check File if not file_test(dirIn+nameIn,/Read) then begin message, /ioError, 'Meta file cannot be read: '+strtrim(dirIn+nameIn,2) return endif ;--III.1.2-- Read Bibcodes bib = mp3cReadBib(dirIn+nameIn) nbBib = n_elements(bib) ;--III.2-- Open File for Header PARAM line ------------------------------------------------- nameXML = resource[kRes]+sufXML openW, idEx, dirBib+nameXML, /Get_Lun ;--III.3-- Update Header for Local Resource ------------------------------------------------ locHead = [header, headBib, $ ;--III.3.1-- Ressource - Description & Information '', $ ; ''+meta.head.desc+' Bibliography', $ ; '', $ ;--III.3.2-- Table - Description '
', $ ''+meta.table.desc+' Bibliography', $ ""+$ "Bibliographic code associated with the resource", $ ""+$ "Acknowledgment associated with the resource" ] ;--III.3.3-- Write Header to XML File nbHead = n_elements(locHead) for kH=0, nbHead-1 do printf, idEx, locHead[kH] ;--III.3.4-- Open Data and Table nbHead = n_elements(headData) for kH=0, nbHead-1 do printf, idEx, headData[kH] ;--III.4-- Loop over Bibliographic Resources ----------------------------------------------- for kBib=0, nbBib-1 do begin line='' printf, idEx, line endfor ;--III.5-- Loop over Footer Lines ----------------------------------------------------------- ;--III.5.1-- Close Table and Data nbFoot = n_elements(footData) for kF=0, nbFoot-1 do printf, idEx, footData[kF] ;--III.5.2-- Close VO Table nbFoot = n_elements(footer) for kF=0, nbFoot-1 do printf, idEx, footer[kF] free_lun, idEx endfor end
' line+= bib[kBib].code line+='' line+= bib[kBib].ack line+='