; docformat = 'rst' ; ; NAME: ; genoidSetObs ; PURPOSE: ; Update the number of epochs in the header of a Genoid VOTable file ; ;+ ; :Description: ; Update the number of epochs in the header of a Genoid VOTable file ; ; :Categories: ; Disk I/O, Genoid ; ; :Params: ; file: in, required, type=string ; The path to the file to be updated ; nRow: in, required, type=integer ; Number of epochs to be set in the file ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in July 2013, B. Carry (IMCCE) ; 2017 Apr. - B.Carry (OCA) - Modified to new Genoid format ;- pro genoide_xmlSetN, file, nRow COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Syntax Validation -------------------------------------------------------------------; if not keyword_set(file) then begin message, /ioError, 'Syntax: genoidSetObs, file, nRow' return endif ;--I.2-- File Accesability -------------------------------------------------------------------; if not file_test(file,/read) then begin message, /Info, 'File cannot be read: '+strTrim(file,2) return endif ;--I.3-- Validation of nRow ------------------------------------------------------------------; if not keyword_set(nRow) then begin message, /ioError, 'Syntax: genoidSetObs, file, nRow' return endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Update the Number of Epoch in File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Find Line Number for Number of Epochs ----------------------------------------------; spawn, 'grep -n obs.dat '+file, result, error split=strSplit( result, ':', /Extract ) lineID = split[0] ;--II.2-- Prepare the Number of Epochs -------------------------------------------------------; line = ' ' ;--II.3-- Update the Number of Epochs --------------------------------------------------------; spawn, "sed '"+strTrim(string(lineID,format='(I)'),2)+"s/.*/"+line+"/' < "+file+" > /tmp/genoid_toto.xml" spawn, 'mv /tmp/genoid_toto.xml '+file end