Exemple #1
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.modeling.core.data import load_data
from pts.core.basics.log import log

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

# Create configuration
definition = ConfigurationDefinition()
definition.add_required("filename", "file_path", "path of the data file")
definition.add_required("new_filename", "string", "path for the completed data file")
config = parse_arguments("upload_status", definition)

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

# Inform the user
log.info("Loading the data file ...")

# Load
data = load_data(config.filename)

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

# Dereference
data.dereference()

# -----------------------------------------------------------------
Exemple #2
0
definition = ConfigurationDefinition()

# Select files
definition.add_optional("contains", "string_list",
                        "only files whose name contain one of these strings")

# Options
definition.add_optional("name", "string", "rebin to this name")
definition.add_optional("wcs", "file_path",
                        "path to the file from which to take the WCS")

# Flags
definition.add_flag("backup", "make backups", True)

# Parse the command line arguments
config = parse_arguments("rebin", definition)

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

# Load frame list
frames = NamedFrameList.from_directory(config.path, contains=config.contains)

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

# Rebin
if config.name is not None: frames.rebin_to_name(config.name)
elif config.wcs is not None:
    wcs = CoordinateSystem.from_file(config.wcs)
    frames.rebin_to_wcs(wcs)
else:
    frames.rebin_to_highest_pixelscale()
Exemple #3
0
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.simulation.skifile import SkiFile
from pts.core.simulation.skifile import show_normalizations

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Ski path
definition.add_required("ski", "file_path", "path of the ski file")

# Optional
definition.add_optional("flux", "photometric_unit", "also show flux in a particular unit")

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

# Parse the arguments into a configuration
config = parse_arguments("normalizations", definition, "Show the normalizations of stellar components in a ski file")

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

# Load the ski file
ski = SkiFile(config.ski)

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

show_normalizations(ski, flux_unit=config.flux)

# -----------------------------------------------------------------
Exemple #4
0
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.services.s4g import get_galaxy_names, has_galaxy
from pts.core.basics.map import Map
from pts.core.basics.log import log
from pts.core.basics.table import SmartTable

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

# Create the configuration
definition = ConfigurationDefinition()

#
definition.add_optional("ngalaxies", "positive_integer", "max number of galaxies")

# Get configuration
config = parse_arguments("plot_galaxies", definition)

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

# Create the database instance
database = DustPediaDatabase()
#username, password = get_account()
#database.login(username, password)

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

sample = DustPediaSample()
galaxy_names = sample.get_names()

# -----------------------------------------------------------------
Exemple #5
0
definition.add_flag("distributions", "show residual distributions", False)

# Extra
definition.add_flag("normalize", "normalize the images")
definition.add_optional("share_scale_with", "string", "share the scale of all other images with this image")
definition.add_optional("colormap", "string", "colormap", "viridis")

# Extra
definition.add_flag("write_data", "write data")

# Output
definition.add_optional("output", "directory_path", "output directory")

# Create the configuration
config = parse_arguments("show_residuals", definition, "Show residuals of photometry images and mock observed images in current director")

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

# Get modeling path
environment = find_modeling_environment_up_cwd()

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

# Create plotter
plotter = ResidualImageGridPlotter()

# Plot residual distributions
plotter.config.distributions = config.distributions

# Downsampling
Exemple #6
0
# Import the relevant PTS classes and modules
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add setting
definition.add_required("step", "string",
                        "the modeling step for which to clear the output")

# Get the configuration
config = parse_arguments("clear", definition)

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

prep_path = fs.join(config.path, "prep")
components_path = fs.join(config.path, "components")
truncated_path = fs.join(config.path, "truncated")
phot_path = fs.join(config.path, "phot")
maps_path = fs.join(config.path, "maps")
fit_path = fs.join(config.path, "fit")
analysis_path = fs.join(config.path, "analysis")

if config.step == "prep": fs.clear_directory(prep_path)
elif config.step == "components": fs.clear_directory(components_path)
elif config.step == "truncated": fs.clear_directory(truncated_path)
elif config.step == "phot": fs.clear_directory(phot_path)
Exemple #7
0
runs = FittingRuns(modeling_path)

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

# Create configuration definition
definition = ConfigurationDefinition()

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

# FITTING RUN
if runs.empty: raise RuntimeError("No fitting runs are present (yet)")
elif runs.has_single: definition.add_fixed("fitting_run", "name of the fitting run", runs.single_name)
else: definition.add_required("fitting_run", "string", "name of the fitting run", choices=runs.names)

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

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

# Load populations table
populations = get_populations(modeling_path)
populations_run = populations[config.fitting_run]

# Load generation table
generations = get_generations_table(modeling_path, config.fitting_run)

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

generation_names = generations.genetic_generations_with_initial

# -----------------------------------------------------------------
Exemple #8
0
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.tools import filesystem as fs
from pts.modeling.core.environment import GalaxyModelingEnvironment
from pts.modeling.html.status import StatusPageGenerator
from pts.modeling.core.environment import verify_modeling_cwd
from pts.core.tools import browser

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

# Create configuration
definition = ConfigurationDefinition()
definition.add_flag("generate", "first (re)generate the HTML", False)
config = parse_arguments("show_status", definition)

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

modeling_path = verify_modeling_cwd()

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

