Commit 3893000c authored by Markus Gaug's avatar Markus Gaug
Browse files

added documentation and display more info on the plot

parent f0abd979
Pipeline #7014 canceled with stages
import glob
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
import json
import sys
from os.path import basename
# LIDAR analysis modules
from licel_reader import LICEL
# initialize the axis ranges
x_min = 0.
x_max = 5000.
y_min = 1e-4
y_max = 1e3
# tell whether the ground line shall be displayed or full signal
is_groundline = False
sig_range = 140000
sig_range = 140000 # signal range shown for ground line only
# standard channel configuration
labels = [ '355 nm (analog)', '355 nm (photon counting)',
'389 nm (analog)', '389 nm (photon counting)',
'532 nm (analog)', '532 nm (photon counting)',
'near range (analog)', 'near range (photon counting)' ]
offsets = [ 2 , -7 , 10, -5 , -7, -9, -3, -5 ] # internal Licel electronic time offsets
bg_range = 5000 # Background subtraction (both atmospheric and electronic)
if (is_groundline):
bg_range = 5000
# apply a constant re-binning (-1 means no re-binning)
rebin = -1
rebin_thres = 0
#global_offset = -5
# apply a dynamic re-binning threshold in photo-electrons
rebin_thres = 0
offsets = [ 6 , -3 , 14, 2, 0, 0, 0, 0 ]
offsets = [ 6 , -2 , 14, 2, 0, 0, -10, -10 ]
offsets = [ 7-5 , -2-5 , 15-5, 0-5 ,3-10, 1-10, -3, -5 ]
offsets = [ 2 , -7 , 10, -5 , -7, -9, -3, -5 ]
bg_range = 5000 # 5000 # Background subtraction (both atmospheric and electronic)
if (is_groundline):
bg_range = 5000
def show_file(filename):
licel = LICEL(filename)
licel.print_header()
nr = 0
plt.figure(figsize=[15,7])
if (is_groundline):
plt.subplot(421)
licel = LICEL(filename) # initialize Licel reader for filename
licel.print_header() # print header informa
plt.figure(figsize=[15,7]) # initialize a new figure for each data file
if (is_groundline):
plt.subplot(421)
for (channel_id,channel) in enumerate(licel.channels):
for (channel_id,channel) in enumerate(licel.channels): # loop over all channels
#if (channel_id > 0):
# continue
channel.offset_range = offsets[nr] # + global_offset # correct for the different zero-offset
if (channel_id > 3):
channel.offset_range = offsets[channel_id] # correct for the different zero-offset
if (channel_id > 3): # work-around, until David has set correct bin widths for the new Licels
channel.bin_width = 3.75
channel.print_header() # print channel header
channel.print_header() # print channel header
if (channel_id == 2):
# get the data to plot
if (channel_id == 2): # channel 2 has a different ground line offset at about half of the signal range, and need separate background estimation
(x,y,yerr,offset,offseterr) = channel.get_data(rebin=rebin,rebin_thres=0,rebin_seq=50,rebin_fac=0,bg_range=bg_range+(int)(channel.num_data/2),bg_range2=(int)(channel.num_data/2),verbose=False)
else:
(x,y,yerr,offset,offseterr) = channel.get_data(rebin=rebin,rebin_thres=0,rebin_seq=50,rebin_fac=0,bg_range=bg_range,verbose=False)
#plt.plot(x,np.log(y*x**2),label=labels[channel_id])
if (channel_id == 0):
x = x - 2 # move x by 2 meters to the left
if (channel_id == 0): # fine-tuning of offset for channel 0
x = x - 2 # move x by 2 meters to the left
if (channel.analog == False):
if (channel.analog == False): # re-scale analog line for better visualation
y = y * 0.008
if (is_groundline):
if (is_groundline): # this part is to display only possible ground line issues
ax = plt.subplot(4,2,channel_id+1)
ax.plot(x,y,label=labels[channel_id])
ax.set_xlim(0.,sig_range)
......@@ -91,21 +87,29 @@ def show_file(filename):
ax.set_ylim(-0.01,0.05)
ax.axhline(y=0., color='k')
ax.legend(loc='best')
else:
plt.plot(x,y,label=labels[channel_id])
else: # this part is to display the full signal
label = labels[channel_id] + '\nHV={:.0f} V'.format(channel.pmt_hv)
if (not channel.analog):
label += ', disc={:.0f} mV'.format(channel.adc_discrim*10000)
plt.plot(x,y,label=label)
plt.text(x_min+(x_max-x_min)*0.45, y_min+(y_max-y_min)*0.5,
u'zenith={:.0f}\u00B0'.format(licel.zenith_ang),
fontsize='x-large')
plt.text(x_min+(x_max-x_min)*0.45, y_min+(y_max-y_min)*0.2,
'{:.0f} shots'.format(licel.laser1['shots']),
fontsize='x-large')
plt.xlim(x_min,x_max)
plt.ylim(y_min,y_max)
plt.yscale('log')
nr = nr + 1
plt.legend(loc='best')
plt.grid(axis='x')
plt.title(basename(filename))
plt.show()
for name in sorted(glob.glob(sys.argv[1])):
print(name)
show_file(name)
if __name__ == "__main__":
for name in sorted(glob.glob(sys.argv[1])):
print(name)
show_file(name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment