本文整理汇总了Python中pts.core.basics.configuration.ConfigurationDefinition.add_positional_optional方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationDefinition.add_positional_optional方法的具体用法?Python ConfigurationDefinition.add_positional_optional怎么用?Python ConfigurationDefinition.add_positional_optional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts.core.basics.configuration.ConfigurationDefinition
的用法示例。
在下文中一共展示了ConfigurationDefinition.add_positional_optional方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# -----------------------------------------------------------------
# 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: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
#!/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")
# -----------------------------------------------------------------
示例3: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# *****************************************************************
# ** 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", suggestions=["remote"])
definition.add_positional_optional("ids", "integer_list", "simulation IDs")
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")
definition.add_optional("endswith", "string", "only adapt properties whose name starts with this string")
示例4: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
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.)
definition.add_flag("use_name_xlabel", "use the distribution name(s) for the x labels of the panels")
definition.add_flag("colours_per_panel", "reuse the same colours for each panel")
示例5: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# *****************************************************************
## \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)
# -----------------------------------------------------------------
示例6: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# 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
if config.names is not None:
示例7: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# -*- 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")
# For PTS:
示例8: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
#!/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
definition.add_positional_optional("host_id", "string", "update on a remote system")
# Add flags
definition.add_flag("dependencies", "also update the dependencies", False)
# Add flag
#definition.add_flag("all_remotes", "update on all remote hosts")
definition.add_flag("conda", "update conda", False)
# -----------------------------------------------------------------
示例9: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.tools.wavelengths import all_regimes, regimes_in_range, wavelength_range_for_regime
from pts.magic.tools.wavelengths import physical_regimes, physical_ranges, physical_regimes_in_range
from pts.core.tools import formatting as fmt
from pts.core.filter.broad import get_filters as get_broad_band_filters
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)
示例10: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
default_instruments_loc = "lower center"
default_observations_loc = "upper left"
default_models_loc = "upper right"
# Locations
locations = sequences.get_lists_combinations(["upper", "center", "lower"], ["left", "center", "right"], combine=lambda x: " ".join(x) if x[0] != x[1] else x[0])
# -----------------------------------------------------------------
# Create configuration definition
definition = ConfigurationDefinition()
#definition.add_flag("old", "old plotting methods", False)
# SEDs from file
definition.add_positional_optional("seds", "filepath_list_or_string_filepath_dictionary", "SED files to be plotted")
definition.add_flag("multi", "look for multiple SEDs per file", False)
definition.add_optional("wavelength_unit_file", "length_unit", "wavelength unit in SED file")
definition.add_optional("unit_file", "photometric_unit", "photometric unit in SED file")
definition.add_optional("distance", "length_quantity", "object distance (for flux <> luminosity unit conversion")
# Add plotting options
definition.import_section("plot", "plotting options", plot_definition)
# Add optional
definition.add_optional("output", "string", "output directory")
definition.add_optional("format", "string", "plotting format", default=default_format, choices=formats)
# -----------------------------------------------------------------
# The unit in which to plot
示例11: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.core.data.sun import Sun
from pts.core.tools import filesystem as fs
from pts.core.data.sed import SED
from pts.core.simulation.wavelengthgrid import WavelengthGrid
# -----------------------------------------------------------------
# Create definition
definition = ConfigurationDefinition()
# Filter
definition.add_required("filter", "filter", "filter in which to calculate the luminosity")
# SFR
definition.add_positional_optional("sfr", "quantity", "star formation rate", "1. Msun/yr", convert_default=True)
# MAPPINGS parameters
definition.add_optional("metallicity", "positive_real", "metallicity", 0.02)
definition.add_optional("compactness", "positive_real", "compactness", 6)
definition.add_optional("pressure", "quantity", "pressure", 1e12 * u("K/m3"))
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)
示例12: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
#!/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.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")
# -----------------------------------------------------------------
示例13: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# -----------------------------------------------------------------
# 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")
示例14: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# *****************************************************************
# ** 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.test.pts import subprojects_with_tests
# -----------------------------------------------------------------
# Create configuration definition
definition = ConfigurationDefinition()
# Add optional
definition.add_positional_optional("subprojects", "string_list", "update on a remote system", subprojects_with_tests(), choices=subprojects_with_tests())
definition.add_positional_optional("tests", "string_list", "test(s) to perform (when one subproject is specified)")
# Flags
definition.add_flag("check_imports", "check import statements", True)
definition.add_flag("check_commands", "check commands", True)
definition.add_flag("check_configurations", "check configurations", True)
definition.add_flag("check_packages", "check package definitions", True)
definition.add_flag("only_checks", "only performs checks, no actual test cases", False)
definition.add_flag("only_tests", "only perform the test cases, not internal checks", False)
# Add flags
definition.add_flag("keep", "keep the output")
definition.add_flag("show", "show results")
definition.add_flag("write", "write results")
definition.add_flag("open_output", "open the output directory after each test for manual inspection")
示例15: ConfigurationDefinition
# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_positional_optional [as 别名]
# ** © 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_basic import definition as basic_definition
from pts.core.config.analyse_batch import definition as batch_definition
# -----------------------------------------------------------------
# Create the configuration definition
definition = ConfigurationDefinition()
# Add required
definition.add_positional_optional("remote", "string", "ID of the remote host", choices=find_host_ids())
definition.add_positional_optional("id", "integer", "ID of the simulation")
# Add flags
definition.add_flag("ignore_missing_data", "ignore missing data when analysing the simulations", False)
# Analyse
definition.add_flag("do_basic", "do basic analysis", True)
definition.add_flag("do_batch", "do batch analysis", True)
definition.add_flag("do_scaling", "do scaling analysis", True)
definition.add_flag("do_extra", "do extra analysis", True)
# -----------------------------------------------------------------
# Import settings for basic, batch analysis
definition.import_section("basic", "basic analysis options", basic_definition)