Ejemplo n.º 1
0
from chandra_suli.work_within_directory import work_within_directory

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Check each candidate transient for hot pixels and '
                                                 'closest variable source')

    parser.add_argument("-o", "--obsid", help="Observation ID Numbers", type=int, required=True, nargs="+")
    parser.add_argument("-f", "--outfile", help="Name of output file which will contain filtered list of transients",
                        required=True)
    parser.add_argument("-d1", "--results_path", help="Path to directory containing results from farm_step_2")
    parser.add_argument("-d2", "--data_path", help="Path to directory containing data of all obsids", required=True,
                        type=str)

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

    # Get the command runner
    runner = CommandRunner(logger)

    args = parser.parse_args()

    results_path = sanitize_filename(args.results_path)
    data_path = sanitize_filename(args.data_path)

    for this_obsid in args.obsid:

        # Go to directory where results from farm_step2 are stored

        with work_within_directory(results_path):
    parser.add_argument("--evtfile",
                        help="Filtered CCD file",
                        required=True,
                        type=str)
    parser.add_argument("--outfile",
                        help="Output file with events in hot pixels removed",
                        required=True,
                        type=str)
    parser.add_argument("--debug",
                        help="Debug mode? (yes or no)",
                        required=False,
                        default='no')

    # 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()

    eventfile = sanitize_filename(args.evtfile)

    # Open event file

    fits_file = pyfits.open(eventfile, mode='update', memmap=False)

    # Make sure we are dealing with only one CCD
    ccds = np.unique(fits_file['EVENTS'].data.ccd_id)
Ejemplo n.º 3
0
from chandra_suli.run_command import CommandRunner
from chandra_suli.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("separate_CCD.py")
    runner = CommandRunner(logger)

    print "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 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
Ejemplo n.º 4
0
import fnmatch
import os
import shutil

import yaml

from chandra_suli.logging_system import get_logger
from chandra_suli.sanitize_filename import sanitize_filename
from chandra_suli.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):
        self._filename = sanitize_filename(filename)
        self._description = description

        assert os.path.exists(self._filename), "Something went wrong when creating File instance. " \
Ejemplo n.º 5
0
                        type=str,
                        required=True)

    parser.add_argument("--debug",
                        help="Debug mode (yes or no)",
                        type=bool,
                        required=False,
                        default=False)

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

    args = parser.parse_args()

    region_dir = sanitize_filename(args.region_dir)

    log = get_logger("create_regions_db")

    with work_within_directory.work_within_directory(region_dir):

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

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

        db = collections.OrderedDict()

        for i, region_file in enumerate(region_files):

            sys.stderr.write("\r%s out of %s" % (i + 1, len(region_files)))

            header = fitsio.read_header(region_file, "SRCREG")
Ejemplo n.º 6
0
    parser = argparse.ArgumentParser(description='Create source database')

    parser.add_argument('--region_dir', help="Directory containing the regions file for this obsid",
                        type=str, required=True)

    parser.add_argument('--outfile', help="Name of the output (filtered) event file", type=str, required=True)

    parser.add_argument("--debug", help="Debug mode (yes or no)", type=bool, required=False, default=False)

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

    args = parser.parse_args()

    region_dir = sanitize_filename(args.region_dir)

    log = get_logger("create_regions_db")

    with work_within_directory.work_within_directory(region_dir):

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

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

        db = collections.OrderedDict()

        for i, region_file in enumerate(region_files):

            sys.stderr.write("\r%s out of %s" % (i + 1, len(region_files)))

            header = fitsio.read_header(region_file, "SRCREG")
Ejemplo n.º 7
0
import os
import subprocess

import astropy.io.fits as pyfits
from chandra_suli.run_command import CommandRunner
from chandra_suli.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("separate_CCD.py")
    runner = CommandRunner(logger)

    print "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 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

        f = pyfits.open("%s" % (ccd_file))