Пример #1
0
## \package pts.do.modeling.list_parameters

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

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

# Import the relevant PTS classes and modules
from pts.core.tools import formatting as fmt
from pts.modeling.config.parameters import possible_parameter_types, possible_parameter_types_descriptions, default_units
from pts.core.units.stringify import represent_unit as ru
from pts.core.basics.configuration import ConfigurationDefinition

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

definition = ConfigurationDefinition()

definition.add_positional_optional("modeling_type", "string", "modeling type")

print("")

for parameter_types in possible_parameter_types:

    print(fmt.green + fmt.bold + parameter_types + fmt.reset)

    print("")
    print(
        " - Description: " +
        possible_parameter_types_descriptions[parameter_types].split(" (")[0])
    print(" - Default unit: " + ru(default_units[parameter_types]))
    print("")
Пример #2
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.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.basics.log import log
from pts.magic.core.image import Image

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

# 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
Пример #3
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.modeling.plotting.preparation import PreparationPlotter

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

# Create the configuration
definition = ConfigurationDefinition(log_path="log", config_path="config")

# Add settings
definition.add_positional_optional("features", "string_list", "features to be plotted", choices=PreparationPlotter.features())

# -----------------------------------------------------------------
Пример #4
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

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

# Additional relative error
definition.add_optional("additional_error", "percentage", "additional percentual error for the observed flux points")

# Flags
definition.add_flag("write", "write the results", True)

# -----------------------------------------------------------------
Пример #5
0
## \package pts.do.core.normalizations Show the normalizations of stellar components in a ski file.

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

# 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.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
Пример #6
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create definition
definition = ConfigurationDefinition(write_config=False)

# Number of frames
definition.add_optional("nframes", "positive_integer", "number of frames", 2)

# Size of frames
definition.add_optional("npixels", "positive_integer",
                        "number of pixels of the frames", 500)

# Number of sources
definition.add_optional("nrandom_sources", "positive_integer",
                        "number of point sources", 100)

# Flags
definition.add_flag("vary_fwhm", "vary the FWHM", False)

# PSF model
Пример #7
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import standard modules
import subprocess

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.tools import introspection
from pts.core.prep.update import PTSUpdater

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

# Configuration definition
definition = ConfigurationDefinition()

# Required parameters
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
Пример #8
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
from pts.core.basics.animation import Animation
from pts.core.basics.apng import APNG
from pts.core.basics.numpngw import write_apng

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

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
Пример #9
0
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.modeling.fitting.component import get_populations
from pts.modeling.fitting.run import get_generations_table, get_generation_path
from pts.modeling.fitting.generation import Generation
from pts.modeling.core.environment import verify_modeling_cwd
from pts.modeling.fitting.run import FittingRuns

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

modeling_path = verify_modeling_cwd()
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)
Пример #10
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create configuration definition
definition = ConfigurationDefinition()

# Add optional arguments
definition.add_positional_optional("host_id", "string", "install SKIRT/PTS remotely")
definition.add_optional("repository", "string", "repository name from which to clone (only possible when installing remotely and SKIRT/PTS is already installed locally)")

# Add flags
definition.add_flag("private", "use the private SKIRT/PTS repository")

# Advanced
definition.add_flag("force", "force re-installation when already present", letter="f")
definition.add_flag("force_conda", "force installation of conda and creation of a conda environment even when it is already present")

definition.add_flag("finish", "finish previously initiated installation")

# Add flag
#definition.add_flag("all_remotes", "update on all remote hosts")
Пример #11
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.host import find_host_ids
from pts.core.tools import introspection
from pts.core.tools import filesystem as fs
from pts.core.simulation.simulation import RemoteSimulation
from pts.core.remote.remote import Remote
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:
Пример #12
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.modeling.fitting.component import get_generation_names, get_last_finished_generation
from pts.core.tools import filesystem as fs

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

# Create the configuration
definition = ConfigurationDefinition(log_path="log", config_path="config")

# Add settings
definition.add_positional_optional("features", "string_list", "features to be plotted")
definition.add_positional_optional("generation", "string", "generation for which to plot the features", choices=get_generation_names(fs.cwd()), default=get_last_finished_generation(fs.cwd()))

# -----------------------------------------------------------------
Пример #13
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.core.remote.host import find_host_ids
from pts.core.config.analyse_simulation import definition as analysis_definition

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

