0
mirror of https://github.com/oresat/oresat-cfc-hardware.git synced 2025-04-05 21:35:09 +00:00

Add scripts subdirectory for test scripts for sensor. Add plothisto.py which plots histograms for the raw sensor pixel data

This commit is contained in:
Scott Dixon 2024-01-31 21:14:17 -08:00
parent 9178f71155
commit 92b6f70441

27
scripts/plothisto.py Normal file
View File

@ -0,0 +1,27 @@
# This script takes raw images from OreSat CFC sensor and plots a histogram
# of the values along with a line plot of the cumulative distribution function.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mp
import sys
bins=200
# For Mac OS X:
# set MPLBACKEND environment variable or
# put backend: MACOSX in matplotlibrc file
# or uncomment the following line:
# mp.use("MACOSX")
def plothisto(file):
data = np.fromfile(file, dtype=np.uint16)
fig, ax = plt.subplots(ncols=1)
ax1 = ax.twinx()
ax1.tick_params(axis='y',colors='red')
ax.hist(data,density=False, bins=bins, range=[0,16384])
N = data.size
X2 = np.sort(data)
F2 = np.array(range(N))/float(N)
ax1.plot(X2, F2,alpha=0.3,color='red')
plt.show()
if __name__ == "__main__" and "get_ipython" not in dir():
plothisto(sys.argv[1])