Beispiel #1
0
def no_match(script_name, scripts, tables):
    """
    This function ...
    :param script_name:
    :param scripts:
    :param tables:
    :return:
    """

    from pts.core.basics.log import setup_log
    log = setup_log()
    log.error("Unknown command: " + script_name)
    show_all_available(scripts, tables)
Beispiel #2
0
Datei: run.py Projekt: SKIRT/PTS
def no_match(script_name, scripts, tables):

    """
    This function ...
    :param script_name:
    :param scripts:
    :param tables:
    :return:
    """

    from pts.core.basics.log import setup_log
    log = setup_log()
    log.error("Unknown command: " + script_name)
    show_all_available(scripts, tables)
Beispiel #3
0
def multiple_matches(matches, table_matches, tables):
    """
    Thisfunction ...
    :param matches:
    :param table_matches:
    :param tables:
    :return:
    """

    # Show error
    from pts.core.basics.log import setup_log
    log = setup_log()
    log.error("The command you provided is ambigious. Possible matches:")
    show_possible_matches(matches, table_matches, tables)
Beispiel #4
0
Datei: run.py Projekt: SKIRT/PTS
def multiple_matches(matches, table_matches, tables):

    """
    Thisfunction ...
    :param matches:
    :param table_matches:
    :param tables:
    :return:
    """

    # Show error
    from pts.core.basics.log import setup_log
    log = setup_log()
    log.error("The command you provided is ambigious. Possible matches:")
    show_possible_matches(matches, table_matches, tables)
Beispiel #5
0
Datei: run.py Projekt: SKIRT/PTS
def initialize_log(config, remote=None, command_name=None):

    """
    This function ...
    :param config:
    :parma remote:
    :param command_name:
    :return:
    """

    # Determine the log level
    level = "INFO"
    if config.debug: level = "DEBUG"
    if config.brief: level = "SUCCESS"

    # Determine memuse flag
    if hasattr(config, "memuse"): memuse = config.memuse
    else: memuse = False

    # Determine log path
    #if args.remote is None: logfile_path = fs.join(config.log_path, time.unique_name("log") + ".txt") if config.report else None
    #else: logfile_path = None

    # Determine name of log file
    if command_name is not None: filename = command_name
    else: filename = "log"

    # Determine the log file path
    if remote is None: logfile_path = fs.join(config.log_path, time.unique_name(filename, separator="__") + ".txt") if config.report else None
    else: logfile_path = None

    # Initialize the logger
    from ..core.basics.log import setup_log
    log = setup_log(level=level, path=logfile_path, memory=memuse)

    # Return the logger
    return log
Beispiel #6
0
def initialize_log(config, remote=None, command_name=None):
    """
    This function ...
    :param config:
    :parma remote:
    :param command_name:
    :return:
    """

    # Determine the log level
    level = "INFO"
    if config.debug: level = "DEBUG"
    if config.brief: level = "SUCCESS"

    # Determine log path
    #if args.remote is None: logfile_path = fs.join(config.log_path, time.unique_name("log") + ".txt") if config.report else None
    #else: logfile_path = None

    # Determine name of log file
    if command_name is not None: filename = command_name
    else: filename = "log"

    # Determine the log file path
    if remote is None:
        logfile_path = fs.join(config.log_path,
                               time.unique_name(filename) +
                               ".txt") if config.report else None
    else:
        logfile_path = None

    # Initialize the logger
    from ..core.basics.log import setup_log
    log = setup_log(level=level, path=logfile_path)

    # Return the logger
    return log
Beispiel #7
0
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.remote.host import find_host_ids
from pts.core.remote.remote import Remote
from pts.core.tools import formatting as fmt
from pts.core.basics.log import setup_log
from pts.core.basics.configuration import parse_logging_arguments

# -----------------------------------------------------------------

config = parse_logging_arguments("hosts")

# -----------------------------------------------------------------

# Set log level in a special way
if config.debug: setup_log("DEBUG")
else: setup_log("ERROR")

# -----------------------------------------------------------------

# Loop over the hosts
for host_id in find_host_ids():

    remote = Remote()
    connected = remote.setup(host_id, login_timeout=15) # only try for 15 seconds
    if connected: print(fmt.green + host_id + ": up" + fmt.reset)
    else: print(fmt.red + host_id + ": down" + fmt.reset)

# -----------------------------------------------------------------
Beispiel #8
0
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np

from pts.magic.tools import plotting
from pts.core.basics.plot import MPLPlot, MPLFigure
from pts.magic.core.frame import Frame
from pts.magic.plot.imagegrid import StandardImageGridPlotter, ResidualImageGridPlotter

# -----------------------------------------------------------------

# Logging
from pts.core.basics.log import setup_log
setup_log("DEBUG")

# -----------------------------------------------------------------

# Set seed
np.random.seed(1)

# -----------------------------------------------------------------

