ImgPixSpectra/data/PlotSpectralArrayFromFile.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #--------------------
00003 # Check input parameters
00004 import SpectralArray as sa
00005 import numpy as np
00006 import numpy as np
00007 import matplotlib.pyplot as plt
00008 import os
00009 import sys
00010 
00011 print ' sys.argv[0]: ', sys.argv[0]
00012 print ' len(sys.argv): ', len(sys.argv)
00013 
00014 if len(sys.argv) == 2 : fname = sys.argv[1]
00015 else                  : fname = '/reg/neh/home/dubrovin/LCLS/PSANA-test/image.txt'
00016 
00017 print 'fname=', fname
00018 
00019 #--------------------
00020 # Define graphical methods
00021 
00022 def plot_histogram (arr) :
00023     fig1 = plt.figure(num=1, figsize=(6,6), dpi=80, facecolor='w',edgecolor='w',frameon=True)
00024     ax1 = plt.subplot2grid((4,4), (0,0), rowspan=2, colspan=4)
00025     plt.hist(arr.flatten(), bins=100 )
00026     ax2 = plt.subplot2grid((4,4), (2,0), rowspan=2, colspan=4)
00027     plt.hist(arr.flatten(), bins=100, range=(0,2000) ) 
00028 
00029 def plot_image (arr, range=None) :    # range = (left, right, low, high)
00030     fig = plt.figure(num=2, figsize=(12,12), dpi=80, facecolor='w',edgecolor='w',frameon=True)
00031     fig.subplots_adjust(left=0.10, bottom=0.08, right=0.98, top=0.92, wspace=0.2, hspace=0.1)
00032     figAxes = fig.add_subplot(111)
00033     imAxes = figAxes.imshow(arr, origin='upper', interpolation='nearest', aspect='auto',extent=range)
00034     #imAxes.set_clim(0,100)
00035     colbar = fig.colorbar(imAxes, pad=0.03, fraction=0.04, shrink=1.0, aspect=40, orientation=1)
00036 
00037 #--------------------
00038 # Read and plot array
00039 
00040 sp = sa.SpectralArray (fname)
00041 sp.print_shape_parameters ()
00042 sp.print_array_subset ()
00043 
00044 arr_inp = sp.arr
00045 print arr_inp.shape
00046 
00047 # Test for any camera
00048 pixmin = 10000
00049 pixmax = pixmin + 1000
00050 
00051 arr = arr_inp[pixmin:pixmax][:]
00052 plot_image (arr, range=(sp.amin, sp.amax, pixmax, pixmin))
00053 
00054 plt.show()
00055 
00056 sys.exit()
00057 #--------------------

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7