📄 roipac2doris
字号:
#!/bin/csh -f# # roipac2doris [dir/]date [s]# # Creates a doris_resultfile for further processing with doris.# processing order:# 1. Run ROI_PAC to create SLCs # 2. this script (create result input file for doris)# 3. doris [porbits/...] (further processing)# ### assume filenames are xxxx_roi.out, xxxx.slc.rsc and xxxx.slc# # Andy Hooper, 18-Jan-2005# (Based on a script by Bert Kampes for creating input from SARP data) ## ===========================================================# 11/2006 AH: Insert ASAR as product identifier for Envisat# 07/2008 AH: Set LINES from FILE_LENGTH instead of YMAX-YMIN# ===========================================================### Initial welcomeset PRG = `basename "$0"`set AUT = "Andy Hooper, (c)2006"echo "$PRG $AUT"echo " "### Handle wrong inputset usage = "1"if ( $#argv == 1 ) set usage = "0"if ( $#argv == 2 && "$2" == "s" ) set usage = "0"if ( "$usage" == "1" ) then echo " $PRG [DIR/]DATE [s]" echo " Create a Doris_resultfile based on " echo " the slc, rsc and roi.out files of ROI_PAC." echo " " echo " $PRG expects to find the following files (in same directory):" echo " ROI_PAC output parameterfile: DATE_roi.out" echo " ROI_PAC output parameterfile: DATE.slc.rsc" echo " ROI_PAC output slc file: DATE.slc" echo " " echo " USAGE: $PRG DATE [s]" echo " INPUT: DATE (and optionally a slave identifier)" echo " OUTPUT: Doris resultfile: master.res or slave.res" echo " " exit 1endifunset usage### Handle inputset IN = $1set OUT = "master.res"if ( "$2" == "s" ) set OUT = "slave.res"set OWD = `pwd`set OUT = $OWD/$OUT### Check if $IN has a directory in front of it.# Check first component is directory.set NEWDIR = $IN:hif ( ! -d $NEWDIR ) set NEWDIR = "."# Remove first component to obtain orbit number.set IN = $IN:tcd $NEWDIRset RSC = $IN.slc.rscif ( ! -e $RSC ) then echo "Inputfile $RSC does not exist." echo "Please enter correct name" set RSC = $< if ( ! -e $RSC ) then echo "File $RSC does not exist either, exiting" exit 2 else echo "continuing" endifendifset ROIOUT = $IN\_roi.outif ( ! -e $ROIOUT ) then echo "Inputfile $ROIOUT does not exist." echo "Please enter correct name" set ROIOUT = $< if ( ! -e $ROIOUT ) then echo "File $ROIOUT does not exist either, exiting" exit 2 else echo "continuing" endifendifset SLCfile = $IN.slcif ( ! -e $SLCfile ) then echo "Inputfile $SLCfile does not exist." echo "Please enter correct name" set SLCfile = $< if ( ! -e $SLCfile ) then echo "File $SLCfile does not exist either, exiting" exit 2 else echo "continuing" endifendif### Get parameters from RSC and ROIOUTecho " Start reading $RSC and $ROIOUT"set DUMMY = "dummyvariable"set UNKNOWN = "9999"set TODO = "THIS MUST BE FILLED ..."set SOL = "299792458" # speed of light in m/sset PI = "3.141592654" set LINES = `awk '/FILE_LENGTH/ {print $2}' < $RSC`#set LINE_L = `awk '/YMAX/ {print $2}' < $RSC`set LINE_F = `awk '/YMIN/ {print $2}' < $RSC`set NPIX = `awk '/WIDTH/ {print $2}' < $RSC`set PIX_F = `awk '/XMIN/ {print $2}' < $RSC`set XSHIFT = "0"#set ERS = `awk '/PLATFORM/ {print $2}' < $RSC`set YEAR = `awk '/FIRST_LINE_YEAR/ {print $2}' < $RSC`set MONTH = `awk '/FIRST_LINE_MONTH_OF_YEAR/ {print $2}' < $RSC`set DAY = `awk '/FIRST_LINE_DAY_OF_MONTH/ {print $2}' < $RSC`set AZIT1 = `awk '/FIRST_LINE_UTC/ {print $2}' < $RSC`set AZITN = `awk '/LAST_LINE_UTC/ {print $2}' < $RSC`set SCVEL = `awk '/VELOCITY / {print $2}' < $RSC`set AZ_PIX = `awk '/AZIMUTH_PIXEL_SIZE / {print $2}' < $RSC`set ANTLEN = `awk '/ANTENNA_LENGTH/ {print $2}' < $RSC`set PRF_PRM = `awk '/PRF / {print $2}' < $RSC`set RSR = `awk '/RANGE_SAMPLING_FREQUENCY/ {print $2}' < $RSC`set LAMBDA = `awk '/WAVELENGTH/ {print $2}' < $RSC`set NEARR = `awk '/RAW_DATA_RANGE/ {print $2}' < $RSC`set NEARR_SLC = `awk '/STARTING_RANGE/ {print $2}' < $RSC`set RE = `awk '/EARTH_RADIUS/ {print $2}' < $RSC`set HEIGHT = `awk '/HEIGHT/ {print $2}' < $RSC`set HEADING = `awk '/HEADING/ {print $2}' < $RSC`#set FD1 = `awk '/DOPPLER_RANGE0/ {print $2}' < $RSC`#set FDD1 = `awk '/DOPPLER_RANGE1/ {print $2}' < $RSC`#set FDDD1 = `awk '/DOPPLER_RANGE2/ {print $2}' < $RSC`set FD1 = `gawk '/Doppler coefficients referenced to output range bin index:/ {getline; print $3}' $ROIOUT`set FDD1 = `gawk '/Doppler coefficients referenced to range bin index:/ {getline; getline; print $4}' $ROIOUT`set FDDD1 = `gawk '/Doppler coefficients referenced to range bin index:/ {getline; getline; getline; print $4}' $ROIOUT`set CHIRP = `awk '/CHIRP_SLOPE/ {printf "%12.10f", $2/1e11}' < $RSC`set PULSE = `awk '/PULSE_LENGTH/ {printf "%12.10f", $2/1e-5}' < $RSC`set SATLAT = `awk '/LATITUDE/ {print $2}' < $RSC`set SATLON = `awk '/LONGITUDE/ {print $2}' < $RSC`set ORB = `awk '/ORBIT_NUMBER/ {print $2}' < $RSC`if ($ERS == "Envisat") then set PRODUCT = "ASAR"else set PRODUCT = `echo ERS $ERS SLC ORB: $ORB` echo $PRODUCTendif### Derive other parameters#@ LINES = ( $LINE_L - $LINE_F ) + 1@ LINESp1 = $LINES + 1@ LINE_L = ( $LINES + $LINE_F ) - 1@ PIX_L = ( $NPIX + $PIX_F ) - 1set FDHZS = `echo $FDD1 $RSR | awk '{print $1*$2}'`set FDHZSS = `echo $FDDD1 $RSR | awk '{print $1*$2*$2}'`set RSR_OUT = `echo $RSR | awk '{printf "%12.10f", $1/1e6}'`set MIDR = `echo $NPIX $SOL $RSR $NEARR_SLC | awk '{printf "%12.10f", ($1/2*$2/$3)+$4}'`set RESQ = `echo $RE | awk '{printf "%12.10f", $1*$1}'`set REH = `echo $RE $HEIGHT | awk '{printf "%12.10f", $1+$2}'`set REHSQ = `echo $REH | awk '{printf "%12.10f", $1*$1}'`set COSANGLE = `echo $RESQ $REHSQ $MIDR $RE $REH | awk '{printf "%12.10f", (($1+$2-($3*$3))/2/$4/$5)}'`set MIDANGLE = `echo $COSANGLE $PI | awk '{printf "%12.10f", sqrt(1-($1*$1))*180/$2}'`set LAT = `echo $SATLAT $MIDANGLE $HEADING $PI | awk '{printf "%12.10f", $1+$2*cos(($3*$4/180)+($4/2))}'`set LON = `echo $SATLON $MIDANGLE $HEADING $PI $SATLAT | awk '{printf "%12.10f", $1+($2*sin(($3*$4/180)+($4/2))/cos($5*$4/180))}'`echo "First line: $LINE_F"echo "Last line: $LINE_L"echo "Number of lines: $LINES"echo "First range pixel: $PIX_F"echo "Last range pixel: $PIX_L"echo "Number of range pixels: $NPIX"set DT = `echo $AZIT1 $AZITN | awk '{printf"%12.10f",($2-$1)}'`echo "Time for acquisition: $DT [s] ($LINES lines)"set PRF = `echo $LINES $DT | awk '{printf"%12.10f",(28000/$1)*($1-1)/$2}'`echo "Computed PRF (based on 28000 l): $PRF [Hz]"echo "Nominal PRF from rsc file: $PRF_PRM [Hz] (used in Doris)"set DR = `echo $SOL $RSR_OUT | awk '{printf"%12.10f",($1/2000000.)/$2}'`echo "Slant range resolution: $DR [m]"echo "Near range in RAW data: $NEARR [m]"echo "Near range in SLC image: $NEARR_SLC [m]"set RAN_T1 = `echo $NEARR_SLC $SOL | awk '{printf"%12.10f",$1/($2/2000)}'`echo "Range time to first pixel: $RAN_T1 [ms]"echo "Lat of mid pixel: $LAT"echo "Lon of mid pixel: $LON"### Range band width#set RBW = `echo "$CHIRP * $PULSE" | bc -l`set RBW = `(echo "$CHIRP * $PULSE"; echo '') | bc -l`echo "Range band width: $RBW [MHz]"### Azimuth band width#set ABW = `echo "$SCVEL *2 / $ANTLEN" | bc -l`set ABW = 1380echo "Azimuth band width: $ABW [Hz]"set AZIT1_WS = `echo $AZIT1 | awk '{printf"%12i",$1}'`#set AZIT1_DS = `echo "$AZIT1 -$AZIT1_WS" | bc -l`set AZIT1_DS = `(echo "$AZIT1 -$AZIT1_WS"; echo '') | bc -l`#set UTC1 = `date --date="$YEAR$MONTH$DAY 0:0:$AZIT1_WS" +"%d-%b-%Y %H:%M:%S"`$AZIT1_DS set UTC1 = `date --date="$YEAR$MONTH$DAY $AZIT1_WS seconds" +"%d-%b-%Y %H:%M:%S"`$AZIT1_DS #set SLCfile = $IN.slcset OFORMAT = 'complex_short'if ( ${#SLCfile} != 1 ) then echo " SLC file: $SLCfile not found, please correct output file $OUT"else # check with filesize #not ok for some large ones...set SLCsize=`ls -l $SLCfile | cut -c35-46` set SLCsize = `ls -l $SLCfile | awk '{print $5}'` @ shortsize = ( ( $LINES * $NPIX ) * 4 ) @ floatsize = ( ( $LINES * $NPIX ) * 8 ) if ( "$shortsize" != "$SLCsize" ) then echo "Setting file format to: complex_real4, based on file size." set OFORMAT = 'complex_real4' if ( "$floatsize" != "$SLCsize" ) then echo "***WARNING***" echo "could not figure out format of SLC file $SLCfile" echo "set to: $OFORMAT" echo "Please check this." endif endif echo "file size of SLC image: $SLCfile = $SLCsize" echo "file format (computed): $OFORMAT"endif### Create a new resultfile with name $OUTset DATE = `date`echo $DATEcat << ___EOFHEREDOC___ >! $OUT TU DELFT - DEOS=====================================================___EOFHEREDOC___if ( "$2" != "s" ) then echo "MASTER RESULTFILE: $OUT" >> $OUTelse echo "SLAVE RESULTFILE: $OUT" >> $OUTendifcat << ___EOFHEREDOC___ >> $OUTThis file has been created with $PRG at $DATEInSAR PROCESSOR: DorisVersion of software: Version ??Compiled at: ??Creation of this file: ??=====================================================Start_process_controlreadfiles: 1precise_orbits: 0crop: 1filt_azi: 0filt_range: 0___EOFHEREDOC___if ( "$2" == "s" ) echo "resample: 0" >> $OUTcat << ___EOFHEREDOC___ >> $OUTEnd_process_control********************************************************************_Start_readfiles:*******************************************************************Volume file: $DUMMYVolume_ID: $$ Volume_identifier: $$Volume_set_identifier: $$(Check)Number of records in ref. file: $LINESp1Product type specifier: $PRODUCTLocation and date/time of product creation: GENERATED AT $DUMMY at $DUMMYScene identification: $DUMMYScene location: $DUMMYLeader file: $DUMMYScene_centre_latitude: $LATScene_centre_longitude: $LONRadar_wavelength (m): $LAMBDAFirst_pixel_azimuth_time (UTC): $UTC1Pulse_Repetition_Frequency (nominal, Hz): $PRF_PRMTotal_azimuth_band_width (Hz): $ABWXtrack_f_DC_constant (Hz, early edge): $FD1Xtrack_f_DC_linear (Hz/s, early edge): $FDHZSXtrack_f_DC_quadratic (Hz/s/s, early edge): $FDHZSSRange_time_to_first_pixel (2way) (ms): $RAN_T1Range_sampling_rate (computed, MHz): $RSR_OUTTotal_range_band_width (MHz): $RBWDatafile: $DUMMYNumber_of_lines_original: $LINESNumber_of_pixels_original: $NPIX******************************************************************** End_readfiles:_NORMAL**************************************************************************************************************************************___EOFHEREDOC___if ( "$2" != "s" ) then echo '*_Start_crop: master' >> $OUTelse echo '*_Start_crop: slave' >> $OUTendifcat << ___EOFHEREDOC___ >> $OUT*******************************************************************Data_output_file: $cwd/$SLCfileData_output_format: $OFORMATFirst_line (w.r.t. original_image): $LINE_FLast_line (w.r.t. original_image): $LINE_LFirst_pixel (w.r.t. original_image): $PIX_FLast_pixel (w.r.t. original_image): $PIX_L******************************************************************** End_crop:_NORMAL*******************************************************************___EOFHEREDOC___### Tidy upecho " "echo " Finished $0."echo " Output: Parameter pool for Doris: $OUT"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -