Skip to content

Commit b998ebf

Browse files
authored
Merge pull request #51 from VERITAS-Observatory/0.5.0-dev2
0.5.0 dev2
2 parents 80f1117 + 85c9b2e commit b998ebf

File tree

5 files changed

+55
-379
lines changed

5 files changed

+55
-379
lines changed

eventdisplay_anasum/spectral_analysis.C

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ void spectral_analysis(
119119
fFitFunction->Draw("same");
120120
}
121121
a.plotFitValues();
122+
if (c)
123+
{
124+
c->Print((output_file + ".pdf").c_str());
125+
}
126+
127+
TCanvas *cCounting = a.plotCountingHistograms();
128+
if (cCounting)
129+
{
130+
cCounting->Print((output_file + "_counting.pdf").c_str());
131+
}
132+
122133

123134
// write fit results as yaml file
124135
string yaml_file = output_file + ".yaml";
@@ -145,11 +156,6 @@ void spectral_analysis(
145156
}
146157
yaml_out.close();
147158

148-
if (c)
149-
{
150-
c->Print((output_file + ".pdf").c_str());
151-
}
152-
153159
// write spectral points
154160
a.writeSpectralPointsToCSVFile((output_file + ".ecsv").c_str());
155161
}

eventdisplay_anasum/spectral_analysis_config.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENERGY_MIN: 0.09
66
ENERGY_MAX: 100.
77
SIGNIFICANCE_FIT_MIN: 0.0
88
EXCESS_EVENTS_FIT_MIN: 0.0
9-
SIGNIFICANCE_PLOT_MIN: 1.0
10-
EXCESS_EVENTS_PLOT_MIN: 1.0
9+
SIGNIFICANCE_PLOT_MIN: 0.5
10+
EXCESS_EVENTS_PLOT_MIN: 0.5
1111
PLOT_UPPER_LIMITS: 1
1212
PLOT_EVENT_NUMBERS: 1

v2dl5/light_curves/binary_plotting.py

