In [1]:
import ifg.shis.rdr.valid as val
from pyfbf import Workspace
import numpy as np
W = Workspace('scatter_test/rdr20170323T170847end20170323T233859sdr20170324T194155')
In [2]:
%matplotlib inline
from pylab import *
In [3]:
debug = {}
ok, seg = val.segments(W, debug=debug)
/data/users/rayg/Repos/svn/SHIS/py/ifg_shis/ifg/shis/rdr/valid.py:151: RuntimeWarning: invalid value encountered in greater_equal
  high_enough = (alt >= limits.min_altitude)
/data/users/rayg/Repos/svn/SHIS/py/ifg_shis/ifg/shis/rdr/valid.py:157: RuntimeWarning: invalid value encountered in less
  level = (abs(pitch) < limits.max_pitch) & (abs(roll) < limits.max_roll)
/data/users/rayg/Repos/svn/SHIS/py/ifg_shis/ifg/shis/rdr/valid.py:159: RuntimeWarning: invalid value encountered in greater
  attitude_changing = diffmask(abs(np.diff(pitch)) > limits.max_delta_pitch) | diffmask(abs(np.diff(roll)) > limits.max_delta_roll)
In [58]:
figure(figsize=(20,10))
plot(seg)
grid()
title('segments unit test for sh170323')
Out[58]:
<matplotlib.text.Text at 0x7f4873673d90>
In [62]:
figure(figsize=(20,10))
# plot(seg)
smp = W['sceneMirrorPosition'][:]
segments = W['segments'][:]
gudrex = np.argwhere(smp==ord('E'))
plot(gudrex, segments[gudrex], color='green')
grid()
title('segments.int4 test for E views sh170323')
Out[62]:
<matplotlib.text.Text at 0x7f4873350510>
In [5]:
min(seg)
Out[5]:
-30
In [6]:
' '.join(str(x) for x in sorted(set(seg)))
Out[6]:
'-30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24'
In [7]:
W['Roll'][np.argwhere(seg==-1).squeeze()]
Out[7]:
array([-19.69000053, -22.48999977, -22.48999977, -22.02000046,
       -22.02000046, -21.68000031, -21.68000031, -21.96999931,
       -21.96999931, -21.59000015, -21.59000015, -20.87000084,
       -20.87000084, -20.11000061, -20.11000061, -19.53000069,
       -19.53000069, -19.21999931, -19.21999931, -19.45999908,
       -19.45999908, -19.55999947, -19.55999947, -19.26000023,
       -19.26000023, -18.84000015, -18.84000015, -18.67000008,
       -18.67000008, -18.70000076, -18.70000076, -18.72999954,
       -18.72999954, -18.81999969, -18.81999969, -18.77000046,
       -18.77000046, -18.64999962, -18.64999962, -18.78000069,
       -18.78000069, -19.12000084, -19.12000084, -19.46999931,
       -19.46999931, -19.67000008, -19.67000008, -19.60000038,
       -19.60000038, -19.59000015, -19.59000015, -19.86000061,
       -19.86000061, -20.20000076, -20.36000061, -20.36000061,
       -20.73999977, -20.73999977, -21.22999954, -21.22999954,
       -21.86000061, -21.86000061, -22.54999924, -22.54999924,
       -22.68000031, -22.68000031, -22.37000084, -22.37000084,
       -21.84000015, -21.84000015, -21.37999916, -21.37999916,
       -21.07999992, -21.07999992, -20.70000076, -20.70000076,
       -20.25      , -20.25      , -19.73999977, -19.73999977,
       -19.45999908, -19.45999908, -19.85000038, -19.85000038,
       -20.07999992, -20.07999992, -19.80999947, -19.80999947,
       -19.47999954, -19.47999954, -19.64999962, -19.64999962,
       -19.98999977, -19.98999977, -20.12000084, -20.12000084,
       -20.09000015, -20.09000015, -20.18000031, -20.18000031,
       -20.48999977, -20.48999977, -20.82999992, -20.82999992,
       -21.02000046, -21.02000046, -20.92000008, -20.92000008,
       -20.48999977, -20.48999977, -20.17000008, -20.17000008,
       -20.06999969, -20.06999969, -20.12999916, -20.12999916,
       -20.35000038, -20.35000038, -20.44000053, -20.44000053,
       -20.64999962, -20.64999962, -21.62000084, -21.62000084,
       -24.48999977, -24.48999977, -27.57999992, -29.21999931,
       -29.21999931, -29.95999908, -29.95999908, -30.51000023,
       -30.51000023, -31.18000031, -31.18000031, -31.54999924,
       -31.54999924, -31.03000069, -31.03000069, -30.97999954,
       -30.97999954, -31.80999947, -31.80999947, -31.88999939,
       -31.88999939, -31.29999924, -31.29999924, -31.56999969,
       -31.56999969, -31.96999931, -31.96999931, -31.73999977,
       -31.73999977, -31.36000061, -31.36000061, -31.03000069,
       -31.03000069, -31.        , -31.        , -30.37000084,
       -30.37000084, -29.27000046, -29.27000046, -28.37000084,
       -28.37000084, -28.47999954, -28.47999954, -28.67000008,
       -28.67000008, -28.59000015, -28.59000015, -28.45999908,
       -28.45999908, -28.14999962, -28.14999962, -27.42000008,
       -27.42000008, -27.45999908, -27.45999908, -28.25      ,
       -28.25      , -28.55999947, -28.55999947, -28.30999947,
       -28.30999947, -27.97999954, -27.97999954, -27.71999931,
       -27.71999931, -27.65999985, -27.65999985, -27.72999954,
       -27.72999954, -27.67000008, -27.67000008, -27.23999977,
       -27.23999977, -26.94000053, -26.94000053, -27.17000008,
       -27.17000008, -27.62000084, -27.69000053, -27.69000053,
       -27.72999954, -27.72999954, -27.87999916, -27.87999916,
       -27.75      , -27.75      , -27.04999924, -27.04999924,
       -26.31999969, -26.31999969, -25.65999985, -25.65999985,
       -25.14999962, -25.14999962, -25.12000084, -25.12000084,
       -24.93000031, -24.93000031, -24.23999977, -24.23999977,
       -22.85000038, -22.85000038, -22.12999916, -22.12999916,
       -22.37999916, -22.37999916, -22.18000031, -22.18000031,
       -21.40999985, -21.40999985, -20.59000015, -20.59000015,
       -19.87999916, -19.87999916, -18.95000076, -18.95000076,
       -17.84000015, -17.84000015, -16.51000023, -16.51000023,
       -15.14000034, -15.14000034, -14.02999973, -14.02999973,
       -14.06000042, -14.06000042, -14.56000042, -14.56000042,
       -14.60000038, -14.60000038, -13.57999992, -13.57999992,
       -12.47999954, -12.47999954], dtype=float32)
