Exemple #1
0
    def resume(self):
        sys.stdout.write("Resuming.")
        self.progress = 'Opening quenches'

        self.qm = quench.QuenchManager()
        self.qm.open_quenches(self.open_quenches, \
                              atten_v = self.initial_atten_vs, \
                              is_on = self.quench_is_on)
        self.qm.cavities_off(self.off_quenches)

        self.progress = 'Opening digitizer'

        self.digi = digitizer.Digitizer(self.run_dictionary \
                                            .ix['Digitizer Address for ' + \
                                                'Power Combiners'].Value,
                                        ch1_range = self.ch_range,
                                        ch2_range = self.ch_range,
                                        sampling_rate = self.sampling_rate,
                                        num_samples = self.num_samples)

        self.progress = 'Opening generator'

        self.gen = generator.Generator(offset_freq = self.offset_freq, \
                                       e_field = self.rf_e_field, \
                                       scan_range = self.rf_scan_range,
                                       calib = True)
        self.gen.set_rf_frequency(910.0, offset_channel = 'A',
                                  change_power = True)

        self.fc = faradaycupclass.FaradayCup()

        self.progress = 'Resume complete'
        super(PhaseMonitor, self).resume()

        return
Exemple #2
0
    def resume(self):
        # Perform any re-initialization actions you want here before
        # communicating with the manager.

        self.progress = 'Resuming'
        self.qm = quench.QuenchManager()
        self.qm.open_quenches(self.open_quenches, \
                              atten_v = self.initial_atten_vs, \
                              is_on = self.quench_is_on)
        self.qm.cavities_off(self.off_quenches)

        self.digi = digitizer.Digitizer(self.run_dictionary \
                                            .ix['Digitizer Address'].Value, \
                                        ch1_range = self.ch_range, \
                                        ch2_range = self.ch_range, \
                                        num_samples = self.num_samples)

        self.gen = generator.Generator(calib=True)
        self.gen.power_low('A')
        self.gen.power_low('B')

        super(QuenchCalibration, self).resume()

        return