# Load the modeling environment
environment = GalaxyModelingEnvironment(modeling_path)

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

# Generate the HTML
if config.generate:
Exemple #9
0
# Create the definition
definition = ConfigurationDefinition()

# Select files
definition.add_optional("contains", "string_list", "only files whose name contain one of these strings")

# Options
definition.add_optional("name", "string", "convolve to the resolution of the image with this name")
definition.add_optional("filter", "filter", "convolve to this filter's resolution")
definition.add_optional("fwhm", "angle", "specify the FWHM if the filter has a variable FWHM")

# Flags
definition.add_flag("backup", "make backups", True)

# Parse the command line arguments
config = parse_arguments("convolve", definition)

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

# Load frame list
frames = NamedFrameList.from_directory(config.path, contains=config.contains)

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

# Convolve
if config.name is not None: frames.convolve_to_name(config.name)
elif config.filter is not None: frames.convolve_to_filter(config.filter, fwhm=config.fwhm)
else: frames.convolve_to_highest_fwhm()

# -----------------------------------------------------------------
Exemple #10
0
from pts.core.basics.log import log
from pts.core.remote.python import RemotePythonSession

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("host_id",
                                   "string",
                                   "remote host ID",
                                   choices=find_host_ids())

# Read the command line arguments
config = parse_arguments(
    "python",
    definition,
    description=
    "Open a python session with PTS modules loaded, and with remote capabilities if requested."
)

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


class PTSConsole(InteractiveConsole):
    """
    This class ...
    """
    def __init__(self, *args, **kwargs):
        """
        This function ...
        :param args:
        """
Exemple #11
0
definition = ConfigurationDefinition()

# Add required
definition.add_required(
    "suite_name", "string",
    "name of the scaling test suite directory (must be inside current directory)"
)

# Add flag
definition.add_flag(
    "small",
    "make plots smaller so that they fit in one column of a publication and have a suiting resolution"
)

# Get configuration
config = parse_arguments("scaling_plots", definition)

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

# Set figsize
if config.small:
    figsize = "8,6"
    figsize_timelines = "8,8"
else:
    figsize = "12,9"
    figsize_timelines = "12,12"

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

# Locate the scaling test suite directory
suite_path = fs.join(fs.cwd(), config.suite_name)
from pts.core.remote.host import find_host_ids
from pts.core.remote.remote import Remote
from pts.core.basics.log import log

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

# Create definition
definition = ConfigurationDefinition()
definition.add_positional_optional("remotes",
                                   "string_list",
                                   "remote hosts on which to clear",
                                   choices=find_host_ids(),
                                   default=find_host_ids())

# Create setter
config = parse_arguments("clear_sessions_and_temp", definition)

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

# Loop over the remote hosts
for host_id in config.remotes:

    # Setup the remote
    remote = Remote()
    if not remote.setup(host_id):
        log.warning("Could not connect to remote host '" + host_id + "'")
        continue

    # Clear temporary directory and clear sessions
    remote.clear_temp_and_sessions()
Exemple #13
0
from pts.core.filter.filter import parse_filter
from pts.core.tools.parsing import real
from pts.magic.core.frame import Frame
from pts.modeling.core.environment import verify_modeling_cwd

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

# Create the configuration definition
definition = ConfigurationDefinition()

# The galaxy name
definition.add_required("factor", "real",
                        "truncation ellipse factor for which to plot")

# Get configuration
config = parse_arguments("plot_truncated", definition)

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

modeling_path = verify_modeling_cwd()

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

# Load the modeling environment
environment = GalaxyModelingEnvironment(modeling_path)

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

# Create plotter
plotter = StandardImageGridPlotter()
Exemple #14
0
# -----------------------------------------------------------------

# Create configuration definition
definition = ConfigurationDefinition()

# FITTING RUN
if runs.empty: raise RuntimeError("No fitting runs are present (yet)")
elif runs.has_single: definition.add_fixed("fitting_run", "name of the fitting run", runs.single_name)
else: definition.add_required("fitting_run", "string", "name of the fitting run", runs.names)

# Generation
definition.add_positional_optional("generations", "string_list", "name of the generations for which to show the recurrence")

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

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

# Load the modeling environment
environment = GalaxyModelingEnvironment(modeling_path)

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

# Load the fitting run
fitting_run = FittingRun.from_name(modeling_path, config.fitting_run)

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

# Get generation names
generations = config.generations if config.generations is not None else fitting_run.genetic_generations
Exemple #15
0
definition.add_required("regions", "string", "path of the output regions file")

# Add optional
definition.add_optional("mask", "string", "path to an output mask file")
definition.add_optional(
    "offset", "real",
    "offset to make the regions larger or smaller, in pixels")

#definition.add_optional("", )
# parser.add_argument("--xc", nargs='?', const=1, help="Optional: If you don't want to mask the galaxy with the given x-coordinate of the center",type=str, default=None)
# parser.add_argument("--yc", nargs='?', const=1, help="Optional: If you don't want to mask the galaxy with the given y-coordinate of the center",type=str, default=None)

# parser.add_argument("--fits_slice", nargs='?', const=1, help="Optional: Fits slice in the segmentation map to be used. Default 0.",type=str, default='0')

# Get the configuration
config = parse_arguments("pix_to_sky", definition)

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

