;+ ; NAME: ; ECSVREAD ; ; PURPOSE: ; Program to read the ECSV file and convert it into an IDL structure ; ; EXPLANTION: ; Program uses readcol to read ECSV columns into string arrays. ; An IDL structure is then created with the appropriate array cast ; to the correct type. ; ; CALLING: ; ecsv_struct = ecsvread(filename=filename, skipline=skipline) ; ; REQUIRED INPUTS: ; FILENAME = String containing the ecsv filename ; ; SKIPLINE = Number of lines to skip in the ECSV file header ; (including the $$CSV -- usually SKIPLINE=45) ; ; PROCEDURE DEPENDENCIES: ; MAKEECSVHEAD ; ; EXAMPLE: ; IDL> ecsv_struct = ecsvread(filename='irs.ecsv', skipline=45) ; ;- FUNCTION ECSVREAD, FILENAME=FILENAME, SKIPLINE=SKIPLINE readcol,filename,f='a,a,a,a,a,a,a,a,a,a,a,a',scet,chan,chtitle,dnval,euval,sclk,chtype,redtype,redalarm,redhigh,redlow,ert,delimiter=',',skipline=skipline scet = strcompress(scet, /remove_all) chan = strcompress(chan, /remove_all) chtitle = strcompress(chtitle, /remove_all) dnval = strcompress(dnval, /remove_all) euval = strcompress(euval, /remove_all) sclk = strcompress(sclk, /remove_all) chtype = strcompress(chtype, /remove_all) redtype = strcompress(redtype, /remove_all) redalarm = strcompress(redalarm, /remove_all) redhigh = strcompress(redhigh, /remove_all) redlow = strcompress(redlow, /remove_all) ert = strcompress(ert, /remove_all) ndata=n_elements(scet) idx=where(strlen(dnval) eq 0,ct) if ct gt 0 then begin dnval(idx) = '-1.e9' endif dnval=double(dnval) idx=where(strlen(euval) eq 0,ct) if ct gt 0 then begin euval(idx) = '-1.e9' endif ;euval=double(euval) length=ndata status=makeecsvhead ( header, data=data ) print, ' ' print,'Building ECSV data structure' ;print,systime() A = { ecsv_rec_struct ,$ scet : ' ' ,$ ; spacecraft event time secs : double(0.0) ,$ ; seconds since sclk(0) [sec] chan : ' ' ,$ ; channel chtitle : ' ' ,$ ; channle title dnval : double(0.0) ,$ ; channel value in DN euval : ' ' ,$ ; channel value in EU (sometimes string value) sclk : double(0.0) ,$ ; spacecraft clock timekey chtype : ' ' ,$ ; channel type redtype : ' ' ,$ ; red alarm type redalarm: ' ' ,$ ; red alarm flag redlow : ' ' ,$ ; red low limit redhigh : ' ' ,$ ; red high limit ert : ' ' } ; earth receive timestamp ECSV = {type : 'ecsv' ,$ ; structure type header : header ,$ ; header string history : strarr(1) ,$ ; history string data : replicate({ecsv_rec_struct},length) } ecsv.data.scet = scet ecsv.data.chan = chan ecsv.data.chtitle = chtitle ecsv.data.dnval = double(dnval) ecsv.data.euval = euval ecsv.data.sclk = double(sclk) sclk=ecsv.data.sclk sclk=sclk(sort(sclk)) sclk0=sclk(0) ecsv.data.secs = double(ecsv.data.sclk - sclk(0)) ecsv.data.chtype = chtype ecsv.data.redtype = redtype ecsv.data.redalarm = redalarm ecsv.data.redlow = redlow ecsv.data.redhigh = redhigh ecsv.data.ert = ert print,' ' print,'ECSV data structure complete' ;print,systime() return, ecsv END