Skip to content

Average

average

cctbx_start

Attributes

logger module-attribute

logger = getLogger(__name__)

Functions

average

average(exp, run, facility, debug)
Source code in scripts/cctbx/average.py
def average(exp, run, facility, debug):
    logging.info(f"Making an average for run: {run}")
    run = str(run).zfill(4)
    run = f'r{run}'

    if facility == "NERSC":
        exp = exp[3:-2]
        proc = [
                f"ssh -i ~/.ssh/cctbx -YAC cctbx@perlmutter-p1.nersc.gov "
                f"sbatch /global/common/software/lcls/mfx/scripts/cctbx/average.sh "
                f"{exp} {facility} {run}"
            ]
    elif facility == "S3DF":
        proc = [
                f"ssh -YAC psana "
                f"sbatch /sdf/group/lcls/ds/tools/mfx/scripts/cctbx/average.sh "
                f"{exp} {facility} {run}"
            ]
    else:
        logging.warning(f"Facility not found: {facility}")

    logging.info(proc)
    if debug:
        os.system(proc[0])
    else:
        subprocess.Popen(
            proc, shell=True,
            stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)

main

main(args)

Main entry point allowing external calls Entry point for console_scripts Args: args ([str]): command line parameter list

Source code in scripts/cctbx/average.py
def main(args):
    """
    Main entry point allowing external calls
    Entry point for console_scripts
    Args:
      args ([str]): command line parameter list
    """
    args = parse_args(args)
    exp = args.experiment
    facility = args.facility
    debug = bool(args.debug)
    run = args.run

    average(exp, run, facility, debug)

parse_args

parse_args(args)

Parse command line parameters

Args: args ([str]): command line parameters as list of strings

Returns: :obj:argparse.Namespace: command line parameters namespace

Source code in scripts/cctbx/average.py
def parse_args(args):
    """Parse command line parameters

    Args:
      args ([str]): command line parameters as list of strings

    Returns:
      :obj:`argparse.Namespace`: command line parameters namespace
    """
    parser = argparse.ArgumentParser(
        description="startup script for cctbx on iana."
    )
    parser.add_argument(
        "--experiment",
        "-e",
        dest="experiment",
        default=None,
        help="Enter -e to specify experiment number",
    )
    parser.add_argument(
        "--facility",
        "-f",
        dest="facility",
        default=None,
        help="Enter -f to specify facility",
    )
    parser.add_argument(
        "--debug",
        "-d",
        dest="debug",
        default=str(False),
        help="Enter -d to set debugging mode",
    )
    parser.add_argument(
        "--run",
        "-r",
        dest="run",
        default=None,
        help="Enter -r for the run number",
    )

    return parser.parse_args(args)

run

run()

Entry point for console_scripts

Source code in scripts/cctbx/average.py
def run():
    """Entry point for console_scripts"""
    main(sys.argv[1:])