本文整理汇总了Python中pts.core.basics.configuration.parse_arguments函数的典型用法代码示例。如果您正苦于以下问题:Python parse_arguments函数的具体用法?Python parse_arguments怎么用?Python parse_arguments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_arguments函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: features
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
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:generation_reanalysis.py
示例2: ConfigurationDefinition
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) + ") ...")
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:reanalyse.py
示例3: ConfigurationDefinition
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)
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:normalizations.py
示例4: ConfigurationDefinition
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()
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:plot_galaxies.py
示例5: parse_arguments
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
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:show_residuals.py
示例6: ConfigurationDefinition
# -----------------------------------------------------------------
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
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:animate.py
示例7: ConfigurationDefinition
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)
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:multiply.py
示例8: ConfigurationDefinition
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()
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:deinstall_all.py
示例9: find_host_ids
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 + "' ...")
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:remotes.py
示例10: ConfigurationDefinition
# -----------------------------------------------------------------
# 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("")
开发者ID:SKIRT,项目名称:PTS,代码行数:29,代码来源:execute.py
示例11: ConfigurationDefinition
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("")
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:regimes.py
示例12: ConfigurationDefinition
# 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)
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:plotprogress.py
示例13: parse_arguments
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
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:sfr_to_lum.py
示例14: ConfigurationDefinition
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")
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:convert.py
示例15: ConfigurationDefinition
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"]):
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:clear_temp.py
示例16: ConfigurationDefinition
# 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("")
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:compare_tables.py
示例17: ConfigurationDefinition
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
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:clear_simulations.py
示例18: ConfigurationDefinition
# ** © 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)))
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:sky_to_pix.py
示例19: FittingRuns
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
# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:check_populations.py
示例20: ConfigurationDefinition
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)
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:test_tsp_steps.py
注:本文中的pts.core.basics.configuration.parse_arguments函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论