Skip to content

Commit 51a60da

Browse files
author
Matt Garthwaite
authored
Merge pull request #155 from GeoscienceAustralia/issue_153
Issue 153 branch
2 parents ba0503a + c0fcd83 commit 51a60da

File tree

12 files changed

+223
-154
lines changed

12 files changed

+223
-154
lines changed

AUTHORS.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ Credits
55
Development Lead
66
----------------
77

8-
* Geoscience Australia InSAR team
8+
* Geoscience Australia InSAR team <insar@ga.gov.au>
99

1010
PyRate has been developed by `Geoscience Australia <http://www.ga.gov.au>`__
1111
and the `National Computational Infrastructure <http://nci.org.au/>`__.
1212

1313
Contributors
1414
------------
1515

16-
* Sudipta Basak <basaks@gmail.com>
17-
* Ben Davies
18-
* Matt Garthwaite <Matt.Garthwaite@ga.gov.au>
19-
* Simon Knapp
20-
* Negin Moghaddam
21-
* Vanessa Newey
22-
* Garrick Paskos
16+
* Sudipta Basak (GA)
17+
* Ben Davies (NCI)
18+
* Matt Garthwaite (GA)
19+
* Simon Knapp (GA)
20+
* Negin Moghaddam (GA)
21+
* Vanessa Newey (GA)
22+
* Garrick Paskos (GA)

conda.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
1-
Instructions for setting up up an anaconda virtualenv on the linux server 'rhe-compute1' at GA.
1+
Instructions for setting up an Anaconda virtual environment on a typical Red Hat linux server.
22

3-
## Download the conda installer
3+
## Install Anaconda:
44