In [8]:
figure(figsize=(20,10))
plot(debug['flat'])
# plot(W['Roll'][:] > 2.0)
Out[8]:
[<matplotlib.lines.Line2D at 0x7f487be05050>]
In [16]:
figure(figsize=(20,10))
plot(debug['turning'])
# plot(W['Roll'][:] > 2.0)
Out[16]:
[<matplotlib.lines.Line2D at 0x7f4878fa75d0>]
In [18]:
figure(figsize=(20,10))
plot(W['Roll'][:])
plot(W['Pitch'][:])
legend(['Roll', 'Pitch'])
grid()
In [19]:
figure(figsize=(20,10))
s,e = 10000,25000
plot(W['Roll'][s:e])
plot(W['Pitch'][s:e])
plot(np.sign(seg[s:e]) * 20)
plot(np.require(ok[s:e], dtype=np.int32) * 25)
legend(['Roll', 'Pitch', 'segments sign', 'segments mask'])
grid()
title('Attitude excerpt sh170323'); xlabel('aircraftTime UTC hours'); ylabel('degrees')
Out[19]:
<matplotlib.text.Text at 0x7f4878dbf810>
In [37]:
figure(figsize=(20,10))
s,e = 11000,23000
plot(W['Roll'][s:e])
plot(W['Pitch'][s:e])
plot(np.sign(seg[s:e]) * 20)
plot(np.require(ok[s:e], dtype=np.int32) * 25)
legend(['Roll', 'Pitch', 'segments sign', 'segments mask'])
grid()
title('Attitude excerpt sh170323'); xlabel('record offset'); ylabel('degrees')
Out[37]:
<matplotlib.text.Text at 0x7f48784c1150>
In [23]:
from ifg.shis.rdr.valid import diffmask
limits = val.DEFAULT_SEGMENT_LIMITS
In [24]:
attitude_changing = diffmask(abs(np.diff(pitch)) > limits.max_delta_pitch) | diffmask(abs(np.diff(roll)) > limits.max_delta_roll)
attitude_stable = ~attitude_changing
steady_not_level = ~level & ~attitude_changing
In [72]:
figure(figsize=(20,10))
s,e = 11000,23000
plot(W['Roll'][s:e])
plot(W['Pitch'][s:e])
plot(np.sign(W['segments'][s:e]) * 20)
plot(np.require(ok[s:e], dtype=np.int32) * 25)
legend(['Roll', 'Pitch', 'segments.int4 sign', 'segments mask'])
grid()
title('Attitude excerpt sh170323'); xlabel('record offset'); ylabel('degrees')
Out[72]:
<matplotlib.text.Text at 0x7f48732d0410>
In [25]:
figure(figsize=(20,10))
plot(pitch[:3000])
plot(roll[:3000])
plot(attitude_changing[:3000]*25)
plot(steady_not_level[:3000]*25)
legend(['pitch', 'roll', 'att_change', 'steady_not_level'])
Out[25]:
<matplotlib.legend.Legend at 0x7f487b1584d0>
In [26]:
plot(W['intactMirrorSequences'][:])
Out[26]:
[<matplotlib.lines.Line2D at 0x7f487b17fc90>]
In [45]:
lat,lon,segments = W['instrumentLatitude'][:], W['instrumentLongitude'][:], W['segments'][:]
s,e = 11000, 23000
rex = np.argwhere(lon[s:e]!=0).squeeze() + s
gudrex = np.argwhere((lon[s:e]!=0) & (segments[s:e]!=0)).squeeze() + s
badrex = np.argwhere((lon[s:e]!=0) & (segments[s:e]==0)).squeeze() + s
figure(figsize=(20,15))
plot(lon[gudrex], lat[gudrex], '.', color='blue')
plot(lon[badrex], lat[badrex], '.', color='red')
Out[45]:
[<matplotlib.lines.Line2D at 0x7f48781769d0>]
In [46]:
lat,lon,segments = W['instrumentLatitude'][:], W['instrumentLongitude'][:], W['segments'][:]
s,e = 11000, 23000
rex = np.argwhere(lon[s:e]!=0).squeeze() + s
gudrex = np.argwhere((lon[s:e]!=0) & (seg[s:e]!=0)).squeeze() + s
badrex = np.argwhere((lon[s:e]!=0) & (seg[s:e]==0)).squeeze() + s
figure(figsize=(20,15))
plot(lon[gudrex], lat[gudrex], '.', color='blue')
plot(lon[badrex], lat[badrex], '.', color='red')
Out[46]:
[<matplotlib.lines.Line2D at 0x7f4873fce390>]
In [70]:
cal = val.calibration(W)
lat,lon,segments,smp = W['instrumentLatitude'][:], W['instrumentLongitude'][:], W['segments'][:], W['sceneMirrorPosition'][:]
s,e = 11000, 23000
rex = np.argwhere(lon[s:e]!=0).squeeze() + s
gudrex = np.argwhere((lon[s:e]!=0) & (seg[s:e]!=0) & (cal[s:e]) & (smp[s:e]==ord('E'))).squeeze() + s
badrex = np.argwhere((lon[s:e]!=0) & (seg[s:e]!=0) & (~cal[s:e]) & (smp[s:e]==ord('E'))).squeeze() + s
gonrex = np.argwhere((lon[s:e]!=0) & (segments[s:e]==0) & (smp[s:e]==ord('E'))).squeeze() + s
figure(figsize=(20,15))
plot(lon[gonrex], lat[gonrex], '.', color='orange')
plot(lon[gudrex], lat[gudrex], '.', color='blue')
plot(lon[badrex], lat[badrex], '.', color='red')
grid()

