当前位置: 首页>>代码示例>>Python>>正文


Python ConfigurationDefinition.add_required方法代码示例

本文整理汇总了Python中pts.core.basics.configuration.ConfigurationDefinition.add_required方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationDefinition.add_required方法的具体用法?Python ConfigurationDefinition.add_required怎么用?Python ConfigurationDefinition.add_required使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pts.core.basics.configuration.ConfigurationDefinition的用法示例。


在下文中一共展示了ConfigurationDefinition.add_required方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
## \package pts.do.magic.scale_regions Scale regions with a certain factor.

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

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

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

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

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

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

regions = load_region_list(config.path)

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

regions *= config.factor

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

# Remove the original file
fs.remove_file(config.path)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:scale_regions.py

示例2: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
# 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
ski = SkiFile(config.ski)

# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:normalizations.py

示例3: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [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 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)
log.start("Starting setup ...")

# -----------------------------------------------------------------
开发者ID:Stargrazer82301,项目名称:CAAPR,代码行数:33,代码来源:setup.py

示例4: verify_modeling_cwd

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
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:

    # Get the modeling command
    filename = fs.name(filepath)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:previous_log.py

示例5: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
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
definition.add_flag("plot", "make a plot")
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:show_file.py

示例6: verify_modeling_cwd

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
# -----------------------------------------------------------------

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)
populations_run = populations[config.fitting_run]

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

# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:check_populations.py

示例7: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
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)

# Get the DustPedia name
name = sample.get_name(config.galaxy)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:strategy.py

示例8: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
from pts.core.tools.stringify import tostr
from pts.modeling.misc.playground import MappingsPlayground
from pts.core.plot.sed import SEDPlotter
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)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:sfr_to_lum.py

示例9: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
## \package pts.do.developer.execute Execute a line on a remote host and check the output.

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

# 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("-----------------------------------------------------------------")
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:execute.py

示例10: load_modeling_environment_cwd

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
environment = load_modeling_environment_cwd()
runs = environment.fitting_runs

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

all_steps = steps + [batch]

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

# Create definition
definition = ConfigurationDefinition()

# The fitting run for which to explore the parameter space
if runs.empty: raise RuntimeError("No fitting runs are present")
elif runs.has_single: definition.add_fixed("name", "name of the fitting run", runs.single_name)
else: definition.add_required("name", "string", "name of the fitting run", choices=runs.names)

# Generations to remove
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)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:generation_reanalysis.py

示例11: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
# 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, prompt_yn
from pts.core.tools.stringify import tostr
from pts.core.units.parsing import is_photometric_unit, is_photometric_quantity, parse_unit, parse_quantity
from pts.core.units.parsing import possible_physical_types, possible_density_flags, possible_brightness_flags

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

# Create the configuration definition
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")

# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:convert.py

示例12: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
# 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()

# Log in
remote.setup(config.remote)
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:compare_python_packages.py

示例13: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [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 the configuration definition
definition = ConfigurationDefinition()

# Add required
definition.add_required("ski_path", "file_path", "ski file")

# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:21,代码来源:fill.py

示例14: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [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.tools import filesystem as fs

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

# Create the configuration
definition = ConfigurationDefinition()

# Add required settings
definition.add_required("runs", )

# -----------------------------------------------------------------
开发者ID:SKIRT,项目名称:PTS,代码行数:22,代码来源:optimize_runs.py

示例15: load_modeling_environment_cwd

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_required [as 别名]
# -----------------------------------------------------------------

# Set the modeling path
environment = load_modeling_environment_cwd()
runs = environment.fitting_runs

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

# Create the configuration definition
definition = ConfigurationDefinition()

# The fitting run name
if runs.empty: raise ValueError("No analysis runs present (yet)")
elif runs.has_single: definition.add_fixed("run", "name of the fitting run", runs.single_name)
else: definition.add_required("run", "string", "name of the fitting run for which to (re)make the wavelength grids", choices=runs.names)

# Options
definition.add_flag("basic", "make basic wavelength grids", True)
definition.add_flag("refined", "make refined wavelength grids", True)
definition.add_flag("highres", "make high-resolution wavelength grids", True)

# Settings for the wavelength grid generation
definition.add_optional("npoints_range_basic", "integer_range", "range of the basic wavelength grid size", default_npoints_range_basic, convert_default=True)
definition.add_optional("npoints_range_refined", "integer_range", "range of the refined wavelength grid size", default_npoints_range_refined, convert_default=True)
definition.add_optional("npoints_range_highres", "integer_range", "range of the high-resolution wavelength grid size", default_npoints_range_highres, convert_default=True)
definition.add_optional("ngrids_basic", "integer", "number of basic wavelength grids to generate", default_ngrids_basic)
definition.add_optional("ngrids_refined", "integer", "number of refined wavelength grids to generate", default_ngrids_refined)
definition.add_optional("ngrids_highres", "integer", "number of high-resolution wavelength grids to generate", default_ngrids_highres)
definition.add_flag("add_emission_lines", "add emission lines to the wavelength grids", True)
definition.add_optional("range", "quantity_range", "range of wavelengths", default_wavelength_range, convert_default=True)
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:make_wavelength_grids.py


注:本文中的pts.core.basics.configuration.ConfigurationDefinition.add_required方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。