def make_random_frame(nxpixels, nypixels=None):

    """
    This function ...
    :param nxpixels:
    :param nypixels:
    :return:
    """
Beispiel #9
0
from pts.evolve.optimize.optimizer import show_best
from pts.evolve.tests.TravelingSalesman.test import settings_optimize, input_optimize, eval_func
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import setup_log

# -----------------------------------------------------------------

# Create configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("ngenerations", "positive_integer", "number of generations (steps)", 10)

# Create the configuration
config = parse_arguments("test_tsp_steps", definition)

# Set logging
log = setup_log("DEBUG")

# -----------------------------------------------------------------

evaluator_kwargs = input_optimize["evaluator_kwargs"]

# -----------------------------------------------------------------

# Determine temporary directory
path = introspection.create_temp_dir(time.unique_name("optimize"))

# Change working directory
fs.change_cwd(path)

# -----------------------------------------------------------------
Beispiel #10
0
# Create configuration definition
definition = ConfigurationDefinition()

# Remote hosts
definition.add_positional_optional("hosts", "host_list", "remote hosts", default=all_hosts, choices=all_host_ids)

# Flags
definition.add_flag("clusters", "show the clusters")

# Create the configuration
config = parse_arguments("remotes", definition, "Check the status of the remotes")

# -----------------------------------------------------------------

# Set log level in a special way
if config.debug: setup_log("DEBUG")
else: setup_log("ERROR")

# -----------------------------------------------------------------

# Loop over the hosts
print("")
for host in config.hosts:

    # Debugging
    log.debug("Connecting to remote host '" + host.id + "' ...")

    # Create remote, try connecting
    remote = Remote()
    connected = remote.setup(host, login_timeout=10) # only try for 10 seconds
Beispiel #11
0
# Import the relevant PTS classes and modules
from pts.core.tools import formatting as fmt
from pts.core.tools import introspection
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import setup_log

# -----------------------------------------------------------------

definition = ConfigurationDefinition()
definition.add_flag("verbose", "verbose output", letter="v")
config = parse_arguments("count", definition)

# -----------------------------------------------------------------

# Setup log
setup_log("ERROR")

# -----------------------------------------------------------------

# Lines
nlines = 0
nlines_per_file = dict()
nlines_per_subproject = defaultdict(int)

# Modules
nmodules = 0
nmodules_per_subproject = defaultdict(int)

# Functions
nfunctions = 0
nfunctions_per_subproject = defaultdict(int)
Beispiel #12
0
# Import the relevant PTS classes and modules
from pts.core.tools import formatting as fmt
from pts.core.tools import introspection
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import setup_log

# -----------------------------------------------------------------

definition = ConfigurationDefinition()
definition.add_flag("verbose", "verbose output", letter="v")
config = parse_arguments("count", definition)

# -----------------------------------------------------------------

# Setup log
setup_log("ERROR")

# -----------------------------------------------------------------

# Lines
nlines = 0
nlines_per_file = dict()
nlines_per_subproject = defaultdict(int)

# Modules
nmodules = 0
nmodules_per_subproject = defaultdict(int)

# Functions
nfunctions = 0
nfunctions_per_subproject = defaultdict(int)
Beispiel #13
0
from pts.evolve.tests.TravelingSalesman.test import settings_optimize, input_optimize, eval_func
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import setup_log

# -----------------------------------------------------------------

# Create configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("ngenerations", "positive_integer",
                                   "number of generations (steps)", 10)

# Create the configuration
config = parse_arguments("test_tsp_steps", definition)

# Set logging
log = setup_log("DEBUG")

# -----------------------------------------------------------------

evaluator_kwargs = input_optimize["evaluator_kwargs"]

# -----------------------------------------------------------------

# Determine temporary directory
path = introspection.create_temp_dir(time.unique_name("optimize"))

# Change working directory
fs.change_cwd(path)

# -----------------------------------------------------------------
Beispiel #14
0
# Imports
from pts.magic.core.frame import Frame
from pts.magic.core.image import Image
from pts.magic.sources.finder import SourceFinder
from pts.magic.catalog.extended import ExtendedSourceCatalog
from pts.magic.sources.extractor import SourceExtractor
from pts.core.basics.log import setup_log

setup_log("DEBUG")

name = '1237678777941229794'
ra = 0.00945
dec = 5.28824
d25 = 0.42657951411792816
redshift = 0.1694

output_find_name = "output_find"
output_extract_name = "output_extract"

## Create the catalog
catalog = ExtendedSourceCatalog()

# Add the principal galaxy
# Arguments: name, ra, dec, z, galtype, alternative_names, distance, inclination, d25, major, minor, posangle, principal, companions, parent
# SET PRINCIPAL=TRUE FOR PRINCIPAL GALAXY
catalog.add_entry(name=name,
                  ra=ra,
                  dec=dec,
                  z=redshift,
                  galtype=None,
                  alternative_names=None,