; docformat = 'rst' ; ; NAME: ; readBDDLC ; PURPOSE: ; Load a lightcurve file in BDD format into a structure. ; ;+ ; :Description: ; Load a lightcurve file in BDD format into a structure. ; ; :Categories: ; Lightcurve ; ; :Params: ; input: in, required, type=string ; Path of the input lightcurve ; ; :Keywords: ; ; :Uses: ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in October 2015, B. Carry (OCA) ;- function readBDDLC, input ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden ;--I.1-- Input Syntax Verification ---------------------------------------------------- if not keyword_set(input) then begin message, /IOERROR, 'Syntax : LC = readBDDLC( input )' return, -1 endif ;--I.2-- Check File Exist ------------------------------------------------------------- if ~file_test(input,/read) then begin message, /IOERROR, 'File '+strtrim(input,2)+' cannot be read.' return, -2 endif ;--I.3-- Output Structure ------------------------------------------------------------- emptyLC = { N:0, JD:ptr_new(/allocate_heap), M:ptr_new(/allocate_heap), dM:ptr_new(/allocate_heap) } emptyALL = { target: {num:0L, name:''}, $ obs: {name:'', mail:''}, $ tel: {iau:'', lat:0., long:0., filter:''}, $ LTC: {type:'', days:0., app:''} } lc = {head:emptyAll, data:emptyLC} ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read File and Store Values in Structure -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Open File -------------------------------------------------------------------- line = ' ' kLC=-1 openr, idIn, input, /get_lun while ~EOF(idIn) do begin ;--II.2-- Read Each Line --------------------------------------------------------------- readf, idIn, line ;--II.3-- Interprete First Characters -------------------------------------------------- code = strmid(line,0,1) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Lightcurve Header Information -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if strcmp(code,'#') then begin ;--III.1-- Header Parsing --------------------------------------------------------------- split=strtrim(strsplit(line,'#=',/extract),2) ;--III.2.1-- Observer Information --------------------------------------------------------- if strcmp(split[0],'IAU code') then LC.head.tel.iau = split[1] if strcmp(split[0],'Observers') then LC.head.obs.name = split[1] if strcmp(split[0],'Mail') then LC.head.obs.mail = split[1] ;--III.2.2-- Lightcurve Information ------------------------------------------------------- if strcmp(split[0],'Nb of dates') then begin lc.data.N = round(float( split[1] )) kPt=0L *lc.data.JD = dblarr(lc.data.N) *lc.data.M = fltarr(lc.data.N) *lc.data.dM = fltarr(lc.data.N) endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- IV -- Lightcurve Data Parsing -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; endif else begin ;--IV.1-- Data Parsing ------------------------------------------------------------- split = strtrim(strsplit(line,' ',/extract, count=nbField),2) ;--IV.2-- Store Lightcurve --------------------------------------------------------- if nbField eq 14 then begin (*lc.data.JD)[kPt] = double(split[1]) (*lc.data.M )[kPt] = float(split[2]) if ~strCmp(split[3],'-') then (*lc.data.dM)[kPt] = float(split[3]) LC.head.tel.filter = split[5] kPt++ endif endelse endwhile close, idIn free_lun, idIn ;--II.4-- Return LC Structure ---------------------------------------------------------- return, lc end