# Create the configuration
definition = ConfigurationDefinition(write_config=False)

# Add positional optional
definition.add_positional_optional("host_ids", "string_list", "name of the remote host(s) for which to show/retrieve simulations and tasks", choices=find_host_ids())
definition.add_positional_optional("ids", "string_integer_list_dictionary", "simulation IDs for the different remote hosts")

# Add flag
definition.add_flag("show_progress", "show the progress of the simulation that is still running (only if there is just one)", False)
definition.add_flag("debug_output", "show all simulation output in debug mode")

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

definition.add_flag("retrieve", "retrieve finished simulations", True)
definition.add_flag("analyse", "analyse retrieved simulations", True)

# -----------------------------------------------------------------
Пример #14
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 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
Пример #15
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import standard modules
import StringIO

# 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:
Пример #16
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration
definition = ConfigurationDefinition()

# Add optional arguments
definition.add_section("wavelengths")
definition.sections["wavelengths"].add_optional("unit", str, "the unit of the wavelengths", "micron")
definition.sections["wavelengths"].add_optional("min", float, "the minimum wavelength", 0.09)
definition.sections["wavelengths"].add_optional("max", float, "the maximum wavelength", 2000)
definition.sections["wavelengths"].add_optional("npoints", int, "the number of wavelength points", 100)
definition.sections["wavelengths"].add_optional("min_zoom", float, "the minimum wavelength of the zoomed-in grid", 1)
definition.sections["wavelengths"].add_optional("max_zoom", float, "the maximum wavelength of the zoomed-in grid", 30)
definition.sections["wavelengths"].add_optional("npoints_zoom", int, "the number of wavelength points in the zoomed-in grid", 100)

definition.add_optional("packages", float, "the number of photon packages per wavelength", 2e5)
definition.add_flag("selfabsorption", "enable dust self-absorption")
definition.add_optional("dust_grid", str, "the type of dust grid to use (bintree, octtree or cartesian)", "bintree")

# -----------------------------------------------------------------
Пример #17
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.plot.sed import plot_sed
from pts.core.plot.distribution import plot_distribution
from pts.core.tools import formatting as fmt
from pts.core.tools import sequences
from pts.core.tools.stringify import tostr
from pts.core.basics.structure import load_structure, filetypes, composite, table, dictionary, sed, distribution, regions

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

# Create configuration definition
definition = ConfigurationDefinition(write_config=False)
definition.add_required("filetype", "string", "type of file", choices=filetypes)
definition.add_required("filename", "file_path", "path of the dictionary file")

# As table?
definition.add_flag("table", "show as table")

# Displaying and formatting
definition.add_flag("interactive", "display tables interactively", False)
definition.add_flag("latex", "print as latex")

# Modyfying the table
definition.add_optional("columns", "string_list", "only show these columns")
definition.add_optional("sort", "string", "sort the entries on this column")

# Extra options
Пример #18
0
# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.core.config.plot import definition as plot_definition
from pts.core.basics.plot import plotting_libraries, mpl

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

formats = ["pdf", "png"]
default_format = "pdf"
normalizations = ["max", "sum"]

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

# Create configuration definition
definition = ConfigurationDefinition()

# Distributions
definition.add_positional_optional("distributions", "filepath_list", "distribution files to be plotted")
definition.add_flag("panels", "plot the distributions in separate panels")
definition.add_flag("recursive", "search distribution files recursively in the working directory")
definition.add_optional("normalize", "string", "normalize all distributions by a certain method", choices=normalizations)
definition.add_optional("normalization_value", "real", "value for normalization", 1.)

# Add plotting options
definition.import_section("plot", "plotting options", plot_definition)
definition.sections["plot"].optional["xsize"].default = 8
definition.sections["plot"].optional["ysize"].default = 4
definition.add_flag("logscale", "use value log scale")
definition.add_flag("logfrequency", "use log scale for frequency")
definition.add_optional("bar_width", "positive_real", "relative width of the bars (1 means edges touch)", 1.)
Пример #19
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create configuration definition
definition = ConfigurationDefinition()

# Add optional
definition.add_positional_optional("ski", "file_path", "ski file to be used (if not specified, all ski files in the current directory will be used)")

# Add flag
definition.add_flag("recursive", "look for ski files recursively")

