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


Python ConfigurationDefinition.add_optional方法代码示例

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


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

示例1: ConfigurationDefinition

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

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

# Check quantity
if is_photometric_quantity(config.quantity):

    #physical_types = possible_physical_types(config.quantity)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:convert.py

示例2: ConfigurationDefinition

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

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

show_normalizations(ski, flux_unit=config.flux)
开发者ID:SKIRT,项目名称:PTS,代码行数:31,代码来源:normalizations.py

示例3: ConfigurationDefinition

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

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

示例4: ConfigurationDefinition

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

# 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")
definition.add_optional("plot_path", "string", "plot output path")
definition.add_optional("plotting", "dictionary", "plotting options", dict())

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

# Additional options
definition.add_flag("unique", "show only the unique in each column")
definition.add_flag("sorted_unique", "sort the unique values")
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:show_file.py

示例5: ConfigurationDefinition

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

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

示例6: ConfigurationDefinition

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

# Add flag
#definition.add_flag("data_parallel", "with data parallelization mode")

# Flags
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:estimate_memory.py

示例7: ConfigurationDefinition

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

示例8: find_host_ids

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_optional [as 别名]
from pts.core.config.analyse_simulation import definition as analysis_definition

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

host_ids = find_host_ids()

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

# Create the configuration definition
definition = ConfigurationDefinition()

# Assignment file
definition.add_positional_optional("assignment", "file_path", "path of assignment file")

# Status file
definition.add_optional("status", "file_path", "path of status file")

# Remotes for which to find corresponding simulations
definition.add_optional("remotes", "string_list", "remote hosts for which to look for matching simulations (not necessary when assignment is specified)", default=host_ids, choices=host_ids)

# To specify the simulations
definition.add_optional("simulation_names", "string_list", "names of the simulations to look for")
definition.add_optional("simulation_ids", "integer_list", "IDs of the simulations (only if one remote host is specified)")
definition.add_flag("from_directories", "use directory names as simulation names")

# Timing and memory table
definition.add_optional("timing", "file_path", "timing table path")
definition.add_optional("memory", "file_path", "memory table path")

# Commands to be run
definition.add_optional("commands", "string_list", "commands to be run in interactive mode")
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:manage_simulations.py

示例9: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_optional [as 别名]
from __future__ import absolute_import, division, print_function

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

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

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

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

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

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

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

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

# Save
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:rename_column.py

示例10: ConfigurationDefinition

# 需要导入模块: from pts.core.basics.configuration import ConfigurationDefinition [as 别名]
# 或者: from pts.core.basics.configuration.ConfigurationDefinition import add_optional [as 别名]
# Create the configuration definition
definition = ConfigurationDefinition()

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

# 3D data file
definition.add_required("filename", "file_path", "path of the 3D data file")

# Orientations
definition.add_required("orientations", "string_list", "orientations from which to project the data", choices=orientations)

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

# Width/height
definition.add_optional("height", "length_quantity", "maximum height above/below midplane for the faceon projection")
definition.add_optional("width", "length_quantity", "maximum width before/behind center vertical plane for the edgeon projection")

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

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

# Spacing of the maps
definition.add_optional("spacing", "string", "method of determining the grid cell spacing", default_spacing_measure, choices=spacing_measures)
definition.add_optional("spacing_factor", "positive_real", "factor by which to multiply the grid cells spacing measure to become the actual map spacing", default_spacing_factor)

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

# Do interpolation on the maps
definition.add_flag("interpolate", "do interpolation", False)
开发者ID:SKIRT,项目名称:PTS,代码行数:32,代码来源:project_data.py

示例11: ConfigurationDefinition

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

# 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", "number of filters to use where stars are visible", 4)
definition.add_optional("nfilters_extra", "positive_integer", "number of filters to use where stars are not visible", 2)

definition.add_optional("psf_model", "string", "model to use for the PSF", "airydisk", choices=["gaussian", "airydisk"])

definition.add_optional("noise_stddev", "real", "stddev of noise", 5.)

definition.add_flag("only_local", "only evaluate PSFs locally", True)
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:config.py

示例12: ConfigurationDefinition

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

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

# Configuration
definition = ConfigurationDefinition()

# Galaxy name
definition.add_required("galaxy_name", "string", "the name of the galaxy")

# Database
definition.add_section("database", "DustPedia database credentials")
definition.add_optional("username", "string", "username")
definition.add_optional("password", "string", "password")

# Other options
definition.add_positional_optional("instruments", "string_list", "instruments for which to download the images", choices=instruments, default=instruments)

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

示例13: ConfigurationDefinition

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

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

# Create configuration definition
definition = ConfigurationDefinition()

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

# Interactive mode
definition.add_flag("interactive", "use interactive mode", True)

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

# Caching
definition.add_optional("cache_volume", "string", "name of the volume to be used for caching")

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

# Set plotting backend
definition.add_optional("mpl_backend", "string", "set the matplotlib backend")

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

示例14: ConfigurationDefinition

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

# Output path
definition.add_optional("output", "directory_path", "output path")
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:sfr_to_lum.py

示例15: ConfigurationDefinition

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

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")

# Add features
definition.add_flag("smooth", "add smooth curves to plot")
definition.add_flag("statistics", "add statistics to plot")
开发者ID:SKIRT,项目名称:PTS,代码行数:33,代码来源:plot_distributions.py


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