Skip to content

Commit

Permalink
added plot_baselines_prf to TSX folder
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhq committed May 15, 2014
1 parent 07da7a0 commit c0313ab
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ALOS/baselines_prf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
111019 0 4955.1822601
131116 59.7008177282794 4448.11024126
140110 22.7939942118882 4408.14005937
140430 147.689111371907 4408.14005937
5 changes: 5 additions & 0 deletions ALOS/get_roi_baselines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
'''
Call ROI_PAC process_2pass.pl from raw to orbbase for combinations with master date
NOTE: calls process_2pass.pl *.proc roi_prep orbbase
which overwrites early processing files if it's already been done!
probably could write PRF to this file too!
Author: Scott Henderson
'''
import sys
Expand Down
66 changes: 66 additions & 0 deletions TSX/plot_baselines_prf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python
"""
Baseline plot for directory of ALOS or TSX data, with dates colored by PRF
Usage: plot_baselines_prf.py [baseline_file]
baselines_prf.txt can be created with:
1) If ROI_PAC hasn't been run yet:
get_roi_baselines.py 111019
2) If it has (sometimes awk/mawk/gawk/ depending on platform):
grep PRF 1*/*raw.rsc | awk '{ print $2}' > prfs.txt
grep P_BASELINE_TOP int*111019/*baseline.rsc | awk '{{print substr($1,5,6)" "$2}}' > dolist.in
cat baselines.txt '111019 0\n' > baselines.txt
paste baselines.txt prfs.txt > baselines_prfs.txt
Author: Scott Henderson
"""
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
import datetime
from matplotlib.dates import MonthLocator, DateFormatter
import matplotlib.mlab as mlab


def make_baseline_plot(baseline_file):
''' More informative version using record array for a particular track'''
fig = plt.figure(figsize=(11,8.5))
ax = fig.add_subplot(111)

# Load date and baseline data from file
dates, bperps, prfs = np.genfromtxt(baseline_file,unpack=True,comments='#',dtype=str) #easiest way to get columns of text, then convert after
prfs = prfs.astype('f4')
bperps = bperps.astype('f4')
unique_prfs = np.unique(prfs)

pltdates = np.array([datetime.datetime.strptime(date,'%y%m%d') for date in dates])
#colors = plt.cm.cool(unique_prfs/unique_prfs.max()) #color scaled by PRF value
colors = plt.cm.cool(np.linspace(0,1,unique_prfs.size)) #max dicrete color separation
for p,color in zip(unique_prfs,colors):
ind = (prfs == p)
plt.scatter(pltdates[ind], bperps[ind], s=100, c=color, label=p)

#plot text shorthand date next to point
for D,B in zip(pltdates, bperps):
plt.text(D,B,D.strftime('%y%m%d'))

plt.title(os.getcwd())
plt.ylabel('B_Perp [m]')

months = MonthLocator() # every month
ax.xaxis.set_minor_locator(months)
ax.fmt_xdata = DateFormatter('%Y-%m-%d') #lower left coodinate display
fig.autofmt_xdate()

plt.legend(loc='upper left', title='PRF [Hz]', scatterpoints=1) #note: legend='best' doesn;t always work
plt.grid(True)
plt.savefig('baseline_plot.pdf',bbox_inches='tight')
plt.show()


if __name__ == '__main__':
basefile = sys.argv[1]
make_baseline_plot(basefile)

0 comments on commit c0313ab

Please sign in to comment.