# Open the segmentation map
segments = SegmentationMap.from_file(config.segments)
output_region_file = config.regions
output_mask_image = config.mask

#fits_slice = config.fits_slice
fits_slice = None
offset = config.offset
#xc = config.xc
#yc = config.yc
xc = yc = None
Exemple #16
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.simulation.simulation import createsimulations
from pts.core.plot.grids import plotgrids
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

# Create configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("simulation", "string", "simulation specification", default="")
definition.add_optional("linewidth", "positive_real", "line width", 0.1)
definition.add_optional("maxlevel", "positive_integer", "maximum tree level")

# Read the command line arguments
config = parse_arguments("plotgrids", definition, description="Unmount a remote mounted with PTS")

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

print("Starting plotgrids...")

# construct the list of simulation objects and make the plots
for simulation in createsimulations(config.simulation): plotgrids(simulation, linewidth=config.linewidth, maxlevel=config.maxlevel)

print("Finished plotgrids")

# -----------------------------------------------------------------
Exemple #17
0
## \package pts.do.core.task_info Show information about a certain remote PTS task.

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

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.remote.host import find_host_ids

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_required("remote", "string", "ID of the remote host", choices=find_host_ids())
definition.add_required("task_id", "integer", "ID of the PTS task")

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

# Parse the arguments into a configuration
config = parse_arguments("task_info", definition, description="Show information about a certain remote PTS task")

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

print("Not implemented yet")

# -----------------------------------------------------------------
Exemple #18
0
# Import standard modules
import importlib
from collections import defaultdict
from inspect import getmembers, isfunction, getdoc

# 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
Exemple #19
0
from pts.core.basics.log import log

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add settings
definition.add_positional_optional("remotes", "string_list", "the IDs of the remote hosts for which to clear the simulations", choices=find_host_ids(), default=find_host_ids())
definition.add_positional_optional("ids", "integer_list", "the IDs of the simulations to clear")
definition.add_flag("full", "fully clear the simulations, also remove remote simulation directories")

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

# Parse the arguments into a configuration
config = parse_arguments("clear_tasks", definition, description="Clear PTS tasks for a certain remote host")

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

# Loop over the remote hosts
for host_id in config.remotes:

    # Check whether the remote is available
    if config.full:
        remote = Remote()
        if not remote.setup(host_id):
            log.warning("The remote host '" + host_id + "' is not available: skipping ...")
            continue
    else: remote = None

    # Determine the path to the run directory for the specified remote host
Exemple #20
0
# -----------------------------------------------------------------

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_required("remote",
                        "string",
                        "remote host to mount",
                        choices=all_host_ids())
definition.add_positional_optional(
    "path", "directory_path",
    "path of directory in which to create the mount point")

# Read the command line arguments
config = parse_arguments(
    "mount",
    definition,
    description="Mount a remote configured in PTS into the local filesystem")

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

# Create the mounter
mounter = RemoteMounter()

# Mount and get the mount path
path = mounter.mount(config.remote, config.path)

# Open the directory
fs.open_directory(path)

# -----------------------------------------------------------------
Exemple #21
0
import numpy as np

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.core.image import Image
from pts.core.tools import filesystem as fs
from pts.core.basics.log import log

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

# Create the configuration
definition = ConfigurationDefinition()
definition.add_required("file_path", "file_path", "path of the image")
definition.add_required("factor", "real", "multiplication factor")
definition.add_flag("backup", "make a backup of each image that is multiplied", False)
config = parse_arguments("multiply", definition)

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

# BACKUP FIRST
if config.backup:

    # Inform the user
    log.info("Making a backup of the original image ...")

    # Determine new filepath and copy
    new_filepath = fs.appended_filepath(config.filepath, "_backup")
    fs.copy_file(config.filepath, new_filepath)

# -----------------------------------------------------------------
Exemple #22
0
definition.add_required("generation", "string", "generation name")

# Simulations to reanalyse
definition.add_optional("simulations", "string_list", "simulation names")

# Reanalyse which steps?
definition.add_positional_optional("steps", "string_list", "re-analyse only certain steps", choices=all_steps, default=all_steps)
definition.add_positional_optional("features", "string_list", "re-analyse only certain features (if a single step is defined)")
definition.add_optional("not_steps", "string_list", "don't analyse these steps", choices=all_steps)
definition.add_optional("not_features", "string_list", "don't analyse these features (if a single not_step is defined)")

# Add section for analysis options
definition.import_section("analysis", "analyser options", analysis_definition)

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

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

# Load the fitting run and the generation
fitting_run = runs.load(config.name)
generation = fitting_run.get_generation(config.generation)

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

# Loop over the simulations
for simulation in generation.simulations:

    # Check
    if config.simulations is not None and simulation.name not in config.simulations: continue
Exemple #23
0
# Create the configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_required("remote",
                        "string",
                        "name of the remote host",
                        choices=find_host_ids())
definition.add_required("id", "positive_integer", "task ID")

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

# Parse the arguments into a configuration
#setter = InteractiveConfigurationSetter("show_log", "Show the log output of a remote PTS task")
config = parse_arguments(
    "show_task_log",
    definition,
    description="Show the log output of a remote PTS task")

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

# Create and setup the remote
remote = Remote()
remote.setup(config.remote)

# Open the task
task_path = fs.join(introspection.pts_run_dir, config.remote,
                    str(config.id) + ".task")
task = Task.from_file(task_path)

# Check whether the log file is present
log_output_path = task.remote_log_path
Exemple #24
0
# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.services.attenuation import GalacticAttenuation
from pts.core.basics.plot import MPLFigure
from pts.core.filter.broad import categorize_filters, categorized_filters_sorted_labels, get_filters_for_regimes
from pts.magic.basics.coordinatesystem import CoordinateSystem

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("galaxy_name", "string", "galaxy name")
definition.add_optional("image", "file_path", "image path")

# Get the configuration
config = parse_arguments("attenuation", definition)

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

# Create attenuation object
if config.image is not None:
    wcs = CoordinateSystem.from_file(config.image)
    attenuation = GalacticAttenuation(wcs.bounding_box.center)
    # or attenuation = GalacticAttenuation(wcs.center_sky)
else:
    attenuation = GalacticAttenuation(config.galaxy_name)

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

#specs = categorize_filters()
#for label in categorized_filters_sorted_labels(specs):
Exemple #25
0
from pts.core.launch.analyser import reanalyse_simulation, all_steps
from pts.core.basics.log import log

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_required("remote", "string", "remote host to mount", choices=all_host_ids())
definition.add_required("ids", "integer_list", "simulation IDs")
definition.add_positional_optional("steps", "string_list", "re-analyse only certain steps", choices=all_steps, default=all_steps)
definition.add_positional_optional("features", "string_list", "re-analyse only certain features (if a single step is defined)")
definition.add_optional("not_steps", "string_list", "don't analyse these steps", choices=all_steps)
definition.add_optional("not_features", "string_list", "don't analyse these features (if a single not_step is defined)")

# Read the command line arguments
config = parse_arguments("reanalyse", definition, description="Re-analyse a certain simulation")

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

# Loop over the simulations
for simulation_id in config.ids:

    # Load the simulation
    simulation = get_simulation_for_host(config.remote, config.id)

    # Check whether retrieved (specific to remote simulations)
    if not simulation.retrieved: raise ValueError("The simulation has not been retrieved yet")

    # Inform the user
    log.info("Re-analysing simulation '" + simulation.name + "' (" + config.remote + " " + str(config.id) + ") ...")
Exemple #26
0
definition = ConfigurationDefinition(write_config=False)

# Quantity to convert and unit to convert to
definition.add_required("quantity", "string", "quantity to convert to another unit")
definition.add_required("unit", "string", "unit to convert the quantity to")

# Extra information
definition.add_optional("distance", "length_quantity", "distance")
definition.add_optional("wavelength", "length_quantity", "wavelength")
definition.add_optional("frequency", "frequency_quantity", "frequency")
definition.add_optional("pixelscale", "pixelscale", "pixelscale")
definition.add_optional("solid_angle", "solid_angle", "solid angle")
definition.add_optional("filter", "filter", "filter")

# Create the configuration
config = parse_arguments("convert", definition, "Convert a quantity from one unit to another")

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

# Check quantity
if is_photometric_quantity(config.quantity):

    #physical_types = possible_physical_types(config.quantity)
    #print(physical_types)

    # Density?
    density_flags = possible_density_flags(config.quantity)
    if len(density_flags) == 1: density = density_flags[0]
    elif len(density_flags) == 2: density = prompt_yn("density", "is this quantity (" + config.quantity + ") a spectral density?")
    else: raise RuntimeError("Something went wrong")
Exemple #27
0
definition.add_required("message", "string", "the commit message")

# Optional parameters
definition.add_positional_optional("git_remotes",
                                   "string_list",
                                   "the remote(s) to commit to",
                                   default="origin")
definition.add_optional("remote", "string",
                        "the remote on which to pull the changes")

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

# Get the configuration
config = parse_arguments(
    "push_pts",
    definition,
    description=
    "Add all, commit and push to remote repositories, and pull again on remote systems"
)

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

# Get the path to the PTS repository
pts_repo_path = introspection.pts_package_dir

# Stage all changes
subprocess.call(["git", "add", "--all"], cwd=pts_repo_path)

# Make a commit with the specified message
subprocess.call(["git", "commit", "-m", config.message], cwd=pts_repo_path)

# Push to the specified remotes
Exemple #28
0
definition.add_optional("covering_factor", "positive_real", "covering factor", 0.2) # fPDR

# Flags
definition.add_flag("plot", "plot the SEDs", False)
definition.add_flag("skirt", "use SKIRT", True)
definition.add_flag("pts", "use PTS", True)
definition.add_flag("sampled", "use SKIRT luminosities already sampled on a wavelength grid", True)
definition.add_flag("only_skirt", "only SKIRT", False)
definition.add_flag("only_pts", "only PTS", False)
definition.add_flag("only_sampled", "only sampled", False)

# Output path
definition.add_optional("output", "directory_path", "output path")

# Get the configuration
config = parse_arguments("sfr_to_lum", definition, "Convert a SFR to a luminosity in a certain band")

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

# Check
if config.only_skirt:
    config.pts = config.sampled = False
    config.skirt = True
elif config.only_pts:
    config.skirt = config.sampled = False
    config.pts = True
elif config.only_sampled:
    config.skirt = config.pts = False
    config.sampled = True

# -----------------------------------------------------------------
Exemple #29
0
# -----------------------------------------------------------------

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.tools import filesystem as fs
from pts.magic.region.list import load_region_list

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

definition = ConfigurationDefinition()
definition.add_required("path", "file_path", "region path list")
definition.add_required("factor", "positive_real", "scale factor")
config = parse_arguments("scale_regions", definition)

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

regions = load_region_list(config.path)

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

regions *= config.factor

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

# Remove the original file
fs.remove_file(config.path)

# Save the regions again
Exemple #30
0
# Import the relevant PTS classes and modules
from pts.core.extract.progress import extract_progress_cwd, ProgressTable
from pts.core.plot.progress import ProgressPlotter
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add flags
definition.add_flag("table", "save the extracted progress table")

# Get configuration
config = parse_arguments("plotprogress", definition)

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

# Look for a file in the current working directory that contains extracted progress information
progress_table_path = fs.join(fs.cwd(), "progress.dat")
if fs.is_file(progress_table_path): table = ProgressTable.from_file(progress_table_path)

# If extracted progress information is not present, first perform the extraction
else: table = extract_progress_cwd()

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

if config.table and not fs.is_file(progress_table_path): table.saveto(progress_table_path)

# -----------------------------------------------------------------
Exemple #31
0
from pts.core.prep.smile import SKIRTSmileSchema
from pts.core.tools import formatting as fmt
from pts.core.units.stringify import stringify_unit
from pts.core.basics.configuration import ConfigurationDefinition
from pts.core.basics.configuration import parse_arguments

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

# Create the configuration
definition = ConfigurationDefinition()
definition.add_positional_optional(
    "match", "string",
    "only show unit systems with names that contain this string")

# Parse
config = parse_arguments("skirt_units", definition)

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

# Create the SKIRT smile schema
smile = SKIRTSmileSchema()

print("")

# Loop over
for unit_system in smile.unit_systems:

    # Get default units
    units = smile.units_for_unit_system(unit_system)

    print(fmt.green + fmt.underlined + unit_system + fmt.reset)
Exemple #32
0
# -----------------------------------------------------------------

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.remote.remote import Remote

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

definition = ConfigurationDefinition()
definition.add_required("remote", "string", "remote host ID")
definition.add_required("line", "string", "line to be executed on the remote host")
config = parse_arguments("sessions", definition)

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

# Initialize the remote
remote = Remote()
if not remote.setup(config.remote): raise RuntimeError("The remote host '" + config.remote + "' is not available at the moment")

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

print("")
#print("-----------------------------------------------------------------")
print("OUTPUT")
print("-----------------------------------------------------------------")
print("")
Exemple #33
0
# Settings for the wavelength grid generation
definition.add_optional("npoints_range_basic", "integer_range", "range of the basic wavelength grid size", default_npoints_range_basic, convert_default=True)
definition.add_optional("npoints_range_refined", "integer_range", "range of the refined wavelength grid size", default_npoints_range_refined, convert_default=True)
definition.add_optional("npoints_range_highres", "integer_range", "range of the high-resolution wavelength grid size", default_npoints_range_highres, convert_default=True)
definition.add_optional("ngrids_basic", "integer", "number of basic wavelength grids to generate", default_ngrids_basic)
definition.add_optional("ngrids_refined", "integer", "number of refined wavelength grids to generate", default_ngrids_refined)
definition.add_optional("ngrids_highres", "integer", "number of high-resolution wavelength grids to generate", default_ngrids_highres)
definition.add_flag("add_emission_lines", "add emission lines to the wavelength grids", True)
definition.add_optional("range", "quantity_range", "range of wavelengths", default_wavelength_range, convert_default=True)

# Backup existing wavelength grids
definition.add_flag("backup", "backup existing wavelength grids", True)

# Create the configuration
config = parse_arguments("make_wavelength_grids", definition, "(Re)make the wavelength grids for a fitting run")

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

# Load the fitting run
fitting_run = runs.load(config.run)

#print("wavelength range of fitting filters: " + tostr(fitting_run.fitting_wavelength_range))
#print("wavelength range of fitting filters (min and max): " + tostr(fitting_run.absolute_fitting_wavelength_range))

#print("filters: " + tostr(fitting_run.normalization_filters))
#print("wavelengths: " + tostr(fitting_run.normalization_wavelengths))
#print("center wavelengths: " + tostr(fitting_run.normalization_center_wavelengths))
#print("effective wavelengths: " + tostr(fitting_run.normalization_effective_wavelengths))
#print("pivot wavelengths: " + tostr(fitting_run.normalization_pivot_wavelengths))
#print("mean wavelengths: " + tostr(fitting_run.normalization_mean_wavelengths))
Exemple #34
0
from pts.core.tools.stringify import tostr, stringify_list_fancy

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

# Create the definition
definition = ConfigurationDefinition()

# Wavelength range
definition.add_positional_optional("wavelength_range", "quantity_range", "wavelength range")

# Flags
definition.add_flag("filters", "show filters in regimes", False)
definition.add_flag("physical", "use physical regimes (star formation, stellar emission, aromatic features, dust thermal emission, microwave)", False)

# Parse the command line arguments
config = parse_arguments("regimes", definition)

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