# Add optional
definition.add_optional("remote", "string", "the remote host (no schedulers) on which to launch the simulations", choices=find_host_ids(schedulers=False))

# Add optional
definition.add_optional("nprocesses", "integer", "number of processes to use", 1)
definition.add_flag("data_parallel", "use data parallelization mode")

# -----------------------------------------------------------------
Пример #20
0
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.core.basics.plot import normal_colormaps
from pts.magic.plot.imagegrid import default_cmap, light_theme, themes

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

# Create definition
definition = ConfigurationDefinition(write_config=False)

# From directory
definition.add_optional("from_directory", "directory_path", "load images from directory")

# Colormap
definition.add_optional("cmap", "string", "colormap", default_cmap, choices=normal_colormaps)

# Options
definition.add_optional("axes_label_size", "positive_integer", "axes label size", 14)
definition.add_optional("ticks_label_size", "positive_integer", "ticks label size", 8)
definition.add_optional("legend_fontsize", "positive_integer", "legend fontsize", 14)
definition.add_optional("legend_markers_cale", "positive_integer", "legend marker scale", 0)
definition.add_optional("lines_marker_size", "positive_real", "lines marker size", 2.5)
definition.add_optional("linewidth", "positive_integer", "linewidth", 1)

# Dark or light theme?
Пример #21
0
## \package pts.do.developer.sessions Check screen/tmux sessions on the remote host.

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

# 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")
Пример #22
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.magic.maps.colour.colour import colour_strings

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

# Create the configuration
definition = ConfigurationDefinition()

# Add optional
definition.add_positional_optional("colours", "string_list", "colour maps to make", default=colour_strings, suggestions=colour_strings)

# -----------------------------------------------------------------
Пример #23
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Flags
definition.add_flag("recursive",
                    "look for simulation in directories recursively", True)

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

# Flags
definition.add_flag("other", "also plot the 'other' phases")
definition.add_flag(
    "group",
    "group timelines for the same number of processes in the same plot")
Пример #24
0
# -----------------------------------------------------------------

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

# Import the relevant PTS classes and modules
from pts.core.remote.remote import Remote
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
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()
Пример #25
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add optional
host_ids = find_host_ids()
if len(host_ids) > 0:
    definition.add_positional_optional("host_ids",
                                       "string_list",
                                       "remote host ids",
                                       choices=host_ids,
                                       default=host_ids)
else:
    definition.add_fixed("host_ids", "remote host_ids", [])

