⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roi_prep.pl

📁 StaMps最新测试版
💻 PL
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/perl### roi_prep.pl######################################################## Modified Version for StaMPS. 2007/12/01 Andy Hooper######################################################## $Id: roi_prep.pl,v 1.2 2007/08/22 18:22:32 ericf Exp $## $Log: roi_prep.pl,v $# Revision 1.2  2007/08/22 18:22:32  ericf# changed default patch size to 16K for L-band data## Revision 1.1.1.1  2007/04/17 22:28:01  ericmg# initial import into erda insarcvs## Revision 1.1.1.1  2007/04/03 03:40:10  ericmg# initial import into erda insarcvs## Revision 1.5  2007/01/26 01:26:30  ericf# fixed slc_ymax sometimes not an integer, courtesy Paul Lundgren## Revision 1.4  2006/12/06 21:17:45  ericf# changed variable names and equations to clarify calculations# modified calculation of the last usable data in SLC (SLC_YMAX)## Revision 1.3  2005/12/16 18:45:39  bswift# RSC keyword documentation changes.#$] >= 5.004 or die "Perl version must be >= 5.004 (Currently $]).\n";use Env qw(INT_SCR INT_BIN);use lib "$INT_SCR";  #### Location of Generic.pmuse Generic;###Usage info/checksub Usage{`$INT_SCR/pod2man.pl  $INT_SCR/roi_prep.pl`;exit 1;}@ARGV ==2 or Usage();@args = @ARGV;$prefix       = shift;$orbit_type   = shift;### Check for input files:if    (-r "$prefix.proc"){$processfile = "$prefix.proc";}elsif (-r "../roi.proc") {$processfile = "../roi.proc";}else  {$processfile = "";}if ($processfile){##########################  Message "Read the inputfile";##########################  open IN, "$processfile" or die "Can't read $processfile\n";  while (chomp($line = <IN>)){    $line =~ /=/ or next;    $line =~ s/\s//g; ###Remove all whitespace    ($keyname, $value) = split /=/, $line;    $$keyname = $value;  }  close(IN);}# changed these to compute below EJF Jan. 2005# --set to zero if not in .proc files so calc is done below$before_z_ext       or $before_z_ext       = 0;$after_z_ext        or $after_z_ext        = 0;$near_rng_ext       or $near_rng_ext       = 0;$far_rng_ext        or $far_rng_ext        = 0;$valid_samples      or $valid_samples      = 0;# moved to calculate below EJF 2007/8/21 $patch_size or $patch_size = 4096;$number_of_patches  or $number_of_patches  = 0;###Can also set number_of_patches and out_pixel### For StaMPS AJH$mean_pixel_rng     or $mean_pixel_rng     = 3156;################## $az_frac = 0.8; # default amount of azimuth extension (fraction of synthetic aperture)$rg_frac = 0.5; # default amount of range extension (fraction of chirp)$az_round = 0.55; # fraction of last patch to add for rounding--decreased from 0.8 EJF 06/11/28### For StaMPS AJH#$dopfile    = "roi.dop";$dopfile    = "$prefix.raw";################## $infile     = "$prefix.raw";$outfile    = "$prefix.slc";$roiin      = "$prefix"."_roi.in";$roiout     = "$prefix"."_roi.out";##########################Message "Checking I/O";##########################@Infiles    = ($infile, "$infile.rsc", "$dopfile.rsc");@Outfiles   = ($roiin, "$outfile.rsc");IOcheck(\@Infiles, \@Outfiles);Log("roi_prep.pl", @args);###########################Message "setting roi default";###########################$speed_of_light = 299792458;##########################################Message "Reading resource file: $infile.rsc";##########################################$orbit_number    = Use_rsc "$infile read ORBIT_NUMBER";$width           = Use_rsc "$infile read WIDTH";$xmin            = Use_rsc "$infile read XMIN";$xmax            = Use_rsc "$infile read XMAX";### For StaMPS AJH$ymin or $ymin            = Use_rsc "$infile read YMIN";$ymax or $ymax            = Use_rsc "$infile read YMAX";##################$velocity        = Use_rsc "$infile read VELOCITY";$height          = Use_rsc "$infile read HEIGHT";$earth_radius    = Use_rsc "$infile read EARTH_RADIUS";$starting_rng    = Use_rsc "$infile read STARTING_RANGE";$prf             = Use_rsc "$infile read PRF";$wavelength      = Use_rsc "$infile read WAVELENGTH";$pulse_length    = Use_rsc "$infile read PULSE_LENGTH";$chirp_slope     = Use_rsc "$infile read CHIRP_SLOPE";$sampling_freq   = Use_rsc "$infile read RANGE_SAMPLING_FREQUENCY";$rng_offset      = Use_rsc "$infile read RANGE_OFFSET";$i_bias          = Use_rsc "$infile read I_BIAS";$q_bias          = Use_rsc "$infile read Q_BIAS";$first_line_utc  = Use_rsc "$infile read FIRST_LINE_UTC";$orbit_direction = Use_rsc "$infile read ORBIT_DIRECTION";$PLANET_GM       = Use_rsc "$infile read PLANET_GM";$AntennaSide     = Use_rsc "$infile read ANTENNA_SIDE"; if(    $AntennaSide == -1 ){ $AntennaSide = "Right"; }elsif( $AntennaSide == 1 ){  $AntennaSide = "Left"; }else{                        $AntennaSide = "Unknown"; }$AntennaLen      = Use_rsc "$infile read ANTENNA_LENGTH";$dop_rng0        = Use_rsc "$dopfile read DOPPLER_RANGE0";$dop_rng1        = Use_rsc "$dopfile read DOPPLER_RANGE1";$dop_rng2        = Use_rsc "$dopfile read DOPPLER_RANGE2";$dop_rng3        = Use_rsc "$dopfile read DOPPLER_RANGE3";$sl_azim_res     = Use_rsc "$dopfile read SL_AZIMUT_RESOL";$squint		 = Use_rsc "$dopfile read SQUINT";if($use1dopp){$dop_rng0        = Use_rsc "$infile read DOPPLER_RANGE0";$dop_rng1        = Use_rsc "$infile read DOPPLER_RANGE1";$dop_rng2        = Use_rsc "$infile read DOPPLER_RANGE2";$dop_rng3        = Use_rsc "$infile read DOPPLER_RANGE3";$squint		 = Use_rsc "$infile read SQUINT";}    ### For StaMPS AJH$dop_rng0=$dop_rng0+$dop_rng1*$mean_pixel_rng;$dop_rng0=$dop_rng0+$dop_rng2*$mean_pixel_rng*$mean_pixel_rng;$dop_rng1=0;$dop_rng2=0;$dop_rng3=0;##############################################Message "Computing parameters";############################$chirp_samps = int($sampling_freq * $pulse_length + 0.5);Message "chirp length in samples $chirp_samps";# set default range extensions to 1/2 chirp$near_rng_ext or $near_rng_ext = int($chirp_samps * $rg_frac );$far_rng_ext or $far_rng_ext = int($chirp_samps * $rg_frac );  # this is now the real far range extension$rng_pixel_size          = $speed_of_light/$sampling_freq/2;$out_pixel or $out_pixel = int($xmax/2-$xmin/2-$chirp_samps+$near_rng_ext+$far_rng_ext);$slc_starting_rng        = $starting_rng - $rng_pixel_size*$near_rng_ext;# use far range$slc_far_range = $starting_rng + $out_pixel*$rng_pixel_size;# use specified if present or change default based on wavelength EJF 2007/8/20$patch_size or $patch_size = 1;if ($patch_size == 1) {  # ugly Perl, but could not add the if to the "or" above  if ( $wavelength < 0.07 )    {$patch_size = 4096;} # e.g., C-band  else    {$patch_size = 16384;}   # need much longer FFT for L-band}Message "Azimuth patch length $patch_size";$synth_apert_samps = int($wavelength*$slc_far_range*$prf/($AntennaLen*$velocity) +0.5);Message "Synthetic aperture length in samples $synth_apert_samps";# default azimuth extensions$before_z_ext or $before_z_ext = int($az_frac * $synth_apert_samps + 0.5);$after_z_ext or $after_z_ext = int($az_frac * $synth_apert_samps + 0.5);# valid azimuth samples per patch$valid_samples or $valid_samples = $patch_size - $synth_apert_samps;# need to make sure this is an even number$valid_samples = (2* int($valid_samples/2));# processing region relative to raw data$proc_start   = int($ymin-$before_z_ext +0.5);$proc_end     = int($ymax+$after_z_ext +0.5);# slc start line is offset due to FFT wrap-around trimming$slc_first_line_offset = ($patch_size-$valid_samples)/2+$proc_start;$delta_line_utc          = 1/$prf;$azimuth_pixel_size      = $velocity/$prf;# data trimmed on both ends by ($patch_size-$valid_samples)/2, #   add $az_round to make sure we get end when taking int()$number_of_patches  or $number_of_patches    = int(($proc_end-$proc_start-($patch_size-$valid_samples))/$valid_samples + $az_round );$slc_first_line_utc      = $first_line_utc + $slc_first_line_offset/$prf;$slc_length              = $number_of_patches*$valid_samples;$slc_last_line_utc           = $slc_first_line_utc + $slc_length/$prf;$slc_center_line_utc         = ($slc_first_line_utc + $slc_last_line_utc)/2;# last remotely useful SLC is $az_frac * $synth_apert_samps past last raw data# calc SLC end relative to raw data$slc_end = $slc_length-1 - $slc_first_line_offset;if ( $slc_end < $ymax + $az_frac*$synth_apert_samps )   { $slc_ymax = $slc_length-1; }  # all SLC good dataelse { $slc_ymax                = $ymax + int($az_frac*$synth_apert_samps); }  # part of SLC not good$dop0                    = $dop_rng0;$dop1                    = $dop_rng1;$dop2                    = $dop_rng2;$dop3                    = $dop_rng3;##########################################Message "Writing resource file: $outfile.rsc";##########################################`cp $infile.rsc $outfile.rsc`;Use_rsc "$outfile write FILE_LENGTH              $slc_length";Use_rsc "$outfile write ORBIT_NUMBER             $orbit_number"; Use_rsc "$outfile write WIDTH                    $out_pixel";Use_rsc "$outfile write FILE_START               1";   Doc_rsc( RSC_Tip => 'Starting line (record) number', RSC_Doc => q[   Starting line (record) number of file.   Is combined with YMIN to determine actual starting line number.   ], RSC_Derivation => q[   Set to constant '1' in roi_prep.pl.   ], RSC_Comment => q[   Only used as 'start' parameter of trees (in new_cut.pl),   corr_flag and grass (in unwrap.pl).   In source code first record read (offs) is calculated as follows -     offs=start+ymin-1;    /* first line of file to start reading/writing */   ], RSC_Type => Int, RSC_Unit => 'record');Use_rsc "$outfile write XMIN                     0";  Use_rsc "$outfile write XMAX                     $out_pixel";  Use_rsc "$outfile write YMIN                     0";   Use_rsc "$outfile write YMAX                     $slc_ymax";   Use_rsc "$outfile write DOPPLER_RANGE0           $dop_rng0";  Use_rsc "$outfile write DOPPLER_RANGE1           $dop_rng1";    Use_rsc "$outfile write DOPPLER_RANGE2           $dop_rng2";   Use_rsc "$outfile write DOPPLER_RANGE3           $dop_rng3";   Use_rsc "$outfile write EARTH_RADIUS             $earth_radius";Use_rsc "$outfile write STARTING_RANGE           $slc_starting_rng"; Use_rsc "$outfile write RAW_DATA_RANGE           $starting_rng"; Doc_rsc( RSC_Tip => 'Range of first sample in raw data file', RSC_Doc => q[   See make_raw.pl STARTING_RANGE.   ], RSC_Derivation => q[   Value is copy of .raw STARTING_RANGE keyword.   ], RSC_Type => Real, RSC_Unit => 'SI:meter',);Use_rsc "$outfile write PRF                      $prf";  Use_rsc "$outfile write WAVELENGTH               $wavelength";   Use_rsc "$outfile write PULSE_LENGTH             $pulse_length";  Use_rsc "$outfile write CHIRP_SLOPE              $chirp_slope";Use_rsc "$outfile write RANGE_SAMPLING_FREQUENCY $sampling_freq"; Use_rsc "$outfile write RANGE_PIXEL_SIZE         $rng_pixel_size";Use_rsc "$outfile write AZIMUTH_PIXEL_SIZE       $azimuth_pixel_size";  Doc_rsc( RSC_Derivation => q[   # $velocity and $prf are read from raw resource file in roi_prep.pl   $azimuth_pixel_size      = $velocity/$prf;   ], RSC_Type => Real, RSC_Unit => 'SI:meter',);Use_rsc "$outfile write DELTA_LINE_UTC           $delta_line_utc";Doc_rsc( RSC_Tip => 'Time between lines (records)', RSC_Derivation => q[   $delta_line_utc          = 1/$prf;   ], RSC_Comment => q[   Initial value is IPP.   ], RSC_Type => Real, RSC_Unit => 'SI:second/record',);Use_rsc "$outfile write SQUINT                   $squint";Use_rsc "$outfile write RANGE_OFFSET             $rng_offset";Doc_rsc( RSC_Derivation => q[   Keyword RANGE_OFFSET doesn't exist in *.raw.rsc,   so a value of 0 is returned from Use_rsc.   ], RSC_Comment => q[   Does not appear to be used anywhere.   ],);Use_rsc "$outfile write FIRST_LINE_UTC           $slc_first_line_utc";Use_rsc "$outfile write CENTER_LINE_UTC          $slc_center_line_utc";Use_rsc "$outfile write LAST_LINE_UTC            $slc_last_line_utc";Use_rsc "$outfile write RLOOKS                   1";Doc_rsc( RSC_Tip => 'Range Looks', RSC_Doc => q[   'Number of Range Looks' based on RDF usage in resamp.pl.   ], RSC_Derivation => q[   Set to constant '1' in roi_prep.pl.   Updated in diffnsim.pl     $new_rlks    = $rlks*$nlook;   Updated in look.pl     $newRlooks          = $oldRlooks*$Rlooks;   ], RSC_Comment => q[   Does anybody ever take fractional looks?   ], RSC_Type => Int, RSC_Unit => 'element/element',);Use_rsc "$outfile write ALOOKS                   1";Doc_rsc( RSC_Tip => 'Azimuth Looks', RSC_Doc => q[   'Number of Azimuth Looks' based on RDF usage in resamp.pl.   ], RSC_Derivation => q[   Set to constant '1' in roi_prep.pl.   Updated in diffnsim.pl     $new_alks    = $alks*$nlook;   Updated in look.pl     $newAlooks          = $oldAlooks*$Alooks;   ], RSC_Comment => q[   Does anybody ever take fractional looks?   ], RSC_Type => Int, RSC_Unit => 'record/record',);################################################ Get peg info and update geometry parameters ## now extracted for SLC, not raw data         ################################################system "cp ${infile}.rsc debug.rsc";system "$INT_SCR/GetPeg.pl $outfile $orbit_type";($name = $outfile) =~ s/\.[^.]*$//; #strip the last extension from the input file nameopen PEGOUT, "$name.peg.out";while( defined( $Line = <PEGOUT> ) ){	if( $Line =~ /Peg Lat\/Lon , H =\s+(\S+)\s+(\S+)\s+(\S+)/ ){		$Latd   = $1;		$Lond   = $2;		$PegHgt = $3;	}	if( $Line =~ /Peg Heading =\s+(\S+)/ ){		$hdgd = $1;	}	if( $Line =~ /Vertical Fit:\s+(\S+)\s+(\S+)\s+(\S+)/ ){		@Height_poly = ( $1, $2, $3 );	}	if( $Line =~ /Horizontal Fit:\s+(\S+)\s+(\S+)\s+(\S+)/ ){		@CrossT_poly = ( $1, $2, $3 );	}	if( $Line =~ /Vertical Velocity Fit:\s+(\S+)\s+(\S+)/ ){		@Vert_V_poly = ( $1, $2 );	}	if( $Line =~ /Cross-Track Velocity Fit:\s+(\S+)\s+(\S+)/ ){		@CrossT_V_poly = ( $1, $2 );	}	if( $Line =~ /Along-Track Velocity Fit:\s+(\S+)\s+(\S+)/ ){		@AlongT_V_poly = ( $1, $2 );	}	if( $Line =~ /Platform SCH Velocity \(m\/s\):\s+(\S+)\s+(\S+)\s+(\S+)/ ){		@VelocitySCH = ( $1, $2, $3 );		$velocity_mid = Norm( @VelocitySCH );	}	if( $Line =~ /Platform SCH Acceleration \(m\/s\^2\):\s+(\S+)\s+(\S+)\s+(\S+)/ ){		@AccelerationSCH = ( $1, $2, $3 );	}	if( $Line =~ /Time to first\/middle scene:\s+\S+\s+(\S+)/ ){		$PegUtc = $1;	}}close PEGOUT;$HgtDt = $Height_poly[1] * $VelocitySCH[0];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -