-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstack_nocorr_adjust.py
executable file
·53 lines (41 loc) · 1.26 KB
/
stack_nocorr_adjust.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python
import sys
import os
import re
from datetime import datetime
from copy import deepcopy
import numpy as np
from lib import iolib
from lib import malib
from lib import timelib
stack_fn = sys.argv[1]
#offset = sys.argv[2]
#This is mean offset for PIG
#Note: PIG offset is trans_reference, so DEMs are above points!
offset = -3.1
s_orig = malib.DEMStack(stack_fn=stack_fn, stats=True, trend=True)
s = deepcopy(s_orig)
idx = np.array([bool(re.search('nocorr', i)) for i in s.source])
print 'Applying %0.2f m offset to %i nocorr DEMs' % (offset, np.nonzero(idx)[0].size)
#idx = [bool(re.search('nocorr', i)) for i in s.source]
#print 'Applying %0.2f m offset to %i nocorr DEMs' % (offset, sum(idx))
s.ma_stack[idx] += offset
out_stack_fn = os.path.splitext(sys.argv[1])[0]+'_nocorr_offset_%0.2fm.npz' % offset
s.stack_fn = out_stack_fn
save = True
if os.path.abspath(s_orig.stack_fn) == os.path.abspath(s.stack_fn):
print "Warning: new stack has identical filename: %s" % s.stack_fn
print "As a precaution, new stack will not be saved"
save = False
#Update stats
if s.stats:
s.compute_stats()
if save:
s.write_stats()
#Update trend
if s.trend:
s.compute_trend()
if save:
s.write_trend()
if save:
s.savestack()