;+ ; Contains the get_n1datarecords function ; ; :Author: ; Gaƫlle Boisnard ; ; :History: ; 2006/02/15: Created ; ; 2006/02/15: Last Edit ;- ; ;+ ; Writes the data listed in DATAFILES for the bands ; indicated in BANDS in a file(FILENAME) and in a binary ; file (FILENAME.b). ; ; :Uses: ; hms_s ; ; :Returns: ; <return desc here> ; ; :Params: ; filename: in, required, type=string ; output files base name ; datafiles: in, required, type=sometype ; list of data to write ; bands: in, required, type=intarr ; list of bands ;- FUNCTION get_n1datarecords, filename, datafiles, bands common R_LOG datapath=getenv('NAS_RPWS') data1={data_N1} nbdata=100L data1=replicate(data1, nbdata) records_nb=(size(datafiles))[1] openw, unit, filename, /get_lun, /swap_if_big_endian idata=0L j=0 file='' fileprec='d' tab0_9=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] band=4 pow=16 bandarr=intarr(5) bandarr=[5, 5, 5, 5, 5] while (bands ne 0) do begin if (bands ge pow) then begin bandarr[band]=band bands=bands-pow endif pow=pow/2 band=band-1 endwhile ;-------------------------------------------------- ; Reading each line of datafiles (from the lis file) ;-------------------------------------------------- for i=0, records_nb-1 do begin if (strmid(datafiles[i], 0, 1) ne ' ') then begin directory=datafiles[i] endif else begin file=datapath+directory+'/n1/R'+strmid(datafiles[i], 3, 10) if (file ne fileprec) then begin j=0L if (file_test(file) eq 0) then begin widget_control, r_infolog_txt, set_value=file+": this file doesn't exist", /append goto, pass endif else begin widget_control, r_infolog_txt, set_value='Reading of the file '+file, /append fileprec=file read_data_binary, file, data, level='n1' datanb=(size(data))[1] endelse endif ; Start ind=where(strmid(datafiles[i], 16, 1) eq tab0_9(0:2), count) if (count eq 0) then begin hour1=fix(strmid(datafiles[i], 17, 1)) endif else begin hour1=fix(strmid(datafiles[i], 16, 2)) endelse ind=where(strmid(datafiles[i], 19, 1) eq tab0_9(0:5), count) if (count eq 0) then begin minute1=fix(strmid(datafiles[i], 20, 1)) endif else begin minute1=fix(strmid(datafiles[i], 19, 2)) endelse ind=where(strmid(datafiles[i], 22, 1) eq tab0_9(0:5), count) if (count eq 0) then begin second1=fix(strmid(datafiles[i], 23, 1)) endif else begin second1=fix(strmid(datafiles[i], 22, 2)) endelse ; End ind=where(strmid(datafiles[i], 25, 1) eq tab0_9(0:2), count) if (count eq 0) then begin hour2=fix(strmid(datafiles[i], 26, 1)) endif else begin hour2=fix(strmid(datafiles[i], 25, 2)) endelse ind=where(strmid(datafiles[i], 28, 1) eq tab0_9(0:5), count) if (count eq 0) then begin minute2=fix(strmid(datafiles[i], 29, 1)) endif else begin minute2=fix(strmid(datafiles[i], 28, 2)) endelse ind=where(strmid(datafiles[i], 31, 1) eq tab0_9(0:5), count) if (count eq 0) then begin second2=fix(strmid(datafiles[i], 32, 1)) endif else begin second2=fix(strmid(datafiles[i], 31, 2)) endelse ; Reading of the N1 file tps1=hms_s(hour1, minute1, second1) tps2=hms_s(hour2, minute2, second2) tps=long(strtrim(strmid(data[j].ti, 7, 5), 2)) while ((j lt datanb-1) and (tps lt tps1)) do begin j=j+1 tps=long(strtrim(strmid(data[j].ti, 7, 5), 2)) endwhile while ((j lt datanb-1) and (tps le tps2)) do begin band=long(strtrim(data[j].fi, 2))/10000000L ind=where(band eq bandarr, count) if (count ne 0) then begin printf, unit, data[j] if (idata eq nbdata) then begin data2={data_n1} data2=replicate(data2, idata) data2(0:idata-1)=data1(0:idata-1) data1={data_n1} nbdata=10L*idata data1=replicate(data1, nbdata) data1(0:idata-1)=data2(0:idata-1) endif data1[idata]=data[j] idata=idata+1 endif j=j+1 tps=long(strtrim(strmid(data[j].ti, 7, 5), 2)) endwhile endelse pass: endfor free_lun, unit ; Writing of the binary data file if (idata ne 0) then begin filebin=filename+'.b' write_data_binary, filebin, data1(0:idata-1) endif end