Lines changed: 0 additions & 336 deletions
Original file line numberDiff line numberDiff line change
@@ -555,339 +555,3 @@ def plot_distribution(
555555
file_type=file_type,
556556
figure_dir=figure_dir,
557557
)
558-
559-
560-
561-
562-
563-
# Temporary stuff - probably not needed
564-
#
565-
# def plotLightCurve_fluxvsPhase_inOrbits(
566-
# fDataDict,
567-
# PlotInstruments,
568-
# F,
569-
# lc_spline_bin_centers,
570-
# lc_spline_sv,
571-
# lc_spline_sv_err,
572-
# orbital_period_BL=315.,
573-
# orbital_periodBins=20,
574-
# plot_variable=None):
575-
# """plot flux vs orbital phase (separated in orbits, all in one plot)
576-
# """
577-
#
578-
# MJD_firstOrbit, N_orbits = getNumberOfOrbits(
579-
# fDataDict, PlotInstruments,
580-
# orbital_period_BL, False)
581-
#
582-
# lightCurvePlottingUtilities.paper_figures(4, 4)
583-
# colors = lightCurvePlottingUtilities.getColorList(N_orbits)
584-
# if N_orbits < 6:
585-
# markers = lightCurvePlottingUtilities.getMarkerList()
586-
# else:
587-
# markers = ['o']*N_orbits
588-
#
589-
# if len(PlotInstruments) < 1:
590-
# return
591-
#
592-
# # plot average and interpolated light curves
593-
# glabel = PlotInstruments[0] + " (average)"
594-
# if lc_spline_bin_centers and len(lc_spline_bin_centers) > 0:
595-
# plt.plot(
596-
# lc_spline_bin_centers,
597-
# lc_spline_sv,
598-
# color='tab:gray',
599-
# linestyle='--',
600-
# linewidth=lightCurvePlottingUtilities.getLineWidth())
601-
# plt.fill_between(lc_spline_bin_centers,
602-
# lc_spline_sv - lc_spline_sv_err,
603-
# lc_spline_sv + lc_spline_sv_err,
604-
# color='tab:gray', linestyle='--',
605-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
606-
# alpha=0.3)
607-
#
608-
# # plot one light curve per orbital period
609-
# for i in range(0, N_orbits):
610-
# x = []
611-
# y = []
612-
# ex = []
613-
# mj = []
614-
# orbit_min = MJD_firstOrbit + i * orbital_period_BL
615-
# orbit_max = MJD_firstOrbit + (i + 1) * orbital_period_BL - 1.
616-
# for j in range(len(PlotInstruments)):
617-
# i_plotValue, i_plotError = lightCurvePlottingUtilities.get_plotting_variable(
618-
# plot_variable, j)
619-
#
620-
# for p in range(len(fDataDict[PlotInstruments[j]]['phaseN'])):
621-
# if fDataDict[PlotInstruments[j]]['MJD'][p] >= orbit_min \
622-
# and fDataDict[PlotInstruments[j]]['MJD'][p] < orbit_max + 1.:
623-
#
624-
# x.append(fDataDict[PlotInstruments[j]]['phase'][p])
625-
# y.append(fDataDict[PlotInstruments[j]][i_plotValue][p])
626-
# ex.append(fDataDict[PlotInstruments[j]][i_plotError][p])
627-
# mj.append(fDataDict[PlotInstruments[j]]['MJD'][p])
628-
#
629-
# if len(mj):
630-
# OrbitPhStr = "MJD %d - %d" % (
631-
# orbit_min, orbit_max)
632-
# plt.errorbar(
633-
# x,
634-
# y,
635-
# ex,
636-
# None,
637-
# color=colors[i],
638-
# marker=markers[i],
639-
# linestyle='none',
640-
# label=OrbitPhStr,
641-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
642-
# markersize=lightCurvePlottingUtilities.getMarkerSize())
643-
#
644-
# plt.xlabel(
645-
# lightCurvePlottingUtilities.get_orbital_phase_axis_string(orbital_period_BL) )
646-
# plt.ylabel(
647-
# lightCurvePlottingUtilities.getFluxAxisString(
648-
# PlotInstruments[0],plot_variable) )
649-
# if PlotInstruments[0].find('Optical') < 0:
650-
# plt.axhline(y=0, linestyle=':')
651-
# if getPrintInstrumentName(PlotInstruments).find( "fwhm" ) < 0 and \
652-
# getPrintInstrumentName(PlotInstruments).find( "ew" ) < 0:
653-
# plt.legend(prop={'size': 10}, framealpha=0.1)
654-
#
655-
# lightCurvePlottingUtilities.printFigure(
656-
# getPrintInstrumentName(PlotInstruments) +
657-
# "-HESSJ0632p057-LC-phaseFolded-%dd-Orbits" %
658-
# orbital_period_BL)
659-
#
660-
#
661-
#
662-
# def plotAverageLightCurve_fluxvsPhase(
663-
# fDataDict,
664-
# PlotInstruments,
665-
# orbital_period_BL=315.,
666-
# orbital_periodBins=20):
667-
# """
668-
# plot average flux vs orbital phase
669-
#
670-
# calculates also average light curves
671-
# """
672-
#
673-
# print("Plot phase binned averaged light curve:")
674-
# print("\t orbital phase (%.1f d)" % orbital_period_BL)
675-
# print("\t number of phase bins (%d)" % orbital_periodBins)
676-
# print("\t calculating average light curve for ", PlotInstruments)
677-
# if len(PlotInstruments) < 1:
678-
# return
679-
#
680-
# # copy all data into one set of arrays
681-
# # averaged light curve is calculated from
682-
# # light curve bins of all data
683-
# i_MJD = []
684-
# i_flux = []
685-
# i_flux_err = []
686-
# for I in PlotInstruments:
687-
# i_MJD.extend(fDataDict[I]['MJD'])
688-
# i_flux.extend(fDataDict[I]['flux'])
689-
# i_flux_err.extend(fDataDict[I]['flux_err'])
690-
#
691-
# lightCurvePlottingUtilities.paper_figures(4, 4)
692-
#
693-
# # calculate phase binned average light curve
694-
# lc_bincenters, lc_mean, lc_std = lightCurveAverageing.calculateAverageLightCurve(
695-
# i_MJD, i_flux, i_flux_err, orbital_period_BL, orbital_periodBins)
696-
#
697-
# # bin width
698-
# lc_binw = np.repeat(0.5 / orbital_periodBins, len(lc_bincenters))
699-
# plt.errorbar(lc_bincenters, lc_mean, lc_std, lc_binw,
700-
# color='b', linestyle='none',
701-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
702-
# markersize=lightCurvePlottingUtilities.getMarkerSize(),
703-
# marker='o', label='average')
704-
#
705-
# # calculate cubic spline smoothed average light curve
706-
# F, lc_spline_bin_centers, lc_spline_sv = \
707-
# lightCurveAverageing.smoothCubeSplineLightCurve(
708-
# i_MJD, i_flux, i_flux_err,
709-
# orbital_period_BL, orbital_periodBins,
710-
# True, 0.)
711-
# # get errors on the same
712-
# F_temp, lc_spline_bin_centers, lc_spline_sv_err = \
713-
# lightCurveAverageing.smoothCubeSplineLightCurve(
714-
# i_MJD, i_flux, i_flux_err,
715-
# orbital_period_BL, orbital_periodBins,
716-
# True, 1.)
717-
# lc_spline_sv_err = list(
718-
# np.array(lc_spline_sv_err) -
719-
# np.array(lc_spline_sv))
720-
#
721-
# plt.plot(lc_spline_bin_centers, lc_spline_sv, color='r', linestyle='--',
722-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
723-
# label='spline average')
724-
#
725-
# # data set used for averaging
726-
# wP = []
727-
# wP = [lightCurveAnalysisorbital_period.getOrbitalPhase(
728-
# x, orbital_period_BL) for x in i_MJD]
729-
# plt.errorbar(wP, i_flux, i_flux_err, None,
730-
# color='g', linestyle='none',
731-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
732-
# markersize=lightCurvePlottingUtilities.getMarkerSize(),
733-
# marker='o', label='average')
734-
#
735-
# plt.fill_between(lc_spline_bin_centers,
736-
# lc_spline_sv - lc_spline_sv_err,
737-
# lc_spline_sv + lc_spline_sv_err,
738-
# color='r', linestyle='--',
739-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
740-
# alpha=0.3)
741-
#
742-
# plt.xlabel(
743-
# lightCurvePlottingUtilities.get_orbital_phase_axis_string(orbital_period_BL))
744-
# plt.ylabel(lightCurvePlottingUtilities.getFluxAxisString(PlotInstruments[0]))
745-
# plt.legend()
746-
# plt.axhline(y=lc_spline_sv[0], linestyle=':')
747-
#
748-
# lightCurvePlottingUtilities.printFigure(
749-
# getPrintInstrumentName(PlotInstruments) +
750-
# "-HESSJ0632p057-LC-phaseFolded-%dd-Average" %
751-
# orbital_period_BL)
752-
#
753-
# return F, lc_spline_bin_centers, lc_spline_sv, lc_spline_sv_err
754-
#
755-
#
756-
# def plotLightCurve_fluxvsMJD_XandGray(
757-
# fDataDict, mjd_min, mjd_max,
758-
# icrc2019Plots=False,
759-
# yaxis_min = -0.9, yaxis_max=7.5,
760-
# fColorDict=None,
761-
# plot_title=None,
762-
# convert_erg=False):
763-
# """plot flux vs MJD with two different y-axis
764-
#
765-
# note: fixed limits for the y-axis
766-
# """
767-
#
768-
# lightCurvePlottingUtilities.paper_figures(4, 4, 1, False)
769-
# # quick and dirty fix to get consistent colors and markers
770-
# if len(fColorDict) == 5:
771-
# colors = lightCurvePlottingUtilities.getColorList(3)
772-
# colors[-1] = 'black'
773-
# colors.append( 'gray' )
774-
# else:
775-
# colors = lightCurvePlottingUtilities.getColorList(len(fColorDict))
776-
# markers = lightCurvePlottingUtilities.getMarkerList(icrc2019Plots)
777-
# markers[3]='+'
778-
# markers[4]='x'
779-
#
780-
# fig, ax1 = plt.subplots()
781-
# ax1_y = ax1.twinx()
782-
# ax1_x = ax1.twiny()
783-
# if convert_erg:
784-
# ax1.set_ylim(ymin=yaxis_min,ymax=yaxis_max*1.8)
785-
# else:
786-
# ax1.set_ylim(ymin=yaxis_min,ymax=yaxis_max)
787-
# ax1_y.set_ylim(ymin=yaxis_min,ymax=yaxis_max)
788-
#
789-
# c = 0
790-
# for key, fData in fDataDict.items():
791-
# print('Plotting %s (%d data points)' % (key, len(fData)))
792-
#
793-
# # scale all data by 1.e-12
794-
# # (scale is added to the legend text)
795-
# y = np.asarray(fData['flux']) / 1.e-12
796-
# y_err = np.asarray(fData['flux_err']) / 1.e-12
797-
#
798-
# if key in fColorDict:
799-
# c = fColorDict[key]
800-
#
801-
# if len(y) == 0:
802-
# c += 1
803-
# continue
804-
#
805-
# # left labelled data
806-
# if "VERITAS" in key or \
807-
# "HESS" in key or \
808-
# "MAGIC" in key:
809-
# ln1 = ax1.errorbar(
810-
# fData['MJD'],
811-
# y,
812-
# y_err,
813-
# fData['MJD_err'],
814-
# color=colors[c],
815-
# marker=markers[c],
816-
# label=key,
817-
# linestyle='none',
818-
# fillstyle='full',
819-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
820-
# markersize=lightCurvePlottingUtilities.getMarkerSize())
821-
# ax1_y.plot(np.nan, '-r',
822-
# color=colors[c], marker=markers[c], label=key,
823-
# linestyle='none', fillstyle='full',
824-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
825-
# markersize=lightCurvePlottingUtilities.getMarkerSize())
826-
# # right labelled data
827-
# else:
828-
# pLabel=key
829-
# if key.find('XRT')>=0:
830-
# pLabel="$\it{Swift}$-XRT"
831-
# ln2 = ax1_y.errorbar(
832-
# fData['MJD'],
833-
# y,
834-
# y_err,
835-
# fData['MJD_err'],
836-
# color=colors[c],
837-
# marker=markers[c],
838-
# label=pLabel,
839-
# linestyle='none',
840-
# fillstyle='full',
841-
# linewidth=lightCurvePlottingUtilities.getLineWidth(),
842-
# markersize=lightCurvePlottingUtilities.getMarkerSize())
843-
# c += 1
844-
#
845-
# ax1.axis(xmin=mjd_min,xmax=mjd_max)
846-
# ax1.locator_params(axis='x', tight=True, nbins=4)
847-
# ax1.set_xlabel('Modified Julian Day (MJD)')
848-
# # left label: assume always gamma rays
849-
# ax1.set_ylabel(lightCurvePlottingUtilities.getFluxAxisString("VERITAS",
850-
# None,
851-
# "10$^{-12} \\times$",
852-
# convert_erg))
853-
#
854-
# if plot_title:
855-
# ty=0.9*yaxis_max
856-
# if convert_erg:
857-
# ty*=1.8
858-
# ax1.text(
859-
# mjd_min+0.75*(mjd_max-mjd_min),
860-
# ty,
861-
# plot_title,
862-
# fontsize=10,
863-
# weight='bold',
864-
# )
865-
#
866-
# # right label: assume always X-rays
867-
# if 'Swift XRT' in fDataDict or 'NuSTAR' in fDataDict:
868-
# ax1_y.set_ylabel(lightCurvePlottingUtilities.getFluxAxisString(
869-
# "Swift XRT", None, "10$^{-12} \\times$"))
870-
#
871-
# ax1_y.legend(loc=2)
872-
# if yaxis_min < 0.:
873-
# plt.axhline(y=0, linestyle=':')
874-
# lightCurvePlottingUtilities.align_yaxis(ax1, 0, ax1_y, 0)
875-
#
876-
# # orbital phase axis
877-
# # (note: use default orbital period here
878-
# # as defined in lightCurveAnalysisorbital_period
879-
# phase_ticks = []
880-
# label_format = '%.2f'
881-
# for t in ax1_x.get_xticks():
882-
# mjd=mjd_min+t*(mjd_max-mjd_min)
883-
# phase_ticks.append(label_format % (
884-
# lightCurveAnalysisorbital_period.getOrbitalPhase(mjd),))
885-
# # remove first and last label from plotting
886-
# if len(phase_ticks)>0:
887-
# phase_ticks[0]=None
888-
# phase_ticks[-1]=None
889-
# ax1_x.set_xticklabels(phase_ticks)
890-
# ax1_x.set_xlabel('orbital phase')
891-
#
892-
# lightCurvePlottingUtilities.printFigure('XG-HESSJ0632p057-LC')
893-
#

0 commit comments

Comments
 (0)