5-
For `rhe-compute` [download this version] (https://repo.continuum.io/archive/Anaconda2-4.1.1-Linux-x86.sh).
5+
For 64bit linux download this version of the conda installer: https://repo.continuum.io/archive/Anaconda2-4.1.1-Linux-x86.sh
66

7-
## Install anaconda:
8-
9-
On 64bit linux:
7+
Run the installer using the linux bash interpreter:
108

119
bash Anaconda2-4.1.1-Linux-x86.sh
1210

1311
Accept all default options. This will install anaconda in the `~/anaconda2` directory.
1412

1513
## Set up proxys for pip (only applicable if working behind proxy):
1614

17-
export http_proxy=http://proxy.ga.gov.au:8080
18-
export https_proxy=http://proxy.ga.gov.au:8080
15+
export http_proxy=<proxy_server>:<port>
16+
export https_proxy=<proxy_server>:<port>
1917

2018
## Set up `~/.condarc` with proxy pass information (only applicable if working behind proxy):
2119

2220
For conda installer to work you need to create a `~/.condarc` file with the following proxy-pass information:
2321

2422
proxy_servers:
25-
http: http://proxy.ga.gov.au:8080
26-
https: http://proxy.ga.gov.au:8080
23+
http: <proxy_server>:<port>
24+
https: <proxy_server>:<port>
2725
28-
## Clone the repo:
29-
30-
The rest of the instructions assume that you cloned the `PyRate` Git repository in your home directory.
26+
## Clone the PyRate repo:
3127

32-
Clone the repo:
28+
The rest of the instructions assume that you cloned the `PyRate` Git repository in your home directory:
3329

30+
cd ~
3431
git clone git@github.com:GeoscienceAustralia/PyRate.git
3532

36-
This will prompt for your rsa key passphrase. If you have access to `PyRate` repo and once you have entered the passphrase, `PyRate` will clone in your current directory.
33+
This will prompt for your rsa key passphrase. If you have access to `PyRate` repo and once you have entered the passphrase, `PyRate` will clone in your current (home) directory.
3734

3835

39-
## Set up PYRATEPATH
40-
You need to add the directory containing the `pyrate` folder to the `PYTHONPATH` environment variable.
36+
## Set up envrionment variables
4137

42-
The environment variable `PYRATEPATH` needs to point to the folder where you put the test data. This is how I set up my environment variable:
38+
You need to add the directory containing the `pyrate/` directory to the `PYTHONPATH` environment variable, and the environment variable `PYRATEPATH` needs to point to the directory containing the `tests/` directory:
4339

44-
export PYRATEPATH="/nas/users/u92456/unix/PyRate"
40+
export PYRATEPATH="~/PyRate"
4541
export PYTHONPATH=$PYRATEPATH/:$PYTHONPATH
4642

4743

@@ -50,21 +46,23 @@ The environment variable `PYRATEPATH` needs to point to the folder where you put
5046
source ~/anaconda2/bin/activate ~/anaconda2/
5147
conda install -c conda conda-env
5248

53-
The `conda-env` package enables `yml` based installation.
49+
The `conda-env` package enables YAML based installation.
5450

5551
Note that using the `source activate` command only works cleanly when using the bash shell
5652

5753
## Create the `pyrate` environment
54+
55+
The required packages for PyRate are listed in the environment.yml (YAML format) file:
5856

59-
conda env create -f /path/to/PyRate/environment.yml
57+
conda env create -f $PYRATEPATH/environment.yml
6058

6159
## Activate the `pyrate` environment
6260

6361
source ~/anaconda2/bin/activate pyrate
6462

6563
## Support for `pygrib`, a package used by `PyAPS` (skip this step if not using PyAPS)
6664

67-
`pygrib` does not install properly in `redhat` systems, `rhe-compute1` being one of them. The way around is the following:
65+
`pygrib` does not install properly in `redhat` systems. The work around is the following:
6866

6967
cp ~/anaconda2/envs/pyrate/lib/libpng16.so.16 ~/anaconda2/envs/pyrate/lib/libpng16.so.16.bk
7068
conda install libpng=1.2.50
@@ -80,16 +78,21 @@ Explanation of the previous three steps:
8078

8179
## Run `PyRate` tests
8280

83-
To run the tests, use the following command inside the `PyRate` directory:
81+
To run the full suite of tests, use the following command inside the `PyRate` directory:
8482

85-
cd PyRate
83+
cd ~/PyRate
8684
py.test tests/
87-
85+
86+
To run the tests for a particular module:
87+
88+
py.test tests/test_orbital.py
89+
8890
## Deactivate
89-
Once you are done using `PyRate` you could deactivate from the conda env using:
91+
92+
Once you are done using `PyRate` you could deactivate the conda environment using:
9093

9194
source deactivate
9295

93-
## Back to main anaconda if you need to:
96+
## Back to main Anaconda environment if you need to:
9497

95-
source activate /home/user/anaconda2
98+
source activate /home/user/anaconda2

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- hdf4
1212
- hdf5
1313
- ipython
14-
- matplotlib
14+
- matplotlib=1.5.1
1515
- networkx
1616
- numpy
1717
# - pygrib

environment.yml1

Lines changed: 0 additions & 30 deletions
This file was deleted.

pyrate/algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def get_epochs(ifgs):
171171
"""
172172
Returns an EpochList derived from all given interferograms.
173173
"""
174-
log.info('Finding epochs')
174+
log.info('Finding unique epochs in given interferogram network')
175175
if isinstance(ifgs, dict):
176176
ifgs = [v for v in ifgs.values() if isinstance(v, PrereadIfg)]
177177
combined = get_all_epochs(ifgs)

pyrate/ifgconstants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
PYRATE_INCIDENCE_DEGREES = 'INCIDENCE_DEGREES'
3737
PYRATE_INSAR_PROCESSOR = 'INSAR_PROCESSOR'
3838
PYRATE_APS_ERROR = 'APS_ERROR'
39+
PYRATE_MAXVAR = 'CVD_MAXVAR'
40+
PYRATE_ALPHA = 'CVD_ALPHA'
3941
MULTILOOKED = 'MULTILOOKED_IFG'
4042
ORIG = 'ORIGINAL_IFG'
4143
DEM = 'ORIGINAL_DEM'
@@ -49,7 +51,7 @@
4951
LINSAMP = 'LINEAR_RATE_SAMPLES'
5052
PYRATE_ORBITAL_ERROR = 'ORBITAL_ERROR'
5153
ORB_REMOVED = 'REMOVED'
52-
REF_PHASE = 'REFERENCE_PHASE'
54+
PYRATE_REF_PHASE = 'REFERENCE_PHASE'
5355
REF_PHASE_REMOVED = 'REMOVED'
5456
NAN_STATUS = 'NAN_STATUS'
5557
NAN_CONVERTED = 'CONVERTED'

pyrate/orbital.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ def remove_orbital_error(ifgs, params, preread_ifgs=None):
400400
preread_ifgs: dict, optional
401401
dict containing information regarding MPI jobs
402402
"""
403-
log.info('Calculating orbital error correction')
404-
405403
if not params[cf.ORBITAL_FIT]:
406404
log.info('Orbital correction not required')
407405
return
@@ -411,7 +409,8 @@ def remove_orbital_error(ifgs, params, preread_ifgs=None):
411409
_ = [preread_ifgs.pop(k) for k in ['gt', 'epochlist', 'md', 'wkt']]
412410
# perform some general error/sanity checks
413411
if mpiops.rank == 0:
414-
_check_orbital_ifgs(preread_ifgs)
412+
if _check_orbital_ifgs(preread_ifgs):
413+
return # return if True condition returned
415414

416415
ifg_paths = [i.data_path for i in ifgs] \
417416
if isinstance(ifgs[0], Ifg) else ifgs
@@ -441,15 +440,18 @@ def remove_orbital_error(ifgs, params, preread_ifgs=None):
441440

442441

443442
def _check_orbital_ifgs(preread_ifgs): # pragma: no cover
444-
443+
"""
444+
Check if the correction has already been performed in a previous run
445+
"""
446+
log.info('Checking Orbital error status')
445447
ifg_paths = sorted(preread_ifgs.keys())
446448
# preread_ifgs[i].metadata contains ifg metadata
447449
flags = [ifc.PYRATE_ORBITAL_ERROR in preread_ifgs[i].metadata
448450
for i in ifg_paths]
449451
if all(flags):
450-
log.info('Skipped orbital correction, ifgs already corrected')
451-
return
452-
if (sum(flags) < len(flags)) and (sum(flags) > 0):
452+
log.info('Skipped orbital corrections, ifgs already corrected')
453+
return True
454+
elif (sum(flags) < len(flags)) and (sum(flags) > 0):
453455
log.debug('Detected mix of corrected and uncorrected '
454456
'orbital error in ifgs')
455457

@@ -460,4 +462,6 @@ def _check_orbital_ifgs(preread_ifgs): # pragma: no cover
460462
msg = '{}: no orbital correction detected'.format(i)
461463
log.debug(msg)
462464
raise OrbitalError(msg)
463-
log.info('Orbital error status checked')
465+
else:
466+
log.info('Calculating orbital corrections')
467+
return False

pyrate/ref_phs_est.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def estimate_ref_phase(ifgs, params, refpx, refpy):
3838
:ref_phs: reference phase correction
3939
:ifgs: reference phase data removed list of ifgs
4040
"""
41-
_validate_ifgs(ifgs)
41+
check_ref_phs_ifgs(ifgs)
4242

4343
# set reference phase as the average of the whole image (recommended)
4444
if params[cf.REF_EST_METHOD] == 1:
@@ -50,7 +50,7 @@ def estimate_ref_phase(ifgs, params, refpx, refpy):
5050
raise ReferencePhaseError('No such option. Use refest=1 or 2')
5151

5252
for i in ifgs:
53-
i.meta_data[ifc.REF_PHASE] = ifc.REF_PHASE_REMOVED
53+
i.meta_data[ifc.PYRATE_REF_PHASE] = ifc.REF_PHASE_REMOVED
5454
i.write_modified_phase()
5555
return ref_phs, ifgs
5656

@@ -135,43 +135,43 @@ def est_ref_phs_method1(phase_data, comp):
135135
"""convenience function for ref phs estimate method 1 parallelisation"""
136136
ifgv = np.ravel(phase_data, order='F')
137137
ifgv[comp == 1] = np.nan
138-
# reference phase
139-
ref_ph = nanmedian(ifgv)
140-
return ref_ph
138+
return nanmedian(ifgv)
141139

142140

143-
def _validate_ifgs(ifgs):
141+
def check_ref_phs_ifgs(ifgs, preread_ifgs=None):
144142
"""
145-
make sure all ifgs have the same ref phase status
143+
Function to check that the ref phase status of all ifgs are the same
146144
"""
145+
log.info('Checking status of reference phase estimation')
147146
if len(ifgs) < 2:
148147
raise ReferencePhaseError('Need to provide at least 2 ifgs')
149-
flags = [i.dataset.GetMetadataItem(ifc.REF_PHASE) for i in ifgs]
150-
if all(flags):
151-
log.info('Ifgs already reference phase corrected')
152-
return
153-
else:
154-
check_ref_phase_ifgs(ifgs, flags)
155148

156-
157-
def check_ref_phase_ifgs(ifgs, flags):
158-
"""
159-
Function to check that the ref phase status of all ifgs are the same
160-
"""
161-
count = sum([f == ifc.REF_PHASE_REMOVED for f in flags])
162-
if (count < len(flags)) and (count > 0):
149+
if preread_ifgs: # check unless for mpi tests
150+
flags = [ifc.PYRATE_REF_PHASE in preread_ifgs[i].metadata
151+
for i in ifgs]
152+
else:
153+
flags = [True if i.dataset.GetMetadataItem(ifc.PYRATE_REF_PHASE)
154+
else False for i in ifgs]
155+
156+
if sum(flags) == len(flags):
157+
log.info('Skipped reference phase estimation, ' \
158+
'ifgs already corrected')
159+
return True
160+
elif (sum(flags) < len(flags)) and (sum(flags) > 0):
163161
log.debug('Detected mix of corrected and uncorrected '
164162
'reference phases in ifgs')
165-
166163
for i, flag in zip(ifgs, flags):
167164
if flag:
168165
msg = '{}: prior reference phase ' \
169166
'correction detected'.format(i.data_path)
170167
else:
171168
msg = '{}: no reference phase ' \
172169
'correction detected'.format(i.data_path)
173-
log.debug(msg.format(i.data_path))
174-
raise ReferencePhaseError(msg)
170+
log.debug(msg.format(i.data_path))
171+
raise ReferencePhaseError(msg)
172+
else: # count == 0
173+
log.info('Estimating and removing reference phase')
174+
return False
175175

176176

177177
class ReferencePhaseError(Exception):

0 commit comments

Comments
 (0)