Skip to content

Commit

Permalink
Script to plot ground error histograms finished. Axis labels added to…
Browse files Browse the repository at this point in the history
… waveform plots.
  • Loading branch information
sthancock committed Mar 23, 2019
1 parent 29238e1 commit 8af8d08
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 41 deletions.
2 changes: 2 additions & 0 deletions gediHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def plotWaves(self,outRoot='teast',useInd=[]):
plt.plot(self.gWave[i]*2000+94,z,label='Ground')
plt.legend()
plt.xlim(left=0)
plt.xlabel('DN')
plt.ylabel('Elevation (m)')
outNamen=outRoot+"."+str(self.waveID[i])+".x."+str(self.lon[i])+".y."+str(self.lat[i])+".png"
plt.savefig(outNamen)
plt.close()
Expand Down
87 changes: 87 additions & 0 deletions groundErrHit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

'''
A sript to plot histograms
of ground finding error
'''

###########################################
import numpy as np
import argparse
import matplotlib.pyplot as plt


###########################################
# class to hold GEDI metrics

class gediMetrics(object):

###########################################

def __init__(self,filename):
'''Read the file'''
self.tG,self.eG=np.loadtxt=np.loadtxt(simMet,usecols=(1,5),unpack=True, dtype=float,comments='#')


###########################################

def groundErrHist(self,outName,nBins=10):
'''make an error histogram'''
# filter out missing data
useInd=np.where((self.tG>-100)&(self.eG>-100)&(selfteG<10000)&(self.eG<10000))
if(len(useInd)>0):
useInd=useInd[0]
# calculate differences
err=self.eG[useInd]-self.tG[useInd]
# make histogram
hist=np.histogram(err,bins=nBins)
x=np.empty(len(hist[0]),dtype=float)
for i in range(1,len(hist[1])):
x[i-1]=(hist[i]+hist[i-1])/2.0
# plot it
plt.plot(x,hist[0])
plt.xlabel('Ground elevation error (m)')
plt.ylabel('Frequency')
plt.ylim(bottom=0)
plt.savefig(outName)
plt.close()
plt.clf()
print("Written to",outNamen)
else:
printf("No usable data in file")


# end of gediMetrics class
###########################################


###########################################
# read the command line

def gediCommands():
'''
Read commandline arguments
'''
p = argparse.ArgumentParser(description=("Writes out properties of GEDI waveform files"))
p.add_argument("--input",dest="inName",type=str,help=("Input GEDI metric filename"))
p.add_argument("--output",dest="output",type=str,default='test.png',help=("Output graph filename"))
p.add_argument("--nBins",dest="nBins",type=int,default=10,help=("Number of histogram bins to use"))
cmdargs = p.parse_args()
return cmdargs


###########################################
# the main block

if __name__ == '__main__':
# read the command line
cmdargs=gediCommands()
inName=cmdargs.inName
output=cmdargs.output
output=nBins.nBins

# read data
data=gediMetrics(inName)

# plot it
data.groundErrHist(output,nBins=nBins)

41 changes: 0 additions & 41 deletions plotMetrics.py

This file was deleted.

0 comments on commit 8af8d08

Please sign in to comment.