pro read_aux,auxdata, filen = filen ;datadir='/home/sansosti/Minerva/deformat/AUX' datadir='/Users/eric/data/Envisat/INS' test_o = strmid(datadir,strlen(datadir)-1,1) if (test_o NE '/') then datadir = datadir+'/' ;filen1='asa_ins_axviec20020628_093155_20020413_000000_20021231_000000' ;filen1='asa_ins_axviec20021030_125454_20021030_110000_20021231_235959' ;filen1='ASA_INS_AXVIEC20030424_154116_20030428_000000_20031231_235959' filen1='ASA_INS_AXVIEC20031209_113421_20030211_000000_20041231_000000' if (n_elements(filen) EQ 0) then begin filen=datadir+filen1 print,'Auxiliary data file : ', filen endif else begin print,'Auxiliary data file : ', filen endelse openr,u1,filen,/get_lun test_endian = fix([0b,1b],0) if (test_endian EQ 256) then endian = 2 else endian = 0 if (endian EQ 2) then begin print,'Byte order : little endian' endif else begin print,'Byte order : big endian' endelse ;endian=2 print,'' he=bytarr(1625) readu,u1,he app1=bytarr(72608) readu,u1,app1 app2=bytarr(89312) readu,u1,app2 freq = rotate(float(rotate(app1(16:19),endian),0,1),endian) fsamp = rotate(float(rotate(app1(20:23),endian),0,1),endian) chirp_im = rotate(float(rotate(app1(65564:65815),endian),0,63),endian) chirp_im = reform(chirp_im,9,7) ant_pat = rotate(float(rotate(app1(66680:69911),endian),0,808),endian) ant_pat = reform(ant_pat,101,8) rdel_bias = rotate(float(rotate(app1(69912:69915),endian),0,1),endian) rdel_bias_GM = rotate(float(rotate(app1(69916:69919),endian),0,1),endian) adc_i = rotate(float(rotate(app1(69920:70939),endian),0,255),endian) adc_q = rotate(float(rotate(app1(70940:71959),endian),0,255),endian) lut8_i = rotate(float(rotate(app2(0 :1023),endian),0,256),endian) lut8_q = rotate(float(rotate(app2(1024:2047),endian),0,256),endian) lut4_i = rotate(float(rotate(app2( 2048:18431),endian),0,4096),endian) lut4_q = rotate(float(rotate(app2(30720:47103),endian),0,4096),endian) lut4_b = rotate(float(rotate(app2(59392:75775),endian),0,4096),endian) lut4_i = reform(lut4_i,256,16) lut4_q = reform(lut4_q,256,16) lut4_b = reform(lut4_b,256,16) ;stop ; **************** Modify LUTs for saturated values ********************** count = 0 thr_up = max(lut4_i(*,8:14)) areap = where(lut4_i gt thr_up,count) if(count NE 0) then lut4_i(areap) = thr_up count = 0 thr_dw = min(lut4_i(*,1:7)) aream = where(lut4_i lt thr_dw,count) if(count NE 0) then lut4_i(aream) = thr_dw count = 0 thr_up = max(lut4_q(*,8:14)) areap = where(lut4_q gt thr_up,count) if(count NE 0) then lut4_q(areap) = thr_up count = 0 thr_dw = min(lut4_q(*,1:7)) aream = where(lut4_q lt thr_dw,count) if(count NE 0) then lut4_q(aream) = thr_dw count = 0 thr_up = max(lut4_b(*,8:14)) areap = where(lut4_b gt thr_up,count) if(count NE 0) then lut4_b(areap) = thr_up count = 0 thr_dw = min(lut4_b(*,1:7)) aream = where(lut4_b lt thr_dw,count) if(count NE 0) then lut4_b(aream) = thr_dw ; **************** samp_wind_num = rotate(fix(rotate(app2(88352:88352+55),endian),0,28),endian) samp_wind_num = reform(samp_wind_num,7,4) res_fact = rotate(float(rotate(app2(88352+56:88352+56+27),endian),0,7),endian) num_per_cal_sw = rotate(fix(rotate(app2(88772:88773),endian),0,1),endian) IM_timeline = rotate(fix(rotate(app2(88986:89041),endian),0,28),endian) IM_timeline = reform(IM_timeline,7,4) auxdata = {fsamp : fsamp(0), $ freq : freq(0), $ rdel_bias : rdel_bias(0), $ rdel_bias_GM : rdel_bias_GM(0), $ lut8_i : lut8_i, $ lut8_q : lut8_q, $ lut4_i : lut4_i, $ lut4_q : lut4_q, $ lut4_b : lut4_b, $ samp_wind_num : samp_wind_num, $ res_fact : res_fact, $ num_per_cal_sw : num_per_cal_sw(0), $ IM_timeline : IM_timeline, $ ant_pat : ant_pat, $ chirp_im : chirp_im } close,/all free_lun,u1 ;stop return end