function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def create_fitted_threshold_hists(self): return self._create_fitted_threshold_hists
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_fitted_threshold_hists(self, value): self._create_fitted_threshold_hists = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def correct_corrupted_data(self): return self._correct_corrupted_data
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def correct_corrupted_data(self, value): self._correct_corrupted_data = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_error_hist(self): return self._create_error_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_error_hist(self, value): self._create_error_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_trigger_error_hist(self): return self._create_trigger_error_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_trigger_error_hist(self, value): self._create_trigger_error_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_service_record_hist(self): return self._create_service_record_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_service_record_hist(self, value): self._create_service_record_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_tdc_counter_hist(self): return self._create_tdc_counter_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_tdc_counter_hist(self, value): self._create_tdc_counter_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_meta_event_index(self): return self._create_meta_event_index
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_meta_event_index(self, value): self._create_meta_event_index = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_meta_word_index(self): return self._create_meta_word_index
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_meta_word_index(self, value): self._create_meta_word_index = value self.interpreter.create_meta_data_word_index(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def fei4b(self): return self._fei4b
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def fei4b(self, value): self._fei4b = value self.interpreter.set_FEI4B(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def n_injections(self): """Get the numbers of injections per pixel.""" return self._n_injection
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def n_injections(self, value): """Set the numbers of injections per pixel.""" self._n_injection = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def trig_count(self): """Get the numbers of BCIDs (usually 16) of one event.""" return self._trig_count
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def trig_count(self, value): """Set the numbers of BCIDs (usually 16) of one event.""" self._trig_count = 16 if value == 0 else value self.interpreter.set_trig_count(self._trig_count)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_tot_value(self): """Get maximum ToT value that is considered to be a hit""" return self._max_tot_value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_tot_value(self, value): """Set maximum ToT value that is considered to be a hit""" self._max_tot_value = value self.interpreter.set_max_tot(self._max_tot_value) self.histogram.set_max_tot(self._max_tot_value) self.clusterizer.set_max_hit_charge(self._max_tot_value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_hit_table(self): return self._create_cluster_hit_table
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_hit_table(self, value): self._create_cluster_hit_table = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_table(self): return self._create_cluster_table
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_table(self, value): self._create_cluster_table = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_size_hist(self): return self._create_cluster_size_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_size_hist(self, value): self._create_cluster_size_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_tot_hist(self): return self._create_cluster_tot_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def create_cluster_tot_hist(self, value): self._create_cluster_tot_hist = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def align_at_trigger(self): return self._align_at_trigger
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def align_at_trigger(self, value): self._align_at_trigger = value self.interpreter.align_at_trigger(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def align_at_tdc(self): return self._align_at_tdc
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def align_at_tdc(self, value): self._align_at_tdc = value self.interpreter.align_at_tdc(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def trigger_data_format(self): return self._trigger_data_format
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def trigger_data_format(self, value): self._trigger_data_format = value self.interpreter.set_trigger_data_format(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def use_tdc_trigger_time_stamp(self): return self._use_tdc_trigger_time_stamp
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def use_tdc_trigger_time_stamp(self, value): self._use_tdc_trigger_time_stamp = value self.interpreter.use_tdc_trigger_time_stamp(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_tdc_delay(self): return self._max_tdc_delay
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_tdc_delay(self, value): self._max_tdc_delay = value self.interpreter.set_max_tdc_delay(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_trigger_number(self): return self._max_trigger_number
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def max_trigger_number(self, value): self._max_trigger_number = value self.interpreter.set_max_trigger_number(value)
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def set_stop_mode(self): return self._set_stop_mode
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def set_stop_mode(self, value): self._set_stop_mode = value
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def _create_additional_data(self): logging.info('Creating selected event histograms...') if self._analyzed_data_file is not None and self._create_meta_event_index: meta_data_size = self.meta_data.shape[0] n_event_index = self.interpreter.get_n_meta_data_event() if meta_data_size == n_event_index: if self.interpreter.meta_table_v2: description = data_struct.MetaInfoEventTableV2().columns.copy() else: description = data_struct.MetaInfoEventTable().columns.copy() last_pos = len(description) if self.scan_parameters is not None: # add additional column with the scan parameter for index, scan_par_name in enumerate(self.scan_parameters.dtype.names): dtype, _ = self.scan_parameters.dtype.fields[scan_par_name][:2] description[scan_par_name] = Col.from_dtype(dtype, dflt=0, pos=last_pos + index) meta_data_out_table = self.out_file_h5.create_table(self.out_file_h5.root, name='meta_data', description=description, title='MetaData', filters=self._filter_table) entry = meta_data_out_table.row for i in range(0, n_event_index): if self.interpreter.meta_table_v2: entry['event_number'] = self.meta_event_index[i][0] # event index entry['timestamp_start'] = self.meta_data[i][3] # timestamp entry['timestamp_stop'] = self.meta_data[i][4] # timestamp entry['error_code'] = self.meta_data[i][5] # error code else: entry['event_number'] = self.meta_event_index[i][0] # event index entry['time_stamp'] = self.meta_data[i][3] # time stamp entry['error_code'] = self.meta_data[i][4] # error code if self.scan_parameters is not None: # scan parameter if available for scan_par_name in self.scan_parameters.dtype.names: entry[scan_par_name] = self.scan_parameters[scan_par_name][i] entry.append() self.out_file_h5.flush() if self.scan_parameters is not None: logging.info("Save meta data with scan parameter " + scan_par_name) else: logging.error('Meta data analysis failed') if self._create_service_record_hist: self.service_record_hist = self.interpreter.get_service_records_counters() if self._analyzed_data_file is not None: service_record_hist_table = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistServiceRecord', title='Service Record Histogram', atom=tb.Atom.from_dtype(self.service_record_hist.dtype), shape=self.service_record_hist.shape, filters=self._filter_table) service_record_hist_table[:] = self.service_record_hist if self._create_tdc_counter_hist: self.tdc_counter_hist = self.interpreter.get_tdc_counters() if self._analyzed_data_file is not None: tdc_counter_hist = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistTdcCounter', title='All Tdc word counter values', atom=tb.Atom.from_dtype(self.tdc_counter_hist.dtype), shape=self.tdc_counter_hist.shape, filters=self._filter_table) tdc_counter_hist[:] = self.tdc_counter_hist if self._create_error_hist: self.error_counter_hist = self.interpreter.get_error_counters() if self._analyzed_data_file is not None: error_counter_hist_table = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistErrorCounter', title='Error Counter Histogram', atom=tb.Atom.from_dtype(self.error_counter_hist.dtype), shape=self.error_counter_hist.shape, filters=self._filter_table) error_counter_hist_table[:] = self.error_counter_hist if self._create_trigger_error_hist: self.trigger_error_counter_hist = self.interpreter.get_trigger_error_counters() if self._analyzed_data_file is not None: trigger_error_counter_hist_table = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistTriggerErrorCounter', title='Trigger Error Counter Histogram', atom=tb.Atom.from_dtype(self.trigger_error_counter_hist.dtype), shape=self.trigger_error_counter_hist.shape, filters=self._filter_table) trigger_error_counter_hist_table[:] = self.trigger_error_counter_hist self._create_additional_hit_data() self._create_additional_cluster_data()
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def _create_additional_cluster_data(self, safe_to_file=True): logging.info('Create selected cluster histograms') if self._create_cluster_size_hist: if self._analyzed_data_file is not None and safe_to_file: cluster_size_hist_table = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistClusterSize', title='Cluster Size Histogram', atom=tb.Atom.from_dtype(self._cluster_size_hist.dtype), shape=self._cluster_size_hist.shape, filters=self._filter_table) cluster_size_hist_table[:] = self._cluster_size_hist if self._create_cluster_tot_hist: self._cluster_tot_hist[:, 0] = self._cluster_tot_hist.sum(axis=1) # First bin is the projection of the others if self._analyzed_data_file is not None and safe_to_file: cluster_tot_hist_table = self.out_file_h5.create_carray(self.out_file_h5.root, name='HistClusterTot', title='Cluster Tot Histogram', atom=tb.Atom.from_dtype(self._cluster_tot_hist.dtype), shape=self._cluster_tot_hist.shape, filters=self._filter_table) cluster_tot_hist_table[:] = self._cluster_tot_hist
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def analyze_hits(self, hits, scan_parameter=None): n_hits = hits.shape[0] logging.debug('Analyze %d hits' % n_hits) if scan_parameter is None: # if nothing specified keep actual setting logging.debug('Keep scan parameter settings ') elif not scan_parameter: # set no scan parameter logging.debug('No scan parameter used') self.histogram.set_no_scan_parameter() else: logging.info('Setting a scan parameter') self.histogram.add_scan_parameter(scan_parameter) if self.is_cluster_hits(): logging.debug('Cluster hits') cluster_hits, clusters = self.cluster_hits(hits) else: cluster_hits = None clusters = None if self.is_histogram_hits(): logging.debug('Histogramming hits') self.histogram_hits(hits) return cluster_hits, clusters
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def histogram_hits(self, hits, start_index=None, stop_index=None): self.histogram.add_hits(hits[start_index:stop_index])
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def plot_histograms(self, pdf_filename=None, analyzed_data_file=None, maximum=None, create_hit_hists_only=False): # plots the histogram from output file if available otherwise from ram logging.info('Creating histograms%s', (' (source: %s)' % analyzed_data_file) if analyzed_data_file is not None else (' (source: %s)' % self._analyzed_data_file) if self._analyzed_data_file is not None else '') close_analyzed_data_file = False if analyzed_data_file is not None: if self.is_open(self.out_file_h5) and os.path.abspath(analyzed_data_file) == os.path.abspath(self.out_file_h5.filename): out_file_h5 = self.out_file_h5 else: # normalize path analyzed_data_file = os.path.abspath(analyzed_data_file) if os.path.splitext(analyzed_data_file)[1].lower() != ".h5": analyzed_data_file = os.path.splitext(analyzed_data_file)[0] + ".h5" out_file_h5 = tb.open_file(analyzed_data_file, mode="r") close_analyzed_data_file = True elif self.is_open(self.out_file_h5): out_file_h5 = self.out_file_h5 else: logging.info('Parameter "analyzed_data_file" not set. Use histograms from memory.') if pdf_filename is not None: # normalize path pdf_filename = os.path.abspath(pdf_filename) if os.path.splitext(pdf_filename)[1].lower() != ".pdf": output_pdf_filename = os.path.splitext(pdf_filename)[0] + ".pdf" else: output_pdf_filename = pdf_filename # reuse existing PDF file if pdf_filename is not None and os.path.abspath(output_pdf_filename) != self.output_pdf._file.fh.name: logging.info('Opening output PDF file: %s', output_pdf_filename) output_pdf = PdfPages(output_pdf_filename) close_pdf = True else: output_pdf = self.output_pdf close_pdf = False if output_pdf is None: raise ValueError('Parameter "pdf_filename" not specified.') logging.info('Saving histograms to PDF file: %s', str(output_pdf._file.fh.name)) if self._create_threshold_hists: if self._create_threshold_mask: # mask pixel with bad data for plotting if out_file_h5 is not None: self.threshold_mask = analysis_utils.generate_threshold_mask(out_file_h5.root.HistNoise[:]) else: self.threshold_mask = analysis_utils.generate_threshold_mask(self.noise_hist) else: self.threshold_mask = np.zeros_like(out_file_h5.root.HistThreshold[:] if out_file_h5 is not None else self.threshold_hist, dtype=np.bool) threshold_hist = np.ma.array(out_file_h5.root.HistThreshold[:] if out_file_h5 is not None else self.threshold_hist, mask=self.threshold_mask) noise_hist = np.ma.array(out_file_h5.root.HistNoise[:] if out_file_h5 is not None else self.noise_hist, mask=self.threshold_mask) mask_cnt = np.ma.count_masked(noise_hist) logging.info('Fast algorithm: masking %d pixel(s)', mask_cnt) plotting.plot_three_way(hist=threshold_hist, title='Threshold%s' % ((' (masked %i pixel(s))' % mask_cnt) if self._create_threshold_mask else ''), x_axis_title="threshold [PlsrDAC]", filename=output_pdf, bins=100, minimum=0, maximum=maximum) plotting.plot_three_way(hist=noise_hist, title='Noise%s' % ((' (masked %i pixel(s))' % mask_cnt) if self._create_threshold_mask else ''), x_axis_title="noise [PlsrDAC]", filename=output_pdf, bins=100, minimum=0, maximum=maximum) if self._create_fitted_threshold_hists: if self._create_fitted_threshold_mask: if out_file_h5 is not None: self.fitted_threshold_mask = analysis_utils.generate_threshold_mask(out_file_h5.root.HistNoiseFitted[:]) else: self.fitted_threshold_mask = analysis_utils.generate_threshold_mask(self.scurve_fit_results[:, :, 1]) else: self.threshold_mask = np.zeros_like(out_file_h5.root.HistThresholdFitted[:] if out_file_h5 is not None else self.scurve_fit_results, dtype=np.bool8) threshold_hist = np.ma.array(out_file_h5.root.HistThresholdFitted[:] if out_file_h5 is not None else self.scurve_fit_results[:, :, 0], mask=self.fitted_threshold_mask) noise_hist = np.ma.array(out_file_h5.root.HistNoiseFitted[:] if out_file_h5 is not None else self.scurve_fit_results[:, :, 1], mask=self.fitted_threshold_mask) threshold_hist_calib = np.ma.array(out_file_h5.root.HistThresholdFittedCalib[:] if out_file_h5 is not None else self.threshold_hist_calib[:], mask=self.fitted_threshold_mask) noise_hist_calib = np.ma.array(out_file_h5.root.HistNoiseFittedCalib[:] if out_file_h5 is not None else self.noise_hist_calib[:], mask=self.fitted_threshold_mask) mask_cnt = np.ma.count_masked(noise_hist) logging.info('S-curve fit: masking %d pixel(s)', mask_cnt) plotting.plot_three_way(hist=threshold_hist, title='Threshold (S-curve fit, masked %i pixel(s))' % mask_cnt, x_axis_title="Threshold [PlsrDAC]", filename=output_pdf, bins=100, minimum=0, maximum=maximum) plotting.plot_three_way(hist=noise_hist, title='Noise (S-curve fit, masked %i pixel(s))' % mask_cnt, x_axis_title="Noise [PlsrDAC]", filename=output_pdf, bins=100, minimum=0, maximum=maximum) plotting.plot_three_way(hist=threshold_hist_calib, title='Threshold (S-curve fit, masked %i pixel(s))' % mask_cnt, x_axis_title="Threshold [e]", filename=output_pdf, bins=100, minimum=0) plotting.plot_three_way(hist=noise_hist_calib, title='Noise (S-curve fit, masked %i pixel(s))' % mask_cnt, x_axis_title="Noise [e]", filename=output_pdf, bins=100, minimum=0) if self._create_occupancy_hist: if self._create_fitted_threshold_hists: _, scan_parameters_idx = np.unique(self.scan_parameters['PlsrDAC'], return_index=True) scan_parameters = self.scan_parameters['PlsrDAC'][np.sort(scan_parameters_idx)] plotting.plot_scurves(occupancy_hist=out_file_h5.root.HistOcc[:] if out_file_h5 is not None else self.occupancy_array[:], filename=output_pdf, scan_parameters=scan_parameters, scan_parameter_name="PlsrDAC") else: hist = np.sum(out_file_h5.root.HistOcc[:], axis=2) if out_file_h5 is not None else np.sum(self.occupancy_array[:], axis=2) occupancy_array_masked = np.ma.masked_equal(hist, 0) if self._create_source_scan_hist: plotting.plot_fancy_occupancy(hist=occupancy_array_masked, filename=output_pdf, z_max='median') plotting.plot_occupancy(hist=occupancy_array_masked, filename=output_pdf, z_max='maximum') else: plotting.plot_three_way(hist=occupancy_array_masked, title="Occupancy", x_axis_title="occupancy", filename=output_pdf, maximum=maximum) plotting.plot_occupancy(hist=occupancy_array_masked, filename=output_pdf, z_max='median') if self._create_tot_hist: plotting.plot_tot(hist=out_file_h5.root.HistTot[:] if out_file_h5 is not None else self.tot_hist, filename=output_pdf) if self._create_tot_pixel_hist: tot_pixel_hist = out_file_h5.root.HistTotPixel[:] if out_file_h5 is not None else self.tot_pixel_hist_array total_hits_masked = np.ma.masked_equal(np.sum(tot_pixel_hist, axis=2), 0) mean_pixel_tot = np.average(tot_pixel_hist, axis=2, weights=range(16)) * sum(range(0, 16)) / total_hits_masked plotting.plot_three_way(mean_pixel_tot, title='Mean ToT', x_axis_title='mean ToT', filename=output_pdf, minimum=0, maximum=15) if self._create_tdc_counter_hist: plotting.plot_tdc_counter(hist=out_file_h5.root.HistTdcCounter[:] if out_file_h5 is not None else self.tdc_hist_counter, filename=output_pdf) if self._create_tdc_hist: plotting.plot_tdc(hist=out_file_h5.root.HistTdc[:] if out_file_h5 is not None else self.tdc_hist, filename=output_pdf) if self._create_cluster_size_hist: plotting.plot_cluster_size(hist=out_file_h5.root.HistClusterSize[:] if out_file_h5 is not None else self.cluster_size_hist, filename=output_pdf) if self._create_cluster_tot_hist: plotting.plot_cluster_tot(hist=out_file_h5.root.HistClusterTot[:] if out_file_h5 is not None else self.cluster_tot_hist, filename=output_pdf) if self._create_cluster_tot_hist and self._create_cluster_size_hist: plotting.plot_cluster_tot_size(hist=out_file_h5.root.HistClusterTot[:] if out_file_h5 is not None else self.cluster_tot_hist, filename=output_pdf) if self._create_rel_bcid_hist: if self.set_stop_mode: plotting.plot_relative_bcid_stop_mode(hist=out_file_h5.root.HistRelBcid[:] if out_file_h5 is not None else self.rel_bcid_hist, filename=output_pdf) else: plotting.plot_relative_bcid(hist=out_file_h5.root.HistRelBcid[0:16] if out_file_h5 is not None else self.rel_bcid_hist[0:16], filename=output_pdf) if self._create_tdc_pixel_hist: tdc_pixel_hist = out_file_h5.root.HistTdcPixel[:, :, :1024] if out_file_h5 is not None else self.tdc_pixel_hist_array[:, :, :1024] # only take first 1024 values, otherwise memory error likely total_hits_masked = np.ma.masked_equal(np.sum(tdc_pixel_hist, axis=2), 0) mean_pixel_tdc = np.average(tdc_pixel_hist, axis=2, weights=range(1024)) * sum(range(0, 1024)) / total_hits_masked plotting.plot_three_way(mean_pixel_tdc, title='Mean TDC', x_axis_title='mean TDC', maximum=2 * np.ma.median(np.ma.masked_invalid(mean_pixel_tdc)), filename=output_pdf) if not create_hit_hists_only: if analyzed_data_file is None and self._create_error_hist: plotting.plot_event_errors(hist=out_file_h5.root.HistErrorCounter[:] if out_file_h5 is not None else self.error_counter_hist, filename=output_pdf) if analyzed_data_file is None and self._create_service_record_hist: plotting.plot_service_records(hist=out_file_h5.root.HistServiceRecord[:] if out_file_h5 is not None else self.service_record_hist, filename=output_pdf) if analyzed_data_file is None and self._create_trigger_error_hist: plotting.plot_trigger_errors(hist=out_file_h5.root.HistTriggerErrorCounter[:] if out_file_h5 is not None else self.trigger_error_counter_hist, filename=output_pdf) if close_analyzed_data_file: out_file_h5.close() if close_pdf: logging.info('Closing output PDF file: %s', str(output_pdf._file.fh.name)) output_pdf.close()
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def is_open(self, h5_file): if isinstance(h5_file, tb.file.File): return True return False
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def is_cluster_hits(self): # returns true if a setting needs to have the clusterizer active if self.create_cluster_hit_table or self.create_cluster_table or self.create_cluster_size_hist or self.create_cluster_tot_hist: return True return False
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def _get_plsr_dac_charge(self, plsr_dac_array, no_offset=False): '''Takes the PlsrDAC calibration and the stored C-high/C-low mask to calculate the charge from the PlsrDAC array on a pixel basis ''' charge = np.zeros_like(self.c_low_mask, dtype=np.float16) # charge in electrons if self.vcal_c0 is not None and self.vcal_c1 is not None and self.c_low is not None and self.c_mid is not None and self.c_high is not None: voltage = self.vcal_c1 * plsr_dac_array if no_offset else self.vcal_c0 + self.vcal_c1 * plsr_dac_array charge[np.logical_and(self.c_low_mask, ~self.c_high_mask)] = voltage[np.logical_and(self.c_low_mask, ~self.c_high_mask)] * self.c_low / 0.16022 charge[np.logical_and(~self.c_low_mask, self.c_high_mask)] = voltage[np.logical_and(self.c_low_mask, ~self.c_high_mask)] * self.c_mid / 0.16022 charge[np.logical_and(self.c_low_mask, self.c_high_mask)] = voltage[np.logical_and(self.c_low_mask, ~self.c_high_mask)] * self.c_high / 0.16022 return charge
SiLab-Bonn/pyBAR
[ 9, 17, 9, 3, 1422005052 ]
def setupUi(self, highlowDialog): highlowDialog.setObjectName("highlowDialog") highlowDialog.resize(352, 128) self.buttonBox = QtGui.QDialogButtonBox(highlowDialog) self.buttonBox.setGeometry(QtCore.QRect(0, 70, 341, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.lowSpinBox = QtGui.QDoubleSpinBox(highlowDialog) self.lowSpinBox.setGeometry(QtCore.QRect(20, 40, 62, 22)) self.lowSpinBox.setMinimum(-1000000.0) self.lowSpinBox.setMaximum(1000000.0) self.lowSpinBox.setObjectName("lowSpinBox") self.highSpinBox = QtGui.QDoubleSpinBox(highlowDialog) self.highSpinBox.setGeometry(QtCore.QRect(100, 40, 62, 20)) self.highSpinBox.setMinimum(-1000000.0) self.highSpinBox.setMaximum(1000000.0) self.highSpinBox.setObjectName("highSpinBox") self.label = QtGui.QLabel(highlowDialog) self.label.setGeometry(QtCore.QRect(20, 20, 71, 16)) self.label.setObjectName("label") self.label_2 = QtGui.QLabel(highlowDialog) self.label_2.setGeometry(QtCore.QRect(100, 20, 76, 16)) self.label_2.setObjectName("label_2") self.retranslateUi(highlowDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), highlowDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), highlowDialog.reject) QtCore.QMetaObject.connectSlotsByName(highlowDialog)
johnmgregoire/vanDover_CHESS
[ 4, 2, 4, 2, 1277070865 ]
def add_pinpoint_gateway_fee_for_migration(apps, schema_editor): bootstrap_pinpoint_gateway(apps)
dimagi/commcare-hq
[ 465, 201, 465, 202, 1247158807 ]
def __init__( self, store: Union[Store, str] = "default", identifier: Optional[Union[IdentifiedNode, str]] = None, namespace_manager: Optional[NamespaceManager] = None, base: Optional[str] = None,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def store(self): return self.__store
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def identifier(self): return self.__identifier
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def namespace_manager(self): """ this graph's namespace-manager """ if self.__namespace_manager is None: self.__namespace_manager = NamespaceManager(self) return self.__namespace_manager
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def namespace_manager(self, nm): self.__namespace_manager = nm
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __str__(self): if isinstance(self.identifier, URIRef): return ( "%s a rdfg:Graph;rdflib:storage " + "[a rdflib:Store;rdfs:label '%s']." ) % (self.identifier.n3(), self.store.__class__.__name__) else: return ( "[a rdfg:Graph;rdflib:storage " + "[a rdflib:Store;rdfs:label '%s']]." ) % self.store.__class__.__name__
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def destroy(self, configuration): """Destroy the store identified by `configuration` if supported""" self.__store.destroy(configuration) return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def commit(self): """Commits active transactions""" self.__store.commit() return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def open(self, configuration, create=False): """Open the graph store Might be necessary for stores that require opening a connection to a database or acquiring some resource. """ return self.__store.open(configuration, create)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def add(self, triple: Tuple[Node, Node, Node]): """Add a triple with self as context""" s, p, o = triple assert isinstance(s, Node), "Subject %s must be an rdflib term" % (s,) assert isinstance(p, Node), "Predicate %s must be an rdflib term" % (p,) assert isinstance(o, Node), "Object %s must be an rdflib term" % (o,) self.__store.add((s, p, o), self, quoted=False) return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def remove(self, triple): """Remove a triple from the graph If the triple does not provide a context attribute, removes the triple from all contexts. """ self.__store.remove(triple, context=self) return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def triples( self, triple: Tuple[ Optional[IdentifiedNode], Optional[IdentifiedNode], Optional[Node] ],
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def triples( self, triple: Tuple[Optional[IdentifiedNode], Path, Optional[Node]],
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def triples( self, triple: Tuple[ Optional[IdentifiedNode], Union[None, Path, IdentifiedNode], Optional[Node] ],
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def triples( self, triple: Tuple[ Optional[IdentifiedNode], Union[None, Path, IdentifiedNode], Optional[Node] ],
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __getitem__(self, item): """ A graph can be "sliced" as a shortcut for the triples method The python slice syntax is (ab)used for specifying triples. A generator over matches is returned, the returned tuples include only the parts not given >>> import rdflib >>> g = rdflib.Graph() >>> g.add((rdflib.URIRef("urn:bob"), namespace.RDFS.label, rdflib.Literal("Bob"))) # doctest: +ELLIPSIS <Graph identifier=... (<class 'rdflib.graph.Graph'>)> >>> list(g[rdflib.URIRef("urn:bob")]) # all triples about bob [(rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.Literal('Bob'))] >>> list(g[:namespace.RDFS.label]) # all label triples [(rdflib.term.URIRef('urn:bob'), rdflib.term.Literal('Bob'))] >>> list(g[::rdflib.Literal("Bob")]) # all triples with bob as object [(rdflib.term.URIRef('urn:bob'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label'))] Combined with SPARQL paths, more complex queries can be written concisely: Name of all Bobs friends: g[bob : FOAF.knows/FOAF.name ] Some label for Bob: g[bob : DC.title|FOAF.name|RDFS.label] All friends and friends of friends of Bob g[bob : FOAF.knows * "+"] etc. .. versionadded:: 4.0 """ if isinstance(item, slice): s, p, o = item.start, item.stop, item.step if s is None and p is None and o is None: return self.triples((s, p, o)) elif s is None and p is None: return self.subject_predicates(o) elif s is None and o is None: return self.subject_objects(p) elif p is None and o is None: return self.predicate_objects(s) elif s is None: return self.subjects(p, o) elif p is None: return self.predicates(s, o) elif o is None: return self.objects(s, p) else: # all given return (s, p, o) in self elif isinstance(item, (Path, Node)): return self.predicate_objects(item) else: raise TypeError( "You can only index a graph by a single rdflib term or path, or a slice of rdflib terms." )
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __iter__(self): """Iterates over all triples in the store""" return self.triples((None, None, None))
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __hash__(self): return hash(self.identifier)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __eq__(self, other): return isinstance(other, Graph) and self.identifier == other.identifier
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __le__(self, other): return self < other or self == other
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __ge__(self, other): return self > other or self == other
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __isub__(self, other): """Subtract all triples in Graph other from Graph. BNode IDs are not changed.""" for triple in other: self.remove(triple) return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __mul__(self, other): """Set-theoretic intersection. BNode IDs are not changed.""" try: retval = type(self)() except TypeError: retval = Graph() for x in other: if x in self: retval.add(x) return retval
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def __xor__(self, other): """Set-theoretic XOR. BNode IDs are not changed.""" return (self - other) + (other - self)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def set(self, triple): """Convenience method to update the value of object Remove any existing triples for subject and predicate before adding (subject, predicate, object). """ (subject, predicate, object_) = triple assert ( subject is not None ), "s can't be None in .set([s,p,o]), as it would remove (*, p, *)" assert ( predicate is not None ), "p can't be None in .set([s,p,o]), as it would remove (s, *, *)" self.remove((subject, predicate, None)) self.add((subject, predicate, object_)) return self
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def predicates( self, subject: Optional[IdentifiedNode] = None, object: Optional[Node] = None, unique: bool = False,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def objects( self, subject: Optional[IdentifiedNode] = None, predicate: Union[None, Path, IdentifiedNode] = None, unique: bool = False,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def subject_predicates( self, object: Optional[Node] = None, unique: bool = False
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def subject_objects( self, predicate: Union[None, Path, IdentifiedNode] = None, unique: bool = False
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def predicate_objects( self, subject: Optional[IdentifiedNode] = None, unique: bool = False
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def triples_choices(self, triple, context=None): subject, predicate, object_ = triple for (s, p, o), cg in self.store.triples_choices( (subject, predicate, object_), context=self ): yield s, p, o
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def items(self, list): """Generator over all items in the resource specified by list list is an RDF collection. """ chain = set([list]) while list: item = self.value(list, RDF.first) if item is not None: yield item list = self.value(list, RDF.rest) if list in chain: raise ValueError("List contains a recursive rdf:rest reference") chain.add(list)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def transitive_objects(self, subject, predicate, remember=None): """Transitively generate objects for the ``predicate`` relationship Generated objects belong to the depth first transitive closure of the ``predicate`` relationship starting at ``subject``. """ if remember is None: remember = {} if subject in remember: return remember[subject] = 1 yield subject for object in self.objects(subject, predicate): for o in self.transitive_objects(object, predicate, remember): yield o
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def qname(self, uri): return self.namespace_manager.qname(uri)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def bind(self, prefix, namespace, override=True, replace=False) -> None: """Bind prefix to namespace If override is True will bind namespace to given prefix even if namespace was already bound to a different prefix. if replace, replace any existing prefix with the new namespace for example: graph.bind("foaf", "http://xmlns.com/foaf/0.1/") """ return self.namespace_manager.bind( prefix, namespace, override=override, replace=replace )
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def absolutize(self, uri, defrag=1): """Turn uri into an absolute URI if it's not one already""" return self.namespace_manager.absolutize(uri, defrag)
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: None, format: str, base: Optional[str], encoding: str, **args
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: None = ..., format: str = ..., base: Optional[str] = ..., *, encoding: str, **args,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: None = ..., format: str = ..., base: Optional[str] = ..., encoding: None = ..., **args,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: Union[str, pathlib.PurePath, IO[bytes]], format: str = ..., base: Optional[str] = ..., encoding: Optional[str] = ..., **args,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: Optional[Union[str, pathlib.PurePath, IO[bytes]]] = ..., format: str = ..., base: Optional[str] = ..., encoding: Optional[str] = ..., **args,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def serialize( self, destination: Optional[Union[str, pathlib.PurePath, IO[bytes]]] = None, format: str = "turtle", base: Optional[str] = None, encoding: Optional[str] = None, **args: Any,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def print(self, format="turtle", encoding="utf-8", out=None): print( self.serialize(None, format=format, encoding=encoding).decode(encoding), file=out, flush=True, )
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]
def query( self, query_object, processor: Union[str, query.Processor] = "sparql", result: Union[str, Type[query.Result]] = "sparql", initNs=None, initBindings=None, use_store_provided: bool = True, **kwargs,
RDFLib/rdflib
[ 1851, 516, 1851, 221, 1328248153 ]