Commit 4a7ff96c authored by Aaron Viets's avatar Aaron Viets
Browse files

gstlal-calibration: plotting script updates

parent aa7f3ace
Pipeline #203251 failed with stages
in 23 minutes and 35 seconds
......@@ -8,18 +8,20 @@ IFO = H
# determines where to look for filters files (e.g., O1, O2, O3, ER10, ER13, ER14, PreER10, PreER13, PreER14)
OBSRUN = O3
START = $(shell echo 1269090018 | bc)
START = $(shell echo 1237831461 | bc)
# 1237831461
# 1238288418
END = $(shell echo 1269133218 | bc)
# 1269090018
END = $(shell echo 1253977218 | bc)
# 1269367218
# 1238338818
# 1269133218
SHMRUNTIME = 600
# How much time does the calibration need to settle at the start and end?
PLOT_WARMUP_TIME = 256
PLOT_COOLDOWN_TIME = 256
GDSCONFIGS = Filters/O3/GDSFilters/H1GDS_1265142330_no_response_corr_test.ini
LOWLATENCYCONFIGS = Filters/O3/GDSFilters/H1GDS_lowLatency_1239476409.ini
LOWLATENCYASYMMETRICCONFIGS = Filters/O3/GDSFilters/H1GDS_lowLatency_asymmetric_1239476409.ini
DCSCONFIGS = Filters/O3/GDSFilters/H1DCS_C01_1256655618_v2_test.ini
DCS_TDCF_UNCERTAINTY_CONFIGS = Filters/O3/GDSFilters/H1DCS_1256655618_v2_tdcf_unc.ini
SCALAR_CORR_CONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_SCALAR_CORR.ini
......@@ -27,26 +29,22 @@ FCC_CORR_CONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_FCC_CORR.ini
ALL_CORR_CONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_ALL_CORR.ini
FCCFS_CORR_CONFIGS = Filters/O2/GDSFilters/H1DCS_FccFsCorrections_Cleaning.ini
NO_CORR_CONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_NO_CORR.ini
DCSEXACTKAPPASCONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_exactKappas.ini
DCSEXACTKAPPASCONFIGS = Filters/O3/GDSFilters/H1DCS_test_1237831461_exactKappas.ini
#Filters/O3/GDSFilters/H1DCS_test_1237831461_exactKappas.ini
DCSAPPROXKAPPASCONFIGS = Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_approxKappas.ini
#Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_exactKappas.ini
DCSAPPROXKAPPASCONFIGS = Filters/O3/GDSFilters/H1DCS_test_1237831461_approxKappas.ini
#Filters/O3/GDSFilters/H1DCS_test_1237831461_approxKappas.ini
DCSLINESCONFIGS = ../../config_files/O2/H1/tests/H1DCS_AllCorrections_CleaningLines.ini
DCSFCCCONFIGS = ../../config_files/O2/H1/tests/H1DCS_FreqIndepAndFccCorrections_Cleaning.ini
#Filters/O3/GDSFilters/H1DCS_test_1256655618_v2_approxKappas.ini
DCSO31CONFIGS = Filters/O3/GDSFilters/H1DCS_KappaErrorTest_1237831461.ini
DCSO32CONFIGS = Filters/O3/GDSFilters/H1DCS_KappaErrorTest_1244307456.ini
DCSO33CONFIGS = Filters/O3/GDSFilters/H1DCS_KappaErrorTest_1251057623.ini
DCSO34CONFIGS = Filters/O3/GDSFilters/H1DCS_KappaErrorTest_1256655618.ini
GDSTESTCONFIGS = Filters/O3/GDSFilters/H1GDS_1239476409_testAllCorrections.ini
DCSTESTCONFIGS = Filters/O3/GDSFilters/H1DCS_C01_1252083618_AllCorrectionsTest.ini
DCSREALKAPPASCONFIGS = Filters/O3/GDSFilters/H1DCS_C01_1252083618_RealKappasTest.ini
DCSREALKAPPASSRCCONFIGS = Filters/O3/GDSFilters/H1DCS_C01_1252083618_RealKappasSRCTest.ini
GDSSHMCONFIGS = Filters/O3/GDSFilters/H1GDS_1258216456_testing.ini
GDSOLDCONFIGS = Filters/ER14/GDSFilters/L1GDS_1235491416_old.ini
GDSBETTERCONFIGS = Filters/ER14/GDSFilters/L1GDS_1235491416_better.ini
GDSBESTCONFIGS = Filters/ER14/GDSFilters/L1GDS_1235491416_best.ini
all: exactkappastimeseries DCSEXACTKAPPAS_act2darm_plots DCSEXACTKAPPAS_pcal2darm_plots
#pcal_DCS_transfer_functions
#TDCFs_pcal2darm_plots
#actuation_timing_plot
#DCS_BB_injection_plots
all: approxKappasErrorPlot
###############################################
### These commands should change less often ###
......@@ -118,6 +116,8 @@ $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache: $(IFO)1_easy_raw_frames.cache filters
$(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache: $(IFO)1_easy_raw_frames.cache filters framesdir
GST_DEBUG=3 gstlal_compute_strain --gps-start-time $(START) --gps-end-time $(END) --frame-cache $(IFO)1_easy_raw_frames.cache --output-path Frames/$(OBSRUN)/$(IFO)1/DCS/ --frame-duration=64 --frames-per-file=1 --wings=0 --config-file $(DCSAPPROXKAPPASCONFIGS)
ls Frames/$(OBSRUN)/$(IFO)1/DCS/$(IFO)-$(IFO)1DCS_APPROXKAPPAS-*.gwf | lalapps_path2cache > $@
#123828
#126912
$(IFO)1_hoft_DCS_TDCFUNC_frames.cache: $(IFO)1_easy_raw_frames.cache filters framesdir
GST_DEBUG=3 gstlal_compute_strain --gps-start-time $(START) --gps-end-time $(END) --frame-cache $(IFO)1_easy_raw_frames.cache --output-path Frames/$(OBSRUN)/$(IFO)1/DCS/ --frame-duration=64 --frames-per-file=1 --wings=0 --config-file $(DCS_TDCF_UNCERTAINTY_CONFIGS)
......@@ -187,6 +187,11 @@ DCSEXACTKAPPAS_pcal2darm_plots: $(IFO)1_easy_raw_frames.cache $(IFO)1_hoft_DCS_A
DCSEXACTKAPPAS_act2darm_plots: $(IFO)1_easy_raw_frames.cache $(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache
python3 act2darm_timeseries.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --raw-frame-cache $(IFO)1_easy_raw_frames.cache --gstlal-frame-cache-list '$(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache,$(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache' --config-file-list '$(DCSAPPROXKAPPASCONFIGS),$(DCSEXACTKAPPASCONFIGS)' --gstlal-channel-list 'DCS-CALIB_STRAINAPPROXKAPPAS,DCS-CALIB_STRAINEXACTKAPPAS' --act-channel-list "SUS-ETMX_L3_CAL_LINE_OUT_DQ,SUS-ETMX_L2_CAL_LINE_OUT_DQ,SUS-ETMX_L1_CAL_LINE_OUT_DQ" --labels '{\rm Approx},{\rm Exact}' --magnitude-ranges '0.95,1.05;0.8,1.2;0.8,1.2' --phase-ranges '-3.0,3.0;-15.0,15.0;-15.0,15.0' --latex-labels --act-time-advance 0.00006103515625 --show-stats
approxKappasErrorPlot: $(IFO)1_C01_frames.cache
python3 approxKappasErrorPlot.py --frame-cache $(IFO)1_C01_frames.cache --config-file-list $(DCSO31CONFIGS),$(DCSO32CONFIGS),$(DCSO33CONFIGS),$(DCSO34CONFIGS) --endtimes-list 1239472998,1251057623,1256655618,1278428752
#$(DCSO31CONFIGS),$(DCSO32CONFIGS),$(DCSO33CONFIGS),$(DCSO34CONFIGS)
#1239472998,1251057623,1256655618,1278428752
TDCFs_pcal2darm_plots: $(IFO)1_easy_raw_frames.cache $(IFO)1_SCALAR_CORR_frames.cache $(IFO)1_FCC_CORR_frames.cache $(IFO)1_FCCFS_CORR_frames.cache $(IFO)1_ALL_CORR_frames.cache
python3 pcal2darm_timeseries.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --raw-frame-cache $(IFO)1_easy_raw_frames.cache --gstlal-frame-cache-list '$(IFO)1_SCALAR_CORR_frames.cache,$(IFO)1_FCC_CORR_frames.cache,$(IFO)1_FCCFS_CORR_frames.cache,$(IFO)1_ALL_CORR_frames.cache' --config-file '$(ALL_CORR_CONFIGS)' --pcal-channel-name CAL-PCALY_RX_PD_OUT_DQ --gstlal-channel-list 'DCS-CALIB_STRAIN,DCS-CALIB_STRAIN,DCS-CALIB_STRAIN,DCS-CALIB_STRAIN' --labels '{\rm Scalars},+f_{\rm cc},+f_{\rm s}+Q,+\tau_i' --latex-labels --pcal-time-advance 0.00006103515625 --show-stats
......@@ -203,6 +208,9 @@ pcal_GDS_transfer_functions: $(IFO)1_easy_raw_frames.cache $(IFO)1_hoft_GDS_fram
pcal_DCS_transfer_functions: $(IFO)1_SCALAR_CORR_frames.cache $(IFO)1_FCC_CORR_frames.cache $(IFO)1_FCCFS_CORR_frames.cache $(IFO)1_ALL_CORR_frames.cache
python3 plot_transfer_function.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --denominator-frame-cache $(IFO)1_easy_raw_frames.cache --denominator-channel-name CAL-PCALY_RX_PD_OUT_DQ --denominator-correction y_arm_pcal_corr --numerator-correction arm_length --frequency-max 400 --numerator-frame-cache-list $(IFO)1_SCALAR_CORR_frames.cache,$(IFO)1_FCC_CORR_frames.cache,$(IFO)1_FCCFS_CORR_frames.cache,$(IFO)1_ALL_CORR_frames.cache --numerator-channel-list DCS-CALIB_STRAIN,DCS-CALIB_STRAIN,DCS-CALIB_STRAIN,DCS-CALIB_STRAIN --config-file $(ALL_CORR_CONFIGS) --use-median --labels '{\rm Scalars},+f_{\rm cc},+f_{\rm s}+Q,+\tau_i' --latex-labels
pcal_DCS_EXACTKAPPAS_transfer_functions: $(IFO)1_easy_raw_frames.cache $(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache $(IFO)1_C01_frames.cache
python3 plot_transfer_function.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --denominator-frame-cache $(IFO)1_easy_raw_frames.cache --denominator-channel-name CAL-PCALY_RX_PD_OUT_DQ --denominator-correction y_arm_pcal_corr --numerator-correction arm_length --frequency-max 400 --numerator-frame-cache-list $(IFO)1_C01_frames.cache,$(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache,$(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache --numerator-channel-list DCS-CALIB_STRAIN_C01,DCS-CALIB_STRAINAPPROXKAPPAS,DCS-CALIB_STRAINEXACTKAPPAS --config-file $(DCSEXACTKAPPASCONFIGS) --labels 'C01,Approx,Exact' --use-median
GDS_BB_injection_plots: filters framesdir BB_inj_dir BB_plots_dir
python3 plot_BB_injections.py --ifo $(IFO) --obs-run $(OBSRUN) --check-directory BB_injections/$(OBSRUN)/$(IFO)1/$($(OBSRUN)_$(IFO)1_BB_INJ_PATH)/$($(OBSRUN)_$(IFO)1_BB_INJ_DIR) --plots-directory BB_injections/$(OBSRUN)/$(IFO)1/$($(OBSRUN)_$(IFO)1_BB_PLOTS_PATH)/$($(OBSRUN)_$(IFO)1_BB_PLOTS_DIR) --update-svn --cal-versions R,HOFT_C00
......@@ -251,7 +259,8 @@ DCS_over_C02: $(IFO)1_hoft_DCS_frames.cache $(IFO)1_C02_frames.cache
kappastimeseries_GDS: $(IFO)1_hoft_GDS_frames.cache $(IFO)1_easy_raw_frames.cache
python3 timeserieskappas.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --frame-cache $(IFO)1_hoft_GDS_frames.cache --channel-list 'GDS-CALIB_KAPPA_TST_REAL_NOGATE','GDS-CALIB_KAPPA_TST_IMAGINARY_NOGATE','GDS-CALIB_KAPPA_PUM_REAL_NOGATE','GDS-CALIB_KAPPA_PUM_IMAGINARY_NOGATE','GDS-CALIB_KAPPA_UIM_REAL_NOGATE','GDS-CALIB_KAPPA_UIM_IMAGINARY_NOGATE','GDS-CALIB_KAPPA_C_NOGATE','GDS-CALIB_F_CC_NOGATE' --raw-channel-list 'CAL-CS_TDEP_KAPPA_TST_REAL_OUTPUT','CAL-CS_TDEP_KAPPA_TST_IMAG_OUTPUT','CAL-CS_TDEP_KAPPA_PUM_REAL_OUTPUT','CAL-CS_TDEP_KAPPA_PUM_IMAG_OUTPUT','CAL-CS_TDEP_KAPPA_UIM_REAL_OUTPUT','CAL-CS_TDEP_KAPPA_UIM_IMAG_OUTPUT','CAL-CS_TDEP_KAPPA_C_OUTPUT','CAL-CS_TDEP_F_C_OUTPUT' --raw-frame-cache $(IFO)1_easy_raw_frames.cache
exactkappastimeseries: $(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache
exactkappastimeseries:
$(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache
python3 frame_manipulator.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --frame-cache $(IFO)1_hoft_DCS_EXACTKAPPAS_frames.cache --output-path txt --channel-list 'DCS-CALIB_KAPPA_TST_REALEXACTKAPPAS,DCS-CALIB_KAPPA_TST_IMAGINARYEXACTKAPPAS,DCS-CALIB_KAPPA_PUM_REALEXACTKAPPAS,DCS-CALIB_KAPPA_PUM_IMAGINARYEXACTKAPPAS,DCS-CALIB_KAPPA_UIM_REALEXACTKAPPAS,DCS-CALIB_KAPPA_UIM_IMAGINARYEXACTKAPPAS,DCS-CALIB_KAPPA_CEXACTKAPPAS,DCS-CALIB_F_CCEXACTKAPPAS,DCS-CALIB_F_S_SQUAREDEXACTKAPPAS,DCS-CALIB_SRC_Q_INVERSEEXACTKAPPAS'
python3 compute_tau.py --kappar-txt $(IFO)1-DCS-CALIB_KAPPA_TST_REALEXACTKAPPAS.txt --kappai-txt $(IFO)1-DCS-CALIB_KAPPA_TST_IMAGINARYEXACTKAPPAS.txt --config-file $(DCSEXACTKAPPASCONFIGS) --kappa-filename $(IFO)1-DCS-CALIB_KAPPA_TST_EXACTKAPPAS.txt --tau-filename $(IFO)1-DCS-CALIB_TAU_TST_EXACTKAPPAS.txt
python3 compute_tau.py --kappar-txt $(IFO)1-DCS-CALIB_KAPPA_PUM_REALEXACTKAPPAS.txt --kappai-txt $(IFO)1-DCS-CALIB_KAPPA_PUM_IMAGINARYEXACTKAPPAS.txt --config-file $(DCSEXACTKAPPASCONFIGS) --kappa-filename $(IFO)1-DCS-CALIB_KAPPA_PUM_EXACTKAPPAS.txt --tau-filename $(IFO)1-DCS-CALIB_TAU_PUM_EXACTKAPPAS.txt
......@@ -262,9 +271,7 @@ exactkappastimeseries: $(IFO)1_hoft_DCS_APPROXKAPPAS_frames.cache $(IFO)1_hoft_D
python3 compute_tau.py --kappar-txt $(IFO)1-DCS-CALIB_KAPPA_PUM_REALAPPROXKAPPAS.txt --kappai-txt $(IFO)1-DCS-CALIB_KAPPA_PUM_IMAGINARYAPPROXKAPPAS.txt --config-file $(DCSAPPROXKAPPASCONFIGS) --kappa-filename $(IFO)1-DCS-CALIB_KAPPA_PUM_APPROXKAPPAS.txt --tau-filename $(IFO)1-DCS-CALIB_TAU_PUM_APPROXKAPPAS.txt
python3 compute_tau.py --kappar-txt $(IFO)1-DCS-CALIB_KAPPA_UIM_REALAPPROXKAPPAS.txt --kappai-txt $(IFO)1-DCS-CALIB_KAPPA_UIM_IMAGINARYAPPROXKAPPAS.txt --config-file $(DCSAPPROXKAPPASCONFIGS) --kappa-filename $(IFO)1-DCS-CALIB_KAPPA_UIM_APPROXKAPPAS.txt --tau-filename $(IFO)1-DCS-CALIB_TAU_UIM_APPROXKAPPAS.txt
python3 compute_fs_over_Q.py --fs-squared-txt $(IFO)1-DCS-CALIB_F_S_SQUAREDAPPROXKAPPAS.txt --Qinv-txt $(IFO)1-DCS-CALIB_SRC_Q_INVERSEAPPROXKAPPAS.txt --filename $(IFO)1-DCS-CALIB_F_S_OVER_QAPPROXKAPPAS.txt
python3 plot_kappas_from_txt.py --txt-list '$(IFO)1-DCS-CALIB_KAPPA_TST_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_PUM_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_UIM_APPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_KAPPA_TST_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_PUM_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_UIM_EXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_TAU_TST_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_PUM_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_UIM_APPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_TAU_TST_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_PUM_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_UIM_EXACTKAPPAS.txt' --labels 'Approx;Exact' --filename actuation_TDCFs.png
python3 plot_kappas_from_txt.py --txt-list '$(IFO)1-DCS-CALIB_KAPPA_CAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_KAPPA_CEXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_F_CCAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_CCEXACTKAPPAS.txt' --labels 'Approx;Exact' --filename sensing_TDCFs.png
python3 plot_kappas_from_txt.py --txt-list '$(IFO)1-DCS-CALIB_F_S_SQUAREDAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_S_SQUAREDEXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_F_S_OVER_QAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_S_OVER_QEXACTKAPPAS.txt' --labels 'Approx;Exact' --filename SRC_TDCFs.png
python3 plot_kappas_from_txt.py --txt-list '$(IFO)1-DCS-CALIB_KAPPA_TST_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_PUM_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_UIM_APPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_KAPPA_TST_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_PUM_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_KAPPA_UIM_EXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_TAU_TST_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_PUM_APPROXKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_UIM_APPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_TAU_TST_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_PUM_EXACTKAPPAS.txt,$(IFO)1-DCS-CALIB_TAU_UIM_EXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_KAPPA_CAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_KAPPA_CEXACTKAPPAS.txt|$(IFO)1-DCS-CALIB_F_CCAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_CCEXACTKAPPAS.txt:$(IFO)1-DCS-CALIB_F_S_SQUAREDAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_S_SQUAREDEXACTKAPPAS.txt|$(IFO)1-DCS-CALIB_F_S_OVER_QAPPROXKAPPAS.txt;$(IFO)1-DCS-CALIB_F_S_OVER_QEXACTKAPPAS.txt' --labels 'Approx;Exact' --filename TDCFs
kappastimeseries: $(IFO)1_hoft_DCS_frames.cache $(IFO)1_C01_frames.cache
python3 frame_manipulator.py --gps-start-time $(PLOT_START) --gps-end-time $(PLOT_END) --ifo $(IFO)1 --frame-cache $(IFO)1_C01_frames.cache --output-path txt --channel-list 'DCS-CALIB_KAPPA_TST_REAL_C01,DCS-CALIB_KAPPA_TST_IMAGINARY_C01,DCS-CALIB_KAPPA_PUM_REAL_C01,DCS-CALIB_KAPPA_PUM_IMAGINARY_C01,DCS-CALIB_KAPPA_UIM_REAL_C01,DCS-CALIB_KAPPA_UIM_IMAGINARY_C01,DCS-CALIB_KAPPA_C_C01,DCS-CALIB_F_CC_C01,DCS-CALIB_F_S_SQUARED_C01,DCS-CALIB_SRC_Q_INVERSE_C01'
......
......@@ -69,159 +69,168 @@ txt_list = options.txt_list.split(':')
for i in range(len(txt_list)):
data.append([])
labels.append([])
ylabels.append(None)
txt_list[i] = txt_list[i].split(';')
ylabels.append([])
data_min.append([])
data_max.append([])
txt_list[i] = txt_list[i].split('|')
for j in range(len(txt_list[i])):
ylabels[i].append(None)
data[i].append([])
labels[i].append([])
txt_list[i][j] = txt_list[i][j].split(',')
txt_list[i][j] = txt_list[i][j].split(';')
if len(txt_list[i][j]) != len(short_labels):
raise ValueError("Number of lables must match number of versions of calibration. %d != %d" % (len(short_labels), len(txt_list[i][j])))
for k in range(len(txt_list[i][j])):
data[i][j].append(np.loadtxt(txt_list[i][j][k]).transpose())
labels[i][j].append(short_labels[j])
t_start = min(t_start, data[i][j][k][0][0])
t_end = max(t_end, data[i][j][k][0][-1])
# Find out which TDCF this is and add that to the label
if 'tst' in txt_list[i][j][k] or 'TST' in txt_list[i][j][k]:
if 'imag' in txt_list[i][j][k] or 'IMAG' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Im(\kappa_{\rm T})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(-0.1)
data_max.append(0.1)
elif 'real' in txt_list[i][j][k] or 'REAL' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Re(\kappa_{\rm T})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'tau' in txt_list[i][j][k] or 'TAU' in txt_list[i][j][k]:
labels[i][j][k] += r': $\tau_{\rm T}$'
ylabels[i] = "Time ($\mu$s)"
if j == 0 and k == 0:
data_min.append(-1000)
data_max.append(1000)
data[i][j].append([])
labels[i][j].append([])
txt_list[i][j][k] = txt_list[i][j][k].split(',')
for l in range(len(txt_list[i][j][k])):
data[i][j][k].append(np.loadtxt(txt_list[i][j][k][l]).transpose())
labels[i][j][k].append(short_labels[k])
t_start = min(t_start, data[i][j][k][l][0][0])
t_end = max(t_end, data[i][j][k][l][0][-1])
# Find out which TDCF this is and add that to the label
if 'tst' in txt_list[i][j][k][l] or 'TST' in txt_list[i][j][k][l]:
if 'imag' in txt_list[i][j][k][l] or 'IMAG' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Im(\kappa_{\rm T})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(-0.1)
data_max[i].append(0.1)
elif 'real' in txt_list[i][j][k][l] or 'REAL' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Re(\kappa_{\rm T})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'tau' in txt_list[i][j][k][l] or 'TAU' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\tau_{\rm T}$'
ylabels[i][j] = "Time ($\mu$s)"
if k == 0 and l == 0:
data_min[i].append(-1000)
data_max[i].append(1000)
else:
# Assume it's the magnitude
labels[i][j][k][l] += r': $\kappa_{\rm T}$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'pum' in txt_list[i][j][k][l] or 'PUM' in txt_list[i][j][k][l]:
if 'imag' in txt_list[i][j][k][l] or 'IMAG' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Im(\kappa_{\rm P})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(-0.1)
data_max[i].append(0.1)
elif 'real' in txt_list[i][j][k][l] or 'REAL' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Re(\kappa_{\rm P})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'tau' in txt_list[i][j][k][l] or 'TAU' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\tau_{\rm P}$'
ylabels[i][j] = "Time ($\mu$s)"
if k == 0 and l == 0:
data_min[i].append(-1000)
data_max[i].append(1000)
else:
# Assume it's the magnitude
labels[i][j][k][l] += r': $\kappa_{\rm P}$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'uim' in txt_list[i][j][k][l] or 'UIM' in txt_list[i][j][k][l]:
if 'imag' in txt_list[i][j][k][l] or 'IMAG' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Im(\kappa_{\rm U})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(-0.1)
data_max[i].append(0.1)
elif 'real' in txt_list[i][j][k][l] or 'REAL' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Re(\kappa_{\rm U})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'tau' in txt_list[i][j][k][l] or 'TAU' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\tau_{\rm U}$'
ylabels[i][j] = "Time ($\mu$s)"
if k == 0 and l == 0:
data_min[i].append(-1000)
data_max[i].append(1000)
else:
# Assume it's the magnitude
labels[i][j][k][l] += r': $\kappa_{\rm U}$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'pu' in txt_list[i][j][k][l] or 'PU' in txt_list[i][j][k][l]:
if 'imag' in txt_list[i][j][k][l] or 'IMAG' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Im(\kappa_{\rm PU})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(-0.1)
data_max[i].append(0.1)
elif 'real' in txt_list[i][j][k][l] or 'REAL' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\Re(\kappa_{\rm PU})$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'tau' in txt_list[i][j][k][l] or 'TAU' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\tau_{\rm PU}$'
ylabels[i][j] = "Time ($\mu$s)"
if k == 0 and l == 0:
data_min[i].append(-1000)
data_max[i].append(1000)
else:
# Assume it's the magnitude
labels[i][j][k][l] += r': $\kappa_{\rm PU}$'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(0.9)
data_max[i].append(1.1)
elif 'kc' in txt_list[i][j][k][l] or 'KC' in txt_list[i][j][k][l] or 'kappac' in txt_list[i][j][k][l] or 'KAPPAC' in txt_list[i][j][k][l] or 'kappa_c' in txt_list[i][j][k][l] or 'KAPPA_C' in txt_list[i][j][k][l] or 'kappa_C' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $\kappa_{\rm C}$'
ylabels[i][j] = r'$\kappa_{\rm C}$'
if k == 0 and l == 0:
data_min[i].append(0.95)
data_max[i].append(1.05)
elif 'fc' in txt_list[i][j][k][l] or 'FC' in txt_list[i][j][k][l] or 'f_c' in txt_list[i][j][k][l] or 'F_C' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $f_{\rm cc}$'
ylabels[i][j] = r'$f_{\rm cc}$ (Hz)'
if k == 0 and l == 0:
data_min[i].append(390)
data_max[i].append(430)
elif ('fs_over_Q' in txt_list[i][j][k][l] or 'FS_OVER_Q' in txt_list[i][j][k][l] or 'f_s_over_Q' in txt_list[i][j][k][l] or 'F_S_OVER_Q' in txt_list[i][j][k][l]):
labels[i][j][k][l] += r': $f_{\rm s} / Q$'
ylabels[i][j] = r'$f_{\rm s} / Q$ (Hz)'
if k == 0 and l == 0:
data_min[i].append(-2.2)
data_max[i].append(1)
elif 'fs' in txt_list[i][j][k][l] or 'FS' in txt_list[i][j][k][l] or 'f_s' in txt_list[i][j][k][l] or 'F_S' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $f_{\rm s}^2$'
ylabels[i][j] = r'$f_{\rm s}^2$ (Hz$^2$)'
if k == 0 and l == 0:
data_min[i].append(-20)
data_max[i].append(300)
elif 'Q' in txt_list[i][j][k][l] or 'q' in txt_list[i][j][k][l]:
labels[i][j][k][l] += r': $Q^{-1}$'
ylabels[i][j] = "Inverse Quality Factor"
if k == 0 and l == 0:
data_min[i].append(-1)
data_max[i].append(1)
else:
# Assume it's the magnitude
labels[i][j][k] += r': $\kappa_{\rm T}$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'pum' in txt_list[i][j][k] or 'PUM' in txt_list[i][j][k]:
if 'imag' in txt_list[i][j][k] or 'IMAG' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Im(\kappa_{\rm P})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(-0.1)
data_max.append(0.1)
elif 'real' in txt_list[i][j][k] or 'REAL' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Re(\kappa_{\rm P})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'tau' in txt_list[i][j][k] or 'TAU' in txt_list[i][j][k]:
labels[i][j][k] += r': $\tau_{\rm P}$'
ylabels[i] = "Time ($\mu$s)"
if j == 0 and k == 0:
data_min.append(-1000)
data_max.append(1000)
else:
# Assume it's the magnitude
labels[i][j][k] += r': $\kappa_{\rm P}$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'uim' in txt_list[i][j][k] or 'UIM' in txt_list[i][j][k]:
if 'imag' in txt_list[i][j][k] or 'IMAG' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Im(\kappa_{\rm U})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(-0.1)
data_max.append(0.1)
elif 'real' in txt_list[i][j][k] or 'REAL' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Re(\kappa_{\rm U})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'tau' in txt_list[i][j][k] or 'TAU' in txt_list[i][j][k]:
labels[i][j][k] += r': $\tau_{\rm U}$'
ylabels[i] = "Time ($\mu$s)"
if j == 0 and k == 0:
data_min.append(-1000)
data_max.append(1000)
else:
# Assume it's the magnitude
labels[i][j][k] += r': $\kappa_{\rm U}$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'pu' in txt_list[i][j][k] or 'PU' in txt_list[i][j][k]:
if 'imag' in txt_list[i][j][k] or 'IMAG' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Im(\kappa_{\rm PU})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(-0.1)
data_max.append(0.1)
elif 'real' in txt_list[i][j][k] or 'REAL' in txt_list[i][j][k]:
labels[i][j][k] += r': $\Re(\kappa_{\rm PU})$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'tau' in txt_list[i][j][k] or 'TAU' in txt_list[i][j][k]:
labels[i][j][k] += r': $\tau_{\rm PU}$'
ylabels[i] = "Time ($\mu$s)"
if j == 0 and k == 0:
data_min.append(-1000)
data_max.append(1000)
else:
# Assume it's the magnitude
labels[i][j][k] += r': $\kappa_{\rm PU}$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.9)
data_max.append(1.1)
elif 'kc' in txt_list[i][j][k] or 'KC' in txt_list[i][j][k] or 'kappac' in txt_list[i][j][k] or 'KAPPAC' in txt_list[i][j][k] or 'kappa_c' in txt_list[i][j][k] or 'KAPPA_C' in txt_list[i][j][k] or 'kappa_C' in txt_list[i][j][k]:
labels[i][j][k] += r': $\kappa_{\rm C}$'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(0.95)
data_max.append(1.05)
elif 'fc' in txt_list[i][j][k] or 'FC' in txt_list[i][j][k] or 'f_c' in txt_list[i][j][k] or 'F_C' in txt_list[i][j][k]:
labels[i][j][k] += r': $f_{\rm cc}$'
ylabels[i] = "Frequency (Hz)"
if j == 0 and k == 0:
data_min.append(390)
data_max.append(450)
elif ('fs_over_Q' in txt_list[i][j][k] or 'FS_OVER_Q' in txt_list[i][j][k] or 'f_s_over_Q' in txt_list[i][j][k] or 'F_S_OVER_Q' in txt_list[i][j][k]):
labels[i][j][k] += r': $f_{\rm s} / Q$'
ylabels[i] = "Frequency (Hz)"
if j == 0 and k == 0:
data_min.append(-2)
data_max.append(0)
elif 'fs' in txt_list[i][j][k] or 'FS' in txt_list[i][j][k] or 'f_s' in txt_list[i][j][k] or 'F_S' in txt_list[i][j][k]:
labels[i][j][k] += r': $f_{\rm s}^2$'
ylabels[i] = "Square Frequency (Hz$^2$)"
if j == 0 and k == 0:
data_min.append(-10)
data_max.append(200)
elif 'Q' in txt_list[i][j][k] or 'q' in txt_list[i][j][k]:
labels[i][j][k] += r': $Q^{-1}$'
ylabels[i] = "Inverse Quality Factor"
if j == 0 and k == 0:
data_min.append(-1)
data_max.append(1)
else:
labels[i][j][k] += 'TDCF'
ylabels[i] = "Correction"
if j == 0 and k == 0:
data_min.append(min(data[i][j][k][1]))
data_max.append(max(data[i][j][k][1]))
print('unknown legend label for %s' % txt_list[i][j][k])
labels[i][j][k][l] += 'TDCF'
ylabels[i][j] = "Correction"
if k == 0 and l == 0:
data_min[i].append(min(data[i][j][k][l][1]))
data_max[i].append(max(data[i][j][k][l][1]))
print('unknown legend label for %s' % txt_list[i][j][k][l])
# Read data from files and plot it
colors = [['red', 'darkred', 'salmon'], ['limegreen', 'darkgreen', 'lightgreen'], ['blue', 'darkblue', 'lightblue']] # Hopefully the user will not compare more than 3 versions of calibration or plot more than 3 TDCFs on the same plot.
......@@ -241,26 +250,36 @@ elif dur > 100:
sec_per_t_unit = 60.0
# Make plots
axs = []
plt.figure(figsize = (18, len(data) * 6))
for i in range(len(data)):
ax = plt.subplot(len(data), 1, i + 1)
axs = []
num_legend = 0
# For the color scheme, we need the indices j (which y-axis) and k (which calibration version) to have the reverse hierarchy.
datasetnum = np.zeros(len(short_labels), dtype = int)
for j in range(len(data[i])):
num_legend = 0
ax = plt.subplot(len(data), 1, i + 1) if j == 0 else ax.twinx()
axs.append(ax)
for k in range(len(data[i][j])):
plt.plot((data[i][j][k][0] - t_start) / sec_per_t_unit, data[i][j][k][1], colors[j % 3][k % 3], linewidth = 2.0, label = labels[i][j][k])
num_legend += 1
if ylabels[i] is not None:
plt.ylabel(ylabels[i])
leg = plt.legend(fancybox = True, loc = 'upper right', ncol = max(1, num_legend // 3))
leg.get_frame().set_alpha(0.5)
for l in range(len(data[i][j][k])):
ax.plot((data[i][j][k][l][0] - t_start) / sec_per_t_unit, data[i][j][k][l][1], colors[k % 3][datasetnum[k] % 3], linewidth = 2.0, label = labels[i][j][k][l])
num_legend += 1
datasetnum[k] += 1
if ylabels[i][j] is not None:
plt.ylabel(ylabels[i][j])
ticks_and_grid(ax, xscale = 'linear', yscale = 'linear', ymin = data_min[i][j], ymax = data_max[i][j], show_grid = j == 0)
if i == 0 and j == 0 and options.plot_title is not None:
plt.title(options.plot_title)
if i == 0 and options.plot_title is not None:
plt.title(options.plot_title)
if i == len(data) - 1 and j == 0:
plt.xlabel(r'${\rm Time \ in \ %s \ since \ %s \ UTC}$' % (t_unit, time.strftime("%b %d %Y %H:%M:%S".replace(':', '{:}').replace('-', '\mbox{-}').replace(' ', '\ '), time.gmtime(t_start + 315964782))))
if i == len(data) - 1:
plt.xlabel(r'${\rm Time \ in \ %s \ since \ %s \ UTC}$' % (t_unit, time.strftime("%b %d %Y %H:%M:%S".replace(':', '{:}').replace('-', '\mbox{-}').replace(' ', '\ '), time.gmtime(t_start + 315964782))))
ticks_and_grid(ax, xscale = 'linear', yscale = 'linear', ymin = data_min[i], ymax = data_max[i])
plt.savefig(options.filename.split('.')[0] + '_%d-%d.' % (t_start, dur) + options.filename.split('.')[1])
# Legends must be added last so that they don't get covered by other things.
for j in range(len(data[i])):
leg = axs[j].legend(fancybox = True, loc = 'upper right' if j == len(data[i]) - 1 else 'upper left', ncol = max(1, num_legend // 3))
leg.get_frame().set_alpha(0.6)
plt.savefig(options.filename + '_%d-%d.' % (t_start, dur) + 'png')
plt.savefig(options.filename + '_%d-%d.' % (t_start, dur) + 'pdf')
......@@ -85,7 +85,7 @@ parser.add_option("--config-file", metavar = "name", default = None, help = "Con
parser.add_option("--sample-rate", metavar = "Hz", type = int, default = 16384, help = "Sample rate at which transfer function is computed")
parser.add_option("--fft-time", metavar = "seconds", type = float, default = 16, help = "Length of FFTs used to compute transfer function")
parser.add_option("--use-median", action = "store_true", help = "Use a median instead of an average to compute transfer function")
parser.add_option("--df", metavar = "Hz", type = float, default = 0.25, help = "Frequency spacing of transfer function")
parser.add_option("--df", metavar = "Hz", type = float, default = 0.5, help = "Frequency spacing of transfer function")
parser.add_option("--frequency-min", type = float, default = 10, help = "Minimum frequency for plot")
parser.add_option("--frequency-max", type = float, default = 5000, help = "Maximum frequency for plot")
parser.add_option("--magnitude-min", type = float, default = 0.9, help = "Minimum for magnitude plot")
......@@ -340,7 +340,7 @@ for i in range(len(real_poles)):
colors = []
# Start with defaults to use if we don't recognize what we are plotting.
default_colors = ['tomato', 'green', 'mediumblue', 'gold', 'orange', 'aqua', 'magenta', 'blue']
default_colors = ['tomato', 'red', 'limegreen', 'gold', 'orange', 'aqua', 'magenta', 'blue']
# Use specific colors for known version of calibration
C02_labels = ['C02', 'c02']
......
......@@ -73,7 +73,7 @@ def find_minor_ticks(major_ticks, scale = 'linear'):
else:
return np.array([])
def ticks_and_grid(ax, xmin = None, xmax = None, ymin = None, ymax = None, xscale = None, yscale = None):
def ticks_and_grid(ax, xmin = None, xmax = None, ymin = None, ymax = None, xscale = None, yscale = None, show_grid = True):
xlim = ax.get_xlim()
xmin = xlim[0] if xmin is None else xmin
......@@ -100,8 +100,9 @@ def ticks_and_grid(ax, xmin = None, xmax = None, ymin = None, ymax = None, xscal
ax.set_yticks(major_yticks)
ax.set_xticks(major_xticks)
ax.set_axisbelow(True)
ax.grid(True, which = "major", ls = '-', linewidth = 0.5, color = 'dimgray')
ax.grid(True, which = "minor", ls = '-', linewidth = 0.5, color = 'lightgray')
if show_grid:
ax.grid(True, which = "major", ls = '-', linewidth = 0.5, color = 'dimgray')
ax.grid(True, which = "minor", ls = '-', linewidth = 0.5, color = 'lightgray')
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
......
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