Skip to content

Commit 4f0b3bd

Browse files
committed
Merge branch 'main' into python310
2 parents ac74080 + 566ebfb commit 4f0b3bd

38 files changed

+4022
-289
lines changed

.circleci/config.yml

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,36 @@ version: 2.1
22
jobs:
33
test-cmake:
44
docker:
5-
- image: hysds/pge-base:latest
6-
user: root
5+
- image: ubuntu:20.04
76
steps:
87
- checkout:
98
path: /root/project/src
109

11-
- run:
12-
name: Install development tools
13-
command: |
14-
set -ex
15-
pwd
16-
yum update -y
17-
yum groupinstall -y "development tools"
18-
1910
- run:
2011
name: Install ISCE requirements
2112
command: |
2213
set -ex
2314
pwd
24-
mkdir config build install
25-
. /opt/conda/bin/activate root
26-
conda install -y cython gdal h5py libgdal pytest numpy fftw scipy scons hdf4 hdf5 libgcc libstdcxx-ng cmake astropy pybind11
27-
yum install -y x11-devel motif-devel jq gcc-gfortran opencv opencv-devel opencv-python
15+
export DEBIAN_FRONTEND=noninteractive
16+
apt-get update
17+
apt-get install -y cmake cython3 git libfftw3-dev libgdal-dev libhdf4-alt-dev libhdf5-dev libopencv-dev python3-gdal python3-h5py python3-numpy python3-scipy
2818
2919
- run:
3020
name: Build and Install ISCE
3121
command: |
3222
set -ex
3323
cd /root/project/src
34-
. /opt/conda/bin/activate root
3524
mkdir build
3625
cd build
37-
INSTALLPATH=/opt/conda
38-
MODPATH=$(python3 -c "import site; print(site.getsitepackages()[0])")
39-
# convert to relative path
40-
MODPATH=$(realpath --relative-to=$INSTALLPATH $MODPATH)
41-
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALLPATH -DPYTHON_MODULE_DIR=$MODPATH
26+
MODPATH=$(python3 -c "import site; print(site.getsitepackages()[-1])")
27+
cmake .. -DCMAKE_INSTALL_PREFIX=install -DPYTHON_MODULE_DIR=$MODPATH
4228
make install VERBOSE=y
4329
4430
- run:
4531
name: Test ISCE installation
4632
command: |
4733
set -ex
4834
cd /root/project/src/build
49-
. /opt/conda/bin/activate root
5035
ctest --output-on-failure
5136
ISCE2DIR=$(python3 -c "import os, isce2; print(os.path.dirname(isce2.__file__))" | tail -n 1)
5237
export PATH=$ISCE2DIR/applications:$PATH
@@ -60,37 +45,20 @@ jobs:
6045
6146
test:
6247
docker:
63-
- image: hysds/pge-base:latest
64-
user: root
48+
- image: ubuntu:20.04
6549
steps:
6650
- checkout:
6751
path: /root/project/src
6852

69-
- run:
70-
name: Install development tools
71-
command: |
72-
set -ex
73-
pwd
74-
yum update -y
75-
yum groupinstall -y "development tools"
76-
7753
- run:
7854
name: Install ISCE requirements
7955
command: |
8056
set -ex
8157
pwd
8258
mkdir config build install
83-
. /opt/conda/bin/activate root
84-
conda install --yes cython gdal h5py libgdal pytest numpy fftw scipy scons hdf4 hdf5 libgcc libstdcxx-ng cmake astropy pybind11
85-
yum install -y uuid-devel x11-devel motif-devel jq gcc-gfortran opencv opencv-devel opencv-python
86-
ln -s /opt/conda/bin/cython /opt/conda/bin/cython3
87-
cd /opt/conda/lib
88-
unlink libuuid.so
89-
unlink libuuid.so.1
90-
ln -s /lib64/libuuid.so.1.3.0 libuuid.so
91-
ln -s /lib64/libuuid.so.1.3.0 libuuid.so.1
92-
cd /lib64
93-
test -f libgfortran.so || ln -sv libgfortran.so.*.* libgfortran.so
59+
export DEBIAN_FRONTEND=noninteractive
60+
apt-get update
61+
apt-get install -y scons cython3 git libfftw3-dev libgdal-dev libhdf4-alt-dev libhdf5-dev libmotif-dev libopencv-dev libx11-dev python3-gdal python3-h5py python3-numpy python3-scipy
9462
9563
- run:
9664
name: Build SConfigISCE and setup dirs
@@ -100,41 +68,36 @@ jobs:
10068
cd config
10169
echo "PRJ_SCONS_BUILD = /root/project/build" > SConfigISCE
10270
echo "PRJ_SCONS_INSTALL = /root/project/install/isce" >> SConfigISCE
103-
echo "LIBPATH = /usr/lib64 /usr/lib /opt/conda/lib" >> SConfigISCE
104-
python_inc="$(echo /opt/conda/include/python3.* /opt/conda/lib/python3.*/site-packages/numpy/core/include)"
105-
echo "CPPPATH = $python_inc /opt/conda/include /usr/include" >> SConfigISCE
106-
echo "FORTRANPATH = /usr/include /opt/conda/include" >> SConfigISCE
71+
echo "LIBPATH = /usr/lib64 /usr/lib /usr/lib/x86_64-linux-gnu" >> SConfigISCE
72+
python_inc="/usr/include/python3.8 /usr/lib/python3/dist-packages/numpy/core/include"
73+
echo "CPPPATH = $python_inc /usr/include /usr/include/gdal /usr/include/opencv4" >> SConfigISCE
74+
echo "FORTRANPATH = /usr/include" >> SConfigISCE
10775
echo "FORTRAN = /bin/gfortran" >> SConfigISCE
10876
echo "CC = /bin/gcc" >> SConfigISCE
10977
echo "CXX = /bin/g++" >> SConfigISCE
11078
echo "MOTIFLIBPATH = /usr/lib64" >> SConfigISCE
11179
echo "X11LIBPATH = /usr/lib64" >> SConfigISCE
11280
echo "MOTIFINCPATH = /usr/include" >> SConfigISCE
11381
echo "X11INCPATH = /usr/include" >> SConfigISCE
114-
echo "RPATH = /opt/conda/lib /usr/lib64 /usr/lib" >> SConfigISCE
82+
echo "RPATH = /usr/lib64 /usr/lib" >> SConfigISCE
11583
cat SConfigISCE
11684
11785
- run:
11886
name: Build and Install ISCE
11987
command: |
12088
set -ex
12189
pwd
122-
. /opt/conda/bin/activate root
12390
cd src
124-
export PATH="/opt/conda/bin:$PATH"
125-
export LD_LIBRARY_PATH="/opt/conda/lib:$LD_LIBRARY_PATH"
12691
SCONS_CONFIG_DIR=/root/project/config scons install --skipcheck
12792
12893
- run:
12994
name: Test ISCE installation
13095
command: |
13196
set -ex
13297
pwd
133-
. /opt/conda/bin/activate root
13498
ISCE_HOME=/root/project/install/isce
135-
export PATH="$ISCE_HOME/bin:$ISCE_HOME/applications:/opt/conda/bin:$PATH"
99+
export PATH="$ISCE_HOME/bin:$ISCE_HOME/applications:$PATH"
136100
export PYTHONPATH="/root/project/install:$PYTHONPATH"
137-
export LD_LIBRARY_PATH="/opt/conda/lib:$LD_LIBRARY_PATH"
138101
topsApp.py --help --steps
139102
stripmapApp.py --help --steps
140103
python3 -c "import isce"

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
4141
endif()
4242

4343
if(NOT DEFINED PYTHON_MODULE_DIR)
44-
set(PYTHON_MODULE_DIR packages CACHE PATH
45-
"Python module directory (relative to install prefix)")
44+
set(PYTHON_MODULE_DIR packages CACHE PATH "Python module directory")
4645
endif()
4746
if(NOT DEFINED ISCE2_PKG)
4847
set(ISCE2_PKG ${PYTHON_MODULE_DIR}/isce2 CACHE PATH
49-
"ISCE 2 python package install dir (relative to install prefix)")
48+
"ISCE 2 python package install dir")
49+
endif()
50+
51+
if(IS_ABSOLUTE "${ISCE2_PKG}")
52+
set(ISCE2_PKG_FULL "${ISCE2_PKG}")
53+
else()
54+
set(ISCE2_PKG_FULL "${CMAKE_INSTALL_PREFIX}/${ISCE2_PKG}")
5055
endif()
5156

5257
include(isce2_buildflags)
@@ -95,3 +100,9 @@ else()
95100
endif()
96101
install(CODE "execute_process(COMMAND
97102
${CMAKE_COMMAND} -E create_symlink ${symsrc} ${symdest})")
103+
104+
# Enable native packaging using CPack
105+
if(NOT CPACK_PACKAGE_CONTACT)
106+
set(CPACK_PACKAGE_CONTACT "Ryan Burns <[email protected]>")
107+
endif()
108+
include(CPack)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ run the following command while in the top directory of the ISCE source (the
293293
directory containing the SConstruct file):
294294

295295
```bash
296-
> rm -rf config.log .sconfig.dblite .sconf_temp
296+
> rm -rf config.log .sconfig.dblite .sconf_temp .sconsign.dblite
297297
```
298298

299299
and then try "scons install" again.

applications/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ install(PROGRAMS ${files}
3232

3333
# Symlink apps into PREFIX/bin so they are on the $PATH
3434
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory \
35-
${CMAKE_INSTALL_PREFIX}/bin)"
35+
${CMAKE_INSTALL_FULL_BINDIR})"
3636
)
37+
3738
foreach(file ${files})
3839
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
39-
${CMAKE_INSTALL_PREFIX}/${ISCE2_PKG}/applications/${file} \
40-
${CMAKE_INSTALL_PREFIX}/bin/${file})"
40+
${ISCE2_PKG_FULL}/applications/${file} \
41+
${CMAKE_INSTALL_FULL_BINDIR}/${file})"
4142
)
4243
endforeach()

components/isceobj/Alos2Proc/Alos2ProcPublic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ def readOffset(filename):
222222
offsets = OffsetField()
223223
for linex in lines:
224224
#linexl = re.split('\s+', linex)
225-
#detect blank lines with only spaces and tabs
226-
if linex.strip() == '':
225+
#detect blank lines with only spaces and tabs, lines with invalid numbers
226+
if (linex.strip() == '') or ('*' in linex):
227227
continue
228228

229229
linexl = linex.split()

components/isceobj/Scene/Track.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def reAdjustStartLine(self, sortedList, width):
237237
indx = self.findOverlapLine(sortedList[i-1][1],sortedList[i][1],endLine,width,i-1,i)
238238
#if indx is not None than indx is the new start line
239239
#otherwise we use startLine computed from acquisition time
240-
if (indx is not None) and (indx + sortedList[i-1][0] != sortedList[i][0]):
240+
#no need to do this for ALOS; otherwise there will be problems when there are multiple prfs and the data are interpolated. C. Liang, 20-dec-2021
241+
if (self._frames[0].instrument.platform._mission != 'ALOS') and (indx is not None) and (indx + sortedList[i-1][0] != sortedList[i][0]):
241242
startLine.append(indx + sortedList[i-1][0])
242243
outputs.append(sortedList[i][1])
243244
self.logger.info("Changing starting line for frame %d from %d to %d"%(i,endLine,indx))

components/isceobj/Sensor/ALOS.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ def populateMetadata(self):
185185

186186
productLevel = float(self.leaderFile.sceneHeaderRecord.metadata[
187187
'Product level code'])
188-
if productLevel == 1.0:
189-
self.updateRawParameters()
188+
189+
#this proves to be not accurate. Adjusting first frame is OK, but adjusting following frames would cause discontinuities between frames. C. Liang, 20-dec-2021
190+
# if productLevel == 1.0:
191+
# self.updateRawParameters()
190192
pass
191193

192194
def _populatePlatform(self):