# Physical
if config.physical:

    # Get the list of regimes
    if config.wavelength_range is not None: regimes = physical_regimes_in_range(config.wavelength_range)
    else: regimes = physical_regimes

    print("")
    for name in regimes:

        print(fmt.bold + fmt.blue + name + fmt.reset)
        print("")
Exemple #35
0
elif runs.has_single:
    definition.add_fixed("fitting_run", "name of the fitting run",
                         runs.single_name)
else:
    definition.add_required("fitting_run",
                            "string",
                            "name of the fitting run",
                            choices=runs.names)

# Generations
definition.add_positional_optional(
    "generations", "string_list",
    "name of the generations for which to check the database")

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

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

# Load the fitting run
fitting_run = FittingRun.from_name(modeling_path, config.fitting_run)

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

# Get generation names
generations = config.generations if config.generations is not None else fitting_run.genetic_generations

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

print("")
Exemple #36
0
from pts.core.remote.remote import Remote

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_required("remote",
                        "string",
                        "remote host to mount",
                        choices=all_host_ids())
definition.add_required("id", "positive_integer", "simulation ID")
definition.add_flag("debug_output", "show all simulation output in debug mode")

# Read the command line arguments
config = parse_arguments(
    "show_progress",
    definition,
    description="Show the progress of a remotely running simulation")

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

# Load the simulation
simulation = get_simulation_for_host(config.remote, config.id)

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

# Load the remote
remote = Remote()
if not remote.setup(host_id=config.remote):
    raise RuntimeError("Could not connect to the remote host")

# -----------------------------------------------------------------
Exemple #37
0
from pts.core.tools import introspection
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.remote.host import find_host_ids
from pts.core.remote.remote import Remote
from pts.core.tools import time

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

# Create definition
definition = ConfigurationDefinition()
definition.add_positional_optional("remote", "string", "remote host on which to clear the temporary directory", choices=find_host_ids())
definition.add_optional("names", "string_list", "remove temporary directories matching these names (e.g. 'installation' matches 'installation_2017-05-03--08-45-44-410', 'installation_2017-05-03--13-52-28-371', etc. and also exact matches")

# Create setter
config = parse_arguments("clear_temp", definition)

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

# Remote
if config.remote is not None:

    # Create the remote
    remote = Remote(host_id=config.remote)

    # Check whether names are given
    if config.names is not None:

        # Loop over the directories in the temporary directory
        for path, name in remote.directories_in_path(remote.pts_temp_path, returns=["path", "name"]):
Exemple #38
0
from pts.core.remote.remote import Remote
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

# Create definition
definition = ConfigurationDefinition()
definition.add_positional_optional("skirt_and_or_pts", "string_list", "SKIRT and/or PTS", default=["skirt", "pts"], choices=["skirt", "pts"])

# Add flags
definition.add_flag("conda", "also remove conda installation")
definition.add_flag("qt", "also remove Qt installation")
definition.add_flag("one_attempt", "only perform one attempt at connecting to a remote")

# Get the config
config = parse_arguments("deinstall_all", definition)

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

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

    # Setup
    remote = Remote()
    if not remote.setup(host_id, one_attempt=config.one_attempt):
        log.warning("Remote host '" + host_id + "' is offline")
        continue

    # Create uninstaller
    uninstaller = Uninstaller()
Exemple #39
0
# -----------------------------------------------------------------

formats = ["avi", "gif", "apng"]
default_format = "gif"

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

# Create the definition
definition = ConfigurationDefinition()

# File format
definition.add_optional("format", "string", "output format", default_format, choices=formats)
definition.add_optional("fps", "positive_integer", "frames per second", 10)

# Parse the command line arguments
config = parse_arguments("animate", definition)

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

# Add the frames
paths = fs.files_in_cwd(extension="png", sort=int)

# Determine path
path = "animation." + config.format

# APNG
if config.format == "apng":

    delay = 1000/config.fps  # in miliseconds

    # CRASHES
Exemple #40
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.tools import filesystem as fs
from pts.core.tools import introspection
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.modeling.component.component import load_modeling_history

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Get configuration
config = parse_arguments("history", definition)

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

# Local table path
local_table_path = fs.join(introspection.pts_dat_dir("modeling"), "s4g", "s4g_p4_table8.dat")

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

# Get the history
history = load_modeling_history(fs.cwd())

# Loop over the entries
for i in range(len(history)):
    print(history["Command"][i], history["Start time"][i], history["End time"][i])
from pts.core.tools import introspection
from pts.core.basics.log import log

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

# Create configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_required("remote", "string", "the remote host ID")

# Add flags
definition.add_flag("versions", "compare versions", "v")

# Get configuration
config = parse_arguments("compare_python_packages", definition)

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

# Create the remote execution environment
remote = Remote()

# Log in
remote.setup(config.remote)

# Get remote python session
remote_python = remote.start_python_session(assume_pts=False)

# Get all python packages installed on the remote host
remote_packages = remote_python.installed_packages
Exemple #42
0
# Import the relevant PTS classes and modules
from pts.modeling.core.environment import verify_modeling_cwd, GalaxyModelingEnvironment
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.tools import filesystem as fs

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

modeling_path = verify_modeling_cwd()

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

# Get config
definition = ConfigurationDefinition()
definition.add_required("commands", "string_list",
                        "commands to remove from the history")
config = parse_arguments("clear_from_history", definition)

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