# Add optional
definition.add_optional("pts_repo_name",
                        "string",
Пример #26
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.evolve.solve.extremizer import genetic_definition

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

# Create the configuration
definition = ConfigurationDefinition()

# Genetic settings
definition.import_section("genetic", "genetic algorithm settings",
                          genetic_definition)

# Add
definition.sections["genetic"].add_optional("ngenerations", "positive_integer",
                                            "number of generations", 10)
definition.sections["genetic"].add_optional(
    "nindividuals", "even_integer", "number of individuals per generation",
    100)

# -----------------------------------------------------------------
Пример #27
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_positional_optional("remote", "string", "name of the remote host", choices=find_host_ids())
definition.add_positional_optional("matching", "string", "only adapt settings with a name matching this string")
definition.add_positional_optional("ids", "integer_list", "simulation IDs (if none specified, all simulation IDs will be used)")
definition.add_optional("names", "string_list", "simulation names")
definition.add_flag("from_directories", "use directory names as simulation names")

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

# Select certain properties
definition.add_optional("contains", "string", "only adapt properties containing this string in their name")
definition.add_optional("not_contains", "string", "don't adapt properties containing this string in their name")
definition.add_optional("exact_name", "string", "only adapt properties with this exact string as their name")
definition.add_optional("exact_not_name", "string", "don't adapt properties with this exact string as their name")
definition.add_optional("startswith", "string", "only adapt properties whose name starts with this string")
Пример #28
0
from pts.modeling.core.environment import verify_modeling_cwd

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

# Set modeling path
modeling_path = verify_modeling_cwd()

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

default_fitting_method = get_default_fitting_method(modeling_path)
cache_host_id = get_cache_host_id(modeling_path)

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

# Create the configuration
definition = ConfigurationDefinition()

# Add flags
definition.add_flag("check_hosts",
                    "check the availability of the remote hosts", True)
definition.add_flag("deploy", "deploy SKIRT and PTS where necessary", False)
definition.add_flag("check_versions",
                    "check versions of SKIRT and PTS where necessary", True)
definition.add_flag("update_dependencies", "update PTS dependencies", False)

# Advanced settings
definition.add_flag("local", "keep computationaly heavy computations local")
definition.add_optional(
    "remotes",
    "string_list",
    "remote hosts for computationally heavy computations (overrule the modeling configuration)",
Пример #29
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Optional
definition.add_optional("default_fwhm",
                        "quantity",
                        "default FWHM",
                        "2.0 arcsec",
                        convert_default=True)
definition.add_optional("sigma_level", "real", "sigma level", 4.0)

# -----------------------------------------------------------------
Пример #30
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_required("ski", "file_path", "path to the ski file")

# Add optional
definition.add_optional("input", "directory_path", "path to the input directory")

# Add optional
definition.add_optional("nwavelengths", "integer", "the number of wavelengths (useful for when a file wavelength grid is used and the file is not present)")
definition.add_optional("ncells", "integer", "number of dust cells (useful only when the ski file includes a tree dust grid)")

# Add flag
definition.add_flag("probe", "probe the number of cells (or memory usage) by launching a dry-run of the simulation, if necessary (tree dust grid and ncells not specified)", True)

# Add optional
definition.add_optional("nprocesses", "integer_list", "number of processes", [1, 2, 4, 8, 12, 20])
Пример #31
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.host import all_host_ids
from pts.core.simulation.remote import get_simulation_for_host
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:
Пример #32
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create definition
definition = ConfigurationDefinition(write_config=False)

definition.add_flag("plot", "do plotting", False)

definition.add_flag("rotate", "rotation", True)

definition.add_optional("nrandom_sources", "positive_integer",
                        "number of random sources", 100)

definition.add_flag("vary_fwhm", "vary the FWHM slightly for each star", True)

definition.add_flag("add_catalogued_sources", "add catalogued sources", False)

definition.add_optional("point_source_catalogs", "string_list",
                        "point source catalogs", ["II/246"])

definition.add_optional("nfilters_stars", "positive_integer",
Пример #33
0
# *****************************************************************

## \package pts.do.magic.rebin Rebin a set of images to the same pixel grid.

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

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

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

# 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", "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)
Пример #34
0
# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import standard modules
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")
Пример #35
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.modeling.reporting.reporting import steps

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

# Create the configuration
definition = ConfigurationDefinition(log_path="log", config_path="config")

# The modeling step for which to create the report
definition.add_required("step", "string", "the modeling step", choices=steps)

# -----------------------------------------------------------------
Пример #36
0
# Import the relevant PTS classes and modules
from pts.core.tools import time
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.dustpedia.core.sample import DustPediaSample
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)
Пример #37
0
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.core.remote.host import find_host_ids
from pts.modeling.tests.base import default_free_parameters, possible_free_parameters
from pts.evolve.solve.extremizer import genetic_definition

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

# Create definition
definition = ConfigurationDefinition(write_config=False)

# Optional settings
definition.add_optional("nwavelengths", "positive_integer", "number of wavelengths for the reference simulation", 50)
definition.add_optional("npackages", "positive_integer", "number of photon packages per wavelength for the reference simulation", int(1e5))
definition.add_optional("dust_grid_relative_scale", "real", "smallest scale of the dust grid relative to the pixelscale of the input maps", 2.)
definition.add_optional("dust_grid_min_level", "positive_integer", "level for the dust grid", 2)
definition.add_optional("dust_grid_max_mass_fraction", "positive_real", "max mass fraction for the dust grid", 1e-6)

# Flags
definition.add_flag("transient_heating", "enable transient heating", False)
definition.add_flag("selfabsorption", "enable dust selfabsorption", False)

# For remote execution
definition.add_optional("host_ids", "string_list", "remote hosts to use for heavy computations and simulations", choices=find_host_ids())
definition.add_flag("attached", "launch remote executions in attached mode", False)
Пример #38
0
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.dustpedia.core.database import DustPediaDatabase, get_account
from pts.dustpedia.core.sample import DustPediaSample
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)

# -----------------------------------------------------------------
Пример #39
0
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.magic.config.extract import definition as extraction_definition
from pts.magic.config.subtract_sky import definition as subtraction_definition
from pts.core.tools.parallelization import ncores

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

# Create the configuration
definition = ConfigurationDefinition()

# The dataset or image
definition.add_positional_optional("dataset", "file_path",
                                   "name of the dataset file or image file")

# The maximum FWHM (minimum resolution that has to be retained in the convolved frames)
definition.add_optional("max_fwhm", "quantity", "maximum FWHM for convolution")

# The minimum pixel size (minimum resolution that has to be retained in the rebinned frames)
definition.add_optional("max_pixelscale", "quantity",
                        "maximum pixelscale for rebinning")

# Add input section
#definition.add_section("input", "the names of the input files")
#definition.sections["input"].add_required("image", "image_path", "name of the input image")
Пример #40
0
Файл: mount.py Проект: SKIRT/PTS
# *****************************************************************

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

# -----------------------------------------------------------------
Пример #41
0
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

default_host_name = "www"

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

# Create the configuration
definition = ConfigurationDefinition(log_path="log", config_path="config")

# Upload
definition.add_optional("host_name",
                        "string",
                        "remote host name",
                        default_host_name,
                        choices=smb_host_ids())

# Flags
definition.add_flag("regenerate", "regenerate the pages", False)
definition.add_flag("replot", "make plots again", False)

# -----------------------------------------------------------------
Пример #42
0
## \package pts.do.modeling.clear Clear the output of one of the radiative transfer modeling steps.

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

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

# Import the relevant PTS classes and modules
from pts.core.tools import logging, time
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, ConfigurationReader

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

# Create the configuration definition
definition = ConfigurationDefinition()

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

# Get the configuration
reader = ConfigurationReader("clear")
config = reader.read(definition)

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

# Determine the log file path
logfile_path = fs.join(fs.cwd(), "log", time.unique_name("log") + ".txt") if config.arguments.report else None

# Determine the log level
level = "DEBUG" if config.arguments.debug else "INFO"
Пример #43
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# -----------------------------------------------------------------
Пример #44
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.host import find_host_ids
from pts.core.tools import filesystem as fs
from pts.core.remote.remote import Remote
from pts.core.basics.task import Task
from pts.core.tools import introspection

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

# 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,
Пример #45
0
# *****************************************************************

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

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

methods = ["skirt", "pts"]
default_method = "pts"
default_downsample_factor = 2.
default_parallelization = "2:1:2"  # 2 cores, 1 process, 2 threads per core

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

# Create the configuration
definition = ConfigurationDefinition(log_path="log", config_path="config")

# Method
definition.add_optional("method",
                        "string",
                        "method for deprojection",
                        default_method,
                        choices=methods)

# Downsample
definition.add_optional(
    "downsample_factor", "positive_real",
    "downsample factor of the deprojected map w.r.t the original map",
    default_downsample_factor)

# Writing
Пример #46
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Required arguments
definition.add_required(
    "ski_path", "file_path",
    "the name of the ski file to be used for the scaling test")
definition.add_required("remote", "string", "the name of the remote host")
definition.add_required("mode",
                        "string",
                        "the parallelization mode for the scaling test",
                        choices=["mpi", "hybrid", "threads"])

# Optional arguments
definition.add_positional_optional("maxnodes", "real",
                                   "the maximum number of nodes", 1)
definition.add_positional_optional(
    "minnodes", "real",
    "the minimum number of nodes. In hybrid mode, this also defines the number of threads per process",
Пример #47
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration
definition = ConfigurationDefinition()

# Number of processes to use
definition.add_optional("nprocesses", "positive_integer", "number of parallel processes", 8)

# Flags
definition.add_flag("write", "write results", True)

# -----------------------------------------------------------------
Пример #48
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
from pts.magic.core.cutout import interpolation_methods

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

default_method = "pts"
default_interpolation_method = "pts"

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

# Create the configuration
definition = ConfigurationDefinition()
definition.add_required("image", "string", "name of the input image")
definition.add_required("regions", "string", "name of the regions file over which to interpolate")
definition.add_flag("write_mask", "write out the mask")
definition.add_optional("color", "string", "only interpolate over the shapes with this color")
definition.add_optional("ignore_color", "string", "ignore shapes with this particular color")
definition.add_optional("shapes", "string_list", "only interpolate over these kinds of shapes")
definition.add_optional("input", "string", "name of the input directory", letter="i")
definition.add_optional("output", "string", "name of the output directory", letter="o")
definition.add_optional("method", "string", "interpolation method to use", default=default_method)
definition.add_optional("interpolation_method", "string", "interpolation method", default_interpolation_method, choices=interpolation_methods)
definition.add_flag("sigma_clip", "apply sigma clipping before interpolation", True)
definition.add_optional("source_outer_factor", "real", "outer factor", 1.4)
definition.add_flag("plot", "plot after interpolation", False)
definition.add_flag("replace", "allow the original image to be replaced", False)
definition.add_flag("backup", "backup if replaced", True)
Пример #49
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create
definition = ConfigurationDefinition()

# Commands to be run
definition.add_optional("commands", "string_list", "commands to be run in interactive mode")

# Interactive mode
definition.add_flag("interactive", "use interactive mode", default=None)

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

# Showing
definition.add_flag("show", "show stuff", True)
definition.add_flag("show_components", "show the model components", False)

# Plotting
definition.add_flag("plot", "do plotting", True)

# Writing
Пример #50
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.host import find_host_ids
from pts.core.tools import introspection
from pts.core.tools import filesystem as fs
from pts.core.simulation.simulation import RemoteSimulation
from pts.core.remote.remote import Remote
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")

# -----------------------------------------------------------------
Пример #51
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

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

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Optional
definition.add_optional("default_fwhm", "quantity", "default FWHM", "2.0 arcsec", convert_default=True)
definition.add_optional("sigma_level", "real", "sigma level", 4.0)

# -----------------------------------------------------------------
Пример #52
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.environment import find_modeling_environment_up_cwd
from pts.magic.plot.imagegrid import ResidualImageGridPlotter
from pts.core.tools import filesystem as fs
from pts.magic.core.frame import Frame

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

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_optional("not_filters", "lazy_broad_band_filter_list", "don't show these filters")

definition.add_flag("downsample", "perform downsampling")
definition.add_optional("max_npixels", "positive_integer", "maximum number of pixels to enabled downsampling", 400)
definition.add_flag("truncate", "truncate the images", True)

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")
Пример #53
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 logging
from pts.magic.tools import catalogs
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, ConfigurationReader

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

# Create the configuration
definition = ConfigurationDefinition()

# Add required settings
definition.add_required("name", str, "the name of the galaxy")

# Get configuration
reader = ConfigurationReader("setup")
config = reader.read(definition)

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

# Determine the log level
level = "DEBUG" if config.debug else "INFO"

# Initialize the logger
log = logging.setup_log(level=level)
Пример #54
0
from pts.modeling.component.component import get_log_file_paths
from pts.core.tools import filesystem as fs
from pts.core.basics.log import log
from pts.core.tools import time
from pts.core.tools import formatting as fmt

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

# 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:
Пример #55
0
## \package pts.do.modeling.clear Clear the output of one of the radiative transfer modeling steps.

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

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

# Import the relevant PTS classes and modules
from pts.core.tools import logging, time
from pts.core.tools import filesystem as fs
from pts.core.basics.configuration import ConfigurationDefinition, ConfigurationReader

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

# Create the configuration definition
definition = ConfigurationDefinition()

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

# Get the configuration
reader = ConfigurationReader("clear")
config = reader.read(definition)

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

# Determine the log file path
logfile_path = fs.join(fs.cwd(), "log", time.unique_name("log") + ".txt") if config.arguments.report else None

# Determine the log level
level = "DEBUG" if config.arguments.debug else "INFO"
Пример #56
0
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# **       PTS -- Python Toolkit for working with SKIRT          **
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition
from pts.magic.tools.catalogs import stellar_catalog_descriptions

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

# Create the configuration definition
definition = ConfigurationDefinition()

definition.add_flag(
    "use_frame_fwhm",
    "If possible, avoid the fitting procedure and use the FWHM defined by the frame",
    True)
definition.add_optional("input_path", "directory_path",
                        "path to the input directory")
definition.add_optional("output_path", "directory_path",
                        "path to the output directory")
definition.add_flag("track_record", "track record", False)
definition.add_flag("plot_track_record_if_exception", True)
definition.add_optional("manual_region", "file_path", "manual star region")
definition.add_flag("remove", "remove stars from the frame", True)
definition.add_flag("find_saturation", "find saturated stars", True)

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