components/isceobj/Sensor/UAVSAR_Stack.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,11 @@ def _populateFrame(self):
146146
frame.setSensingStart(tStart)
147147
frame.setSensingStop(tStop)
148148
frame.setSensingMid(tMid)
149-
frame.setNumberOfLines(
150-
int(self.metadata['slc_1_1x1_mag.set_rows']))
151-
frame.setNumberOfSamples(
152-
int(self.metadata['slc_1_1x1_mag.set_cols']))
149+
frame.setNumberOfLines(int(self.metadata['slc_{}_1x1_mag.set_rows'.format(self.segment_index)]))
150+
frame.setNumberOfSamples(int(self.metadata['slc_{}_1x1_mag.set_cols'.format(self.segment_index)]))
153151
frame.setPolarization(self.metadata['Polarization'])
154-
frame.C0 = self.metadata['slc_1_1x1_mag.col_addr']
155-
frame.S0 = self.metadata[
156-
'Segment {} Data Starting Azimuth'.format(self.segment_index)]
152+
frame.C0 = self.metadata['slc_{}_1x1_mag.col_addr'.format(self.segment_index)]
153+
frame.S0 = self.metadata['Segment {} Data Starting Azimuth'.format(self.segment_index)]
157154
frame.nearLookAngle = self.metadata['Minimum Look Angle']
158155
frame.farLookAngle = self.metadata['Maximum Look Angle']
159156
frame.setStartingRange(self.startingRange)
@@ -175,8 +172,7 @@ def _populateFrame(self):
175172
#of values in degrees at each corner (without rdf unit specified)
176173
llC = []
177174
for ic in range(1,5):
178-
key = 'Segment {0} Data Approximate Corner {1}'.format(
179-
self.segment_index, ic)
175+
key = 'Segment {0} Data Approximate Corner {1}'.format(self.segment_index, ic)
180176
self.logger.info("key = {}".format(key))
181177
self.logger.info("metadata[key] = {}".format(self.metadata[key], type(self.metadata[key])))
182178
llC.append(list(map(float, self.metadata[key].split(','))))
@@ -316,9 +312,9 @@ def extractDoppler(self):
316312
drho = instrument.getRangePixelSize() #full res value, not spacing in the dop file
317313
prf = instrument.getPulseRepetitionFrequency()
318314
self.logger.info("extractDoppler: rho0, drho, prf = {}, {}, {}".format(rho0, drho, prf))
319-
dopfile = self.metadata['dop']
320-
f = open(dopfile,'r')
321-
x = f.readlines() #first line is a header
315+
dopfile = getattr(self, 'dopplerFile', self.metadata['dop'])
316+
with open(dopfile,'r') as f:
317+
x = f.readlines() #first line is a header
322318

323319
import numpy
324320
z = numpy.array(
@@ -337,21 +333,20 @@ def extractDoppler(self):
337333
res2 = fit[1][0] #sum of squared residuals
338334
self.logger.info("coeffs = {}".format(coefs))
339335
self.logger.info("rms residual = {}".format(numpy.sqrt(res2/len(dop))))
340-
o = open("dop.txt", 'w')
341-
for i, d in zip(rhoi, dop):
342-
val = polyval(coefs,i)
343-
res = d-val
344-
o.write("{0} {1} {2} {3}\n".format(i, d, val, res))
345-
dopfile = self.metadata['dop']
336+
with open("dop.txt", 'w') as o:
337+
for i, d in zip(rhoi, dop):
338+
val = polyval(coefs,i)
339+
res = d-val
340+
o.write("{0} {1} {2} {3}\n".format(i, d, val, res))
346341

347342
self.dopplerVals = {'Near':polyval(coefs, 0)} #need this temporarily in this module
348343

349344
self.logger.info("UAVSAR_Stack.extractDoppler: self.dopplerVals = {}".format(self.dopplerVals))
350345
self.logger.info("UAVSAR_Stack.extractDoppler: prf = {}".format(prf))
351346

352-
#The doppler file values are in units rad/m. divide by 2*pi rad/cycle to convert
353-
#to cycle/m. Then multiply by velocity to get Hz and divide by prf for dimensionless
354-
#doppler coefficients
347+
#The doppler file values are in units rad/m. divide by 2*pi rad/cycle to convert
348+
#to cycle/m. Then multiply by velocity to get Hz and divide by prf for dimensionless
349+
#doppler coefficients
355350
dop_scale = self.velocity/2.0/math.pi
356351
coefs = [x*dop_scale for x in coefs]
357352
#Set the coefs in frame._dopplerVsPixel because that is where DefaultDopp looks for them
@@ -361,14 +356,14 @@ def extractDoppler(self):
361356

362357
@property
363358
def terrainHeight(self):
364-
#The peg point incorporates the actual terrainHeight
359+
#The peg point incorporates the actual terrainHeight
365360
return 0.0
366361

367362
@property
368363
def platformHeight(self):
369364
h = self.metadata['Global Average Altitude']
370-
#Reduce the platform height by the terrain height because the
371-
#peg radius of curvature includes the terrain height
365+
#Reduce the platform height by the terrain height because the
366+
#peg radius of curvature includes the terrain height
372367
h -= self.metadata['Global Average Terrain Height']
373368
return h
374369

components/isceobj/Sensor/src/ALOS_pre_process/ALOS_pre_process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ char date[8];
409409
//line number of first line of this prf file
410410
line_number_first = (rspi_new.SC_clock_start[i] - rspi_pre[0].SC_clock_start[0]) * d2s / (1.0 / rspi_pre[0].prf[0]);
411411
//unit: pri of first prf of first image
412-
num_lines_out = (rspi_pre[image_i].frame_counter_end[i] - rspi_pre[image_i].frame_counter_start[i] + 1) * (1.0/rspi_pre[image_i].prf[i]) / (1.0/rspi_pre[0].prf[0]);
412+
num_lines_out = (int)((rspi_pre[image_i].frame_counter_end[i] - rspi_pre[image_i].frame_counter_start[i] + 1) * (1.0/rspi_pre[image_i].prf[i]) / (1.0/rspi_pre[0].prf[0]));
413413

414414
if((fabs(roundfi(line_number_first)-line_number_first)<0.1) && (rspi_pre[image_i].prf[i]==rspi_pre[0].prf[0]))
415415
continue;
@@ -469,7 +469,7 @@ char date[8];
469469
//append prf i
470470
for(i = 1; i < rspi_new.nPRF; i++){
471471
//number of lines to be appended between frames if there are gaps
472-
num_lines_append = (rspi_new.SC_clock_start[i] - rspi_new.SC_clock_start[0]) * d2s / (1.0/rspi_pre[0].prf[0]) - rspi_new.num_lines[0];
472+
num_lines_append = roundfi((rspi_new.SC_clock_start[i] - rspi_new.SC_clock_start[0]) * d2s / (1.0/rspi_pre[0].prf[0])) - rspi_new.num_lines[0];
473473
if(num_lines_append >= 1){
474474
for(j = 0; j < num_lines_append; j++){
475475
for(k = 0; k < 2*rspi_new.num_bins[i]; k++)
@@ -485,7 +485,7 @@ char date[8];
485485
die("can't open", rspi_new.input_file[i]);
486486
num_lines_append = 0;
487487
for(j = 0; j < rspi_new.num_lines[i]; j++){
488-
if((rspi_new.SC_clock_start[i] + j * (1.0/rspi_pre[0].prf[0]) / d2s - rspi_new.SC_clock_start[0]) * d2s / (1.0/rspi_pre[0].prf[0]) >= rspi_new.num_lines[0]){
488+
if(roundfi((rspi_new.SC_clock_start[i] + j * (1.0/rspi_pre[0].prf[0]) / d2s - rspi_new.SC_clock_start[0]) * d2s / (1.0/rspi_pre[0].prf[0])) >= rspi_new.num_lines[0]){
489489
if(fread((char *)data, 2*sizeof(char)*rspi_new.num_bins[i], 1, next_prf_fp) != 1)
490490
die("can't read data from", rspi_new.input_file[i]);
491491
if(fwrite((char *)data, 2*sizeof(char)*rspi_new.num_bins[i], 1, first_prf_fp) != 1)

components/isceobj/Sensor/src/ALOS_pre_process/readOrbitPulse.f

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ double precision function gete22_15(str)
144144
end
145145

146146
integer*4 function unpackBytes(i1, i2, i3, i4)
147-
integer*4 i1, i2, i3, i4
148-
unpackBytes = iand(i1, 255)*256*256*256 + iand(i2, 255)*256*256 +
149-
$ iand(i3, 255)*256 + iand(i4, 255)
147+
integer*1 i1, i2, i3, i4, i255
148+
i255 = 255 ! needed to keep gfortran >9 happy
149+
unpackBytes = iand(i1, i255)*256*256*256 + iand(i2, i255)*256*256 +
150+
$ iand(i3, i255)*256 + iand(i4, i255)
150151
end function

0 commit comments

Comments
 (0)