environment = GalaxyModelingEnvironment(modeling_path)
history = environment.history

# Make backup
#backup_path = fs.appended_filepath(environment.history_file_path, "_backup")
#fs.copy_file(environment.history_file_path, backup_path)

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

# Loop over the commands
for command in config.commands:
    history.remove_entries(command)
Exemple #43
0
from pts.dustpedia.core.database import DustPediaDatabase, get_account
from pts.core.tools import formatting as fmt
from pts.core.tools import introspection
from pts.dustpedia.core.photometry import DustPediaPhotometry
from pts.core.tools import stringify

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

# Create the configuration definition
definition = ConfigurationDefinition()

# The galaxy name
definition.add_required("galaxy", "string", "galaxy name")

# Get configuration
config = parse_arguments("strategy", definition)

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

sample = DustPediaSample()

# Database
username, password = get_account()
database = DustPediaDatabase()
database.login(username, password)

# Get the DustPedia name
name = sample.get_name(config.galaxy)

# Get info
info = database.get_galaxy_info_table(name)
Exemple #44
0
all_host_ids = find_host_ids()
all_hosts = find_hosts()

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

# 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 + "' ...")
Exemple #45
0
# *****************************************************************

## \package pts.do.core.mount Mount a remote configured in PTS into a local directory.

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

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.remote.mounter import mount_and_open
from pts.core.remote.host import all_host_ids

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_required("remote", "string", "remote host to mount", choices=all_host_ids())
definition.add_positional_optional("path", "directory_path", "path of directory in which to create the mount point")

# Read the command line arguments
config = parse_arguments("mount", definition, description="Mount a remote configured in PTS into the local filesystem")

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

# Mount and open
mount_and_open(config.remote, path=config.path)

# -----------------------------------------------------------------
Exemple #46
0
from pts.modeling.maps.component import get_maps_sub_name
from pts.modeling.component.component import load_modeling_history
from pts.modeling.core.environment import verify_modeling_cwd

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add settings
definition.add_required("sub_name", "string", "maps sub name for plotting",
                        map_sub_names)
definition.add_positional_optional("method", "string", "method for plotting")

# Get configuration
config = parse_arguments("plot_maps", definition)

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

modeling_path = verify_modeling_cwd()

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

# Load the modeling environment
environment = GalaxyModelingEnvironment(modeling_path)

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

# Load the modeling history
history = load_modeling_history(modeling_path)
Exemple #47
0
    "remotes",
    "string_list",
    "the IDs of the remote hosts for which to clear the simulations",
    choices=find_host_ids(),
    default=find_host_ids())
definition.add_positional_optional("ids", "integer_list",
                                   "the IDs of the simulations to clear")
definition.add_flag(
    "full",
    "fully clear the simulations, also remove remote simulation directories")

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

# Parse the arguments into a configuration
config = parse_arguments(
    "clear_tasks",
    definition,
    description="Clear PTS tasks for a certain remote host")

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

# Loop over the remote hosts
for host_id in config.remotes:

    # Check whether the remote is available
    if config.full:
        remote = Remote()
        if not remote.setup(host_id):
            log.warning("The remote host '" + host_id +
                        "' is not available: skipping ...")
            continue
    else:
Exemple #48
0
# Import standard modules
import numpy as np

# Import the relevant PTS classes and modules
from pts.core.tools import formatting as fmt
from pts.core.tools import tables
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

definition = ConfigurationDefinition(write_config=False)
definition.add_required("path_a", "file_path", "path of the first table")
definition.add_required("path_b", "file_path", "path of the second table")

config = parse_arguments("compare_tables", definition, add_logging=False, add_cwd=False)

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

format_a = "ascii." + fs.get_extension(config.path_a)
format_b = "ascii." + fs.get_extension(config.path_b)

table_a = tables.from_file(config.path_a, format=format_a)
table_b = tables.from_file(config.path_b, format=format_b)

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

print("")

print(fmt.underlined + fmt.green + "Table a" + fmt.reset + " [" + config.path_a + "]:")
print("")
Exemple #49
0
# -----------------------------------------------------------------

# Get the modeling commands
modeling_path = verify_modeling_cwd()
filepaths = get_log_file_paths(modeling_path)

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add settings
definition.add_required("match", "string", "(partial) command name")

# Get configuration
config = parse_arguments("previous_config", definition)

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

matches = defaultdict(list)

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

# Loop over the filepaths
for filepath in filepaths:

    # Get the modeling command
    filename = fs.name(filepath)
    command = filename.split("__")[0]

    # Skip other commands
Exemple #50
0
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

## \package pts.do.magic.sky_to_pix Convert a sky coordinate to a pixel coordinate for a specific WCS.

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

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.basics.coordinatesystem import CoordinateSystem

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

definition = ConfigurationDefinition()

definition.add_required("coordinate", "skycoordinate", "the sky coordinate")
definition.add_required("wcs_path", "file_path", "the path to the file holding the WCS info")

# Get the configuration
config = parse_arguments("pix_to_sky", definition)

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

# Print the pixel coordinate
print(config.coordinate.to_pixel(CoordinateSystem.from_file(config.wcs_path)))

