%matplotlib inline
import mpld3
mpld3.enable_notebook()
import matplotlib.pyplot as plt
# import ifg.shis.rdr.valid as val
from pyfbf import Workspace
import numpy as np
W = Workspace('rdr20170328T161512end20170328T231525sdr20170329T002148')
pitch,roll,segments,smp,sequences = W['Pitch'][:], W['Roll'][:], W['segments'][:], W['sceneMirrorPosition'][:], W['intactMirrorSequences'][:]
gudrex = np.argwhere(smp==ord('E'))
fig = plt.figure(figsize=(15,10))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
# ax.plot(seg, color='blue')
ax.plot(gudrex, segments[gudrex], color='green')
# ax.legend(['test segmentize', 'original segments'])
ax.set_title('segments.int4 test for E views sh170328')
' '.join(str(x) for x in sorted(set(segments)))
fig = plt.figure(figsize=(15,10))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
ax.plot(roll, alpha=0.7, color='blue', linewidth=0.5)
ax.plot(pitch, alpha=0.7, color='green', linewidth=0.5)
ax.legend(['Roll', 'Pitch'])
# ax.set_title()
s,e = 16000,30000
fig = plt.figure(figsize=(15,10))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
ax.plot(roll[s:e], alpha=0.7, linewidth=0.5, color='blue')
ax.plot(roll[s:e], alpha=0.7, linewidth=0.5, color='green')
ax.plot(np.sign(segments[s:e]) * 20, linewidth=0.5, color='red')
# plot(np.require(ok[s:e], dtype=np.int32) * 25)
ax.legend(['Roll', 'Pitch', 'segments sign'])
ax.set_title('Attitude excerpt sh170328')
ax.set_xlabel('record offset')
ax.set_ylabel('degrees')
unroll, turnroll, flatroll, calroll = np.array(roll), np.array(roll), np.array(roll), np.array(roll)
eview = smp==ord('E')
unroll[(segments!=0) | ~eview] = np.NAN
turnroll[(segments>=0) | ~eview] = np.NAN
flatroll[(segments<=0) | ~eview] = np.NAN
calroll[eview] = np.NAN
fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
ax.plot(calroll, alpha=0.7, linewidth=0.5, color='purple')
ax.plot(unroll, alpha=0.9, linewidth=0.5, color='red')
ax.plot(flatroll, alpha=0.9, linewidth=0.5, color='blue')
ax.plot(turnroll, alpha=0.9, linewidth=0.5, color='green')
ax.set_title('Roll for Segment-Categorized Views')
ax.legend(['not earth', 'segments==0', 'segments>0', 'segments<0'])
unpitch, turnpitch, flatpitch, calpitch = np.array(pitch), np.array(pitch), np.array(pitch), np.array(pitch)
eview = smp==ord('E')
unpitch[(segments!=0) | ~eview] = np.NAN
turnpitch[(segments>=0) | ~eview] = np.NAN
flatpitch[(segments<=0) | ~eview] = np.NAN
calpitch[eview] = np.NAN
fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
ax.plot(calpitch, alpha=0.6, linewidth=0.5, color='purple')
ax.plot(unpitch, alpha=0.9, linewidth=0.5, color='red')
ax.plot(flatpitch, alpha=0.9, linewidth=0.5, color='blue')
ax.plot(turnpitch, alpha=0.9, linewidth=0.5, color='green')
ax.set_title('pitch for Segment-Categorized Views')
ax.legend(['not earth', 'segments==0', 'segments>0', 'segments<0'])
lat, lon = W['instrumentLatitude'][:], W['instrumentLongitude'][:]
unlat, turnlat, flatlat, callat = np.array(lat), np.array(lat), np.array(lat), np.array(lat)
eview = smp==ord('E')
unlat[(segments!=0) | (lat==0) | ~eview] = np.NAN
turnlat[(segments>=0) | (lat==0) | ~eview] = np.NAN
flatlat[(segments<=0) | (lat==0) | ~eview] = np.NAN
callat[eview | (lon==0)] = np.NAN
unlon, turnlon, flatlon, callon = np.array(lon), np.array(lon), np.array(lon), np.array(lon)
eview = smp==ord('E')
unlon[(segments!=0) | (lon==0) | ~eview] = np.NAN
turnlon[(segments>=0) | (lon==0) | ~eview] = np.NAN
flatlon[(segments<=0) | (lon==0) | ~eview] = np.NAN
callon[eview | (lon==0)] = np.NAN
fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot(111, axisbg='#EEEEEE')
ax.grid(color='white', linestyle='solid')
ax.plot(callon, callat, alpha=0.6, linewidth=0.5, color='purple')
ax.plot(unlon, unlat, alpha=0.9, linewidth=0.5, color='red')
ax.plot(flatlon, flatlat, alpha=0.9, linewidth=0.5, color='blue')
ax.plot(turnlon, turnlat, alpha=0.9, linewidth=0.5, color='green')
ax.set_title('flight track for Segment-Categorized Views')
ax.legend(['not earth', 'segments==0', 'segments>0', 'segments<0'])