Exemple #3
0
    def initialize_acquisition(self):
        # Initialize all global variables here, including the 'progress'
        # variable.

        self.progress = 'Printing data.txt comment header'

        self.comments = qol.make_comment_string(self.run_dictionary, \
                                                self.run_dictionary['Order'] \
                                                    .values)

        data_file = open(self.folder + 'data.txt', 'w')
        data_file.write(self.comments)
        data_file.close()

        self.progress = 'Reading quench parameters'

        self.quench_file = pd.read_csv(
            self.run_dictionary.ix['Quenches'].Value)
        self.quench_file = self.quench_file.set_index('Quench Name')

        self.progress = 'Setting up quenches'

        self.qm = quench.QuenchManager()

        quench_arrays = qol.quench_arrays(self.quench_file)

        self.open_quenches = quench_arrays[0]
        self.quench_is_on = quench_arrays[1]
        self.off_quenches = quench_arrays[2]
        self.initial_atten_vs = quench_arrays[3]
        self.on_quenches = quench_arrays[4]
        self.scan_quench = self.run_dictionary.ix[
            'Quench Cavity to Scan'].Value

        self.progress = 'Opening quenches'

        self.qm.open_quenches(self.open_quenches, \
                              atten_v = self.initial_atten_vs, \
                              is_on = self.quench_is_on)
        self.qm.cavities_off(self.off_quenches)

        self.progress = 'Opening digitizer'

        self.num_samples = int(self.run_dictionary \
                                   .ix['Number of Digitizer Samples'].Value)
        self.sampling_rate = int(self.run_dictionary \
                                     .ix['Digitizer Sampling Rate [S/s]'].Value)
        self.ch_range = int(self.run_dictionary \
                                .ix['Digitizer Channel Range [V]'].Value)
        self.digi = digitizer.Digitizer(self.run_dictionary \
                                            .ix['Digitizer Address'].Value, \
                                        ch1_range = self.ch_range, \
                                        ch2_range = self.ch_range, \
                                        sampling_rate = self.sampling_rate, \
                                        num_samples = self.num_samples)
        self.digi_channel = int(self.run_dictionary.ix['Digitizer Channel ' + \
                                                       'for Detector'].Value)

        self.progress = 'Opening generator'

        self.gen = generator.Generator(calib=True)
        #self.gen.power_low('A')
        #self.gen.power_low('B')

        self.max_rep = int(self.run_dictionary.ix['Number of Repeats'].Value)
        self.max_avg = int(self.run_dictionary.ix['Number of Averages'].Value)

        v_min = float(self.run_dictionary \
                          .ix['RF Attenuator Voltage (Start) [V]'].Value)
        v_max = float(self.run_dictionary \
                          .ix['RF Attenuator Voltage (Stop) [V]'].Value)
        self.n_atten_vs = int(self.run_dictionary \
                                  .ix['Number of Scan Steps'].Value)

        self.atten_v_list = self.linear_sqpower_list(v_min, v_max,
                                                     self.n_atten_vs)
        self.atten_v_randomized = np.random.permutation(self.atten_v_list)

        self.progress = 'Setting up data table'

        cols = [
            "Repeat", "Average", "Attenuator Voltage Setting [V]",
            "Digitizer DC (Quenches On) [V]",
            "Digitizer STD (Quenches On) [V]",
            "Digitizer DC (Quenches Off) [V]",
            "Digitizer STD (Quenches Off) [V]", "Digitizer DC On/Off Ratio",
            "Time"
        ]

        for q in self.open_quenches:
            cols.append(qol.formatted_quench_name(q) + \
                        ' Power Detector Reading (Quenches On) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Attenuator Voltage Reading (Quenches On) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Power Detector Reading (Quenches Off) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Attenuator Voltage Reading (Quenches Off) [V]')

        # Write column headers
        self.data = pd.DataFrame(columns=cols)
        data_file = open(self.folder + 'data.txt', 'a')
        self.data.to_csv(data_file, index=False)
        data_file.close()
        print('\t'.join(self.data.columns))

        self.rep = 0
        self.avg = 0
        self.atten_v_iterator = 0

        self.total_traces = self.max_rep * self.max_avg * self.n_atten_vs

        self.progress = 'Initialization complete'
        self.start_time = dt.now()
        print('Beginning acquisition...')

        return
    def initialize_acquisition(self):
        # Initialize all global variables here, including the 'progress'
        # variable.

        self.progress = 'Printing data.txt comment header'

        self.comments = qol.make_comment_string(self.run_dictionary, \
                                                self.run_dictionary['Order'] \
                                                    .values)

        data_file = open(self.folder + 'data.txt', 'w')
        data_file.write(self.comments)
        data_file.close()

        self.progress = 'Reading quench parameters'

        self.quench_file = pd.read_csv(
            self.run_dictionary.ix['Quenches'].Value)
        self.quench_file = self.quench_file.set_index('Quench Name')

        self.progress = 'Setting up quenches'

        self.qm = quench.QuenchManager()

        quench_arrays = qol.quench_arrays(self.quench_file)

        self.open_quenches = quench_arrays[0]
        self.quench_is_on = quench_arrays[1]
        self.off_quenches = quench_arrays[2]
        self.initial_atten_vs = quench_arrays[3]
        self.on_quenches = quench_arrays[4]

        self.progress = 'Opening quenches'

        self.qm.open_quenches(self.open_quenches, \
                              atten_v = self.initial_atten_vs, \
                              is_on = self.quench_is_on)
        self.qm.cavities_off(self.off_quenches)

        self.progress = 'Opening digitizer'

        self.num_samples = int(self.run_dictionary \
                                   .ix['Number of Digitizer Samples'].Value)
        self.sampling_rate = int(self.run_dictionary \
                                     .ix['Digitizer Sampling Rate [S/s]'].Value)
        self.ch_range = int(self.run_dictionary \
                                .ix['Digitizer Channel Range [V]'].Value)
        self.digi = digitizer.Digitizer(self.run_dictionary \
                                            .ix['Digitizer Address'].Value, \
                                        ch1_range = self.ch_range, \
                                        ch2_range = self.ch_range, \
                                        sampling_rate = self.sampling_rate, \
                                        num_samples = self.num_samples)
        self.digi_channel = int(self.run_dictionary.ix['Digitizer Channel ' + \
                                                       'for Detector'].Value)

        self.progress = 'Opening generator'

        self.gen = generator.Generator(calib=True)
        self.scan_wg = self.run_dictionary.ix['Waveguide to Scan'].Value
        self.gen.power_low('A')
        self.gen.power_on('A')
        self.gen.power_low('B')
        self.gen.power_on('B')

        self.max_rep = int(self.run_dictionary.ix['Number of Repeats'].Value)
        self.max_avg = int(self.run_dictionary.ix['Number of Averages'].Value)

        p_min = float(self.run_dictionary \
                          .ix['Waveguide Power (Start) [dBm]'].Value)
        p_max = float(self.run_dictionary \
                          .ix['Waveguide Power (Stop) [dBm]'].Value)
        self.n_powers = int(self.run_dictionary \
                                .ix['Number of Power Scan Steps'].Value)

        self.gen_p_list = np.linspace(p_min, p_max, self.n_powers)
        self.gen_p_randomized = np.random.permutation(self.gen_p_list)

        f_min = float(self.run_dictionary \
                          .ix['Waveguide Frequency (Start) [MHz]'].Value)
        f_max = float(self.run_dictionary \
                          .ix['Waveguide Frequency (Stop) [MHz]'].Value)
        self.n_freqs = int(self.run_dictionary \
                                .ix['Number of Frequency Scan Steps'].Value)

        self.gen_f_list = np.linspace(f_min, f_max, self.n_freqs)
        self.gen_f_randomized = np.random.permutation(self.gen_f_list)

        self.progress = 'Setting up data table'

        cols = [
            'Generator Channel', 'Repeat', 'Waveguide Frequency Setting [MHz]',
            'Waveguide Power Setting [dBm]', 'Average',
            "Waveguide A Power Reading  (Generator On) [V]",
            "Waveguide B Power Reading (Generator On) [V]",
            "Waveguide A Power Reading  (Generator Off) [V]",
            "Waveguide B Power Reading (Generator Off) [V]",
            "Digitizer DC (Quenches On) [V]",
            "Digitizer STD (Quenches On) [V]",
            "Digitizer DC (Quenches Off) [V]",
            "Digitizer STD (Quenches Off) [V]", "Digitizer DC On/Off Ratio",
            "Time"
        ]

        for q in self.open_quenches:
            cols.append(qol.formatted_quench_name(q) + \
                        ' Power Detector Reading (Generator On) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Attenuator Voltage Reading (Generator On) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Power Detector Reading (Generator Off) [V]')
            cols.append(qol.formatted_quench_name(q) + \
                        ' Attenuator Voltage Reading (Generator Off) [V]')

        # Write column headers
        self.data = pd.DataFrame(columns=cols)
        data_file = open(self.folder + 'data.txt', 'a')
        self.data.to_csv(data_file, index=False)
        data_file.close()
        print('\t'.join(self.data.columns))

        self.rep = 0
        self.avg = 0
        self.gen_p_iterator = 0
        self.gen_f_iterator = 0
        self.wg_iterator = 0

        self.frequency = 0.0

        if self.scan_wg == 'A' or self.scan_wg == 'B':
            self.n_wgs = 1
            self.waveguide_list = [self.scan_wg]
        elif self.scan_wg == 'BOTH':
            self.n_wgs = 2
            self.waveguide_list = ['A', 'B']
        else:
            raise qol.Travisty("Waveguide to Scan must have value \'A\', " + \
                               "\'B\', or BOTH.")

        self.waveguide_list_randomized = np.random  \
                                           .permutation(self.waveguide_list)

        self.total_traces = self.max_rep * self.max_avg * self.n_powers * \
                            self.n_freqs * self.n_wgs

        self.progress = 'Initialization complete'
        self.start_time = dt.now()
        print('Beginning acquisition...')

        return
