pro conv_date,dsr_time,timeout sd = ishft((dsr_time(0) AND 128), -7) fd= (dsr_time(0) AND 127) day = long(fd)*256L^3+long(dsr_time(1))*256L^2+ $ long(dsr_time(2))*256L+long(dsr_time(3)) day = (-1)^fd *day seconds = long(dsr_time(4))*256L^3+long(dsr_time(5))*256L^2+ $ long(dsr_time(6))*256L +long(dsr_time(7)) microsec = long(dsr_time(8))*256L^3+long(dsr_time(9))*256L^2+ $ long(dsr_time(10))*256L +long(dsr_time(11)) caldat,day+2451545L,appmo,appd,appy ;mo = strcompress(string(appmo),/remove_all) ;if (appmo LT 9) then mo='0'+mo d = strcompress(string(appd),/remove_all) if (appd LT 9) then d='0'+d y = strcompress(string(appy),/remove_all) case appmo of 1 : mo='JAN' 2 : mo='FEB' 3 : mo='MAR' 4 : mo='APR' 5 : mo='MAY' 6 : mo='JUN' 7 : mo='JUL' 8 : mo='AUG' 9 : mo='SEP' 10 : mo='OCT' 11 : mo='NOV' 12 : mo='DEC' endcase date=d+'-'+mo+'-'+y apph= seconds/3600L h = strcompress(string(apph),/remove_all) if (apph LE 9) then h='0'+h appm = (seconds-h*3600L)/60L m = strcompress(string(appm),/remove_all) if (appm LE 9) then m='0'+m appss = seconds-h*3600L-m*60L ss= strcompress(string(appss+microsec*1D-6),/remove_all) if (appss LE 9) then ss='0'+ss time=h+':'+m+':'+ss timeout = date+' '+time ;stop return end pro convert_bit, a, res res='' ; pu=128L n_bit = 8L for k=n_bit-1,0,-1 do begin pu = 2L^k res=res+string((long(a) and pu)/pu) ; print,k,pu,app,long((a and pu)/pu) endfor res = strcompress(res) return end function sm2binoff,data_i ; works only if data are on 4 bits!!!! ;data_i=byte([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) ; binary offset format ;data_i=byte([15,14,13,12,11,10,9,8,0,1,2,3,4,5,6,7]) ; sign and magnitude format data_out = data_i ss_i = ishft((data_out AND 8B), -3) data_out = (data_out XOR 8B) data_out = (ss_i EQ 0)*data_out + (ss_i EQ 1)*(data_out XOR 7B) return, data_out end function binoff2sm,data_i ; works only if data are on 4 bits!!!! data_out = data_i ss_i = ishft((data_out AND 8B), -3) data_out = (data_out XOR 8B) data_out = (ss_i EQ 1)*data_out + (ss_i EQ 0)*(data_out XOR 7B) return, data_out end function shift_pad,a,b dime = size(a) nn = dime(1) if (b EQ 0) then return, a app = shift(a,b) if (b GT 0) then begin app(0:b-1) = 0 endif else begin app(nn+b:nn-1) = 0 endelse return, app end ; *************************************************************** ; ****************** Main Program ****************************** ; *************************************************************** pro read_raw,par,outc,dumpcomplex=dumpcomplex,dumpbyte=dumpbyte,$ limits=limits, $ Lstart=Lstart,Lend=Lend,Pstart=Pstart,Pend=Pend, $ dirout=dir_out, filename = nomefile, auxname = auxfile, $ debug=debug_flag,no_zero_fill=no_zero_fill nparam = n_params() if (nparam EQ 0) then begin print,'Usage: read_raw,par,[mat][/dumpcomplex][/dumpbyte][/debug] [/no_zero_fill]' print,' [dirout=''path_to_output''][filename=''path/input_file_name'']' print,' [auxname=''path/auxiliary_file_name''][Lstart=starting_line][Lend=ending_line]' print,' [Pstart=starting_pixel][Pend=ending_pixel][limits=frame]' print,'' print,'Output parameters' print,'par IDL structure with parameters' print,'mat (optional) complex array containing the raw data' print,'' print,'Input parameters' print,'/dumpcomplex if set complex format data are written on the disk' print,'/dumpbyte if set complex-byte data are written on the disk' print,'/debug if set additional log files are witten to the disk' print,'/no_zero_fill if set missing lines are a duplication of previous one, otherwise a line of zeros' print,'path_to_output path where output file are written; if not set, uses current directory' print,'filename input file name (including the full path); if not set, the program prompts for it' print,'auxname auxiliary file name (including the full path)' print,'starting_line first line to be read; if not given is set to 1' print,'ending_line last line to be read; if not given is set to the last line' print,'starting_pixel first pixel to be read; if not given is set to 1' print,'ending_pixel last pixel to be read; if not given is set to the last pixel' print,'frame frame = [Pstart, Lstart, Pend, Lend] is an alternative way to specify the part of' print,' the data to be extracted' print,'' return endif bias=127. if (n_elements(limits) NE 0) then begin lim_size = size(limits) if ((lim_size(0) EQ 1) AND (lim_size(1) EQ 4)) then begin Pstart1 = limits[0] Lstart1 = limits[1] Pend1 = limits[2] Lend1 = limits[3] endif else begin print,'Incorrect format for "Limits" keyword. Keyword Ignored !!!' endelse endif if (n_elements(dumpbyte) EQ 0) then dumpbyte = 0 if (n_elements(dumpcomplex) EQ 0) then dumpcomplex = 0 if (n_elements(debug_flag) EQ 0) then debug_flag = 0 if (n_elements(dir_out) EQ 0) then begin dir_out = '' endif else begin test_s = strmid(dir_out,strlen(dir_out)-1,1) if (test_s NE '/') then dir_out = dir_out+'/' endelse if (n_elements(nomefile) EQ 0) then begin nomefile = '' read,'Insert Data filename : ',nomefile endif if (n_elements(no_zero_fill) EQ 0) then no_zero_fill=0 matout = (nparam EQ 2) ;stop read_aux,auxdata, filen = auxfile FSAMP = auxdata.fsamp FREQ = auxdata.freq lut4_i = auxdata.lut4_i lut4_q = auxdata.lut4_q lut4_b = auxdata.lut4_b rdel_bias = auxdata.rdel_bias rank = auxdata.IM_timeline(*,2) ; swap LUTs index indapplut = sm2binoff(bindgen(16)) lut4_i = lut4_i(*,indapplut) lut4_q = lut4_q(*,indapplut) lut4_b = lut4_b(*,indapplut) dir_in = '' ;dir_out = '/proj3/sansosti/ENVISAT/' ;nomefile = '/proj3/sansosti/ENVISAT/asa_im__0pnpdk20020711_095619_000000212007_00337_01894_0062.n1' nomefile = dir_in+nomefile openr,u1,nomefile,/get_lun mph = bytarr(1247) sph = bytarr(1956) m_stuff = 100L ; maximum allowed missing lines if matout is to be used c_missing = 0L ; total number of detected missing lines readu,u1,mph readu,u1,sph tag = string(mph(23:31))+string(mph(58:67))+'_'+string(sph(789:791)) nomeout_c = tag+'_raw_cmpx.dat' nomeout_b = tag+'_raw_byte.dat' nome_mph = tag+'_mph.txt' nome_sph = tag+'_sph.txt' nome_log = tag+'_summary.txt' nome_log_rdel =tag+'_log.txt' nome_par = tag+'_par.sav' nomelog1 = tag+'_annotation.txt' nomelog2 = tag+'_packet_header.txt' nomelog3 = tag+'_data_field_header1.txt' nomelog4 = tag+'_data_field_header2.txt' nomelog5 = tag+'_counters.txt' nomeout_c = dir_out+nomeout_c nomeout_b = dir_out+nomeout_b nome_mph = dir_out+nome_mph nome_sph = dir_out+nome_sph nome_log = dir_out+nome_log nome_log_rdel = dir_out+nome_log_rdel nome_par = dir_out+nome_par nomelog1 = dir_out+ nomelog1 nomelog2 = dir_out+ nomelog2 nomelog3 = dir_out+ nomelog3 nomelog4 = dir_out+ nomelog4 nomelog5 = dir_out+ nomelog5 openw,u2,nome_mph,/get_lun openw,u3,nome_sph,/get_lun printf,u2,string(mph) printf,u3,string(sph) close,u2,u3 free_lun,u2,u3 openw,u10,nome_log,/get_lun openw,u11,nome_log_rdel,/get_lun ;debug_flag =1 if (debug_flag EQ 1) then begin openw,u23, nomelog1, /get_lun openw,u24, nomelog2, /get_lun openw,u25, nomelog3, /get_lun openw,u26, nomelog4, /get_lun openw,u27, nomelog5, /get_lun printf,u23,format='(A10,2A30,5A6)', $ 'NLine','Sensing Time (DSR) ','Reception Time (GSR) ', $ 'Length','CRC','RS','S1','S2' printf,u24,format='(A10,3A12,3A10)', $ 'NLine','PCK_VERSION', 'PACKET_TYPE', 'DAT_FLD_FLG', 'APP_ID', 'SEG_FLAG', 'PCK_LEN' printf,u25,format='(A10,9A10)', $ 'Nline','HDR_LEN', 'MOD_ID', 'SPARE3', 'ANT_BEAM', $ 'COMP_RAT', 'ECHO_FL', 'NOISE_FL', 'CAL_FL', 'CAL_TYP' printf,u26,format='(14A10)', $ 'Nline','PRI', 'SWST', 'SWL', 'GAIN', 'ATTEN', 'TX_POL', 'RX_POL', 'CAL_ROW', $ 'PULSE_LEN', 'BEAM_ADJ', 'C_BAND', 'AUX_MON', 'RESAMP' printf,u27,format='(A10,3A16,A14)', $ 'Nline','SEQ_COUNT','MODE_PCK_COUNT', 'CYCLE_PCK_COUNT', 'OB_TIME' endif if (dumpcomplex NE 0) then openw,u5, nomeout_c,/get_lun if (dumpbyte NE 0) then openw,u6, nomeout_b,/get_lun Nline = 0L ; ======================================= indapp=lindgen(63) b_max = 180L c_max = 1L NN_max = b_max * 63L + c_max index1_max = lonarr(NN_max) index2_max = lonarr(NN_max) for k1 = 0L,b_max-1 do begin index1_max(63*k1:63*k1+62) = ((64L*k1)+1L)+indapp index2_max(63*k1:63*k1+62) = 64L*k1 endfor index1_max(b_max*63L:b_max*63L+c_max-1)= ((64L*k1)+1L)+indapp(0:c_max-1) index2_max(b_max*63L:b_max*63L+c_max-1)= 64L*k1 ; ======================================= N_record = long(string(sph(1043:1053))) ; set default if (n_elements(Lstart) EQ 0) then begin if (n_elements(Lstart1) EQ 0) then $ Lstart = 1L else $ Lstart = Lstart1 endif if (n_elements(Lend) EQ 0) then begin if (n_elements(Lend1) EQ 0) then $ Lend = N_record else $ Lend = Lend1 endif if (Lstart LT 1) then Lstart = 1L if (Lend GT N_record) then Lend = N_record if (Lend LE Lstart) then begin print,' Starting line greather than ending line' print,' Program aborted !!! return endif timein = systime(1) for k=1L,Lend do begin ; ------------ start of annotations ------------ dsr_time=bytarr(12) gsr_time=bytarr(12) appf = bytarr(8) readu,u1,dsr_time readu,u1,gsr_time readu,u1,appf conv_date,dsr_time,DSR_TIME_UTC ; this is the "sensing" time. conv_date,gsr_time,GSR_TIME_UTC ; this is the Ground Station Reference time of data reception. LEN_ISP = long(appf(0))*256L+long(appf(1)) NUM_CRC_ERR = long(appf(2))*256L+long(appf(3)) NUM_RS_ERR = long(appf(4))*256L+long(appf(5)) SPARE1 = appf(6) SPARE2 = appf(7) ; ------------ end of annotations ------------ ;stop ; ------------ start of packet header ------------ app = bytarr(6) readu,u1,app app1 = app(0:1) app2 = app(2:3) app3 = app(4:5) PCK_VERSION = ishft((app1(0) AND 224B), -5) PACKET_TYPE = ishft((app1(0) AND 16B), -4) DATA_FLD_HD_FLG = ishft((app1(0) AND 8B), -3) APP_ID = long(app1(0) AND 7B)*256L+long(app1(1)) ;;;;; convert_bit,app1(0),res0 convert_bit,app1(1),res1 VCID = strmid(res0,10,6)+strmid(res1,0,6) OPS_MODE = strmid(res1,6,10) ;;;;;; SEG_FLAG = ishft((app2(0) AND 192B), -6) SEQ_COUNT = long((app2(0) AND 63B))*256L+long(app2(1)) PCK_LEN = long(app3(0))*256L+long(app3(1)) ; ------------ end of packet header ------------ ; ------------ start of data field header ------------ app = bytarr(30) readu,u1,app a1 = app(0:1) a2 = app(2:3) a3 = app(4:8) a4 = app(9) a5 = app(10:12) a6_7 = app(13) a8_12 = app(14:15) a13 = app(16:17) a14 = app(18:19) a15 = app(20:21) a16_20 = app(22:23) a21_22 = app(24:25) a23 = app(26) a24 = app(27) a25 = app(28:29) DATA_FIELD_HDR_LEN = long(a1(0))*256L+long(a1(1)) MODE_ID = long(a2(0))*256L+long(a2(1)) OB_TIME = (256D^4)*double(a3(0))+(256D^3)*double(a3(1)) + $ (256D^2)*double(a3(2))+256D*double(a3(3))+double(a3(4)) SPARE3 = a4 MODE_PCK_COUNT = 65536L*long(a5(0))+256L*long(a5(1))+long(a5(2)) ANT_BEAM = ishft((a6_7 AND 252B), -2) COMP_RATIO = (a6_7 AND 3B) ECHO_FLAG = ishft((a8_12(0) AND 128B), -7) NOISE_FLAG = ishft((a8_12(0) AND 64B), -6) CAL_FLAG = ishft((a8_12(0) AND 32B), -5) CAL_TYP_FLAG = ishft((a8_12(0) AND 16B), -4) CYCLE_PCK_COUNT = long((a8_12(0) AND 15B))*256L + long(a8_12(1)) PRI = long(a13(0))*256L+long(a13(1)) SWST = long(a14(0))*256L+long(a14(1)) SWL = long(a15(0))*256L+long(a15(1)) GAIN = ishft((a16_20(0) AND 240B), -4) ATTEN = ishft((a16_20(0) AND 15B), +1) + ishft((a16_20(1) AND 128B), -7) TX_POL = ishft((a16_20(1) AND 64B), -6) RX_POL = ishft((a16_20(1) AND 32B), -5) CAL_ROW_NO = (a16_20(1) and 31B) TX_PULSE_LEN = long(a21_22(0))*4L + long(ishft((a21_22(1) AND 192B), -6)) BEAM_ADJ_DELTA = (a21_22(1) AND 63B) CHIRP_BAND = long(a23) AUX_MON_LEV = long(a24) RESAMP_FACT = long(a25(0))*256L+long(a25(1)) ; -------- Conversion in physical units (start) ------------------- PRI_s = double(PRI)/FSAMP PRF_hz = 1D0/PRI_s SWST_s = double(SWST)/FSAMP SWL_s = double(SWL)/FSAMP TX_PULSE_LEN_s = double(TX_PULSE_LEN)/FSAMP BEAM_ADJ_DELTA_deg = double(BEAM_ADJ_DELTA-32)*360./4096. CHIRP_BAND_hz = double(CHIRP_BAND)/255*16D6 TX_POL_asc = string((TX_POL EQ 1)*byte('V')+(TX_POL EQ 0)*byte('H')) RX_POL_asc = string((RX_POL EQ 1)*byte('V')+(RX_POL EQ 0)*byte('H')) OBT_s = OB_TIME/2D16 rdel_s = (double(rank(ant_beam -1))/PRF_hz)+(double(SWST))/FSAMP - rdel_bias ; -------- Conversion in physical units (end) ------------------- ; ------------ end of data field header ------------ if (LEN_ISP NE PCK_LEN) then begin print, 'WARNING: Packet lenght mismatch. Using packet header information. Line', k printf,u11,'WARNING: Packet lenght mismatch. Using packet header information. Line', k endif ;data_len = PCK_LEN+1L-30L data_len = LEN_ISP+1L-30L data = bytarr(data_len) readu,u1,data if (k LT Lstart) then goto, no_action ;-------------- Missing lines handling --------------------- ; initialize counters if (k EQ Lstart) then begin SEQ_COUNT_old = ((SEQ_COUNT - 1) MOD 16384) MODE_PCK_COUNT_old = ((MODE_PCK_COUNT -1) MOD 16777216) CYCLE_PCK_COUNT_old = ((CYCLE_PCK_COUNT -1) MOD 4096) endif ; check on all the three counters n_missing1 = SEQ_COUNT - ((SEQ_COUNT_old+1) MOD 16384) n_missing2 = MODE_PCK_COUNT - ((MODE_PCK_COUNT_old+1) MOD 16777216) n_missing3 = CYCLE_PCK_COUNT - ((CYCLE_PCK_COUNT_old+1) MOD 4096) ; make decision on the number of lines to be added case_index = long(n_missing1 EQ n_missing2)*4 + $ long(n_missing2 EQ n_missing3)*2 + $ long(n_missing1 EQ n_missing3) missing=0L case case_index of 0: begin print, 'WARNING: Inconsistent counters: ignoring missing lines' printf,u11,'WARNING: Inconsistent counters: ignoring missing lines' missing = 0 end 1: begin missing = n_missing1 if (n_missing2 GT 0) then begin print, 'WARNING: Inconsistent MODE_PCK_COUNT ignored for missing lines' printf,u11,'WARNING: Inconsistent MODE_PCK_COUNT ignored for missing lines' endif end 2: begin print, 'WARNING: Inconsistent SEQ_COUNT: using MODE_PCK_COUNT for missing lines' printf,u11,'WARNING: Inconsistent SEQ_COUNT: using MODE_PCK_COUNT for missing lines' missing = n_missing2 end 4: begin missing = n_missing1 if (n_missing3 GT 0) then begin print, 'WARNING: Inconsistent CYCLE_PCK_COUNT ignored for missing lines' printf,u11,'WARNING: Inconsistent CYCLE_PCK_COUNT ignored for missing lines' endif end else : begin missing = n_missing1 if (n_missing1 GT 0) then begin print, 'INFO: Missing lines detected: consistent counters ' printf,u11,'INFO: Missing lines detected: consistent counters ' endif end endcase ; Add empty lines when missing lines are detected ; (only if at least one data line has been already read) if (Nline GT 0) then begin for nm = 1,missing do begin c_missing = c_missing + 1L Nline = Nline + 1L printf, u10, 'Missing line added at line No.: ', Nline, ' (',strcompress(string(k),/remove_all),' w.r.t. original)' print, 'Missing line added at line No.: ', Nline, ' (',strcompress(string(k),/remove_all),' w.r.t. original)' if (no_zero_fill EQ 0) then begin data_c(*)= complex(0.,0.) app_byte(*) = byte(bias) endif if (matout NE 0) then outc(*,Nline-1)=data_c if (dumpcomplex NE 0) then writeu,u5,data_c if (dumpbyte NE 0) then writeu,u6,app_byte((Pstart-1L)*2L:(Pend-1L)*2L+1L) ; write in logs if (debug_flag EQ 1) then begin ; printf,u23, DSR_TIME_UTC printf,u23,'missing line' printf,u24,'missing line' printf,u25,'missing line' printf,u26,'missing line' printf,u27,'missing line' endif endfor endif ; update counters SEQ_COUNT_old = SEQ_COUNT MODE_PCK_COUNT_old = MODE_PCK_COUNT CYCLE_PCK_COUNT_old = CYCLE_PCK_COUNT ;-------------- Missing lines handling (end) --------------------- ; ******** if (echo_flag EQ 1) then begin Nline = Nline + 1L if (Nline EQ 1) then begin PRI_old = PRI SWL_old = SWL TX_PULSE_LEN_old = TX_PULSE_LEN BEAM_ADJ_DELTA_old = BEAM_ADJ_DELTA CHIRP_BAND_old = CHIRP_BAND ANT_BEAM_old = ANT_BEAM COMP_RATIO_old = COMP_RATIO TX_POL_old = TX_POL RX_POL_old = RX_POL GAIN_old = GAIN ATTEN_old = ATTEN SWST_ref = SWST SWST_old = SWST if (n_elements(Pstart) EQ 0) then begin if (n_elements(Pstart1) EQ 0) then $ Pstart = 1L else $ Pstart = Pstart1 endif if (n_elements(Pend) EQ 0) then begin if (n_elements(Pend1) EQ 0) then $ Pend = long(SWL) else $ Pend = Pend1 endif if (Pstart LT 1) then Pstart = 1L if (Pend GT SWL) then Pend = long(SWL) if (Pend LE Pstart) then begin print,' Starting pixel greather than ending pixel' print,' Program aborted !!! return endif N_rg_point = long(Pend-Pstart+1) ; define matout larger than necessary to give room to missing lines if (matout NE 0) then outc = complexarr(Pend-Pstart+1,Lend-Lstart+1+m_stuff) b = long(float(SWL)/63e0) c = SWL - 63L*b NN = b * 63L + c if (NN GT NN_max) then begin print,'Too shoort recordlenght' print,'Program aborted !!!' return endif index1 = index1_max(0:NN-1) index2 = index2_max(0:NN-1) ind_i = lindgen(NN)*2L ind_q = ind_i + 1L app_byte=bytarr(2*NN) printf,u10,'No. record original : ',N_record printf,u10,'No. pixel original : ',NN printf,u10,'' printf,u10,'Line start = ', Lstart printf,u10,'Line end = ', Lend printf,u10,'Pixel start = ', Pstart printf,u10,'Pixel end = ', Pend printf,u10,'' rdel_s = rdel_s + (double(Pstart)-1.)/PRF_hz par = {TX_PULSE_LEN_s : TX_PULSE_LEN_s, $ FSAMP_hz : double(FSAMP), $ CHIRP_BAND_hz : CHIRP_BAND_hz, $ FREQ_hz : double(FREQ), $ PRF_hz : double(PRF_hz), $ t_start_UTC : DSR_TIME_UTC, $ rdel_s : rdel_s, $ N_rg_point : N_rg_point, $ N_lines : 0L } endif ; (NLine EQ 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; b = long(float(SWL)/63e0) c = SWL - 63L*b NN = b * 63L + c if (NN GT NN_max) then begin print,'Too shoort recordlenght' print,'Program aborted !!!' return endif index1 = index1_max(0:NN-1) index2 = index2_max(0:NN-1) ind_i = lindgen(NN)*2L ind_q = ind_i + 1L app_byte=bytarr(2*NN) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; data_i = ishft((data(index1) AND 240B), -4) data_q = (data(index1) AND 15B) ; ====== shift if range delay changes (start) =========================== data_i = shift_pad(data_i,SWST-SWST_ref) data_q = shift_pad(data_q,SWST-SWST_ref) if ((SWST-SWST_old) NE 0) then begin printf,u11,'Range delay changed at line : ', Nline print, 'Range delay changed at line : ', Nline endif SWST_old = SWST ; ====== shift if range delay changes(end) =========================== ; ================================= ; **** Fixed values **** if (NUM_CRC_ERR NE 0) then begin printf,u11,'CRC errors at line : ', Nline print, 'CRC errors at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (NUM_RS_ERR NE 0) then begin printf,u11,'RS errors at line : ', Nline print, 'RS errors at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (PCK_VERSION NE 4) then begin printf,u11,'Packet version wrong at line : ', Nline print, 'Packet version wrong at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (PACKET_TYPE NE 0) then begin printf,u11,'Wrong Packet Type at line : ', Nline print, 'Wrong Packet Type at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (DATA_FLD_HD_FLG NE 1) then begin printf,u11,'Data Flag wrong at line : ', Nline print, 'Data Flag wrong at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (APP_ID NE 1556) then begin printf,u11,'App ID wrong at line : ', Nline print, 'App ID wrong at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (SEG_FLAG NE 3) then begin printf,u11,'Segmentation Flag wrong at line : ', Nline print, 'Segmentation Flag wrong at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif if (DATA_FIELD_HDR_LEN NE 29) then begin printf,u11,'Data Field Header length wrong at line : ', Nline print, 'Data Field Header length wrong at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif if (MODE_ID NE 84) then begin printf,u11,'Mode ID wrong at line : ', Nline print, 'Mode ID wrong at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif ; **** Fixed values (end) **** if (PRI NE PRI_old) then begin printf,u11,'PRF changed at line : ', Nline print, 'PRF changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif PRI_old = PRI if (SWL NE SWL_old) then begin printf,u11,'Record lenght changed at line : ', Nline print, 'Record lenght changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif SWL_old = SWL if (TX_PULSE_LEN NE TX_PULSE_LEN_old) then begin printf,u11,'Pulse length changed at line : ', Nline print, 'Pulse length changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif TX_PULSE_LEN_old = TX_PULSE_LEN if (BEAM_ADJ_DELTA NE BEAM_ADJ_DELTA_old) then begin printf,u11,'Beam adj. delta changed at line : ', Nline print, 'Beam adj. delta changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif BEAM_ADJ_DELTA_old = BEAM_ADJ_DELTA if (CHIRP_BAND NE CHIRP_BAND_old) then begin printf,u11,'Chirp Bandwidth changed at line : ', Nline print, 'Chirp Bandwidth changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif CHIRP_BAND_old = CHIRP_BAND if (ANT_BEAM NE ANT_BEAM_old) then begin printf,u11,'Antenna Beam changed at line : ', Nline print, 'Antenna Beam changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif ANT_BEAM_old = ANT_BEAM if (COMP_RATIO NE COMP_RATIO_old) then begin printf,u11,'Compression Ratio changed at line : ', Nline print, 'Compression Ratio changed at line : ', Nline print, 'Stop processing...' Nline = Nline - 1 goto, no_process endif COMP_RATIO_old = COMP_RATIO if (TX_POL NE TX_POL_old) then begin printf,u11,'TX Polarization changed at line : ', Nline print, 'TX Polarization changed at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif TX_POL_old = TX_POL if (RX_POL NE RX_POL_old) then begin printf,u11,'RX Polarization changed at line : ', Nline print, 'RX Polarization changed at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif RX_POL_old = RX_POL if (GAIN NE GAIN_old) then begin printf,u11,'Gain changed at line : ', Nline print, 'Gain changed at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif GAIN_old = GAIN if (ATTEN NE ATTEN_old) then begin printf,u11,'Attenuation changed at line : ', Nline print, 'Attenuation changed at line : ', Nline print, 'Continue processing...' ; Nline = Nline - 1 ; goto, no_process endif ATTEN_old = ATTEN ; ================================= ;--------------- ; *** Meglio cambiare la LUT una tantum piuttosto che fare questo ad ogni ciclo ; data_i = sm2binoff(data_i) ; data_q = sm2binoff(data_q) ;--------------- ;stop baq_i = data(index2) baq_q = baq_i app_i = lut4_i(baq_i,data_i)*127. app_q = lut4_q(baq_q,data_q)*127. ; app_i = lut4_b(baq_i,data_i) ; app_q = lut4_b(baq_q,data_q) data_c = complex(app_i,app_q) data_c = data_c(Pstart-1:Pend-1) if (matout NE 0) then outc(*,Nline-1)=data_c if (dumpcomplex NE 0) then writeu,u5,data_c ;goto, no_action app_byte(ind_i)=byte(round(app_i+bias)) app_byte(ind_q)=byte(round(app_q+bias)) if (dumpbyte NE 0) then $ writeu,u6,app_byte((Pstart-1L)*2L:(Pend-1L)*2L+1L) ;stop if (max(app_i) GE 127.5) then print,'WARNING UP , I, line :',Nline if (min(app_i) LE -128.5) then print,'WARNING DOWN, I, line :',Nline if (max(app_q) GE 127.5) then print,'WARNING UP , Q, line :',Nline if (min(app_q) LE -128.5) then print,'WARNING DOWN, Q, line :',Nline ;if k eq 11008 then stop endif else begin ; echo flag eq 1 if ((CAL_FLAG EQ 1) AND (Nline GT 0)) then begin ;stop Nline = Nline + 1L printf, u10, 'Calibration line detected at line No.: ', Nline, ' (',strcompress(string(k),/remove_all),' w.r.t. original)' print, 'Calibration line detected at line No.: ', Nline, ' (',strcompress(string(k),/remove_all),' w.r.t. original)' if (no_zero_fill EQ 0) then begin data_c(*)= complex(0.,0.) app_byte(*) = byte(bias) endif if (matout NE 0) then outc(*,Nline-1)=data_c if (dumpcomplex NE 0) then writeu,u5,data_c if (dumpbyte NE 0) then writeu,u6,app_byte((Pstart-1L)*2L:(Pend-1L)*2L+1L) endif if (NOISE_FLAG EQ 1) then printf, u10, 'Noise line detected at line No.: ', k endelse ; ******* if (debug_flag EQ 1) then begin printf,u23,format='(I10,2A30,5I6)', $ Nline,DSR_TIME_UTC, GSR_TIME_UTC, LEN_ISP, NUM_CRC_ERR, NUM_RS_ERR, SPARE1, SPARE2 printf,u24,format='(I10,3I12,3I10)', $ Nline,PCK_VERSION, PACKET_TYPE, DATA_FLD_HD_FLG, APP_ID, SEG_FLAG, PCK_LEN printf,u25,format='(10I10)', $ Nline,DATA_FIELD_HDR_LEN, MODE_ID, SPARE3, ANT_BEAM, $ COMP_RATIO, ECHO_FLAG, NOISE_FLAG, CAL_FLAG, CAL_TYP_FLAG printf,u26,format='(14I10)', $ Nline,PRI, SWST, SWL, GAIN, ATTEN, TX_POL, RX_POL, CAL_ROW_NO, $ TX_PULSE_LEN, BEAM_ADJ_DELTA, CHIRP_BAND, AUX_MON_LEV, RESAMP_FACT printf,u27,format='(I10,3I16,I14)', $ Nline,SEQ_COUNT,MODE_PCK_COUNT, CYCLE_PCK_COUNT, OB_TIME endif no_action: ;stop endfor no_process: if (matout NE 0) then outc=outc(*,0:Nline-1) par.N_lines=Nline save,par,filename=nome_par ; Input file for MINERVA Focusing software openw,u15,dir_out+tag+'_focusing.in',/get_lun printf,u15,tag+'_focused.dat' printf,u15,nomeout_b printf,u15,1 ; which sensor (1=ENVISAT) printf,u15,par.N_rg_point printf,u15,0 ; range skip printf,u15,par.N_rg_point ; record lenght printf,u15,3.d8/par.FREQ_hz printf,u15,par.FSAMP_hz printf,u15,par.CHIRP_BAND_hz printf,u15,11.1 ; antenna azimut dimension [m] printf,u15,1. ; antenna range dimension [m] printf,u15,par.TX_PULSE_LEN_s printf,u15,par.PRF_hz printf,u15,par.rdel_s printf,u15,par.N_lines printf,u15,tag+'_foc_par.log' printf,u15,tag+'_doppl_par.log' printf,u15,0 ; azimuth skip printf,u15,bias ; bias printf,u15,1 ; forward velocity estimation printf,u15,1 ; replica estimation printf,u15,1 ; reprocess if replica is wrong print,'' print,'Total Number of missing lines = ',c_missing print,'' print,'No. records :', Nline print,'No. samples :', N_rg_point printf,u10,'' printf,u10,'Total Number of missing lines = ',c_missing printf,u10,'' printf,u10,'No. records :', Nline printf,u10,'No. samples :', N_rg_point close,/all free_lun,u1,u10,u11,u15 if (dumpcomplex NE 0) then free_lun,u5 if (dumpbyte NE 0) then free_lun,u6 if (debug_flag EQ 1) then free_lun,u23,u24,u25,u26,u27 timeend = systime(1) Print,'Time in processing = ', (timeend - timein)/60.,' m' ;stop return end