From f76b01a31ad448b105e18285f14c4125046d9d20 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 1 Mar 2023 19:17:00 +0800 Subject: [PATCH 01/22] hard coding the orbit length to be about 2800s for TOPS data --- preproc/S1A_preproc/src_orbit/ext_orb_s1a.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c b/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c index 642f4861..04632175 100644 --- a/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c +++ b/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c @@ -73,12 +73,14 @@ int main(int argc, char **argv) { // fprintf(stderr,"%.12f %.12f\n",prm.SC_clock_start,prm.SC_clock_stop); // revising t1 and t2 in case only one burst is used. // if smaller than 2 burst, extract more - t1 = prm.SC_clock_start - 10 * (prm.SC_clock_stop - prm.SC_clock_start); - t2 = prm.SC_clock_stop + 10 * (prm.SC_clock_stop - prm.SC_clock_start); - if (fabs(t2-t1) < 1/86400.0*150) { - t1 = prm.SC_clock_start - 20 * (prm.SC_clock_stop - prm.SC_clock_start); - t2 = prm.SC_clock_stop + 20 * (prm.SC_clock_stop - prm.SC_clock_start); - } + //t1 = prm.SC_clock_start - 10 * (prm.SC_clock_stop - prm.SC_clock_start); + //t2 = prm.SC_clock_stop + 10 * (prm.SC_clock_stop - prm.SC_clock_start); + t1 = prm.SC_clock_start - 1400.0/86400.0; + t2 = prm.SC_clock_stop + 1400.0/86400.0; +// if (fabs(t2-t1) < 1/86400.0*150) { +// t1 = prm.SC_clock_start - 20 * (prm.SC_clock_stop - prm.SC_clock_start); +// t2 = prm.SC_clock_stop + 20 * (prm.SC_clock_stop - prm.SC_clock_start); +// } // generate the LED file n = pop_led_pre(xml_tree, sv, t1, t2); From 852bdb023a42432b80e8fbfccbaf7e60f79fd0ce Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Mon, 6 Mar 2023 14:13:14 +0800 Subject: [PATCH 02/22] updating version and gmtsar.csh --- configure.ac | 2 +- gmtsar/csh/gmtsar.csh | 118 ++++++++++++++++++++++++++++-------------- 2 files changed, 81 insertions(+), 39 deletions(-) diff --git a/configure.ac b/configure.ac index 07206856..236f5561 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl 1. Location of GMT include and library files dnl 2. Location of ORBITS directory dnl ------------------------------------------------------------------ dnl -AC_INIT([GMTSAR],[5.5.0],[gmtsar-l@ucsd.edu]) +AC_INIT([GMTSAR],[6.2.0],[gmtsar-l@ucsd.edu]) dnl dnl ------------------------------------------------------------------ dnl The remainder should need no editing diff --git a/gmtsar/csh/gmtsar.csh b/gmtsar/csh/gmtsar.csh index 6f70448e..c7471135 100755 --- a/gmtsar/csh/gmtsar.csh +++ b/gmtsar/csh/gmtsar.csh @@ -3,42 +3,84 @@ # summary of shell scripts # echo ' ' -echo 'align.csh - align a pair of SAR images' -echo 'align_batch.csh - align a stack of SAR images' -echo 'baseline_table.csh - make baseline vs time table' -echo 'cleanup.csh - cleanup the directories' -echo 'dem2topo_ra.csh - transform a dem into range and azimuth coordinates' -echo 'filter.csh - filter the interferogram and make amp, phase and corr' -echo 'fitoffset.csh - solve for the affine parameters' -echo 'geocode.csh - convert range/azimuth to lon/lat' -echo 'grd2kml.csh - make a kml file for google earth' -echo 'intf.csh - make the interferogram from a single pair of SLCs' -echo 'intf_batch.csh - make interferograms for a set of aligned SLCs' -echo 'landmask.csh - make a landmask' -echo 'make_a_offset.csh - make azimuth offsets' -echo 'make_dem.csh - construct a dem from tiles' -echo 'pre_proc.csh - preprocess the raw SAR data for a pair of images' -echo 'pre_proc_batch.csh - preprocess raw SAR data for a stack of images with common parameters ' -echo 'pre_proc_init.csh - preprocess raw SAR data for a stack of images with default parameters ' -echo 'p2p_ALOS.csh - process an interferogram from end-to-end for ALOS' -echo 'p2p_ALOS_SLC.csh - process an interferogram from end-to-end for ALOS 1 0r 2 starting at SLC' -echo 'p2p_CSK.csh - process an interferogram from end-to-end for CSK' -echo 'p2p_CSK_SLC.csh - process an interferogram from end-to-end for CSK_SLC' -echo 'p2p_ENVI.csh - process an interferogram from end-to-end for ENVI' -echo 'p2p_ERS.csh - process an interferogram from end-to-end for ERS' -echo 'p2p_ERS.csh - process an interferogram from end-to-end for ERS' -echo 'p2p_RS2_SLC.csh - process an interferogram from end-to-end for RS2_SLC' -echo 'p2p_S1A_SLC.csh - process an interferogram from end-to-end for S1A_SLC' -echo 'p2p_TSX_SLC.csh - process an interferogram from end-to-end for TSX_SLC' -echo 'proj_ll2ra.csh - project a grd file from lon/lat to range/azimuth' -echo 'proj_ll2ra_ascii.csh - project points from lon/lat to range/azimuth' -echo 'proj_model.csh - project a crust motion model into radar looking directions' -echo 'proj_ra2ll.csh - project a grd file from range/azimuth to lon/lat' -echo 'proj_ra2ll_ascii.csh - project points from range/azimuth to lon/lat' -echo 'sarp.csh - focus a single SAR image' -echo 'slc2amp.csh - make and amplitude image from and SLC' -echo 'snaphu.csh - unwrap phase using snaphu' -echo 'stack_corr.bash - stack the correlation to compute mean correlation' -echo 'stack_phase.bash - stack the phase to compute mean LOS velocity' -echo 'update_PRM - replace a value in a PRF-file' +echo 'GMTSAR version 6.2 - list of shell scripts' +echo ' ' +echo 'align.csh - align a pair of SAR images' +echo 'align_ALOS2_SCAN.csh - align ALOS2 ScanSAR images' +echo 'align_ALOS_SLC.csh - align ALOS SLC images' +echo 'align_batch.csh - align a stack of ERS/ENVISAR/ALOS1 images' +echo 'align_batch_ALOS2_SCAN.csh - align a stack of ALOS2 ScanSAR images' +echo 'align_batch_ALOS_SLC.csh - align a stack of ALOS SLC images' +echo 'align_tops.csh - align Sentinel-1 TOPS images' +echo 'align_tops_esd.csh - align Sentinel-1 TOPS images with enhance spectral diversity' +echo 'baseline_table.csh - create a baseline table for a pair of images' +echo 'cleanup.csh - remove processed data in raw/SLC/intf directory' +echo 'correct_insar_with_gnss.csh - correct interferogram with GNSS displacement' +echo 'correct_merge_offset.csh - correct offset between subswaths after merging' +echo 'create_frame_tops.csh - re-assemble TOPS bursts to create a new frame' +echo 'create_merge_input.csh - create inputlist for merge_batch.csh' +echo 'dem2topo_ra.csh - back geocode the topography to radar coordinates' +echo 'dem2topo_ra_ALOS2.csh - back geocode the topography for ALOS2 data' +echo 'download_sentinel_orbits.csh - Downloads precise or restituted orbits for a list of Sentinel-1 data on Mac' +echo 'download_sentinel_orbits_linux.csh - Downloads precise or restituted orbits for a list of Sentinel-1 data on Linux' +echo 'estimate_ionospheric_phase.csh - estimate ionosphere based on split spectrum method' +echo 'extract_one_time_series.csh - extract for a given position the SBAS time series' +echo 'filter.csh - Apply gaussian filter to amplitude and phase images' +echo 'fitoffset.csh - fit resampling parameters using offset estimates from xcorr' +echo 'geocode.csh - geocode the product in intf/day1_day2 directory' +echo 'get_baseline_table.csh - create a baseline_table.dat for time-series analysis' +echo 'gmtsar.csh - list shell scripts in GMTSAR' +echo 'gmtsar_sharedir.csh - print the path of the shared directory of GMTSAR' +echo 'gnss_enu2los.csh - project E N U displacement into line of sight' +echo 'grd2geotiff.csh - convert grids into geotiff format for viewing' +echo 'grd2kml.csh - convert grids into kml(+png) format for viewing' +echo 'intf.csh - perform interferometry for a pair of SAR images' +echo 'intf_batch.csh - perform interferometry for a stack of ERS/ENVISAR/ALOS1 images' +echo 'intf_batch_ALOS2_SCAN.csh - perform interferometry for a stack of ALOS2 ScanSAR images' +echo 'intf_tops.csh - perform interferometry for a stack of Sentinel-1 TOPS images' +echo 'intf_tops_parallel.csh - perform interferometry for a stack of Sentinel-1 TOPS images using GNU parallel' +echo 'landmask.csh - make a landmask (remove wet region) in radar coordinates' +echo 'landmask_ALOS2.csh - make a landmask (remove wet region) in radar coordinates for ALOS2 data' +echo 'MAI_processing.csh - perform Multi-Aperture Interferometry' +echo 'm2s.csh - convert pixel dimension in meters to dx/dy in arc seconds at mean latitude' +echo 'make_a_offset.csh - use xcorr to compute azimuth(range) offset and make a grid/plot' +echo 'make_dem.csh - Uses GMT server to download SRTM 1-arcsec data' +echo 'make_los_ascii.csh - subsample LOS grid and add the look vector ' +echo 'merge_batch.csh - combine data from multiple subswaths for a stack of TOPS data' +echo 'merge_unwrap_geocode_tops.csh - combine data from multiple subswaths of TOPS data, unwrap and geocode the results' +echo 'organize_files_tops.csh - organize one track of S1A TOPS data, redefine frames, auto-download precise orbits on Mac' +echo 'organize_files_tops_linux.csh - organize one track of S1A TOPS data, redefine frames, auto-download precise orbits on Linux' +echo 'p2p_ALOS2_SCAN_Frame.csh - process a pair of ALOS2 ScanSAR images' +echo 'p2p_ALOS2_SCAN_SLC.csh - process a pair of ALOS2 ScanSAR subswath images' +echo 'p2p_ENVI.csh - process a pair of ENVISAR images using re-focusing' +echo 'p2p_ERS.csh - process a pair of ERS images using re-focusing' +echo 'p2p_S1_TOPS_Frame.csh - process a pair of Sentinel-1 TOPS images' +echo 'p2p_processing.csh - process a pair of any SAR images' +echo 'pop_config.csh - print config file for data from a specific satellite' +echo 'pre_proc.csh - preprocess satellite data and convert to GMTSAR format' +echo 'pre_proc_batch.csh - preprocess a stack of ERS/ENVISAR/ALOS1 data and convert to GMTSAR format' +echo 'pre_proc_batch_ALOS2_SCAN.csh - preprocess a stack of ALOS2 ScanSAR data' +echo 'pre_proc_batch_ALOS_SLC.csh - preprocess a stack of ALOS SLC data' +echo 'prep_data.csh - prepare an inputlist for preproc_batch_tops.csh automatically on Mac' +echo 'prep_data_linux.csh - prepare an inputlist for preproc_batch_tops.csh automatically on Linux' +echo 'prep_sbas.csh - prepare an inputlist for sbas' +echo 'preproc_batch_tops.csh - preprocess and align a stack of Sentinel-1 TOPS data' +echo 'preproc_batch_tops_esd.csh - preprocess and align a stack of Sentinel-1 TOPS data using enhance spectral diversity' +echo 'proj_ll2ra.csh - project a grid in geocoordinates to radar coordinates' +echo 'proj_ll2ra_ascii.csh - project records (3 or more) in geocoordinates to radar coordiantes' +echo 'proj_model.csh - project a simulated crust motion model into radar look directions ' +echo 'proj_ra2ll.csh - project a grid in radar coordiantes to geocoordinates' +echo 'proj_ra2ll_ascii.csh - project records (3 or more) in radar coordinates to geocoordinates' +echo 'samp_slc.csh - resample SLC data to a new PRF and rng_samp_rate' +echo 'sarp.csh - focus a raw SAR image to form a SLC image' +echo 'select_pairs.csh - generate the input file for intf_tops.csh with given threshold of time and baseline' +echo 'shift_atime_PRM.csh - shift the PRM file with a given number of lines along azimuth' +echo 'slc2amp.csh - convert a SLC image to an amplitude grid' +echo 'snaphu.csh - unwrap interferogram' +echo 'snaphu_interp.csh - unwrap interferogram assuming smooth deformation' +echo 'stack.csh - compute mean and standard deviation for a list of grids' +echo 'stack_coherence_mask.csh - stack the coherence and create a mask for data below a certain mean coherence' +echo 'stack_corr.csh - compute mean for a list of coherence grids' +echo 'tide_correction.csh - compute solid earth tide for a given grid' +echo 'unwrap_parallel.csh - run a customized unwrap_intf.csh using GNU parallel' echo ' ' From da11931116d305680f679cd11ea6da4ba01735e0 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Thu, 9 Mar 2023 14:57:54 +0800 Subject: [PATCH 03/22] fixing a few typos --- gmtsar/csh/landmask.csh | 5 +++-- gmtsar/sbas.c | 2 +- gmtsar/sbas_parallel.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gmtsar/csh/landmask.csh b/gmtsar/csh/landmask.csh index 0e148323..de408c82 100755 --- a/gmtsar/csh/landmask.csh +++ b/gmtsar/csh/landmask.csh @@ -8,8 +8,9 @@ if ($#argv != 1) then echo "" echo "Usage: landmask.csh region_cut[0/10600/0/27648]" echo "" - echo " make a landmask in radar coordinates " - echo "NOTE: The region_cut can be specified in batch.config file" + echo " make a landmask in radar coordinates, needs to run with trans.dat " + echo "" + echo " NOTE: The region_cut can be specified in batch.config file" echo "" exit 1 endif diff --git a/gmtsar/sbas.c b/gmtsar/sbas.c index 13da999e..1b486097 100644 --- a/gmtsar/sbas.c +++ b/gmtsar/sbas.c @@ -95,7 +95,7 @@ char *USAGE = "USAGE: sbas intf.tab scene.tab N S xdim ydim [-atm ni] [-smooth s "rms.grd\n" " -dem -- output DEM error (m): dem_err.grd \n" " -mmap -- use mmap to allocate disk space for less use of memory \n" - " -robust -- only work with -atm turnned on, estimate velocity with records that has atm correction\n\n" + " -robust -- only work with -atm turnned on, estimate velocity with records that has atm correction\n\n" " output: \n" " disp_##.grd -- cumulative displacement time series (mm) " "grids\n" diff --git a/gmtsar/sbas_parallel.c b/gmtsar/sbas_parallel.c index becc2c5e..e9efc1ce 100644 --- a/gmtsar/sbas_parallel.c +++ b/gmtsar/sbas_parallel.c @@ -98,7 +98,7 @@ char *USAGE = "USAGE: sbas_parallel intf.tab scene.tab N S xdim ydim [-atm ni] [ "rms.grd\n" " -dem -- output DEM error (m): dem_err.grd \n" " -mmap -- use mmap to allocate disk space for less use of memory \n" - " -robust -- only work with -atm turnned on, estimate velocity with records that has atm correction\n\n" + " -robust -- only work with -atm turnned on, estimate velocity with records that has atm correction\n\n" " output: \n" " disp_##.grd -- cumulative displacement time series (mm) " "grids\n" From 7c6f81e8e6bef5b7ed1447d56620519dc1ac64a1 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Thu, 30 Mar 2023 19:21:46 +0800 Subject: [PATCH 04/22] fixing a bug that may fail sentinel-1 processing when there are many bursts. --- preproc/S1A_preproc/src_tops/make_s1a_tops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preproc/S1A_preproc/src_tops/make_s1a_tops.c b/preproc/S1A_preproc/src_tops/make_s1a_tops.c index 38b7ec07..d85691b6 100644 --- a/preproc/S1A_preproc/src_tops/make_s1a_tops.c +++ b/preproc/S1A_preproc/src_tops/make_s1a_tops.c @@ -402,7 +402,6 @@ int pop_burst(struct PRM *prm, tree *xml_tree, struct burst_bounds *bb, char *fi ker = (int *)malloc((count + 1) * sizeof(int)); kover = (int *)malloc((count + 1) * sizeof(int)); cflag_orig = (char *)malloc(sizeof(char) * 180 * (lpb + 1)); - cflag = cflag_orig; search_tree(xml_tree, "/product/imageAnnotation/imageInformation/productFirstLineUtcTime/", tmp_c, 2, 0, 1); prm->clock_start = str2double(tmp_c); @@ -417,6 +416,7 @@ int pop_burst(struct PRM *prm, tree *xml_tree, struct burst_bounds *bb, char *fi t[i] = str2double(tmp_c); search_tree(xml_tree, "/product/swathTiming/burstList/burst/firstValidSample/", tmp_cc, 1, 4, i); lines_this_burst = get_words(tmp_cc); + cflag = cflag_orig; strcpy(cflag, tmp_cc); for (j = 0; j < lines_this_burst; j++) { flag = (int)strtol(cflag, &cflag, 10); From 692f8e38767c616c9131afc174e1d385be99701c Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Fri, 31 Mar 2023 12:21:17 +0800 Subject: [PATCH 05/22] changing the output to [ERROR]: for a few error messages --- gmtsar/hermite_c.c | 6 +++--- preproc/S1A_preproc/src_orbit/ext_orb_s1a.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gmtsar/hermite_c.c b/gmtsar/hermite_c.c index aeb74b15..e4341e2b 100644 --- a/gmtsar/hermite_c.c +++ b/gmtsar/hermite_c.c @@ -48,7 +48,7 @@ void hermite_c(double *x, double *y, double *z, int nmax, int nval, double xp, d /* reduced index by 1 */ if (xp < x[0] || xp > x[nmax - 1]) { - fprintf(stderr, "interpolation point outside of data constraints, %f %f %f\n", xp, x[0], x[nmax - 1]); + fprintf(stderr, "[ERROR]:hermite interpolation point outside of data constraints, %f %f %f\n", xp, x[0], x[nmax - 1]); *ir = 2; exit(1); } @@ -70,7 +70,7 @@ void hermite_c(double *x, double *y, double *z, int nmax, int nval, double xp, d /* reduced index by 1 */ if (i0 + n > nmax) { - fprintf(stderr, "hermite: interpolation not in center interval\n"); + fprintf(stderr, "[ERROR]:hermite interpolation not in center interval\n"); i0 = nmax - n - 1; *ir = 0; } @@ -91,7 +91,7 @@ void hermite_c(double *x, double *y, double *z, int nmax, int nval, double xp, d *yp = *yp + (y[i + i0] * f0 + z[i + i0] * f1) * hj * hj; if (isnan(*yp) != 0) { - fprintf(stderr, "nan!\n"); + fprintf(stderr, "[ERROR]:hermite interpolation contains nan!\n"); exit(1); } } diff --git a/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c b/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c index 04632175..4aee2da5 100644 --- a/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c +++ b/preproc/S1A_preproc/src_orbit/ext_orb_s1a.c @@ -101,7 +101,7 @@ int write_orb(state_vector *sv, FILE *fp, int n) { double dt; if (n <= 0) { - fprintf(stderr, "NO orbit coverage in the selected file...\n"); + fprintf(stderr, "[ERROR]: NO orbit coverage in the selected file...\n"); return (-1); } else { From 24a89c9f2a5fb969640083baca5c10ee8c8664ff Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Tue, 18 Apr 2023 12:54:41 +0800 Subject: [PATCH 06/22] Adding universal batch processing script, not well tested, bugs may exist --- gmtsar/csh/align_tops.csh | 3 + gmtsar/csh/align_tops_esd.csh | 4 + gmtsar/csh/batch_processing.csh | 340 ++++++++++++++++++++++++++++++ gmtsar/csh/get_baseline_table.csh | 10 + gmtsar/csh/intf_tops.csh | 2 +- gmtsar/csh/p2p_processing.csh | 2 +- gmtsar/csh/pop_config.csh | 4 + 7 files changed, 363 insertions(+), 2 deletions(-) create mode 100755 gmtsar/csh/batch_processing.csh diff --git a/gmtsar/csh/align_tops.csh b/gmtsar/csh/align_tops.csh index b82d5bde..8ff6ff50 100755 --- a/gmtsar/csh/align_tops.csh +++ b/gmtsar/csh/align_tops.csh @@ -94,6 +94,7 @@ if ($skip_master == 2) then calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp + update_PRM $mpre".PRM" input_file $mpre".raw" else if ($skip_master == 0) then make_s1a_tops $mxml $mtiff $mpre 0 @@ -242,11 +243,13 @@ else calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp + update_PRM $mpre".PRM" input_file $mpre".raw" endif set earth_radius = `grep earth_radius $mpre".PRM" | awk '{print $3}'` calc_dop_orb $spre".PRM" tmp2 $earth_radius 0 cat tmp2 >> $spre".PRM" rm tmp2 + update_PRM $spre".PRM" input_file $spre".raw" # rm topo.llt master.ratll aligned.ratll *tmp* flt.grd r.xyz a.xyz *.PRM0 endif diff --git a/gmtsar/csh/align_tops_esd.csh b/gmtsar/csh/align_tops_esd.csh index 1f39ebfd..a6b72a38 100755 --- a/gmtsar/csh/align_tops_esd.csh +++ b/gmtsar/csh/align_tops_esd.csh @@ -101,6 +101,7 @@ if ($skip_master == 2) then calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp + update_PRM $mpre".PRM" input_file $mpre".raw" else if ($skip_master == 0) then make_s1a_tops $mxml $mtiff $mpre 0 @@ -284,12 +285,15 @@ else ext_orb_s1a $mpre".PRM" $2 $mpre calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" + rm tmp + update_PRM $mpre".PRM" input_file $mpre".raw" endif ext_orb_s1a $spre".PRM" $4 $spre set earth_radius = `grep earth_radius $mpre".PRM" | awk '{print $3}'` calc_dop_orb $spre".PRM" tmp2 $earth_radius 0 cat tmp2 >> $spre".PRM" rm tmp2 + update_PRM $spre".PRM" input_file $spre".raw" # rm topo.llt master.ratll aligned.ratll *tmp* flt.grd r.xyz a.xyz *.PRM0 *SLCH *SLCL endif diff --git a/gmtsar/csh/batch_processing.csh b/gmtsar/csh/batch_processing.csh new file mode 100755 index 00000000..5f88f141 --- /dev/null +++ b/gmtsar/csh/batch_processing.csh @@ -0,0 +1,340 @@ +#!/bin/csh -f + + if ($#argv != 5 && $#argv != 4) then + echo "" + echo "Usage: batch_processing.csh SAT master_image inputfile step [configuration_file] " + echo "" + echo "Example: batch_processing.csh ALOS IMG-HH-ALPSRP055750660-H1.0__A imagelist 1 [config.alos.txt]" + echo "" + echo " Put the data and orbit files in the raw folder, put DEM in the topo folder" + echo " The SAT needs to be specified, choices with in ERS, ENVI, ALOS, ALOS_SLC, ALOS2, ALOS2_SCAN" + echo " S1_STRIP, S1_TOPS, ENVI_SLC, CSK_RAW, CSK_SLC, TSX, RS2, GF3" + echo "" + echo " Make sure the files from the same date have the same stem, e.g. stem.tif stem.xml stem.cos stem.EOF, etc" + echo "" + echo " If the configuration file is left blank, the program will generate one " + echo " with default parameters " + echo "" + echo "Details: The step could be 1-preprocessing, 2-alignment, 3-backgeocoding, 4-interferometry, " + echo " 5-phase unwrapping, and 6-geocoding. For TOPS data, step 1 and 2 are done together." + echo "" + echo " step 1: preprocessing, inputfile should be a list of inputdata with or without orbit files, master_image should be in the first line" + echo " NEED at least THREE records to run " + echo " e.g., for ALOS data, the list should be: (pick FBS to be master image)" + echo " IMG-HH-ALPSRP160702940-H1.0__D " + echo " IMG-HH-ALPSRP200962940-H1.0__D " + echo " IMG-HH-ALPSRP268062940-H1.0__D " + echo " and for Sentinel-1 TOPS data, the list should be like:" + echo " s1a-iw1-slc-vv-20150109t134413-20150109t134421-004095-004f4a-001:S1A_OPER_AUX_POEORB_OPOD_20210305T105546_V20150108T225944_20150110T005944.EOF " + echo " s1a-iw1-slc-vv-20150121t134413-20150121t134421-004270-005317-001:S1A_OPER_AUX_POEORB_OPOD_20210305T143838_V20150120T225944_20150122T005944.EOF " + echo " s1a-iw1-slc-vv-20150226t134412-20150226t134420-004795-005f58-001:S1A_OPER_AUX_POEORB_OPOD_20210306T014915_V20150225T225944_20150227T005944.EOF " + echo "" + echo " step 2: alignment, inputfile should be a list of inputdata with master image in the first line " + echo " e.g., for ALOS data, the list should be like:" + echo " NEED at least THREE records to run " + echo " IMG-HH-ALPSRP160702940-H1.0__D " + echo " IMG-HH-ALPSRP200962940-H1.0__D " + echo " IMG-HH-ALPSRP268062940-H1.0__D " + echo " and for Sentinel-1 TOPS data, this step could be skipped." + echo " For secondary alignment, run this step multiple times with -skip_master = 1, for secondary and tertiary alignment." + echo "" + echo " step 3: backgeocoding, make sure DEM is in the topo directory, and PRM and LED file of the master image exist in the raw directory. " + echo " This only need to be run once for a stack of data." + echo "" + echo " step 4: interferometry, inputfile should be a list of interfer " + echo " e.g., for ALOS data the list should be like:" + echo " IMG-HH-ALPSRP160702940-H1.0__D:IMG-HH-ALPSRP200962940-H1.0__D " + echo " IMG-HH-ALPSRP160702940-H1.0__D:IMG-HH-ALPSRP268062940-H1.0__D " + echo " IMG-HH-ALPSRP200962940-H1.0__D:IMG-HH-ALPSRP268062940-H1.0__D" + echo " and for Sentinel-1 TOPS data, the list should be like:" + echo " S1_20150121_ALL_F1:S1_20150310_ALL_F1" + echo " S1_20150121_ALL_F1:S1_20150403_ALL_F1" + echo " S1_20150310_ALL_F1:S1_20150403_ALL_F1" + echo "" + echo " setp 5: phase unwrapping, give the same input as step 4, and the script will go through every directory in intf_all and run " + echo " phase unwrapping using parameters specified in the config file" + echo "" + echo " step 6: geocoding, give the same input as step 4, and the script will go through every directory in intf_all and run geocoding" + echo "" + echo "Note: for data that comes with multiple subswaths, this script only works with one subswath. One'll need to perform merging first " + echo " and then unwrap or geocode." + echo " Also, this script does data processing only. For time-series analysis, refer to the sbas or sbas_parallel program, or use external" + echo " software to construct time-series." + echo "" + echo "" + exit 1 + endif + + +# start +# Make sure the config exist + if ($#argv == 5) then + if(! -f $5 ) then + echo " [ERROR]: no configure file: "$5 + echo " Leave it blank to generate config file with default values." + exit 1 + endif + endif + + if ($4 != 1 && $4 != 2 && $4 != 3 && $4 != 4 && $4 != 5 && $4 != 6) then + echo "[ERROR]: Wrong step input" + exit 1 + endif + +# +# Read parameters from the configure file +# + set SAT = `echo $1` + if ($#argv == 5) then + set conf = `echo $5` + else + pop_config.csh $SAT > config.$SAT.txt + set conf = `echo "config.$SAT.txt"` + endif + + set stage = $4 + set num_patches = `grep num_patches $conf | awk '{print $3}'` + set near_range = `grep near_range $conf | awk '{print $3}'` + set earth_radius = `grep earth_radius $conf | awk '{print $3}'` + set fd = `grep fd1 $conf | awk '{print $3}'` + set topo_phase = `grep topo_phase $conf | awk '{print $3}'` + set topo_interp_mode = `grep topo_interp_mode $conf | awk '{print $3}'` + if ( "x$topo_interp_mode" == "x" ) then + set topo_interp_mode = 0 + endif + set shift_topo = `grep shift_topo $conf | awk '{print $3}'` + set switch_master = `grep switch_master $conf | awk '{print $3}'` + set filter = `grep filter_wavelength $conf | awk '{print $3}'` + set compute_phase_gradient = `grep compute_phase_gradient $conf | awk '{print $3}'` + set iono = `grep correct_iono $conf | awk '{print $3}'` + if ( "x$iono" == "x" ) then + set iono = 0 + endif + set iono_filt_rng = `grep iono_filt_rng $conf | awk '{print $3}'` + set iono_filt_azi = `grep iono_filt_azi $conf | awk '{print $3}'` + set iono_dsamp = `grep iono_dsamp $conf | awk '{print $3}'` + set iono_skip_est = `grep iono_skip_est $conf | awk '{print $3}'` + set spec_div = `grep spec_div $conf | awk '{print $3}'` + if ( "x$spec_div" == "x" ) then + set spec_div = 0 + endif + set spec_mode = `grep spec_mode $conf | awk '{print $3}'` + # set filter = 200 + # echo " " + # echo "WARNING filter wavelength was not set in config.txt file" + # echo " please specify wavelength (e.g., filter_wavelength = 200)" + # echo " remove filter1 = gauss_alos_200m" + #endif + set dec = `grep dec_factor $conf | awk '{print $3}'` + set threshold_snaphu = `grep threshold_snaphu $conf | awk '{print $3}'` + set threshold_geocode = `grep threshold_geocode $conf | awk '{print $3}'` + set region_cut = `grep region_cut $conf | awk '{print $3}'` + set mask_water = `grep mask_water $conf | awk '{print $3}'` + set switch_land = `grep switch_land $conf | awk '{print $3}'` + set defomax = `grep defomax $conf | awk '{print $3}'` + set range_dec = `grep range_dec $conf | awk '{print $3}'` + set azimuth_dec = `grep azimuth_dec $conf | awk '{print $3}'` + set SLC_factor = `grep SLC_factor $conf | awk '{print $3}'` + set near_interp = `grep near_interp $conf | awk '{print $3}'` + set geometric_coreg = `grep geometric_coreg $conf | awk '{print $3}'` + set master = ` echo $2` + set inputlist = ` echo $3 ` + echo "" + + +############################# +# 1 - start from preprocess # +############################# + + if ($stage == 1) then + + echo "" + echo "PREPROCESS BATCH - START" + echo "" + echo " DO MAKE SURE Every needed image and orbit file exist in the raw directory" + echo "" + echo " Cleaning raw directory, removing all .raw, .PRM, .LED and .SLC files" + echo "" + + cd raw + rm *.PRM* *.raw *.LED *.SLC + cd .. + + set nl = `wc -l $inputlist | awk '{print $1}'` + if ($nl < 3) then + echo "" + echo "NEED at least THREE records to run batch preprocessing" + echo "" + exit 1 + endif +# +# Start preprocessing +# +# if ($SAT == "S1_TOPS") then +# ln -s ../topo/dem.grd . +# preproc_batch_tops.csh ../$inputlist dem.grd 1 +# echo "Finished preprocessing $nl $SAT images " +# exit 1 +# endif + + set commandline = "" + if (!($earth_radius == "")) then + set commandline = "$commandline -radius $earth_radius" + endif + if (!($num_patches == "")) then + set commandline = "$commandline -npatch $num_patches" + endif + if (!($SLC_factor == "")) then + set commandline = "$commandline -SLC_factor $SLC_factor" + endif + if (!($spec_div == 0)) then + set commandline = "$commandline -ESD $spec_mode" + endif + + + set ii = 0 + foreach aligned (`cat $inputlist`) + if ($SAT == "S1_TOPS") then + cd raw + set orb = `echo $aligned | awk -F':' '{print $2}'` + set aligned = `echo $aligned | awk -F':' '{print $1}'` + ln -s $orb ./$aligned".EOF" + cd .. + endif + if ($ii == 0) then + else if ($ii == 1) then + sed "s/.*proc_stage.*/proc_stage = 1/g" $conf | sed "s/.*skip_stage.*/skip_stage = 2,3,4,5,6/g" | sed "s/.*skip_master.*/skip_master = 0/g" > tmp_conf_$aligned + p2p_processing.csh $SAT $master $aligned tmp_conf_$aligned + #echo "pre_proc.csh $SAT $master $aligned $commandline -skip_master 0" + #pre_proc.csh $SAT $master $aligned $commandline -skip_master 0 + rm tmp_conf_$aligned + else + sed "s/.*proc_stage.*/proc_stage = 1/g" $conf | sed "s/.*skip_stage.*/skip_stage = 2,3,4,5,6/g" | sed "s/.*skip_master.*/skip_master = 1/g" > tmp_conf_$aligned + p2p_processing.csh $SAT $master $aligned tmp_conf_$aligned + #echo "pre_proc.csh $SAT $master $aligned $commandline -skip_master 1" + #pre_proc.csh $SAT $master $aligned $commandline -skip_master 1 + rm tmp_conf_$aligned + endif + set ii = `echo $ii | awk '{print $ii+1}'` + end + cd raw + ls *.PRM > prmlist + if ($SAT == "S1_TOPS") then + set mmaster = ` echo $master | awk '{ print "S1_"substr($1,16,8)"_"substr($1,25,6)"_F"substr($1,7,1)}'` + endif + get_baseline_table.csh prmlist $mmaster".PRM" + cd .. + + echo "" + echo "PREPROCESS BATCH - END" + echo "" + echo "Finished preprocessing $ii $SAT images " + echo "" + exit 1 + endif + +############################################# +# 2 - start from focus and align SLC images # +############################################# + + if ($stage == 2) then + +# +# focus and align SLC images +# + echo "" + echo "ALIGN BATCH - START" + echo "" + + set ii = 0 + if ($geometric_coreg == 0 || $SAT == "S1_TOPS" ) then + foreach aligned (`cat $inputlist`) + if ($SAT == "S1_TOPS") then + set orb = `echo $aligned | awk -F':' '{print $2}'` + set aligned = `echo $aligned | awk -F':' '{print $1}'` + echo "Skipping TOPS data $aligned, as alignment is done in the first step.." + endif + if ($ii == 0) then + else if ($ii == 1) then + sed "s/.*proc_stage.*/proc_stage = 2/g" $conf | sed "s/.*skip_stage.*/skip_stage = 3,4,5,6/g" | sed "s/.*skip_master.*/skip_master = 0/g" > tmp_conf_$aligned + p2p_processing.csh $SAT $master $aligned tmp_conf_$aligned + rm tmp_conf_$aligned + else + sed "s/.*proc_stage.*/proc_stage = 2/g" $conf | sed "s/.*skip_stage.*/skip_stage = 3,4,5,6/g" | sed "s/.*skip_master.*/skip_master = 1/g" > tmp_conf_$aligned + p2p_processing.csh $SAT $master $aligned tmp_conf_$aligned + rm tmp_conf_$aligned + endif + set ii = `echo $ii | awk '{print $ii+1}'` + end + else + if ($SAT == "ERS" || $SAT == "ENVI" || $SAT == "ALOS" || $SAT == "CSK_RAW") then + align_batch.csh RAW 1 $inputlist + else + align_batch.csh SLC 1 $inputlist + endif + endif + + echo "" + echo "ALIGN BATCH - END" + echo "" + echo "Finished aligning $ii $SAT images" + echo "" + exit 1 + endif + +################################## +# 3 - start from make topo_ra # +################################## + + if ($stage == 3) then + +# +# back-geocode dem.grd and make topo_ra +# + echo "" + echo "BACKGEOCODING - START" + echo "" + sed "s/.*proc_stage.*/proc_stage = 3/g" $conf | sed "s/.*skip_stage.*/skip_stage = 4,5,6/g" > tmp_conf_$master + p2p_processing.csh $SAT $master $master tmp_conf_$master + rm tmp_conf_$master + echo "" + echo "BACKGEOCODING - END" + echo "" + endif + +################################################## +# 4 - start from make and filter interferograms # +################################################## + + if ($stage == 4) then + + echo "" + echo "INTERFEROMETRY BATCH - START" + echo "" + mkdir -p intf_all + sed "s/.*proc_stage.*/proc_stage = 4/g" $conf > tmp_conf_$master + foreach pair (`cat $inputlist`) + set ref = `echo $pair | awk -F: '{print $1}'` + set rep = `echo $pair | awk -F: '{print $2}'` + set ref_id = `grep SC_clock_start ./raw/$ref.PRM | awk '{printf("%d",int($3))}' ` + set rep_id = `grep SC_clock_start ./raw/$rep.PRM | awk '{printf("%d",int($3))}' ` + if ($SAT == "S1_TOPS") then + set tref = `ls raw/$ref".PRM" | awk -F'/' '{print substr($2,4,8)}'` + set ref = `ls raw/*$tref*.xml | awk -F'/' '{print substr($2,1,length($2)-4)}'` + set trep = `ls raw/$rep".PRM" | awk -F'/' '{print substr($2,4,8)}'` + set rep = `ls raw/*$trep*.xml | awk -F'/' '{print substr($2,1,length($2)-4)}'` + endif + p2p_processing.csh $SAT $ref $rep tmp_conf_$master + if (-e intf_all/$ref_id"_"$rep_id) rm -rf intf_all/$ref_id"_"$rep_id + mv intf/$ref_id"_"$rep_id intf_all/$ref_id"_"$rep_id + end + rm tmp_conf_$master + echo "" + echo "INTERFEROMETRY BATCH - END" + echo "" + + endif + + + + diff --git a/gmtsar/csh/get_baseline_table.csh b/gmtsar/csh/get_baseline_table.csh index 41fda364..7b52f7e7 100755 --- a/gmtsar/csh/get_baseline_table.csh +++ b/gmtsar/csh/get_baseline_table.csh @@ -17,3 +17,13 @@ if (-f baseline_table.dat) rm baseline_table.dat foreach prm (`cat $list`) baseline_table.csh $master $prm >> baseline_table.dat end + +awk '{printf("%.6f %.6f %s\n",$2%1000.0/365.25+int($2/1000.0),$5,$1)}' baseline_table.dat > tmp_text +set region = `gmt gmtinfo tmp_text -C | awk '{print $1-0.5, $2+0.5, $3-50, $4+50}'` +gmt pstext tmp_text -JX8.8i/6.8i -R$region[1]/$region[2]/$region[3]/$region[4] -D0.2/0.2 -X1.5i -Y1i -K -N -F+f8,Helvetica+j5 > baseline.ps +awk '{print $1,$2}' < tmp_text > tmp_text2 +gmt psxy tmp_text2 -Sp0.2c -G0 -R -JX -Ba0.5:"year":/a50g00f25:"baseline (m)":WSen -O >> baseline.ps +rm tmp_text tmp_text2 +gmt psconvert baseline.ps -Tf -A +rm baseline.ps + diff --git a/gmtsar/csh/intf_tops.csh b/gmtsar/csh/intf_tops.csh index f2330a35..ad77d1f7 100755 --- a/gmtsar/csh/intf_tops.csh +++ b/gmtsar/csh/intf_tops.csh @@ -243,7 +243,7 @@ if ($stage <= 2) then endif cd ../.. - if(-f intf_all/$ref_id"_"$rep_id) rm -rf intf_all/$ref_id"_"$rep_id + if(-e intf_all/$ref_id"_"$rep_id) rm -rf intf_all/$ref_id"_"$rep_id mv intf/$ref_id"_"$rep_id intf_all/$ref_id"_"$rep_id end diff --git a/gmtsar/csh/p2p_processing.csh b/gmtsar/csh/p2p_processing.csh index c65e7173..deb04e01 100755 --- a/gmtsar/csh/p2p_processing.csh +++ b/gmtsar/csh/p2p_processing.csh @@ -777,7 +777,7 @@ # clean up # mkdir -p intf - cleanup.csh intf +# cleanup.csh intf # # make and filter interferograms # diff --git a/gmtsar/csh/pop_config.csh b/gmtsar/csh/pop_config.csh index b868d2d6..9bfc7855 100755 --- a/gmtsar/csh/pop_config.csh +++ b/gmtsar/csh/pop_config.csh @@ -90,6 +90,10 @@ echo "# region to cut in radar coordinates (leave it blank if process the whole echo "# example 300/5900/0/25000" echo "region_cut =" echo "" +echo "# works in batch mode, for ERS/ENVISAT/ALOS-1, etc., whether to perform geometric " +echo "# coregistration plus a bulk range shift" +echo "geometric_coreg = 0" +echo "" echo "#" echo "#####################################" echo "# parameters for make topo_ra #" From dfd4ec64d79790d0b2264d4705bbc8f1e2ebc19f Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Fri, 21 Apr 2023 12:17:46 +0800 Subject: [PATCH 07/22] adding 3s option for make_dem.csh --- gmtsar/csh/make_dem.csh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/gmtsar/csh/make_dem.csh b/gmtsar/csh/make_dem.csh index 6fd3b76f..300b2917 100755 --- a/gmtsar/csh/make_dem.csh +++ b/gmtsar/csh/make_dem.csh @@ -4,13 +4,15 @@ # # Script to create DEM for GMTSAR, relative to WGS84 ellipsoid # - if ($#argv != 4) then + if ($#argv != 4 && $#argv != 5) then echo "" - echo "Usage: make_dem.csh W E S N" - echo " Uses GMT server to download SRTM 1-arcsec data (@earth_relief_01s)" + echo "Usage: make_dem.csh W E S N [mode]" + echo " Uses GMT server to download SRTM 1-arcsec data (@earth_relief_xxs)" echo " and removes the EGM96 geoid to make heights relative to WGS84." echo "" - echo "Example: make_dem.csh -115 -112 32 35" + echo " mode 1:SRTM-1s 2:SRTM-3s" + echo "" + echo "Example: make_dem.csh -115 -112 32 35 2" echo "" exit 1 endif @@ -18,6 +20,13 @@ echo "" echo "START: make_dem.csh" echo "" + + if ($#argv == 5) then + set mode = $5 + else + set mode = 1 + endif + # # get region in GMT format # @@ -29,12 +38,18 @@ # # get srtm data # - gmt grdcut @earth_relief_01s $R -Gdem_ortho.grd -V + if ($mode == 1) then + gmt grdcut @earth_relief_01s $R -Gdem_ortho.grd + else if ($mode == 2) then + gmt grdcut @earth_relief_03s $R -Gdem_ortho.grd + else + echo "[ERROR]:Wrong DEM mode selected." + endif # # resample and remove geoid # - gmt grdsample $sharedir/geoid_egm96_icgem.grd -Rdem_ortho.grd -Ggeoid_resamp.grd -V - gmt grdmath -V dem_ortho.grd geoid_resamp.grd ADD = dem.grd + gmt grdsample $sharedir/geoid_egm96_icgem.grd -Rdem_ortho.grd -Ggeoid_resamp.grd -Vq + gmt grdmath -Vq dem_ortho.grd geoid_resamp.grd ADD = dem.grd # # clean up # From 52eb320b41c78171736be6cc5c3026ae9750411b Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 3 May 2023 16:49:38 +0800 Subject: [PATCH 08/22] adding a script to stitch product in radar coordiantes, not fully tested, bugs may exist --- gmtsar/csh/stitch_ra_product.csh | 206 +++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100755 gmtsar/csh/stitch_ra_product.csh diff --git a/gmtsar/csh/stitch_ra_product.csh b/gmtsar/csh/stitch_ra_product.csh new file mode 100755 index 00000000..4f2cc809 --- /dev/null +++ b/gmtsar/csh/stitch_ra_product.csh @@ -0,0 +1,206 @@ +#!/bin/csh -f +# $Id$ +# + if ($#argv != 4 && $#argv != 5 ) then + echo " " + echo "Usage: stitch_ra_product.csh PRM1 grid1 PRM2 grid2 [compute_trans]" + echo " " + echo " Note: set compute_trans to 1 to re-compute projection matric" + echo " dem.grd is required and need to cover the two grids." + echo "" + echo " Product: saved in stitch_product.grd" + echo " " + exit 1 + endif + + set buf = 500 + + if ($#argv == 5) then + set compute_trans = $5 + else + set compute_trans = 0 + endif + + set prm1 = $1 + set grid1 = $2 + set prm2 = $3 + set grid2 = $4 + + set fs1 = `grep rng_samp_rate $prm1 | tail -1 | awk '{printf("%d", $3)}'` + set fs2 = `grep rng_samp_rate $prm2 | tail -1 | awk '{printf("%d", $3)}'` + set near1 = `grep near_range $prm1 | awk '{printf("%d", $3)}'` + set near2 = `grep near_range $prm2 | awk '{printf("%d", $3)}'` + set t_start1 = `grep clock_start $prm1 | grep -v SC_clock_start | awk '{print $3}'` + set t1 = `echo $t_start1 | awk '{printf("%d",$1*86400.0)}'` + set t_start2 = `grep clock_start $prm2 | grep -v SC_clock_start | awk '{print $3}'` + set t2 = `echo $t_start2 | awk '{printf("%d",$1*86400.0)}'` + set nl1 = `grep num_lines $prm1 | awk '{print $3}'` + set nl2 = `grep num_lines $prm2 | awk '{print $3}'` + set xinc1 = `gmt grdinfo -C $grid1 | awk '{print $8}'` + set xinc2 = `gmt grdinfo -C $grid2 | awk '{print $8}'` + set nx1 = `gmt grdinfo -C $grid1 | awk '{print $10}'` + set nx2 = `gmt grdinfo -C $grid2 | awk '{print $10}'` + set yinc1 = `gmt grdinfo -C $grid1 | awk '{print $9}'` + set yinc2 = `gmt grdinfo -C $grid2 | awk '{print $9}'` + set ny1 = `gmt grdinfo -C $grid1 | awk '{print $11}'` + set ny2 = `gmt grdinfo -C $grid2 | awk '{print $11}'` + set prf1 = `grep PRF $prm1 | awk '{print $3}'` + set prf2 = `grep PRF $prm2 | awk '{print $3}'` + + set r1x1 = `gmt grdinfo -C $grid1 | awk '{print $2}'` + set r1x2 = `gmt grdinfo -C $grid1 | awk '{print $3}'` + set r1y1 = `gmt grdinfo -C $grid1 | awk '{print $4}'` + set r1y2 = `gmt grdinfo -C $grid1 | awk '{print $5}'` + set r2x1 = `gmt grdinfo -C $grid2 | awk '{print $2}'` + set r2x2 = `gmt grdinfo -C $grid2 | awk '{print $3}'` + set r2y1 = `gmt grdinfo -C $grid2 | awk '{print $4}'` + set r2y2 = `gmt grdinfo -C $grid2 | awk '{print $5}'` + +echo $fs1 + + set rng_pixel = `echo $fs1 | awk '{printf("%.12f",299792458.0/$1/2.0)}'` + echo "range pixel size is $rng_pixel ..." + + if ($fs1 != $fs2) then + echo "[ERROR]: The two grids have different range sampling rate ..." + exit 1 + endif + + if ($xinc1 != $xinc2) then + echo "[ERROR]: The two grids have different range pixel spcaing ..." + exit 1 + endif + if ($yinc1 != $yinc2) then + echo "[ERROR]: The two grids have different azimuth pixel spcaing ..." + exit 1 + endif + + echo "parameters of grid 1:" $near1 $t_start1 $nl1 $xinc1 $yinc1 + echo "parameters of grid 2:" $near2 $t_start2 $nl2 $xinc2 $yinc2 + + if ($t1 >= $t2) then + echo "[ERROR]: Time of grid2 is ahead of time of grid 1 ..." + exit 1 + endif + + set dy_pixel = `echo $t_start1 $t_start2 $yinc1 $prf1 | awk '{printf ("%d",($2-$1)*86400.0*$4/$3)}'` + echo "shift in azimuth is $dy_pixel pixels ..." + set ny_ovlp = `echo $ny1 $dy_pixel | awk '{printf("%d",$1-$2)}'` + + if ($near1 <= $near2) then + set dx_pixel = `echo $near1 $near2 $xinc1 $rng_pixel | awk '{printf ("%d",($2-$1)/$3/$4)}'` + echo "shift in near range is $dx_pixel pixels ..." + set rtmp = `echo $xinc2 $dx_pixel | awk '{print $1*$2}'` + gmt grdcut $grid2 -R0/$rtmp/0/$r2y2 -Gtmp.grd + gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd + gmt grdedit tmp.grd -R-$rtmp/0/0/$r2y2 -Gtmp2.grd + gmt grdpaste $grid2 tmp2.grd -Gtmp_grid2.grd + set rtmp2 = `echo $rtmp $r2x2 | awk '{print $1+$2}'` + gmt grdedit tmp_grid2.grd -R0/$rtmp2/0/$r2y2 + + if ($rtmp2 >= $r1x2) then + set dx_pixel2 = `echo $rtmp2 $r1x2 $xinc1 | awk '{printf ("%d",($1-$2)/$3)}'` + echo "extending first grid with $dx_pixel2 pixels ..." + set rtmp = `echo $xinc1 $dx_pixel2 | awk '{print $1*$2}'` + gmt grdcut $grid1 -R0/$rtmp/0/$r1y2 -Gtmp.grd + gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd + set rtmp2 = `echo $rtmp $r1x2 | awk '{print $1+$2}'` + gmt grdedit tmp.grd -R$r1x2/$rtmp2/0/$r1y2 -Gtmp2.grd + gmt grdpaste $grid1 tmp2.grd -Gtmp_grid1.grd + set rxx = `echo "0/$rtmp2"` + set r_end = `echo $rtmp2` + else + set dx_pixel2 = `echo $rtmp2 $r1x2 $xinc1 | awk '{printf ("%d",($2-$1)/$3)}'` + echo "extending second grid with $dx_pixel2 pixels ..." + set rtmp = `echo $xinc1 $dx_pixel2 | awk '{print $1*$2}'` + gmt grdcut $grid2 -R0/$rtmp/0/$r2y2 -Gtmp.grd + gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd + set rtmp3 = `echo $rtmp $rtmp2 | awk '{print $1+$2}'` + gmt grdedit tmp.grd -R$rtmp2/$rtmp3/0/$r2y2 -Gtmp2.grd + gmt grdpaste tmp2.grd tmp_grid2.grd -Gtmp3.grd + mv tmp3.grd tmp_grid2.grd + set rxx = `echo "0/$rtmp3"` + set r_end = `echo $rtmp3` + endif + cp $prm1 stitch_product.PRM + set LED = `grep led_file $prm1 | awk '{print $3}'` + set pth = `echo $prm1 | awk -F"/" '{for (i=1;i= $r2x2) then + set dx_pixel2 = `echo $rtmp2 $r2x2 $xinc2 | awk '{printf ("%d",($1-$2)/$3)}'` + echo "extending second grid with $dx_pixel2 pixels ..." + set rtmp = `echo $xinc2 $dx_pixel2 | awk '{print $1*$2}'` + gmt grdcut $grid2 -R0/$rtmp/0/$r2y2 -Gtmp.grd + gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd + set rtmp2 = `echo $rtmp $r2x2 | awk '{print $1+$2}'` + gmt grdedit tmp.grd -R$r1x2/$rtmp2/0/$r2y2 -Gtmp2.grd + gmt grdpaste $grid2 tmp2.grd -Gtmp_grid2.grd + set rxx = `echo "0/$rtmp2"` + set r_end = `echo $rtmp2` + else + set dx_pixel2 = `echo $rtmp2 $r2x2 $xinc2 | awk '{printf ("%d",($2-$1)/$3)}'` + echo "extending first grid with $dx_pixel2 pixels ..." + set rtmp = `echo $xinc1 $dx_pixel2 | awk '{print $1*$2}'` + gmt grdcut $grid1 -R0/$rtmp/0/$r1y2 -Gtmp.grd + gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd + set rtmp3 = `echo $rtmp $rtmp2 | awk '{print $1+$2}'` + gmt grdedit tmp.grd -R$rtmp2/$rtmp3/0/$r1y2 -Gtmp2.grd + gmt grdpaste tmp2.grd tmp_grid1.grd -Gtmp3.grd + mv tmp3.grd tmp_grid1.grd + set rxx = `echo "0/$rtmp3"` + set r_end = `echo $rtmp3` + endif + cp $prm2 stitch_product.PRM + set LED = `grep led_file $prm2 | awk '{print $3}'` + set pth = `echo $prm2 | awk -F"/" '{for (i=1;i trans.dat + endif + + + + + From 36cbee1c881ac4b723e49a1da2b96c568a8859fe Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 17 May 2023 13:26:00 +0800 Subject: [PATCH 09/22] fixing a few bugs cuased by recent updates --- gmtsar/csh/align_tops.csh | 6 +++--- gmtsar/csh/align_tops_esd.csh | 6 +++--- gmtsar/csh/merge_unwrap_geocode_tops.csh | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gmtsar/csh/align_tops.csh b/gmtsar/csh/align_tops.csh index 8ff6ff50..a9f63ed6 100755 --- a/gmtsar/csh/align_tops.csh +++ b/gmtsar/csh/align_tops.csh @@ -94,7 +94,7 @@ if ($skip_master == 2) then calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp - update_PRM $mpre".PRM" input_file $mpre".raw" + #update_PRM $mpre".PRM" input_file $mpre".raw" else if ($skip_master == 0) then make_s1a_tops $mxml $mtiff $mpre 0 @@ -243,13 +243,13 @@ else calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp - update_PRM $mpre".PRM" input_file $mpre".raw" + #update_PRM $mpre".PRM" input_file $mpre".raw" endif set earth_radius = `grep earth_radius $mpre".PRM" | awk '{print $3}'` calc_dop_orb $spre".PRM" tmp2 $earth_radius 0 cat tmp2 >> $spre".PRM" rm tmp2 - update_PRM $spre".PRM" input_file $spre".raw" + #update_PRM $spre".PRM" input_file $spre".raw" # rm topo.llt master.ratll aligned.ratll *tmp* flt.grd r.xyz a.xyz *.PRM0 endif diff --git a/gmtsar/csh/align_tops_esd.csh b/gmtsar/csh/align_tops_esd.csh index a6b72a38..e2ae3c60 100755 --- a/gmtsar/csh/align_tops_esd.csh +++ b/gmtsar/csh/align_tops_esd.csh @@ -101,7 +101,7 @@ if ($skip_master == 2) then calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp - update_PRM $mpre".PRM" input_file $mpre".raw" + #update_PRM $mpre".PRM" input_file $mpre".raw" else if ($skip_master == 0) then make_s1a_tops $mxml $mtiff $mpre 0 @@ -286,14 +286,14 @@ else calc_dop_orb $mpre".PRM" tmp 0 0 cat tmp >> $mpre".PRM" rm tmp - update_PRM $mpre".PRM" input_file $mpre".raw" + #update_PRM $mpre".PRM" input_file $mpre".raw" endif ext_orb_s1a $spre".PRM" $4 $spre set earth_radius = `grep earth_radius $mpre".PRM" | awk '{print $3}'` calc_dop_orb $spre".PRM" tmp2 $earth_radius 0 cat tmp2 >> $spre".PRM" rm tmp2 - update_PRM $spre".PRM" input_file $spre".raw" + #update_PRM $spre".PRM" input_file $spre".raw" # rm topo.llt master.ratll aligned.ratll *tmp* flt.grd r.xyz a.xyz *.PRM0 *SLCH *SLCL endif diff --git a/gmtsar/csh/merge_unwrap_geocode_tops.csh b/gmtsar/csh/merge_unwrap_geocode_tops.csh index 85474d31..80742eec 100755 --- a/gmtsar/csh/merge_unwrap_geocode_tops.csh +++ b/gmtsar/csh/merge_unwrap_geocode_tops.csh @@ -84,14 +84,14 @@ set nl = `wc -l $1 | awk '{print $1}'` if ($nl == 2) then set pth2 = `head -1 $1 | awk -F: '{print $1}'` - gmt grdcut $pth2"phasefilt.grd" -Z+n+N -Gtmp.grd + gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set xm1 = `gmt grdinfo $pth2"phasefilt.grd" -C | awk '{print $3}'` set xc1 = `gmt grdinfo tmp.grd -C | awk '{print $3}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n12 = `echo $xm1 $xc1 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `tail -1 $1 | awk -F: '{print $1}'` - gmt grdcut $pth2"phasefilt.grd" -Z+n+N -Gtmp.grd + gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x01 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n21 = `echo $x01 $incx | awk '{printf("%d",$1/$2)}'` @@ -105,14 +105,14 @@ rm tmp.grd else if ($nl == 3) then set pth2 = `head -1 $1 | awk -F: '{print $1}'` - gmt grdcut $pth2"phasefilt.grd" -Z+n+N -Gtmp.grd + gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set xm1 = `gmt grdinfo $pth2/phasefilt.grd -C | awk '{print $3}'` set xc1 = `gmt grdinfo tmp.grd -C | awk '{print $3}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n12 = `echo $xm1 $xc1 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `head -2 $1 | tail -1 | awk -F: '{print $1}'` - gmt grdcut $pth2"phasefilt.grd" -Z+n+N -Gtmp.grd + gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x02 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n21 = `echo $x02 $incx | awk '{printf("%d",$1/$2)}'` @@ -122,7 +122,7 @@ set n22 = `echo $xm2 $xc2 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `tail -1 $1 | awk -F: '{print $1}'` - gmt grdcut $pth2"phasefilt.grd" -Z+n+N -Gtmp.grd + gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x03 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n31 = `echo $x03 $incx | awk '{printf("%d",$1/$2)}'` From f3a01282c5ee33ea22459e76ff83da5595023499 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 31 May 2023 15:35:10 +0800 Subject: [PATCH 10/22] fixing a bug in batch_processing.csh --- gmtsar/csh/batch_processing.csh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gmtsar/csh/batch_processing.csh b/gmtsar/csh/batch_processing.csh index 5f88f141..1f483208 100755 --- a/gmtsar/csh/batch_processing.csh +++ b/gmtsar/csh/batch_processing.csh @@ -220,7 +220,9 @@ cd raw ls *.PRM > prmlist if ($SAT == "S1_TOPS") then - set mmaster = ` echo $master | awk '{ print "S1_"substr($1,16,8)"_"substr($1,25,6)"_F"substr($1,7,1)}'` + set mmaster = `echo $master | awk '{ print "S1_"substr($1,16,8)"_"substr($1,25,6)"_F"substr($1,7,1)}'` + else + set mmaster = `echo $master` endif get_baseline_table.csh prmlist $mmaster".PRM" cd .. From b6dc6afd0d9659f3f3a3531477126fef479404a2 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 31 May 2023 15:38:58 +0800 Subject: [PATCH 11/22] fxing a bug caused by update_PRM.csh in ***pre_process scripts --- preproc/ENVI_preproc/scripts/ENVI_SLC_pre_process.in | 2 +- preproc/ENVI_preproc/scripts/ENVI_pre_process.in | 2 +- preproc/ERS_preproc/scripts/ERS_pre_process.in | 2 +- preproc/ERS_preproc/scripts/ERS_pre_process_031014 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/preproc/ENVI_preproc/scripts/ENVI_SLC_pre_process.in b/preproc/ENVI_preproc/scripts/ENVI_SLC_pre_process.in index c218ffd2..fc80835e 100644 --- a/preproc/ENVI_preproc/scripts/ENVI_SLC_pre_process.in +++ b/preproc/ENVI_preproc/scripts/ENVI_SLC_pre_process.in @@ -96,7 +96,7 @@ endif set FD1 = `grep fd1 $1.PRM | awk '{print $3}'` calc_dop_orb $1.PRM $1.log $2 $FD1 cat $1.log >> $1.PRM -update_PRM.csh $1.PRM fd1 $FD1 +update_PRM $1.PRM fd1 $FD1 # # clean unwanted files # diff --git a/preproc/ENVI_preproc/scripts/ENVI_pre_process.in b/preproc/ENVI_preproc/scripts/ENVI_pre_process.in index fd17f768..6b4819e7 100755 --- a/preproc/ENVI_preproc/scripts/ENVI_pre_process.in +++ b/preproc/ENVI_preproc/scripts/ENVI_pre_process.in @@ -130,7 +130,7 @@ echo "SLC_file = $1.SLC" >> $1.PRM # 6) change the number of patches # if ($4 != 0) then - update_PRM.csh $1.PRM num_patches $4 + update_PRM $1.PRM num_patches $4 echo "Number of patches is set to $4" endif # diff --git a/preproc/ERS_preproc/scripts/ERS_pre_process.in b/preproc/ERS_preproc/scripts/ERS_pre_process.in index 573d5261..643440e9 100755 --- a/preproc/ERS_preproc/scripts/ERS_pre_process.in +++ b/preproc/ERS_preproc/scripts/ERS_pre_process.in @@ -159,7 +159,7 @@ grep near_range $1fix.log >> $1.PRM # 8) change the number of patches # if ($4 != 0) then - update_PRM.csh $1.PRM num_patches $4 + update_PRM $1.PRM num_patches $4 echo "Number of patches is set to $4" endif # diff --git a/preproc/ERS_preproc/scripts/ERS_pre_process_031014 b/preproc/ERS_preproc/scripts/ERS_pre_process_031014 index 62d9919b..a1f9e639 100755 --- a/preproc/ERS_preproc/scripts/ERS_pre_process_031014 +++ b/preproc/ERS_preproc/scripts/ERS_pre_process_031014 @@ -157,7 +157,7 @@ grep near_range $1fix.log >> $1.PRM # 8) change the number of patches # if ($4 != 0) then - update_PRM.csh $1.PRM num_patches $4 + update_PRM $1.PRM num_patches $4 echo "Number of patches is set to $4" endif # From fc6f209304774278f1d6798ae649918cf73b0987 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Fri, 2 Jun 2023 11:45:05 +0800 Subject: [PATCH 12/22] fixing a bug in stitch_ra_product.csh --- .gitignore | 4 ++++ gmtsar/csh/stitch_ra_product.csh | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7f1eb553..66464434 100644 --- a/.gitignore +++ b/.gitignore @@ -232,6 +232,10 @@ preproc/S1A_preproc/src_tops/make_s1a_tops_6par preproc/S1A_preproc/src_tops/make_s1a_tops_6par.o preproc/TSX_preproc/src/make_slc_tsx preproc/TSX_preproc/src/make_slc_tsx.o +preproc/NSR_preproc/include +preproc/NSR_preproc/lib +preproc/NSR_preproc/src_slc/make_slc_nsr +preproc/NSR_preproc/src_slc/make_slc_nsr.o share/ snaphu/src/snaphu snaphu/src/snaphu.o diff --git a/gmtsar/csh/stitch_ra_product.csh b/gmtsar/csh/stitch_ra_product.csh index 4f2cc809..d5530d45 100755 --- a/gmtsar/csh/stitch_ra_product.csh +++ b/gmtsar/csh/stitch_ra_product.csh @@ -133,7 +133,7 @@ echo $fs1 gmt grdcut $grid1 -R0/$rtmp/0/$r1y2 -Gtmp.grd gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd gmt grdedit tmp.grd -R-$rtmp/0/0/$r1y2 -Gtmp2.grd - gmt grdpaste $grid2 tmp2.grd -Gtmp_grid1.grd + gmt grdpaste $grid1 tmp2.grd -Gtmp_grid1.grd set rtmp2 = `echo $rtmp $r1x2 | awk '{print $1+$2}'` gmt grdedit tmp_grid1.grd -R0/$rtmp2/0/$r1y2 @@ -144,7 +144,7 @@ echo $fs1 gmt grdcut $grid2 -R0/$rtmp/0/$r2y2 -Gtmp.grd gmt grdmath tmp.grd 0 MUL 0 NAN = tmp.grd set rtmp2 = `echo $rtmp $r2x2 | awk '{print $1+$2}'` - gmt grdedit tmp.grd -R$r1x2/$rtmp2/0/$r2y2 -Gtmp2.grd + gmt grdedit tmp.grd -R$r2x2/$rtmp2/0/$r2y2 -Gtmp2.grd gmt grdpaste $grid2 tmp2.grd -Gtmp_grid2.grd set rxx = `echo "0/$rtmp2"` set r_end = `echo $rtmp2` @@ -201,6 +201,3 @@ echo $fs1 endif - - - From 5d9c164ec2571750113f4c65c60290cbef49a1c0 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Sun, 25 Jun 2023 13:58:59 +0800 Subject: [PATCH 13/22] fixing a bug in make_los_ascii.csh in master --- gmtsar/csh/make_los_ascii.csh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gmtsar/csh/make_los_ascii.csh b/gmtsar/csh/make_los_ascii.csh index 28ea24bd..4c1f84bd 100755 --- a/gmtsar/csh/make_los_ascii.csh +++ b/gmtsar/csh/make_los_ascii.csh @@ -18,12 +18,12 @@ else set V = "-V" endif -gmt grdsample $2 -Gtmp_topo.grd `grdinfo $1 -I-` `grdinfo $1 -I` -F +gmt grdsample $2 -Gtmp_topo.grd `gmt grdinfo $1 -I-` `gmt grdinfo $1 -I` -F gmt grdmath $1 0 MUL 1 ADD tmp_topo.grd MUL = tmp_topo.grd gmt grd2xyz $1 > tmp.xyz gmt grd2xyz tmp_topo.grd > tmp_topo.xyz -gmt blockmedian tmp.xyz `grdinfo $1 -I-` $3 $V > tmp_b.xyz -gmt blockmedian tmp_topo.xyz `grdinfo $1 -I-` $3 $V > tmp_topo_b.xyz +gmt blockmedian tmp.xyz `gmt grdinfo $1 -I-` $3 $V > tmp_b.xyz +gmt blockmedian tmp_topo.xyz `gmt grdinfo $1 -I-` $3 $V > tmp_topo_b.xyz set SAT = $5 if($SAT == ERS) then From 479d3d7a06f400d9028531a6c150c7eb08ff24b6 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Tue, 27 Jun 2023 16:03:42 +0800 Subject: [PATCH 14/22] fixing a bug in make_slc_csk.c --- preproc/CSK_preproc/src_slc/make_slc_csk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/preproc/CSK_preproc/src_slc/make_slc_csk.c b/preproc/CSK_preproc/src_slc/make_slc_csk.c index 97ccc5da..b05f7184 100644 --- a/preproc/CSK_preproc/src_slc/make_slc_csk.c +++ b/preproc/CSK_preproc/src_slc/make_slc_csk.c @@ -98,7 +98,7 @@ int main(int argc, char **argv) { int write_slc_hdf5(hid_t input, FILE *slc) { - int i, j, width, height; + int i, j, width, height, widthi; short *buf, *tmp; hsize_t dims[10]; hid_t memtype, dset, group; @@ -107,6 +107,7 @@ int write_slc_hdf5(hid_t input, FILE *slc) { hdf5_read(dims, input, "/S01", "SBI", "", 'n'); height = (int)dims[0]; width = (int)dims[1]; + widthi = width; buf = (short *)malloc(height * width * 2 * sizeof(short)); tmp = (short *)malloc(width * 2 * sizeof(short)); @@ -127,8 +128,8 @@ int write_slc_hdf5(hid_t input, FILE *slc) { for (i = 0; i < height; i++) { for (j = 0; j < width * 2; j += 2) { - tmp[j] = (short)buf[i * width * 2 + j]; - tmp[j + 1] = (short)buf[i * width * 2 + j + 1]; + tmp[j] = (short)buf[i * widthi * 2 + j]; + tmp[j + 1] = (short)buf[i * widthi * 2 + j + 1]; } fwrite(tmp, sizeof(short), width * 2, slc); } From f3666a05dddcb672e4f148ee07018e53ab6848cf Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 19 Jul 2023 14:00:33 +0800 Subject: [PATCH 15/22] fixing a bug in preproc_batch_tops.csh that baseline_table.dat may get twice the records --- gmtsar/csh/preproc_batch_tops.csh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gmtsar/csh/preproc_batch_tops.csh b/gmtsar/csh/preproc_batch_tops.csh index b54d21ca..392bdcf8 100755 --- a/gmtsar/csh/preproc_batch_tops.csh +++ b/gmtsar/csh/preproc_batch_tops.csh @@ -52,9 +52,7 @@ set mmaster = `awk -F: 'NR==1 {print $1}' $1 | awk '{ print "S1_"substr($1,16,8)"_ALL_F"substr($1,7,1)}'` # clean up a little bit rm *.PRM* *.SLC *.LED tmp* - if($mode == 1) then - rm baseline_table.dat - endif + if (-f baseline_table.dat) rm baseline_table.dat # loop over all the acquisitions foreach line (`awk '{print $0}' $1`) From e98ebc0f4164939a4780b1534bac186924d7c998 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Sun, 6 Aug 2023 08:50:49 +0800 Subject: [PATCH 16/22] extending solid_tide to 2050 as leap seconds are abandoned hopefully --- gmtsar/solid_tide.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmtsar/solid_tide.c b/gmtsar/solid_tide.c index b2055985..3a1a640e 100644 --- a/gmtsar/solid_tide.c +++ b/gmtsar/solid_tide.c @@ -1084,7 +1084,7 @@ double gpsleap(double tsec) { //***** parameter(mjdhard=58118) !*** cut-off date 2017dec31 // parameter(mjdhard=58299) !*** cut-off date 2018jun30 // parameter(mjdhard=58664) !*** cut-off date 2019jun30 - double mjdhard = 59030.0; // temporary new cut-off date until 2020jun30 + double mjdhard = 69807.0; // temporary new cut-off date until 2050 Jan 1 double ttsec, mjd0t, tai_utc, gpsleap_return; // save /mjdoff/ From ff716f8b668fbeec212c68f69807ce86149a996e Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Mon, 28 Aug 2023 14:40:23 +0800 Subject: [PATCH 17/22] changing xml.c to account for situation when time records have sigle digits like 12:5:31 --- preproc/S1A_preproc/lib/xml.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/preproc/S1A_preproc/lib/xml.c b/preproc/S1A_preproc/lib/xml.c index d997f502..5e3492c1 100644 --- a/preproc/S1A_preproc/lib/xml.c +++ b/preproc/S1A_preproc/lib/xml.c @@ -423,11 +423,23 @@ int show_tree(tree *T, int ct, int lvl) { int cat_nums(char *str_out, char *str) { // cat out the numbers in str to str_out - int i = 0, j = 0; + int i = 0, j = 0, sep1 = -1, sep2 = -1; + while (str[i] != '\0') { if (str[i] >= '0' && str[i] <= '9') { str_out[j++] = str[i]; } + // to account for single digits time such as 5:6:7.123456 + else if (str[i] == 'T' || str[i] == ':' || str[i] == '.') { + sep2 = i; + if (sep2 - sep1 == 2) { + str_out[j] = str_out[j-1]; + str_out[j-1] = '0'; + j++; + sep2++; + } + sep1 = i; + } i++; } str_out[j] = '\0'; From 621ecf33fb3188087795617a6d84d07e3c76fcfa Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Mon, 28 Aug 2023 14:51:05 +0800 Subject: [PATCH 18/22] adding a preprocessor for LT1 --- Makefile | 2 +- gmtsar/PRM.h | 4 +- preproc/LT1_preproc/Makefile | 27 ++ preproc/LT1_preproc/src/Makefile | 21 ++ preproc/LT1_preproc/src/make_slc_lt1.c | 338 +++++++++++++++++++++++++ 5 files changed, 389 insertions(+), 3 deletions(-) create mode 100644 preproc/LT1_preproc/Makefile create mode 100644 preproc/LT1_preproc/src/Makefile create mode 100644 preproc/LT1_preproc/src/make_slc_lt1.c diff --git a/Makefile b/Makefile index 4f4e4db9..156167a7 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ sinclude config.mk # Currently, S1A must happen before the CSK, TSZ, and RS2 builds due to dependencies via links # We will fix this so one can make anyting in any order # -PREPROCESSORS = ALOS ERS S1A CSK TSX RS2 ENVI GF3 NSR +PREPROCESSORS = ALOS ERS S1A CSK TSX RS2 ENVI GF3 NSR LT1 # DIRS = gmtsar snaphu/src ORBITS_URL = http://topex.ucsd.edu/gmtsar/tar/ORBITS.tar diff --git a/gmtsar/PRM.h b/gmtsar/PRM.h index cff019c7..85290245 100644 --- a/gmtsar/PRM.h +++ b/gmtsar/PRM.h @@ -36,9 +36,9 @@ struct PRM { int rec_start; int rec_stop; int SC_identity; /* (1)-ERS1 (2)-ERS2 (3)-Radarsat (4)-Envisat (5)-ALOS - (6)-Envisat_SLC (7)-TSX (8)-CSK (9)-RS2 (10)-S1A (11)-GF3 */ + (6)-Envisat_SLC (7)-TSX (8)-CSK (9)-RS2 (10)-S1A (11)-GF3 (12)-LT1 */ int ref_identity; /* (1)-ERS1 (2)-ERS2 (3)-Radarsat (4)-Envisat (5)-ALOS (6)- - (7)-TSX (8)-CSK (9)-RS2 (10)-S1A (11)-GF3*/ + (7)-TSX (8)-CSK (9)-RS2 (10)-S1A (11)-GF3 (12)-LT1 */ int nrows; int num_lines; int SLC_format; /* 1 => complex ints (2 bytes) 2 => complex floats (4 diff --git a/preproc/LT1_preproc/Makefile b/preproc/LT1_preproc/Makefile new file mode 100644 index 00000000..2294c434 --- /dev/null +++ b/preproc/LT1_preproc/Makefile @@ -0,0 +1,27 @@ +include ../../config.mk +# +# make all the files +# +DIRS = lib src + +all: + $(LN_S) -f ../S1A_preproc/include include + $(LN_S) -f ../S1A_preproc/lib lib + for d in $(DIRS); do \ + (cd $$d; $(MAKE) all); \ + done + +install: all + for d in $(DIRS); do \ + (cd $$d; $(MAKE) install); \ + done + +uninstall: + (cd src; $(MAKE) uninstall) + +clean: + for d in $(DIRS); do \ + (cd $$d; $(MAKE) clean); \ + done + +spotless: clean diff --git a/preproc/LT1_preproc/src/Makefile b/preproc/LT1_preproc/src/Makefile new file mode 100644 index 00000000..584dd3ad --- /dev/null +++ b/preproc/LT1_preproc/src/Makefile @@ -0,0 +1,21 @@ +include ../../../config.mk +PROG = make_slc_lt1 +CSRCS = make_slc_lt1.c + +OBJS = $(CSRCS:.c=.o) +INCLUDES = -I../include -I../../../gmtsar -I$(TIFF_INC) +CLIBS = -L../../../gmtsar -lgmtsar -L../lib -lxmlC -L$(TIFF_LIB) -ltiff -lm + +$(PROG): $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(CLIBS) + +all: $(PROG) + +install: + $(INSTALL) $(PROG) $(bindir) + +uninstall: + rm -f $(bindir)/$(PROG) + +clean: + rm -f $(OBJS) tags core diff --git a/preproc/LT1_preproc/src/make_slc_lt1.c b/preproc/LT1_preproc/src/make_slc_lt1.c new file mode 100644 index 00000000..e7c28890 --- /dev/null +++ b/preproc/LT1_preproc/src/make_slc_lt1.c @@ -0,0 +1,338 @@ +/*************************************************************************** + * Creator: Xiaohua(Eric) XU * + * (University of Texas Austin, Institute for Geophysics) * + * Date : 05/06/2022 * + ***************************************************************************/ + +/*************************************************************************** + * Modification history: * + * * + * DATE * + * * + ***************************************************************************/ + +#include "PRM.h" +#include "lib_defs.h" +#include "lib_functions.h" +#include "stateV.h" +#include "tiffio.h" +#include +#include +#include +#include + +int pop_prm(struct PRM *, tree *, char *); +int pop_led(tree *, state_vector *); +int write_orb(state_vector *sv, FILE *fp, int); +int write_slc(TIFF *, FILE *, char *); + +char *USAGE = "\n\nUsage: make_slc_lt1 name_of_xml_file name_of_tiff_file name_output\n" + "\nExample: make_slc_lt1 LT1A_MONO_KSC_STRIP2_006353_E112.2_N33.4_20230328_SLC_HH_S2A_0000087472.meta.xml LT1A_MONO_KSC_STRIP2_006353_E112.2_N33.4_20230328_SLC_HH_S2A_0000087472.tiff LT1A_20230328\n" + "\nOutput: LT1A_20230328.SLC LT1A_20230328.PRM LT1A_20230328.LED\n"; + +int main(int argc, char **argv) { + + FILE *XML_FILE, *OUTPUT_PRM, *OUTPUT_SLC, *OUTPUT_LED; + TIFF *TIFF_FILE; + char tmp_str[200]; + struct PRM prm; + tree *xml_tree; + state_vector sv[2000]; + int ch, n = 0, nc = 0, nlmx = 0; + + if (argc < 4) + die(USAGE, ""); + + if ((XML_FILE = fopen(argv[1], "rb")) == NULL) + die("Couldn't open xml file: \n", argv[1]); + + // find the number of lines and the maximum line length of the xml file + while (EOF != (ch = fgetc(XML_FILE))) { + ++nc; + if (ch == '\n') { + ++n; + if (nc > nlmx) + nlmx = nc; + nc = 0; + } + } + fprintf(stderr, "%d %d \n", n, nlmx); + xml_tree = (struct tree *)malloc(n * 5 * sizeof(struct tree)); + fclose(XML_FILE); + + // generate the xml tree + if ((XML_FILE = fopen(argv[1], "r")) == NULL) + die("Couldn't open xml file: \n", argv[1]); + get_tree(XML_FILE, xml_tree, 1); + fclose(XML_FILE); + + // show_tree(xml_tree,0,0); + + // initiate the prm + null_sio_struct(&prm); + + // generate the PRM file + pop_prm(&prm, xml_tree, argv[3]); + strcpy(tmp_str, argv[3]); + strcat(tmp_str, ".PRM"); + if ((OUTPUT_PRM = fopen(tmp_str, "w")) == NULL) + die("Couldn't open prm file: \n", tmp_str); + put_sio_struct(prm, OUTPUT_PRM); + + // generate the LED file + n = pop_led(xml_tree, sv); + + strcpy(tmp_str, argv[3]); + strcat(tmp_str, ".LED"); + if ((OUTPUT_LED = fopen(tmp_str, "w")) == NULL) + die("Couldn't open led file: \n", tmp_str); + write_orb(sv, OUTPUT_LED, n); + fclose(OUTPUT_LED); + + // generate the SLC file + TIFFSetWarningHandler(NULL); + if ((TIFF_FILE = TIFFOpen(argv[2], "r")) == NULL) + die("Couldn't open tiff file: \n", argv[2]); + + strcpy(tmp_str, argv[3]); + strcat(tmp_str, ".SLC"); + if ((OUTPUT_SLC = fopen(tmp_str, "wb")) == NULL) + die("Couldn't open slc file: \n", tmp_str); + write_slc(TIFF_FILE, OUTPUT_SLC, prm.orbdir); + + TIFFClose(TIFF_FILE); + fclose(OUTPUT_SLC); +} + +int write_slc(TIFF *tif, FILE *slc, char *orbdir) { + + uint32 width, height, widthi; + int i, j; + uint16 s = 0, nsamples; + uint16 *buf; + short *tmp; + + // get the width and the height of the file, make width dividable by 4 + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &widthi); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); + // printf("%d %d \n",width,height); + + buf = (uint16 *)_TIFFmalloc(TIFFScanlineSize(tif)); + width = widthi - widthi % 4; + tmp = (short *)malloc(width * 2 * sizeof(short)); + printf("Writing SLC..Image Size: %d X %d...\n", width, height); + + for (i = 0; i < height; i++) { + TIFFReadScanline(tif, buf, i, s); + for (j = 0; j < width * 2; j++) { + tmp[j] = (short)buf[j]; + } + fwrite(tmp, sizeof(short), width * 2, slc); + } +/* + if (strcmp(orbdir, "A") == 0) { + printf("Fliping upside down for Ascending Image...\n"); + for (i = height - 1; i >= 0; i--) { + TIFFReadScanline(tif, buf, i, s); + for (j = 0; j < width * 2; j++) { + tmp[j] = (short)buf[j]; + } + fwrite(tmp, sizeof(short), width * 2, slc); + } + } + // For Descending Condition... + else { + printf("Fliping leftside right for Descending Image...\n"); + for (i = 0; i < height; i++) { + TIFFReadScanline(tif, buf, i, s); + for (j = 0; j < width; j++) { + tmp[(width - 1 - j) * 2] = (short)buf[j * 2]; + tmp[(width - 1 - j) * 2 + 1] = (short)buf[j * 2 + 1]; + } + fwrite(tmp, sizeof(short), width * 2, slc); + } + } +*/ + _TIFFfree(buf); + free(tmp); + return (1); +} + +int write_orb(state_vector *sv, FILE *fp, int n) { + int i; + double dt; + + dt = trunc((sv[1].sec) * 1000.0) / 1000.0 - trunc((sv[0].sec) * 1000.0) / 1000.0; + if (n <= 1) + return (-1); + fprintf(fp, "%d %d %d %.3lf %lf \n", n, sv[0].yr, sv[0].jd, sv[0].sec, dt); + for (i = 0; i < n; i++) { + fprintf(fp, "%d %d %.3lf %.6lf %.6lf %.6lf %.8lf %.8lf %.8lf \n", sv[i].yr, sv[i].jd, sv[i].sec, sv[i].x, sv[i].y, + sv[i].z, sv[i].vx, sv[i].vy, sv[i].vz); + } + return (1); +} + +int pop_led(tree *xml_tree, state_vector *sv) { + int i, ct; + char tmp_c[200]; + double tmp_d; + + search_tree(xml_tree,"/level1Product/platform/orbit/orbitHeader/numStateVectors/",tmp_c, 1, 0, 1); + ct = (int)str2double(tmp_c); + for (i=1;i<=ct;i++) { + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/timeUTC/",tmp_c, 2, 4, i); + tmp_d = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/timeUTC/",tmp_c, 1, 4, i); + tmp_c[4] = '\0'; + sv[i - 1].yr = (int)(str2double(tmp_c)); + sv[i - 1].jd = (int)(tmp_d - trunc(tmp_d / 1000.0) * 1000.0); + sv[i - 1].sec = (tmp_d - trunc(tmp_d)) * 86400.0; + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/posX/",tmp_c, 1, 4, i); + sv[i - 1].x = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/posY/",tmp_c, 1, 4, i); + sv[i - 1].y = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/posZ/",tmp_c, 1, 4, i); + sv[i - 1].z = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/velX/",tmp_c, 1, 4, i); + sv[i - 1].vx = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/velY/",tmp_c, 1, 4, i); + sv[i - 1].vy = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/platform/orbit/stateVec/velZ/",tmp_c, 1, 4, i); + sv[i - 1].vz = str2double(tmp_c); + + } + printf("%d Lines Written for Orbit...\n", i); + return (ct); +} + +int pop_prm(struct PRM *prm, tree *xml_tree, char *file_name) { + char tmp_c[2000]; + double tmp_d; + int tmp_i; + double c_speed = 299792458.0; + + // define some of the variables + prm->first_line = 1; + prm->st_rng_bin = 1; + search_tree(xml_tree,"/level1Product/productInfo/imageDataInfo/imageRaster/rangeLooks/",tmp_c, 1, 0, 1); + prm->nlooks = (int)str2double(tmp_c); + //fprintf(stderr, "%s \n", tmp_c); + prm->rshift = 0; + prm->ashift = 0; + prm->sub_int_r = 0.0; + prm->sub_int_a = 0.0; + prm->stretch_r = 0.0; + prm->stretch_a = 0.0; + prm->a_stretch_r = 0.0; + prm->a_stretch_a = 0.0; + prm->first_sample = 1; + strasign(prm->dtype, "a", 0, 0); + + search_tree(xml_tree, "/level1Product/productInfo/imageDataInfo/imageRaster/columnSpacing/", tmp_c, 1, 0, 1); + prm->fs = c_speed/2.0/str2double(tmp_c); // rng_samp_rate + prm->SC_identity = 12; /* (1)-ERS1 (2)-ERS2 (3)-Radarsat (4)-Envisat (5)-ALOS + (6)- (7)-TSX (8)-CSK (9)-RS2 (10) Sentinel-1a (11)-GF3 (12)-LT1 */ + + search_tree(xml_tree, "/level1Product/processing/processingParameter/rangeCompression/chirps/referenceChirp/centerFrequency/", tmp_c, 1, 0, 1); + prm->lambda = c_speed / str2double(tmp_c); + + search_tree(xml_tree, "/level1Product/processing/processingParameter/rangeCompression/chirps/referenceChirp/pulseLength/", tmp_c, 1, 0, 1); + tmp_d = str2double(tmp_c); + prm->pulsedur = tmp_d; + search_tree(xml_tree, "/level1Product/processing/processingParameter/rangeCompression/chirps/referenceChirp/pulseBandwidth/", tmp_c, 1, 0, 1); + prm->chirp_slope = str2double(tmp_c) / tmp_d ; + search_tree(xml_tree, "/level1Product/processing/processingParameter/rangeCompression/chirps/referenceChirp/chirpSlope/", tmp_c, 1, 0, 1); + if (strcmp(tmp_c,"DOWN") == 0) { + prm->chirp_slope = prm->chirp_slope*(-1.0); + } + + // search_tree(xml_tree,"/product/qualityInformation/qualityDataList/qualityData/imageQuality/imageStatistics/outputDataMean/re/",tmp_c,1,0,1); + prm->xmi = 0; // str2double(tmp_c); //I_mean + + // search_tree(xml_tree,"/product/qualityInformation/qualityDataList/qualityData/imageQuality/imageStatistics/outputDataMean/im/",tmp_c,1,0,1); + prm->xmq = 0; // str2double(tmp_c); //Q_mean + + search_tree(xml_tree, "/level1Product/instrument/settings/settingRecord/PRF/", tmp_c, 1, 0, 1); + prm->prf = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/productInfo/sceneInfo/rangeTime/firstPixel/",tmp_c, 1, 0, 1); + prm->near_range = c_speed*str2double(tmp_c)/2.0; + prm->ra = 6378137.00; // equatorial_radius + prm->rc = 6356752.31; // polar_radius + + search_tree(xml_tree,"/level1Product/productInfo/missionInfo/orbitDirection/",tmp_c, 1, 0, 1); + if (strcmp(tmp_c,"DESCENDING") == 0) { + strasign(prm->orbdir, "D", 0, 0); + } + else { + strasign(prm->orbdir, "A", 0, 0); + } + + search_tree(xml_tree, "/level1Product/productInfo/acquisitionInfo/lookDirection/", tmp_c, 1, 0, 1); + if (strcmp(tmp_c,"RIGHT") == 0) { + strasign(prm->lookdir, "R", 0, 0); + } + else { + strasign(prm->lookdir, "L", 0, 0); + } + + strcpy(tmp_c, file_name); + strcat(tmp_c, ".raw"); + strcpy(prm->input_file, tmp_c); + + strcpy(tmp_c, file_name); + strcat(tmp_c, ".LED"); + strcpy(prm->led_file, tmp_c); + + strcpy(tmp_c, file_name); + strcat(tmp_c, ".SLC"); + strcpy(prm->SLC_file, tmp_c); + + prm->SLC_scale = 1.0; + search_tree(xml_tree,"/level1Product/productInfo/sceneInfo/start/timeUTC/",tmp_c, 2, 0, 1); + prm->clock_start = str2double(tmp_c); + search_tree(xml_tree,"/level1Product/productInfo/sceneInfo/start/timeUTC/",tmp_c, 1, 0, 1); + tmp_c[4] = '\0'; + prm->SC_clock_start = prm->clock_start + 1000. * str2double(tmp_c); + + strasign(prm->iqflip, "n", 0, 0); // Flip_iq + strasign(prm->deskew, "n", 0, 0); // deskew + strasign(prm->offset_video, "n", 0, 0); + + search_tree(xml_tree, "/level1Product/productInfo/imageDataInfo/imageRaster/numberOfColumns/", tmp_c, 1, 0, 1); + // tmp_i = (int)str2double(tmp_c) - (int)str2double(tmp_c)%4; + prm->num_rng_bins = (int)str2double(tmp_c) - (int)str2double(tmp_c)%4; + prm->bytes_per_line = prm->num_rng_bins * 4; // tmp_i*4; + prm->good_bytes = prm->bytes_per_line; + prm->caltone = 0.0; + prm->pctbwaz = 0.0; // rm_az_band + prm->pctbw = 0.2; // rm_rng_band + prm->rhww = 1.0; // rng_spec_wgt + strasign(prm->srm, "0", 0, 0); // scnd_rng_mig + prm->az_res = 0.0; + // prm.antenna_side = -1; + //search_tree(xml_tree, "/product/processinfo/DopplerCentroidCoefficients/d0/", tmp_c, 1, 0, 1); + //prm->fd1 = str2double(tmp_c); + // looks like the SLCs are focused to zero doppler. + prm->fd1 = 0.0; + prm->fdd1 = 0.0; + prm->fddd1 = 0.0; + + search_tree(xml_tree, "/level1Product/productInfo/imageDataInfo/imageRaster/numberOfRows/", tmp_c, 1, 0, 1); + tmp_i = (int)str2double(tmp_c); + prm->num_lines = tmp_i - tmp_i % 4; + //fprintf(stderr,"%d %d %.6f\n",prm->num_rng_bins, prm->num_lines, prm->fd1); + //exit(1); + + // search_tree(xml_tree,"/product/adsHeader/stopTime/",tmp_c,2,0,1); + prm->SC_clock_stop = prm->SC_clock_start + prm->num_lines / prm->prf / 86400; + prm->clock_stop = prm->clock_start + prm->num_lines / prm->prf / 86400; + + prm->nrows = prm->num_lines; + prm->num_valid_az = prm->num_lines; + prm->num_patches = 1; + prm->chirp_ext = 0; + + printf("PRM set for Image File...\n"); + return (1); +} From 59657165d7ded2871d2b730f45bc17fbfe96a89d Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Mon, 28 Aug 2023 14:55:31 +0800 Subject: [PATCH 19/22] changing the shell scripts accordingly --- gmtsar/csh/p2p_processing.csh | 17 +++++++++++++++++ gmtsar/csh/pre_proc.csh | 11 +++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gmtsar/csh/p2p_processing.csh b/gmtsar/csh/p2p_processing.csh index deb04e01..5b671459 100755 --- a/gmtsar/csh/p2p_processing.csh +++ b/gmtsar/csh/p2p_processing.csh @@ -283,6 +283,23 @@ echo " no file raw/"$aligned".tiff" exit endif + else if ($SAT == "LT1") then + if(! -f raw/$master.xml ) then + echo " no file raw/"$master".xml" + exit + endif + if(! -f raw/$aligned.xml ) then + echo " no file raw/"$aligned".xml" + exit + endif + if(! -f raw/$master.tiff ) then + echo " no file raw/"$master".tiff" + exit + endif + if(! -f raw/$aligned.tiff ) then + echo " no file raw/"$aligned".tiff" + exit + endif endif # diff --git a/gmtsar/csh/pre_proc.csh b/gmtsar/csh/pre_proc.csh index b75146d2..5a7111b2 100755 --- a/gmtsar/csh/pre_proc.csh +++ b/gmtsar/csh/pre_proc.csh @@ -415,9 +415,9 @@ echo $commandline echo "" echo " Pre-Process CSK Raw data - END" echo "" - else if ($SAT == "CSK_SLC" || $SAT == "TSX" || $SAT == "S1_STRIP" || $SAT == "RS2" || $SAT == "GF3") then + else if ($SAT == "CSK_SLC" || $SAT == "TSX" || $SAT == "S1_STRIP" || $SAT == "RS2" || $SAT == "GF3" || $SAT == "LT1") then echo "" - echo " Pre-Process CSK/TSX/RS2/S1_STRIP/GF3 SLC data - START" + echo " Pre-Process CSK/TSX/RS2/S1_STRIP/GF3/LT1 SLC data - START" echo "" if ($SAT == "CSK_SLC") then if ($skip_master == 0 || $skip_master == 2) then @@ -451,6 +451,13 @@ echo $commandline if ($skip_master == 0 || $skip_master == 1) then make_slc_gf3 $aligned.xml $aligned.tiff $aligned endif + else if ($SAT == "LT1") then + if ($skip_master == 0 || $skip_master == 2) then + make_slc_lt1 $master.xml $master.tiff $master + endif + if ($skip_master == 0 || $skip_master == 1) then + make_slc_lt1 $aligned.xml $aligned.tiff $aligned + endif else if ($skip_master == 0 || $skip_master == 2) then make_slc_s1a $master.xml $master.tiff $master From 208f6bb49b82611e43a26b8bf97a22946e37ff78 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Mon, 28 Aug 2023 15:13:39 +0800 Subject: [PATCH 20/22] more edits to the shell scripts --- gmtsar/csh/batch_processing.csh | 2 +- gmtsar/csh/p2p_processing.csh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gmtsar/csh/batch_processing.csh b/gmtsar/csh/batch_processing.csh index 1f483208..fcf5356b 100755 --- a/gmtsar/csh/batch_processing.csh +++ b/gmtsar/csh/batch_processing.csh @@ -8,7 +8,7 @@ echo "" echo " Put the data and orbit files in the raw folder, put DEM in the topo folder" echo " The SAT needs to be specified, choices with in ERS, ENVI, ALOS, ALOS_SLC, ALOS2, ALOS2_SCAN" - echo " S1_STRIP, S1_TOPS, ENVI_SLC, CSK_RAW, CSK_SLC, TSX, RS2, GF3" + echo " S1_STRIP, S1_TOPS, ENVI_SLC, CSK_RAW, CSK_SLC, TSX, RS2, GF3, LT1" echo "" echo " Make sure the files from the same date have the same stem, e.g. stem.tif stem.xml stem.cos stem.EOF, etc" echo "" diff --git a/gmtsar/csh/p2p_processing.csh b/gmtsar/csh/p2p_processing.csh index 5b671459..36274418 100755 --- a/gmtsar/csh/p2p_processing.csh +++ b/gmtsar/csh/p2p_processing.csh @@ -14,7 +14,7 @@ echo "" echo " Put the data and orbit files in the raw folder, put DEM in the topo folder" echo " The SAT needs to be specified, choices with in ERS, ENVI, ALOS, ALOS_SLC, ALOS2, ALOS2_SCAN" - echo " S1_STRIP, S1_TOPS, ENVI_SLC, CSK_RAW, CSK_SLC, TSX, RS2, GF3" + echo " S1_STRIP, S1_TOPS, ENVI_SLC, CSK_RAW, CSK_SLC, TSX, RS2, GF3, LT1" echo "" echo " Make sure the files from the same date have the same stem, e.g. aaaa.tif aaaa.xml aaaa.cos aaaa.EOF, etc" echo "" From 5252ee86f99eb5da94f4f02d44d027119f118da6 Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Wed, 6 Sep 2023 10:12:05 +0800 Subject: [PATCH 21/22] fixing a bug in det_stitch, merging center determined incorrectly from blank area --- gmtsar/csh/merge_unwrap_geocode_tops.csh | 38 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/gmtsar/csh/merge_unwrap_geocode_tops.csh b/gmtsar/csh/merge_unwrap_geocode_tops.csh index 80742eec..2e014d91 100755 --- a/gmtsar/csh/merge_unwrap_geocode_tops.csh +++ b/gmtsar/csh/merge_unwrap_geocode_tops.csh @@ -84,6 +84,9 @@ set nl = `wc -l $1 | awk '{print $1}'` if ($nl == 2) then set pth2 = `head -1 $1 | awk -F: '{print $1}'` + set near1 = `grep near $pth2"tmp.PRM" | awk '{print $3}'` + set rng1 = `grep num_rng_bins $pth2"tmp.PRM" | awk '{print $3}'` + set fs = `grep rng_samp_rate $pth2"tmp.PRM" | tail -1 | awk '{print $3}'` gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set xm1 = `gmt grdinfo $pth2"phasefilt.grd" -C | awk '{print $3}'` set xc1 = `gmt grdinfo tmp.grd -C | awk '{print $3}'` @@ -91,20 +94,26 @@ set n12 = `echo $xm1 $xc1 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `tail -1 $1 | awk -F: '{print $1}'` + set near2 = `grep near $pth2"tmp.PRM" | awk '{print $3}'` gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x01 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n21 = `echo $x01 $incx | awk '{printf("%d",$1/$2)}'` - set n1 = `echo $n12 $n21 | awk '{printf("%d",($1+$2)/2)}'` - if ($n1 == 0) then - echo "WARNING: Stitching position estimated to be zero" - echo "Check merged grids carefully" - set n1 = "" - endif + set ovl12 = `echo $near1 $near2 $fs $rng1 $incx | awk '{printf("%d",($4-($2-$1)/(299792458.0/$3/2))/$5)}'` + set n1 = `echo $n12 $n21 $ovl12 | awk '{printf("%d",($3-$1-$2)/2+$2)}'` set n2 = 0 + if ($n1 <= 0) then + echo "WARNING: Stitching position estimated to be zero" + echo "Check merged grids carefully" + set n1 = "" + set n2 = "" + endif rm tmp.grd else if ($nl == 3) then set pth2 = `head -1 $1 | awk -F: '{print $1}'` + set near1 = `grep near $pth2"tmp.PRM" | awk '{print $3}'` + set rng1 = `grep num_rng_bins $pth2"tmp.PRM" | awk '{print $3}'` + set fs = `grep rng_samp_rate $pth2"tmp.PRM" | tail -1 | awk '{print $3}'` gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set xm1 = `gmt grdinfo $pth2/phasefilt.grd -C | awk '{print $3}'` set xc1 = `gmt grdinfo tmp.grd -C | awk '{print $3}'` @@ -112,26 +121,31 @@ set n12 = `echo $xm1 $xc1 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `head -2 $1 | tail -1 | awk -F: '{print $1}'` + set near2 = `grep near $pth2"tmp.PRM" | awk '{print $3}'` + set rng2 = `grep num_rng_bins $pth2"tmp.PRM" | awk '{print $3}'` gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x02 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n21 = `echo $x02 $incx | awk '{printf("%d",$1/$2)}'` - set n1 = `echo $n12 $n21 | awk '{printf("%d",($1+$2)/2)}'` + set ovl12 = `echo $near1 $near2 $fs $rng1 $incx | awk '{printf("%d",($4-($2-$1)/(299792458.0/$3/2))/$5)}'` + set n1 = `echo $n12 $n21 $ovl12 | awk '{printf("%d",($3-$1-$2)/2+$2)}'` set xm2 = `gmt grdinfo $pth2/phasefilt.grd -C | awk '{print $3}'` set xc2 = `gmt grdinfo tmp.grd -C | awk '{print $3}'` set n22 = `echo $xm2 $xc2 $incx | awk '{printf("%d",($1-$2)/$3)}'` set pth2 = `tail -1 $1 | awk -F: '{print $1}'` + set near3 = `grep near $pth2"tmp.PRM" | awk '{print $3}'` gmt grdcut $pth2"phasefilt.grd" -Z+N -Gtmp.grd set x03 = `gmt grdinfo tmp.grd -C | awk '{print $2}'` set incx = `gmt grdinfo tmp.grd -C | awk '{print $8}'` set n31 = `echo $x03 $incx | awk '{printf("%d",$1/$2)}'` - set n2 = `echo $n22 $n31 | awk '{printf("%d",($1+$2)/2)}'` + set ovl23 = `echo $near2 $near3 $fs $rng2 $incx | awk '{printf("%d",($4-($2-$1)/(299792458.0/$3/2))/$5)}'` + set n2 = `echo $n22 $n31 $ovl23 | awk '{printf("%d",($3-$1-$2)/2+$2)}'` if ($n2 == 0) then - echo "WARNING: Stitching positions estimated to be zero" - echo "Check merged grids carefully" - set n1 = "" - set n2 = "" + echo "WARNING: Stitching positions estimated to be zero" + echo "Check merged grids carefully" + set n1 = "" + set n2 = "" endif rm tmp.grd else From 811ea5060eca4ac9b8245bf46901041ad1e3428c Mon Sep 17 00:00:00 2001 From: Xiaohua-Eric-Xu Date: Sun, 10 Sep 2023 17:14:45 +0800 Subject: [PATCH 22/22] fixing typo in c-shells calling for t-shell instead --- gmtsar/csh/align_batch.csh | 2 +- gmtsar/csh/make_a_offset.csh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gmtsar/csh/align_batch.csh b/gmtsar/csh/align_batch.csh index 71f3b9e0..402b96e7 100755 --- a/gmtsar/csh/align_batch.csh +++ b/gmtsar/csh/align_batch.csh @@ -1,4 +1,4 @@ -#!/bin/tcsh -f +#!/bin/csh -f # $Id$ # Align RAW or SLC images using orbits and DEM diff --git a/gmtsar/csh/make_a_offset.csh b/gmtsar/csh/make_a_offset.csh index f1cb4788..6f6d0e66 100755 --- a/gmtsar/csh/make_a_offset.csh +++ b/gmtsar/csh/make_a_offset.csh @@ -1,4 +1,4 @@ -#!/bin/tcsh -f +#!/bin/csh -f # $Id$ # Script to drive the xcorr to do the azimuthal pixel-tracking # Originated by Matt Wei, April 19, 2010