Exemple #5
0
    def initialize_acquisition(self):
        # Initialize all global variables here, including the 'progress'
        # variable.

        self.progress = 'Printing data.txt comment header'
        print(digitizer)

        self.comments = qol.make_comment_string(self.run_dictionary, \
                                                self.run_dictionary['Order'] \
                                                    .values)

        data_file = open(self.folder + 'data.txt', 'w')
        data_file.write(self.comments)

        self.progress = 'Reading quench parameters'

        self.quench_file = pd.read_csv(self.run_dictionary.ix['Quenches'].Value)
        self.quench_file = self.quench_file.set_index('Quench Name')

        self.progress = 'Setting up quenches'

        self.qm = quench.QuenchManager()

        quench_arrays = qol.quench_arrays(self.quench_file)

        self.open_quenches = quench_arrays[0]
        self.quench_is_on = quench_arrays[1]
        self.off_quenches = quench_arrays[2]
        self.initial_atten_vs = quench_arrays[3]

        self.progress = 'Opening quenches'

        self.qm.open_quenches(self.open_quenches, \
                              atten_v = self.initial_atten_vs, \
                              is_on = self.quench_is_on)
        self.qm.cavities_off(self.off_quenches)

        self.progress = 'Opening digitizer'

        self.num_samples = int(self.run_dictionary \
                                   .ix['Number of Digitizer Samples'].Value)
        self.sampling_rate = int(self.run_dictionary \
                                     .ix['Digitizer Sampling Rate [S/s]'].Value)
        self.ch_range = int(self.run_dictionary \
                                .ix['Digitizer Channel Range [V]'].Value)
        self.digi = digitizer.Digitizer(self.run_dictionary \
                                            .ix['Digitizer Address for ' + \
                                                'Power Combiners'].Value,
                                        ch1_range = self.ch_range,
                                        ch2_range = self.ch_range,
                                        sampling_rate = self.sampling_rate,
                                        num_samples = self.num_samples)
        self.digi_channel_i = int(self.run_dictionary \
                                      .ix['Digitizer Channel for Power ' + \
                                          'Combiner I'].Value)
        self.digi_channel_i -= 1

        self.digi_channel_r = int(self.run_dictionary \
                                      .ix['Digitizer Channel for Power ' + \
                                          'Combiner R'].Value)
        self.digi_channel_r -= 1

        self.progress = 'Opening generator'

        self.offset_freq = int(self.run_dictionary.ix['RF Generator ' + \
                                                      'Frequency Offset ' + \
                                                      '[Hz]'].Value)
        self.rf_e_field = int(self.run_dictionary.ix['RF Electric Field ' + \
                                                     'Peak Amplitude ' + \
                                                     '[V/cm]'].Value)
        self.rf_scan_range = self.run_dictionary.ix['RF Frequency Range'].Value
        print("OFFSET FREQUENCY")
        print(self.offset_freq)
        self.gen = generator.Generator(offset_freq = self.offset_freq, \
                                       e_field = self.rf_e_field, \
                                       scan_range = self.rf_scan_range,
                                       calib = True)
        self.gen.set_rf_frequency(910.0, offset_channel = 'A',
                                  change_power = True)

        self.max_avg = int(self.run_dictionary \
                               .ix['Number of Traces per Loop'].Value)

        self.fc = faradaycupclass.FaradayCup()

        self.progress = 'Setting up data table'

        cols = ["Repeat", \
                "Average", \
                "Power Combiner I Amplitude [V]", \
                "Power Combiner I DC Offset [V]", \
                "Power Combiner R Amplitude [V]",
                "Power Combiner R DC Offset [V]", \
                "Power Combiner Phase Difference (R - I) [rad]", \
                "Waveguide A Power Detector Reading [V]", \
                "Waveguide B Power Detector Reading [V]", \
                "Time",
                "fc1a",
                "fc1b",
                "fc1c",
                "fc1d",
                "fc2i",
                "fc2ii",
                "fc2iii",
                "fc2iv",
                "fc3",
                "fccentre" ]

        for q in self.open_quenches:
            cols.append(qol.formatted_quench_name(q) + \
                       ' Power Detector Reading [V]')
            cols.append(qol.formatted_quench_name(q) + \
                       ' Attenuator Voltage Reading [V]')

        self.data = pd.DataFrame(columns = cols)
        self.data.set_index(['Repeat','Average']).to_csv(data_file)
        data_file.close()
        print('\t'.join(self.data.columns))

        self.rep = 0
        self.avg = 0

        self.progress = 'Initialization complete'
        self.start_time = dt.now()
        print('Beginning acquisition...')

        return