def main(): input_path = get_data("spe_spectrum_comparison/mc_lab.h5") output_path = get_plot("d190624_icrc/mc_lab.pdf") process(input_path, output_path) input_path = get_data("spe_spectrum_comparison/checm_checs.h5") output_path = get_plot("d190624_icrc/checm_checs.pdf") process(input_path, output_path)
def main(): # sql = ASTRISQLQuerier() # start = pd.Timestamp("2019-04-29 00:00") # end = pd.Timestamp("2019-05-13 00:00") # ra = sql.get_table_between_datetimes("TCU_ACTUAL_RA", start, end) # dec = sql.get_table_between_datetimes("TCU_ACTUAL_DEC", start, end) # alt = sql.get_table_between_datetimes("TCU_ELACTPOS", start, end) # az = sql.get_table_between_datetimes("TCU_AZACTPOS", start, end) path = get_astri_2019("astri_db.h5") with HDF5Reader(path) as reader: ra = reader.read("TCU_ACTUAL_RA") dec = reader.read("TCU_ACTUAL_DEC") alt = reader.read("TCU_ELACTPOS") az = reader.read("TCU_AZACTPOS") df = pd.merge(pd.merge( ra, dec, on='timestamp').rename(columns=dict(value_x="ra", value_y="dec")), pd.merge(alt, az, on='timestamp').rename( columns=dict(value_x="alt", value_y="az")), on='timestamp') location = EarthLocation.from_geodetic(lon=14.974609, lat=37.693267, height=1750) altaz_frame = AltAz(location=location, obstime=df['timestamp']) telescope_pointing = SkyCoord( alt=df['alt'].values, az=df['az'].values, unit='deg', frame=altaz_frame, ) telescope_pointing_icrs = telescope_pointing.icrs df['ra_calc'] = telescope_pointing_icrs.ra.deg df['dec_calc'] = telescope_pointing_icrs.dec.deg d_ra = np.arctan2(np.sin(df['ra'] - df['ra_calc']), np.cos(df['ra'] - df['ra_calc'])) d_dec = np.arctan2(np.sin(df['dec'] - df['dec_calc']), np.cos(df['dec'] - df['dec_calc'])) p = Plotter() p.ax.plot(df['timestamp'], d_ra) p.ax.set_xlabel("Timestamp") p.ax.set_ylabel("RA_database - RA_calculated (deg)") p.fig.autofmt_xdate() p.save(get_plot("d190527_astri_sql/ra.pdf")) p = Plotter() p.ax.plot(df['timestamp'], d_dec) p.ax.set_xlabel("Timestamp") p.ax.set_ylabel("DEC_database - DEC_calculated (deg)") p.fig.autofmt_xdate() p.save(get_plot("d190527_astri_sql/dec.pdf"))
def main(): # path = get_data("d191018_alpha/d2019-05-15_simulations_gamma1deg_onoff.h5") # output = get_plot("d191018_alpha/optimise_alpha_cut/d2019-05-15_simulations_gamma1deg_onoff_nocut.pdf") # title = "ON/OFF MC (1deg) (No cuts)" # process(path, output, title, None) # output = get_plot("d191018_alpha/optimise_alpha_cut/d2019-05-15_simulations_gamma1deg_onoff_softcut.pdf") # title = "ON/OFF MC (1deg) (Soft cuts)" # process(path, output, title, CUTS_ONOFF_SOFT) # output = get_plot("d191018_alpha/optimise_alpha_cut/d2019-05-15_simulations_gamma1deg_onoff_harshcut.pdf") # title = "ON/OFF MC (1deg) (Harsh cuts)" # process(path, output, title, CUTS_ONOFF_HARSH) # # path = get_data("d191018_alpha/d2019-05-15_simulations_gamma1deg_wobble.h5") # output = get_plot("d191018_alpha/optimise_alpha_cut/d2019-05-15_simulations_gamma1deg_wobble_nocut.pdf") # title = "Wobble MC (1deg) (No cuts)" # process(path, output, title, None) # output = get_plot("d191018_alpha/optimise_alpha_cut/d2019-05-15_simulations_gamma1deg_wobble_cut.pdf") # title = "Wobble MC (1deg)" # process(path, output, title, CUTS_WOBBLE) path = get_data( "d191018_alpha/extract_alpha_mc/d2019-10-03_simulations_gamma1deg_onoff.h5" ) output = get_plot( "d191018_alpha/optimise_alpha_cut/d2019-10-03_simulations_gamma1deg_onoff_nocut.pdf" ) title = "ON/OFF MC (1deg) (No cuts)" process(path, output, title, None) output = get_plot( "d191018_alpha/optimise_alpha_cut/d2019-10-03_simulations_gamma1deg_onoff_softcut.pdf" ) title = "ON/OFF MC (1deg) (Soft cuts)" process(path, output, title, CUTS_ONOFF_SOFT) output = get_plot( "d191018_alpha/optimise_alpha_cut/d2019-10-03_simulations_gamma1deg_onoff_harshcut.pdf" ) title = "ON/OFF MC (1deg) (Harsh cuts)" process(path, output, title, CUTS_ONOFF_HARSH) path = get_data( "d191018_alpha/extract_alpha_mc/d2019-10-03_simulations_gamma1deg_wobble.h5" ) output = get_plot( "d191018_alpha/optimise_alpha_cut/d2019-10-03_simulations_gamma1deg_wobble_nocut.pdf" ) title = "Wobble MC (1deg) (No cuts)" process(path, output, title, None) output = get_plot( "d191018_alpha/optimise_alpha_cut/d2019-10-03_simulations_gamma1deg_wobble_cut.pdf" ) title = "Wobble MC (1deg)" process(path, output, title, CUTS_WOBBLE)
def main(): path = get_data( "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma1deg_onoff.h5" ) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_onoff_nocut.pdf") title = "ON/OFF MC (1deg) (No cuts)" process(path, output, title, None) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_onoff_softcut.pdf") title = "ON/OFF MC (1deg) (Soft cuts)" process(path, output, title, CUTS_ONOFF_SOFT) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_onoff_harshcut.pdf" ) title = "ON/OFF MC (1deg) (Harsh cuts)" process(path, output, title, CUTS_ONOFF_HARSH) path = get_data( "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma1deg_wobble.h5" ) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_wobble_nocut.pdf") title = "Wobble MC (1deg) (No cuts)" process(path, output, title, None) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_wobble_cut.pdf") title = "Wobble MC (1deg)" process(path, output, title, CUTS_WOBBLE) path = get_data( "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gamma1deg_5off_wobble.h5" ) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_5off_wobble_nocut.pdf" ) title = "Wobble MC (1deg) (5 OFF) (No cuts)" process(path, output, title, None) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gamma1deg_5off_wobble_cut.pdf" ) title = "Wobble MC (1deg) (5 OFF)" process(path, output, title, CUTS_WOBBLE) path = get_data( "d190918_alpha/extract_alpha_mc/d2019-05-15_simulations_gammaonly_wobble.h5" ) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gammaonly_wobble_nocut.pdf") title = "Wobble MC (1deg) (No cuts)" process(path, output, title, None) output = get_plot( "d190918_alpha/mc/d2019-05-15_simulations_gammaonly_wobble_cut.pdf") title = "Wobble MC (1deg)" process(path, output, title, CUTS_WOBBLE)
def main(): paths = dict( self=get_data( "d191118_pedestal_temperature/d191118/residuals_self.h5"), single_31degree=get_data( "d191118_pedestal_temperature/d191118/residuals_single_30.h5"), lookup=get_data( "d191118_pedestal_temperature/d191118/residuals_lookup.h5"), interp=get_data( "d191118_pedestal_temperature/d191118/residuals_interp.h5"), pchip=get_data( "d191118_pedestal_temperature/d191118/residuals_pchip.h5"), ) p_mean = MeanVsTemperature() p_std = StdVsTemperature() p_relstd = RelativeStdVsTemperature() with HDF5Reader(paths['self']) as reader: df = reader.read("data") df = df.set_index("temperature_r0_primary").sort_index() ref_std = df['std'].values for label, path in paths.items(): with HDF5Reader(path) as reader: df = reader.read("data") df = df.set_index("temperature_r0_primary").sort_index() temperature = df.index.values mean = df['mean'].values std = df['std'].values p_mean.plot(temperature, mean, label) p_std.plot(temperature, std, label) p_relstd.plot(temperature, std, ref_std, label) p_mean.save(get_plot(f"d191118_pedestal_temperature/d191118/mean.pdf")) p_std.save(get_plot(f"d191118_pedestal_temperature/d191118/std.pdf")) p_relstd.save( get_plot(f"d191118_pedestal_temperature/d191118/rel_std.pdf")) with HDF5Reader(paths['self']) as reader: df = reader.read("data") df = df.set_index("temperature_r0_chamber").sort_index() chamber = df.index.values primary = df['temperature_r0_primary'].values p_temp = TemperatureComparison() p_temp.plot(chamber, primary) p_temp.save(get_plot(f"d191118_pedestal_temperature/d191118/temp.pdf"))
def main(): input_path = get_data("d191122_dc_tf/vped/VPED_13deg.h5") output_path = get_plot("d191122_dc_tf/vped/VPED_13deg.pdf") process(input_path, output_path) input_path = get_data("d191122_dc_tf/vped/VPED_23deg.h5") output_path = get_plot("d191122_dc_tf/vped/VPED_23deg.pdf") process(input_path, output_path) input_path = get_data("d191122_dc_tf/vped/VPED_33deg.h5") output_path = get_plot("d191122_dc_tf/vped/VPED_33deg.pdf") process(input_path, output_path) input_path = get_data("d191122_dc_tf/vped/VPED_43deg.h5") output_path = get_plot("d191122_dc_tf/vped/VPED_43deg.pdf") process(input_path, output_path) input_path = get_data("d191122_dc_tf/vped/VPED_23deg.h5") output_path = get_plot("d191122_dc_tf/vped/VPED_23deg_sc.pdf") process_single_channel(input_path, 8, output_path) input_paths = [ get_data("d191122_dc_tf/vped/VPED_13deg.h5"), get_data("d191122_dc_tf/vped/VPED_23deg.h5"), get_data("d191122_dc_tf/vped/VPED_33deg.h5"), get_data("d191122_dc_tf/vped/VPED_43deg.h5"), ] output_path = get_plot("d191122_dc_tf/vped/temperature_comparison.pdf") process_different_temps(input_paths, 8, output_path) input_path = get_data("d191122_dc_tf/vped/VPED_23deg.h5") mean_path = get_plot("d191122_dc_tf/vped/VPED_23deg_mean.pdf") std_path = get_plot("d191122_dc_tf/vped/VPED_23deg_std.pdf") process_mean_std(input_path, mean_path, std_path)
def process_file(file): name = file.__class__.__name__ input_path = file.tio_paths[0] output_path = get_plot( "d190111_trigger_stability/{}/disabled_start.pdf".format(name)) hv_path = file.hv_path process(input_path, output_path, hv_path, np.s_[:100]) name = file.__class__.__name__ input_path = file.tio_paths[-1] output_path = get_plot( "d190111_trigger_stability/{}/disabled_end.pdf".format(name)) hv_path = file.hv_path process(input_path, output_path, hv_path, np.s_[-100:])
def main(): path = get_astri_2019("astri_db.h5") with HDF5Reader(path) as reader: ra = reader.read("TCU_ACTUAL_RA") dec = reader.read("TCU_ACTUAL_DEC") alt = reader.read("TCU_ELACTPOS") az = reader.read("TCU_AZACTPOS") df = pd.merge(pd.merge( ra, dec, on='timestamp').rename(columns=dict(value_x="ra", value_y="dec")), pd.merge(alt, az, on='timestamp').rename( columns=dict(value_x="alt", value_y="az")), on='timestamp') df = df.query(" (timestamp > '2019-06-12 18:00')" "&(timestamp < '2019-06-13 05:00')") embed() altaz_frame = AltAz(location=LOCATION, obstime=df['timestamp'].values) telescope_pointing = SkyCoord( alt=df['alt'].values, az=df['az'].values, unit='deg', frame=altaz_frame, ) telescope_pointing_icrs = telescope_pointing.icrs df['ra_calc'] = telescope_pointing_icrs.ra.deg df['dec_calc'] = telescope_pointing_icrs.dec.deg d_ra = np.arctan2(np.sin(df['ra'] - df['ra_calc']), np.cos(df['ra'] - df['ra_calc'])) d_dec = np.arctan2(np.sin(df['dec'] - df['dec_calc']), np.cos(df['dec'] - df['dec_calc'])) p = Plotter() p.ax.plot(df['timestamp'], d_ra) p.ax.set_xlabel("Timestamp") p.ax.set_ylabel("RA_database - RA_calculated (deg)") p.fig.autofmt_xdate() p.save(get_plot("d190918_alpha/pointing/ra.pdf")) p = Plotter() p.ax.plot(df['timestamp'], d_dec) p.ax.set_xlabel("Timestamp") p.ax.set_ylabel("DEC_database - DEC_calculated (deg)") p.fig.autofmt_xdate() p.save(get_plot("d190918_alpha/pointing/dec.pdf"))
def main(): # path = "/Users/Jason/Downloads/tempdata/alpha/mc/gamma_1deg.h5" path = "/Volumes/gct-jason/astri_onsky_archive/d2019-05-15_simulations/gamma_1deg/run1_hillas.h5" with HDF5Reader(path) as reader: df_hillas = reader.read("data") df_source = reader.read("source") mapping = reader.get_mapping() # mapping = get_clp_mapping_from_version("1.1.0") p_image = ImagePlotter(mapping) order = np.argsort(df_source['alpha90']) with PdfPages(get_plot("d190717_alpha/mc_alpha_test.pdf")) as pdf: for index in order: row_hillas = df_hillas.iloc[index] row_source = df_source.iloc[index] cog_x = row_hillas['x'] cog_y = row_hillas['y'] length = row_hillas['length'] width = row_hillas['width'] psi = row_hillas['psi'] src_x = row_source['source_x'] src_y = row_source['source_y'] alpha90 = row_source['alpha90'] p_image.update(cog_x, cog_y, length, width, psi, src_x, src_y) p_image.ax.set_title(np.rad2deg(alpha90)) # pdf.savefig(p_image.fig) plt.pause(0.3)
def plot_dynamic_range(df, nsb, matched_voltage): fig, ax = plt.subplots() df_gb = df.groupby('expected_illumination_pe').agg( ['mean', 'std', 'count']) yerr = df_gb['charge_pe']['std'] / np.sqrt(df_gb['charge_pe']['count']) ax.errorbar(df_gb.index, df_gb['charge_pe']['mean'], fmt='.', yerr=yerr, label="Average") # ax.plot(df_gb.index, df_gb['charge_pe']['mean'], ',', label="Average") # df_c = df.loc[(df['true_illumination_pe'] < 100) & (df['true_illumination_pe'] > 10)] # c = polyfit(df_c['true_illumination_pe'], df_c['charge_pe'], [1]) # ax.plot(df_gb.index, polyval(df_gb.index, c), label="Fit") min_ = df['true_illumination_pe'].min() max_ = df['true_illumination_pe'].max() ax.plot([min_, max_], [min_, max_], label="1-to-1") ax.set_xscale('log') ax.set_yscale('log') ax.set_xlabel("True Illumination (p.e.)") ax.set_ylabel("Measured Charge (p.e.)") ax.set_title(f"{nsb}MHz {matched_voltage}mV") ax.legend(loc='best') output_path = get_plot( f"d201202_tutorial_material/charge_{nsb}MHz_{matched_voltage}mV.pdf") fig.savefig(output_path)
def process(file, fitter_class): name = file.__class__.__name__ input_paths = file.dl1_paths spe_config = file.spe_config poi = file.poi output_dir = get_plot(f"d190313_spectra_fitting/{name}") fitter_class_name = fitter_class.__name__ readers = [DL1Reader(path) for path in input_paths] n_illuminations = len(readers) fitter = fitter_class(n_illuminations, spe_config) charges = [] for reader in readers: pixel, charge = reader.select_columns(['pixel', 'charge_cc']) if poi != -1: charge_p = charge[pixel == poi] else: charge_p = charge charges.append(charge_p) fitter.apply(*charges) fitx = np.linspace(fitter.range[0], fitter.range[1], 1000) p_spe = SPEPlotter() p_spe.plot(fitx, fitter) p_spe.save(os.path.join(output_dir, f"fit_{fitter_class_name}.pdf")) p_spe_table = SPEPlotterTable() p_spe_table.plot(fitx, fitter) p_spe_table.save( os.path.join(output_dir, f"fit_table_{fitter_class_name}.pdf"))
def process_file(file): name = file.__class__.__name__ amplitude_path = get_data("d190117_trigger_stability/{}/amplitudes.h5".format(name)) hv_path = get_data("d190117_trigger_stability/{}/hv.h5".format(name)) output_dir = get_plot("d190117_trigger_stability/amp_vs_hv/{}".format(name)) spoi = file.spoi process(amplitude_path, hv_path, output_dir, spoi)
def main(): path = get_data("d190717_alpha/wobble.h5") with pd.HDFStore(path, mode='r') as store: df = store['data'] mapping = store['mapping'] with warnings.catch_warnings(): warnings.simplefilter('ignore', UserWarning) mapping.metadata = store.get_storer('mapping').attrs.metadata p_camera = CameraMovie(mapping, get_plot("d190717_alpha/wobble_animation/frames")) n_row = df.index.size for _, row in tqdm(df.iterrows(), total=n_row): timestamp = row['timestamp'] x_src = row['x_src'] y_src = row['y_src'] dl1 = row['dl1'] r1 = row['r1'] x_cog = row['x_cog'] y_cog = row['y_cog'] psi = row['psi'] p_camera.set_source_position(x_src, y_src) p_camera.set_image(dl1) # p_camera.set_alpha_line(x_cog, y_cog, psi) p_camera.save_frame()
def process(name, tcal_path): ped_reader = PedestalArrayReader(tcal_path) hits_tcal = np.array(ped_reader.GetHits()) std_tcal = np.array(ped_reader.GetStdDev()) mask = (hits_tcal < 6) | np.isnan(std_tcal) std_tcal = np.ma.masked_array(std_tcal, mask=mask) embed() # std_values = std_tcal.compressed() # std_pix = std_tcal.mean((2, 3)).ravel() std_max_pix = std_tcal.max((2, 3)).ravel() # p_hist = Hist() # p_hist.plot(std_values) # p_hist.save(get_plot(f"d190730_pedestal/plot_from_tcals/hist/{name}.png")) # # p_ci = CameraImage.from_camera_version("1.1.0") # p_ci.image = std_pix # p_ci.add_colorbar() # p_ci.save(get_plot(f"d190730_pedestal/plot_from_tcals/camera/{name}.png")) p_ci = CameraImage.from_camera_version("1.1.0") p_ci.image = std_max_pix p_ci.add_colorbar() p_ci.save( get_plot(f"d190730_pedestal/plot_from_tcals/camera_max/{name}.png"))
def process(input_path, function): pattern = '(.+)(SN\d{4})(.+)' reg_exp = re.search(pattern, input_path) sn = reg_exp[2] name = function.__name__ output_path = get_data("d181027_tf_generation/alter_tf/{}_{}.tcal".format( name, sn)) plot_path = get_plot("d181027_tf_generation/alter_tf/{}_{}.pdf".format( name, sn)) print("Reading TF: {}".format(input_path)) reader = TFArrayReader(input_path) tf = np.array(reader.GetTF()) steps = np.array(reader.GetAdcSteps()) steps, tf = function(steps, tf) print("Writing TF: {}".format(output_path)) rw = CalibReadWriter() rw.WriteTfData(output_path, steps.tolist(), tf, True) reader = TFArrayReader(output_path) tf = np.array(reader.GetTF()) steps = np.array(reader.GetAdcSteps()) p_tf = TFPlot() p_tf.plot(steps, tf) p_tf.save(plot_path)
def main(): paths = dict( self=get_data("d191118_pedestal_temperature/d191118/residuals_self.h5"), single_31degree=get_data("d191118_pedestal_temperature/d191118/residuals_single_30.h5"), lookup=get_data("d191118_pedestal_temperature/d191118/residuals_lookup.h5"), interp=get_data("d191118_pedestal_temperature/d191118/residuals_interp.h5"), pchip=get_data("d191118_pedestal_temperature/d191118/residuals_pchip.h5"), ) p_hist = dict() for label, path in paths.items(): with HDF5Reader(path) as reader: df = reader.read("data") df = df.set_index("temperature_r0_primary").sort_index() for temperature, row in df.iterrows(): hist = row['hist'] edges = row['edges'] mean = row['mean'] std = row['std'] if temperature not in p_hist: p_hist[temperature] = HistPlot() p_hist[temperature].ax.set_title(f"TM Primary Temperature = {temperature:.2f} °C") p_hist[temperature].plot(hist, edges, mean, std, label) for temperature, plot in p_hist.items(): plot.save(get_plot(f"d191118_pedestal_temperature/d191118/hist/T{temperature:.2f}.pdf"))
def main(): paths = [ "/Volumes/gct-jason/astri_onsky_archive/d2019-05-15_simulations/proton/run1_dl1.h5", ] df_list = [] for ipath, path in enumerate(paths): with DL1Reader(path) as reader: n_events = reader.get_metadata()['n_events'] mapping = reader.get_mapping() geom = get_ctapipe_camera_geometry(mapping, plate_scale=37.56e-3) desc = "Looping over events" it = reader.iterate_over_events() for df in tqdm(it, total=n_events, desc=desc): iev = df['iev'].values[0] image = df['photons'].values time = df['pulse_time'].values mask = obtain_cleaning_mask(geom, image, time) if not mask.any(): continue image_m = image[mask] time_m = time[mask] geom_m = geom[mask] try: hillas = hillas_parameters(geom_m, image_m) except HillasParameterizationError: continue # timing_parameters(geom_m, image_m, time_m, hillas) gt0 = image_m > 0 pix_x = geom_m.pix_x[gt0] pix_y = geom_m.pix_y[gt0] peakpos = time_m[gt0] intensity = image_m[gt0] longi, trans = camera_to_shower_coordinates( pix_x, pix_y, hillas.x, hillas.y, hillas.psi) longi = longi.value trans = trans.value # df_list.append(pd.DataFrame(dict( # ipath=ipath, # iev=iev, # longi=longi, # peakpos=peakpos, # ))) p_relation = RelationPlotter() p_relation.plot(longi, peakpos, intensity) p_relation.save( get_plot( f"d190524_time_gradient/relation/i{ipath}_e{iev}.pdf"))
def process_file(file): name = file.__class__.__name__ input_path = get_data( "d181206_pedestal_investigation/cell_info/{}.h5".format(name)) output_path = get_plot( "d181206_pedestal_investigation/cell_adc_vs_position/{}/{}.pdf".format( name, "{}")) process(input_path, output_path)
def main(): with HDF5Reader(get_data("d190730_pedestal/tcal_std.h5")) as r: df = r.read("data").iloc[2:] p_std = ComparisonPlotter() p_std.plot(df['name'].values, df['mean'].values, df['std'].values, df['max'].values) p_std.save(get_plot("d190730_pedestal/tcal_std.pdf"))
def main(): path = get_data(f"d191118_pedestal_temperature/d191118/adc_vs_temperature.h5") with HDF5Reader(path) as reader: df = reader.read("data") df = df.set_index("temperature").sort_index() temperature = df.index.values delta_mean = df['delta_mean'].values delta_std = df['delta_std'].values delta_channel_mean = df['delta_channel_mean'].values delta_channel_std = df['delta_channel_std'].values spead_mean = df['spread_mean'].values spread_std = df['spread_std'].values p_delta = ValueVsTemp() p_delta.plot(temperature, delta_mean, delta_std, "TM") p_delta.plot(temperature, delta_channel_mean, delta_channel_std, "Channel 0") p_delta.save(get_plot(f"d191118_pedestal_temperature/d191118/delta_vs_temp.pdf")) # p_delta = ValueVsTemp() # p_delta.plot(temperature, delta_channel_mean, delta_channel_std) # p_delta.save(get_plot(f"d191118_pedestal_temperature/d191118/delta_channel_vs_temp.pdf")) p_delta = SpreadVsTemp() p_delta.plot(temperature, spead_mean, spread_std) p_delta.save(get_plot(f"d191118_pedestal_temperature/d191118/spread_vs_temp.pdf")) paths = dict( d191118_60hz=get_data("d191118_pedestal_temperature/d191118/adc_vs_temperature.h5"), d191119_600hz=get_data("d191118_pedestal_temperature/d191119/adc_vs_temperature.h5"), d191120_200hz=get_data("d191118_pedestal_temperature/d191120/adc_vs_temperature.h5"), ) p_delta = ValueVsTemp() for label, path in paths.items(): with HDF5Reader(path) as reader: df = reader.read("data") df = df.set_index("temperature").sort_index() temperature = df.index.values delta_mean = df['delta_mean'].values delta_std = df['delta_std'].values p_delta.plot(temperature, delta_mean, delta_std, label) p_delta.save(get_plot(f"d191118_pedestal_temperature/delta_vs_temp_vs_day.pdf"))
def process_file(file): name = file.__class__.__name__ input_path = get_data( "d190104_vped_pedestal_steps/cell_info/{}.h5".format(name)) output_dir = get_plot( "d190104_vped_pedestal_steps/steps_vs_vped/{}".format(name)) coi = 12 process(input_path, output_dir, coi)
def main(): x = np.linspace(-2, 15, 300000, dtype=np.double) y = mapm(x, **kwargs) p = xyPlotter() p.plot(x, y, kwargs) p.ax.set_xlabel("Charge (AU)") p.ax.set_ylabel("Counts") p.save(get_plot("d190209_spectra/hist.pdf"))
def main(): path = "/Volumes/gct-jason/astri_onsky_archive/d2019-10-03_simulations/gamma_1deg/run1_dl1.h5" # path = "/Volumes/gct-jason/astri_onsky_archive/d2019-05-15_simulations/gamma_1deg/run1_dl1_old.h5" reader = DL1Reader(path) df = reader.load_entire_table() image = df.groupby(['pixel']).sum()['photons'] ci = CameraImage.from_mapping(reader.mapping) ci.image = image ci.save(get_plot("d190717_alpha/true_images.pdf"))
def __init__(self, **kwargs): super().__init__(**kwargs) self.dl1_path = "/Volumes/gct-jason/sim_telarray/d180907_illumination_profile/Run43489_dl1.h5" self.illumination_profile_path = get_data( "d181021_charge_resolution/illumination_profile/d180907_MC.h5") self.plot_dir = get_plot( "d181021_charge_resolution/illumination_profile/d180907_MC") self.angular_response_path = get_data( "d181021_charge_resolution/illumination_profile/transmission_pmma_vs_theta_20150422.dat" )
def main(): with HDF5Reader(get_data("d190730_pedestal/ped.h5")) as reader: df = reader.read('data') df = setup_cells(df) std = df.groupby(['fblock', 'fbpisam'])['adc'].std() print(f"Min hits: {count.min()}") p_count = LookupTable() p_count.plot(count, "Counts") p_count.save(get_plot("d190730_pedestal/count.pdf")) p_mean = LookupTable() p_mean.plot(mean, "Mean") p_mean.save(get_plot("d190730_pedestal/mean.pdf")) p_std = LookupTable() p_std.plot(std, "Stddev") p_std.save(get_plot("d190730_pedestal/std.pdf"))
def main(): before_tfs = dict( before_25deg=get_tf( get_data("d191128_pedestal_lab/dc_tf/before_25deg.h5")), before_35deg=get_tf( get_data("d191128_pedestal_lab/dc_tf/before_35deg.h5")), ) after_tfs = dict( c440pF_25deg=get_tf( get_data("d191128_pedestal_lab/dc_tf/after_25deg.h5")), c440pF_25deg_2=get_tf( get_data("d191128_pedestal_lab/dc_tf/after_25deg_3.h5")), c440pF_35deg=get_tf( get_data("d191128_pedestal_lab/dc_tf/after_35deg.h5")), c440pF_35deg_2=get_tf( get_data("d191128_pedestal_lab/dc_tf/after_35deg_3.h5")), ) # after_tfs = dict( # c100pF_25deg=get_tf(get_data("d191128_pedestal_lab/dc_tf/100pF_25deg.h5")), # c100pF_1k_25deg=get_tf(get_data("d191128_pedestal_lab/dc_tf/100pF_1k_25deg.h5")), # c100pF_35deg=get_tf(get_data("d191128_pedestal_lab/dc_tf/100pF_35deg.h5")), # ) # after_tfs = dict( # c200pF_25deg=get_tf(get_data("d191128_pedestal_lab/dc_tf/200pF_25deg.h5")), # c200pF_35deg=get_tf(get_data("d191128_pedestal_lab/dc_tf/200pF_35deg.h5")), # ) channel = 8 cell = 0 title = f"BEFORE Capacitor Change, Channel = {channel}, Cell = {cell}" output_path = get_plot("d191128_pedestal_lab/dc_tf/before.pdf") plot_comparison(before_tfs, channel, cell, title, output_path) output_path = get_plot("d191128_pedestal_lab/dc_tf/ref_before.pdf") plot_comparison_ref(before_tfs, channel, cell, title, output_path) title = f"AFTER Capacitor Change, Channel = {channel}, Cell = {cell}" output_path = get_plot("d191128_pedestal_lab/dc_tf/after.pdf") plot_comparison(after_tfs, channel, cell, title, output_path) output_path = get_plot("d191128_pedestal_lab/dc_tf/ref_after.pdf") plot_comparison_ref(after_tfs, channel, cell, title, output_path) output_path = get_plot("d191128_pedestal_lab/dc_tf/ref_stat_after.pdf") plot_comparison_ref_stat(after_tfs, "", output_path)
def main(): sql = ASTRISQLQuerier() p_uptime = Uptime() start = pd.Timestamp("2019-04-29 00:00") end = pd.Timestamp("2019-05-13 00:00") p_uptime.plot(sql, start, end, None) start = pd.Timestamp("2019-06-10 00:00") end = pd.Timestamp("2019-06-16 00:00") p_uptime.plot(sql, start, end, "ASTRI Pointing Database Uptime") p_uptime.save(get_plot("d191009_astri_db_uptime/campaign_all.pdf"))
def main(): path = get_data("d190507_check_amplitude_calib/data.h5") output_path = get_plot("d190507_check_amplitude_calib/plot.pdf") with HDF5Reader(path) as reader: df = reader.read('data') df = df.sort_values('t_cpu') datetime = df['t_cpu'].values nudge = df['nudge'].values temperature = df['temperature'].values p = Plot() p.plot(datetime, nudge, temperature) p.save(output_path)
def main(): d_list = [] for file in all_files[2:]: adict = np.load(file.reduced_residuals) d_list.append( dict( name=file.name, mean=adict['mean'], std=adict['std'], )) df = pd.DataFrame(d_list) p_std = ComparisonPlotter() p_std.plot(df['name'].values, df['mean'].values, df['std'].values) p_std.save(get_plot("d190730_pedestal/residuals.pdf"))
def plot_charge_resolution(df_cr, poi, nsb, matched_voltage): df = df_cr.loc[df_cr['pixel'] == poi] x = df['true'] y = df['charge_res'] yerr = (1 / np.sqrt(df['n'])) / x cr = ChargeResolutionPlotter() cr._plot(x, y, yerr, label="CR") cr.plot_poisson(x) cr.plot_requirement(x) output_path = get_plot( f"d201202_tutorial_material/cr_{nsb}MHz_{matched_voltage}mV.pdf") cr.save(output_path)