title('segmentize!=0 & calibration for earth views %d:%d %s' % (s,e,W.path))
legend(['segments==0', 'Earth segmentize!=0 & cal OK', 'earth segmentize!=0 & bad cal'])
Out[70]:
<matplotlib.legend.Legend at 0x7f4872d11ad0>
In [55]:
cal = val.calibration(W)
lat,lon,segments,smp = W['instrumentLatitude'][:], W['instrumentLongitude'][:], W['segments'][:], W['sceneMirrorPosition'][:]
s,e = 11000, 23000
rex = np.argwhere(lon[s:e]!=0).squeeze() + s
gudrex = np.argwhere((lon[s:e]!=0) & (segments[s:e]!=0) & (cal[s:e]) & (smp[s:e]==ord('E'))).squeeze() + s
badrex = np.argwhere((lon[s:e]!=0) & (segments[s:e]!=0) & (~cal[s:e]) & (smp[s:e]==ord('E'))).squeeze() + s
figure(figsize=(20,15))
plot(lon[gudrex], lat[gudrex], '.', color='blue')
plot(lon[badrex], lat[badrex], '.', color='red')
title('segments.int4!=0 & calibration for earth views')
legend(['good cal', 'bad cal'])
Out[55]:
<matplotlib.legend.Legend at 0x7f487389fad0>
In [ ]: