Example #1
0
    parser.add_argument("--package",
                        help="Data package containing the output of step 2",
                        required=True,
                        type=str)
    parser.add_argument(
        "--masterfile",
        help="Path to file containing list of transients in this set",
        required=True,
        type=str)
    # parser.add_argument("--evtfile", help="Main event file for observation, used to get total exposure time",
    #                    required=True, type=str)

    # Get logger for this command

    logger = logging_system.get_logger(os.path.basename(sys.argv[0]))

    # Instance the command runner

    runner = CommandRunner(logger)

    args = parser.parse_args()

    data_package = DataPackage(sanitize_filename(args.package))

    for bbfile_tag in data_package.find_all("ccd_?_check_var"):

        logger.info("Processing %s..." % bbfile_tag)

        bbfile = data_package.get(bbfile_tag).filename
Example #2
0
import fnmatch
import os
import shutil

import yaml

from XtDac.ChandraUtils.logging_system import get_logger
from XtDac.ChandraUtils.sanitize_filename import sanitize_filename
from XtDac.ChandraUtils.work_within_directory import work_within_directory

logger = get_logger("DataPackage")

_index_file = "index.yml"


def _check_directory(directory):
    sanitized_directory = sanitize_filename(directory)

    assert os.path.exists(
        sanitized_directory
    ), "Directory %s does not exists" % sanitized_directory

    assert os.path.isdir(
        sanitized_directory
    ), "The file %s is not a directory" % sanitized_directory

    return sanitized_directory


class File(object):
    def __init__(self, filename, description):
Example #3
0
from XtDac.ChandraUtils.run_command import CommandRunner
from XtDac.ChandraUtils.logging_system import get_logger

if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description='Create new event files separated by CCD')

    parser.add_argument('--evtfile',
                        help="Event file name",
                        type=str,
                        required=True)

    args = parser.parse_args()

    logger = get_logger("xtc_separate_CCDs.py")
    runner = CommandRunner(logger)

    logger.info("Separating by CCD...")

    for ccd_id in range(10):

        ccd_file = "ccd_%s_%s" % (ccd_id, os.path.basename(args.evtfile))

        cmd_line = "dmcopy %s[EVENTS][ccd_id=%s] %s option=all clobber=yes" % (
            args.evtfile, ccd_id, ccd_file)

        runner.run(cmd_line)

        # check if certain CCD files are empty and then delete them if so
Example #4
0
if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Create source database')

    parser.add_argument("-c",
                        "--config_file",
                        help="Path to the configuration file",
                        type=str,
                        required=True)

    # assumption = all level 3 region files and event file are already downloaded into same directory, the region_dir

    args = parser.parse_args()

    # Get logger
    logger = get_logger(os.path.basename(sys.argv[0]))

    # Get the configuration
    config = get_configuration(args.config_file)

    region_dir = sanitize_filename(config['region repository'])

    with work_within_directory.work_within_directory(region_dir):

        # Find all region files
        region_files = find_files.find_files('.', '*_reg3.fits.gz')

        logger.info("Found %s region files" % len(region_files))

        db = collections.OrderedDict()