Beispiel #1
0
    def get_user_value_changes(self, detnum):
        """Goes through individual settings and asks the user if things are
        correct

        Parameters
        ----------
        detnum : int
            The detector number this detector is stored as
        """
        self.print_self(detnum)
        if inp.get_yes_no("Change Digitizer Setup", default_value=False):
            brd = inp.get_int("New Board Number")
            chan = inp.get_int("New Channel Number")
            self.digi_pair = (brd, chan)
        if inp.get_yes_no("Change MPOD Setup", default_value=False):
            brd = inp.get_int("New Board Number")
            chan = inp.get_int("New Channel Number")
            self.mpod_pair = (brd, chan)
        if inp.get_yes_no("Change Det. Position Offsets", default_value=False):
            xoff = inp.get_float("New X Offset")
            yoff = inp.get_float("New Y Offset")
            zoff = inp.get_float("New Z Offset")
            self.pos_offset = (xoff, yoff, zoff)
        if inp.get_yes_no("Change Detector Type", default_value=False):
            print "Known Types are: NaI, LS, CeBr3, HeMod, HeUnmod"
            new_type = inp.get_str("New Detector Type")
            self.det_type = new_type
        if inp.get_yes_no("Change Projection Thresholds", default_value=False):
            en_thresh = inp.get_float("New Energy Threshold for PSD Proj")
            psd_thresh = inp.get_float("New PSD Threshold for Energy Proj")
            self.thresh_pair = (int(en_thresh), psd_thresh)
Beispiel #2
0
 def get_array_changes(self):
     """Asks the user for changes in the setup"""
     self.print_array_setup()
     print ""
     if inp.get_yes_no("Remove dets from the array", default_value=False):
         self.get_removed_dets()
     self.print_array_setup()
     print ""
     if inp.get_yes_no("Add dets to the array", default_value=False):
         self.get_added_dets()
     self.print_array_setup()
     print ""
     if inp.get_yes_no("Modify dets in the array", default_value=False):
         self.get_modded_dets()
def generate_sub_script(batch_files):
    """This function takes the list of batch files and makes a simple batch
    script that jumps into each directory it generated, and submits the output
    script

    Parameters
    ----------
    batch_files : list
        A list of the files generated for batch processing, in order they are
        Reader config file, Detector Setup File, Input List File, Queue Script
        File, and finally, the Output Directory

    Returns
    -------
    sub_script_name : str
        Path to the script generated to submit the individual files to the
        queue for processing
    """
    outfile = None
    if inp.get_yes_no("Append to existing submit_script", default_value=True):
        outfile = open("./submit_script", 'a')
    else:
        outfile = open("./submit_script", 'w')
        outfile.write("#!/usr/bin/bash\n")
    for num, batch in enumerate(batch_files):
        outfile.write("# Batch number: {0:d}\n".format(num))
        outfile.write("cd {0:s}\n".format(batch[4]))
        outfile.write("qsub ./batch_script\n")
    outfile.close()
    return "./submit_script"
def check_sub_batch(batch, setup, times, pos):
    """Takes a specific sub batch, displays information about it and allows the
    user to modify it if they wish

    Parameters
    ----------
    batch : list
        list of file data tuples
    setup : tuple
        Name of setup and ArraySetup in a pair
    times : tuple
        Header time of the first file and last modification time of the last
        file
    pos : tuple
        X-Y position pair
    """
    start_time = times[0].strftime("%Y-%m-%d %H:%M:%S.%f")
    stop_time = times[1].strftime("%Y-%m-%d %H:%M:%S.%f")
    print SUB_BATCH_INFO.format(batch[0][0], batch[-1][0], start_time,
                                stop_time, setup[0], pos[0], pos[1][0],
                                pos[1][1])
    setup[1].print_array_setup()
    print ""
    ans = inp.get_yes_no("Do you wish to edit the array position",
                         default_value=False)
    while ans:
        xpos = inp.get_float("New X Position")
        ypos = inp.get_float("New Y Position")
        pos[1][0] = xpos
        pos[1][1] = ypos
        print SUB_BATCH_INFO.format(batch[0][0], batch[-1][0], start_time,
                                    stop_time, setup[0], pos[0], pos[1][0],
                                    pos[1][1])
        setup[1].print_array_setup()
        ans = inp.get_yes_no("Do you wish to edit the array position",
                             default_value=False)
    ans = inp.get_yes_no("Do you wish to edit the detector setup",
                         default_value=False)
    while ans:
        setup[1].get_array_changes()
        print SUB_BATCH_INFO.format(batch[0][0], batch[-1][0], start_time,
                                    stop_time, setup[0], pos[0], pos[1][0],
                                    pos[1][1])
        setup[1].print_array_setup()
        ans = inp.get_yes_no("Do you wish to edit the detector setup",
                             default_value=False)
Beispiel #5
0
 def get_removed_dets(self):
     """Asks the user which detectors to remove"""
     ans = True
     while ans:
         self.print_array_setup()
         val = inp.get_int("Detector Number to Remove")
         if val in self.det_dict:
             del self.det_dict[val]
         else:
             print "Detector number not in array setup!"
         ans = inp.get_yes_no("Remove Another Detector",
                              default_value=False)
Beispiel #6
0
 def get_added_dets(self):
     """Asks the user to define new detectors"""
     ans = True
     while ans:
         self.print_array_setup()
         val = inp.get_int("New Detector Number")
         if val in self.det_dict:
             print "Detector number already exists!"
         else:
             new_det = DetectorSetup.build_new_det(val)
             self.det_dict[val] = new_det
         ans = inp.get_yes_no("Add Another Detector", default_value=False)
Beispiel #7
0
 def get_modded_dets(self):
     """Asks the user to modify existing detectors"""
     ans = True
     while ans:
         self.print_array_setup()
         val = inp.get_int("Detector to modify")
         if val in self.det_dict:
             self.det_dict[val].get_user_value_changes(val)
         else:
             print "Detector does not exist"
         ans = inp.get_yes_no("Modify Another Detector",
                              default_value=False)
Beispiel #8
0
    def build_new_det(detnum):
        """Static method to make a new detector from user input

        Parameters
        ----------
        detnum : int
            The detector number this detector is stored as

        Returns
        -------
        det_setup : DetectorSetup
            A newly initialized detector setup
        """
        is_good = 'n'
        while is_good in ['n', 'N']:
            brd = inp.get_int("New Digitizer Board Number")
            chan = inp.get_int("New Digitizer Channel Number")
            temp = [(brd, chan)]
            brd = inp.get_int("New MPOD Board Number")
            chan = inp.get_int("New MPOD Channel Number")
            temp.append((brd, chan))
            xoff = inp.get_float("New X Offset")
            yoff = inp.get_float("New Y Offset")
            zoff = inp.get_float("New Z Offset")
            temp.append((xoff, yoff, zoff))
            print "Known Detector Types are: NaI, LS, CeBr3, HeMod, HeUnmod"
            new_type = inp.get_str("New Detector Type")
            temp.append(new_type)
            out_str = "New Energy Threshold for PSD Proj"
            en_thresh = inp.get_float(out_str)
            out_str = "New PSD Threshold for Energy Proj"
            psd_thresh = inp.get_float(out_str)
            temp.append((int(en_thresh), psd_thresh))
            det_setup = DetectorSetup((temp[0], temp[1]), temp[2], temp[3],
                                      temp[4])
            det_setup.print_self(detnum)
            if inp.get_yes_no("Is this correct", default_value=True):
                return det_setup