# -----------------------------------------------------------------
Exemple #51
0
# Import the relevant PTS classes and modules
from pts.core.prep.smile import SKIRTSmileSchema
from pts.core.tools import formatting as fmt
from pts.core.tools import stringify
from pts.core.basics.configuration import ConfigurationDefinition, write_definition, parse_arguments

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

# Create the configuration
definition = ConfigurationDefinition()
definition.add_positional_optional("match", "string", "only show types with names that contain this string")
definition.add_flag("definitions", "format the properties for each item as a configuration definition")

# Parse
config = parse_arguments("skirt_items", definition)

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

# Create the SKIRT smile schema
smile = SKIRTSmileSchema()

print("")

# Loop over the concrete types
for name in smile.concrete_types:

    if config.match is not None and config.match not in name: continue

    print(fmt.green + fmt.underlined + name + fmt.reset)
    print("")
Exemple #52
0
from pts.core.tools import introspection
from pts.core.tools import time
from pts.evolve.optimize.stepwise import StepWiseOptimizer
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)
Exemple #53
0
definition.add_flag("plot", "make a plot")
definition.add_optional("plot_path", "string", "plot output path")
definition.add_optional("plotting", "dictionary", "plotting options", dict())

# Formatting of the values
definition.add_flag("round", "round the table values")
definition.add_optional("ndecimal_places", "positive_integer", "number of decimal places when rounding")

# Additional options
definition.add_flag("unique", "show only the unique in each column")
definition.add_flag("sorted_unique", "sort the unique values")

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

# Create the configuration
config = parse_arguments("show_file", definition, add_logging=False, add_cwd=False)

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

def show_table(tab):

    """
    This function ...
    :param table:
    :return:
    """

    # Only unique values per column
    if config.unique:

        # Loop over the columns
Exemple #54
0
# Import the relevant PTS classes and modules
from pts.core.basics.table import SmartTable
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.tools import filesystem as fs
from pts.core.tools import sequences

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

# Create configuration
definition = ConfigurationDefinition(write_config=False)
definition.add_required("filename", "file_path", "table file")
definition.add_required("old_name", "string", "original column name")
definition.add_required("new_name", "string", "new column name")
definition.add_optional("method", "string", "table reading method", "lines")
config = parse_arguments("remove_columns", definition)

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

# Load the table
table = SmartTable.from_file(config.filename, method=config.method)

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

# Rename
table.rename_column(config.old_name, config.new_name)

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

# Save
table.save()
Exemple #55
0
# -----------------------------------------------------------------

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.log import log
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.remote.remote import Remote

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

definition = ConfigurationDefinition()
definition.add_required("remote", "string", "remote host ID")
setter = parse_arguments("sessions", definition)

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

remote = Remote()
if not remote.setup(config.remote):
    raise RuntimeError("The remote host '" + config.remote +
                       "' is not available at the moment")

screen_names = remote.screen_names()

tmux_names = remote.tmux_names()

print("SCREEN")
print(screen_names)
Exemple #56
0
from pts.core.advanced.resources import ResourceEstimator
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import log

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

# Create the command-line parser
definition = ConfigurationDefinition()
definition.add_required("skifile", "file_path", "name of the ski file")
definition.add_required("nthreads", "positive_integer",
                        "number of parallel threads")
definition.add_required("nprocesses", "positive_integer",
                        "number of parallel processes")

# Parse
config = parse_arguments("estimate", definition)

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

# Determine the full path to the parameter file
ski_path = config.skifile

# Create and run a ResourceEstimator oject
estimator = ResourceEstimator()
estimator.run(ski_path, config.nprocesses, config.nthreads)

# Inform the user about the resource requirements
log.info("This simulation requires " + estimator.memory +
         " GB of virtual memory")
#log.info("This simulation requires a walltime of " + estimator.walltime)
Exemple #57
0
# -----------------------------------------------------------------

# Create the configuration
definition = ConfigurationDefinition()
definition.add_required("add_to", "file_path", "add to this FITS file")
definition.add_required("add_from", "file_path", "add from this FITS file")
definition.add_flag("frames", "add frames", True)
definition.add_flag("masks", "add masks", True)
definition.add_flag("segments", "add segmentation maps", True)
definition.add_flag("replace", "replace planes", False)
definition.add_flag("replace_frames", "replace frames", False)
definition.add_flag("replace_masks", "replace masks", False)
definition.add_flag("replace_segments", "replace segmentation maps", False)
definition.add_flag("backup", "make backup", False)
config = parse_arguments("interpolate", definition)

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

if config.replace: config.replace_frames = config.replace_masks = config.replace_segments = True

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

# Inform the user
log.info("Loading the images ...")

# Load
to_image = Image.from_file(config.add_to)
from_image = Image.from_file(config.add_from)

# -----------------------------------------------------------------
Exemple #58
0
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.dustpedia.core.database import DustPediaDatabase, get_account
from pts.dustpedia.core.sample import DustPediaSample
from pts.core.tools import filesystem as fs
from pts.core.tools.stringify import tostr
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments

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

definition = ConfigurationDefinition()
definition.add_required("galaxy_name", "string", "galaxy name")

# Set
config = parse_arguments("get_mbb_parameters", definition)

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

path = fs.cwd()

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

# Create the DustPedia sample
sample = DustPediaSample()
galaxy_name = sample.get_name(config.galaxy_name)

# Create the database
database = DustPediaDatabase()

# Login