# Ensure Python 3 compatibility from __future__ import absolute_import, division, print_function # Import the relevant PTS classes and modules from pts.core.tools import filesystem as fs from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments from pts.core.basics.log import log from pts.magic.core.image import Image # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() definition.add_required("add_to", "file_path", "add to this FITS file") definition.add_required("add_from", "file_path", "add from this FITS file") definition.add_flag("frames", "add frames", True) definition.add_flag("masks", "add masks", True) definition.add_flag("segments", "add segmentation maps", True) definition.add_flag("replace", "replace planes", False) definition.add_flag("replace_frames", "replace frames", False) definition.add_flag("replace_masks", "replace masks", False) definition.add_flag("replace_segments", "replace segmentation maps", False) definition.add_flag("backup", "make backup", False) config = parse_arguments("interpolate", definition) # ----------------------------------------------------------------- if config.replace: config.replace_frames = config.replace_masks = config.replace_segments = True # -----------------------------------------------------------------
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() # Add optional arguments definition.add_section("wavelengths") definition.sections["wavelengths"].add_optional("unit", str, "the unit of the wavelengths", "micron") definition.sections["wavelengths"].add_optional("min", float, "the minimum wavelength", 0.09) definition.sections["wavelengths"].add_optional("max", float, "the maximum wavelength", 2000) definition.sections["wavelengths"].add_optional("npoints", int, "the number of wavelength points", 100) definition.sections["wavelengths"].add_optional("min_zoom", float, "the minimum wavelength of the zoomed-in grid", 1) definition.sections["wavelengths"].add_optional("max_zoom", float, "the maximum wavelength of the zoomed-in grid", 30) definition.sections["wavelengths"].add_optional("npoints_zoom", int, "the number of wavelength points in the zoomed-in grid", 100) definition.add_optional("packages", float, "the number of photon packages per wavelength", 2e5) definition.add_flag("selfabsorption", "enable dust self-absorption") definition.add_optional("dust_grid", str, "the type of dust grid to use (bintree, octtree or cartesian)", "bintree") # -----------------------------------------------------------------
#definition.sections["input"].add_optional("galaxy_region", "file_path", "file with galaxy regions", "galaxies.reg") #definition.sections["input"].add_optional("star_region", "file_path", "file with star regions", "stars.reg") #definition.sections["input"].add_optional("saturation_region", "file_path", "file with regions for saturated stars", "saturation.reg") #definition.sections["input"].add_optional("other_region", "file_path", "file with regions for other contaminating sources", "other_sources.reg") #definition.sections["input"].add_optional("segments", "file_path", "image with segmentation maps (as planes 'galaxies', 'stars' and 'other_sources')", "segments.fits") # Number of parallel processes definition.add_optional("nprocesses", "integer", "number of parallel processes for the preparation", max(8, ncores())) definition.add_optional( "error_frame_names", "string_list", "the names of error planes to be included in the final error map") definition.add_flag("write_steps", "write the results of intermediate steps") # Sky subtraction definition.add_flag("write_sky_apertures", "write sky apertures and sky annulus") definition.add_optional( "sky_apertures_path", "directory_path", "the path to the directory where the aperture frames and annulus region should be written to" ) definition.add_flag("calculate_calibration_uncertainties", "calculate calibration uncertainties", True) # Source extraction definition.add_flag("extract_sources", "extract sources", True) definition.import_section("extraction", "star extraction options",
# -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() # Flags definition.add_flag("recursive", "look for simulation in directories recursively", True) # Output definition.add_optional("output", "directory_path", "output directory", letter="o") # Flags definition.add_flag("other", "also plot the 'other' phases") definition.add_flag( "group", "group timelines for the same number of processes in the same plot") # Plot definition.add_optional("label_fontsize",
# ----------------------------------------------------------------- # 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:
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") definition.add_optional("plot_path", "string", "plot output path") definition.add_optional("plotting", "dictionary", "plotting options", dict()) # Formatting of the values
# ***************************************************************** # ** 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") # -----------------------------------------------------------------
# -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) definition.add_flag("plot", "do plotting", False) definition.add_flag("rotate", "rotation", True) definition.add_optional("nrandom_sources", "positive_integer", "number of random sources", 100) definition.add_flag("vary_fwhm", "vary the FWHM slightly for each star", True) definition.add_flag("add_catalogued_sources", "add catalogued sources", False) definition.add_optional("point_source_catalogs", "string_list", "point source catalogs", ["II/246"]) definition.add_optional("nfilters_stars", "positive_integer", "number of filters to use where stars are visible", 4)
# Import the relevant PTS classes and modules from pts.modeling.preparation.initialization import PreparationInitializer from pts.core.tools import logging, time, tables from pts.core.tools import filesystem as fs from pts.magic.core.frame import Frame from pts.core.basics.configuration import ConfigurationDefinition, ConfigurationReader # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() # Add optional arguments definition.add_optional( "image", str, "the name of the image for which to run the initialization") definition.add_flag("visualise", "make visualisations") # Get configuration reader = ConfigurationReader("initialize_preparation") config = reader.read(definition) # ----------------------------------------------------------------- # Determine the log file path logfile_path = fs.join(fs.cwd(), "log", time.unique_name("log") + ".txt") if config.report else None # Determine the log level level = "DEBUG" if config.debug else "INFO"
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) else: regimes = physical_regimes print("")
#!/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) # -----------------------------------------------------------------
# Ensure Python 3 compatibility from __future__ import absolute_import, division, print_function # 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() # -----------------------------------------------------------------
#!/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() # Positional optional definition.add_positional_optional("directories", "directorypath_list", "input directories to search in") # Flags definition.add_flag("recursive", "look for simulations in directories recursively", True) definition.add_flag("list", "list the found simulations", True) # NEW definition.add_flag("output", "list the simulation output", False) # -----------------------------------------------------------------
definition.add_optional("center", "skycoordinate", "center coordinate") # Spacing definition.add_optional("spacing", "angle", "spacing of the ticks", "1 arcsec", convert_default=True) # For saving plot file definition.add_optional("dpi", "positive_integer", "dots per inch", 300) # ------------------------------------------------------------------------------ # Vmin and vmax? definition.add_optional("vmin", "real", "vmin") definition.add_optional("vmax", "real", "vmax") # ------------------------------------------------------------------------------ # Showing definition.add_flag("show", "show", True) # ------------------------------------------------------------------------------ # Writing definition.add_flag("write", "do writing", True) # ------------------------------------------------------------------------------ definition.add_optional("major_tick_length", "positive_integer", "length of major ticks", 7) definition.add_optional("minor_tick_length", "positive_integer", "length of minor ticks", 4) # ------------------------------------------------------------------------------
# Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.magic.view.html import scales, colormaps, zooms # ----------------------------------------------------------------- default_scale = "log" default_colormap = "viridis" default_zoom = "toFit" # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition(log_path="log", config_path="config") definition.add_flag("show", "show the page", False) # Filters definition.add_optional("filters", "filter_list", "filters") # Preload definition.add_flag("preload_all", "preload all images", False) definition.add_optional("preload", "filter_list", "filters for which to preload the image") # View settings definition.add_optional("scale", "string", "scale", default_scale, choices=scales)
# Set modeling path modeling_path = verify_modeling_cwd() # ----------------------------------------------------------------- default_fitting_method = get_default_fitting_method(modeling_path) cache_host_id = get_cache_host_id(modeling_path) # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() # Add flags definition.add_flag("check_hosts", "check the availability of the remote hosts", True) definition.add_flag("deploy", "deploy SKIRT and PTS where necessary", False) definition.add_flag("check_versions", "check versions of SKIRT and PTS where necessary", True) definition.add_flag("update_dependencies", "update PTS dependencies", False) # Advanced settings definition.add_flag("local", "keep computationaly heavy computations local") definition.add_optional( "remotes", "string_list", "remote hosts for computationally heavy computations (overrule the modeling configuration)", choices=find_host_ids()) definition.add_flag( "fitting_local", "launch the simulations as part of the fitting locally (overrule the modeling configuration"
from pts.core.remote.host import all_host_ids from pts.core.simulation.remote import get_simulation_for_host from pts.core.simulation.status import LogSimulationStatus from pts.core.basics.log import no_debugging from pts.core.remote.remote import Remote # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() definition.add_required("remote", "string", "remote host to mount", choices=all_host_ids()) definition.add_required("id", "positive_integer", "simulation ID") definition.add_flag("debug_output", "show all simulation output in debug mode") # Read the command line arguments config = parse_arguments( "show_progress", definition, description="Show the progress of a remotely running simulation") # ----------------------------------------------------------------- # Load the simulation simulation = get_simulation_for_host(config.remote, config.id) # ----------------------------------------------------------------- # Load the remote
definition.add_required( "ski_path", "file_path", "the name of the ski file to be used for the scaling test") definition.add_required("remote", "string", "the name of the remote host") definition.add_required("mode", "string", "the parallelization mode for the scaling test", choices=["mpi", "hybrid", "threads"]) # Optional arguments definition.add_positional_optional("maxnodes", "real", "the maximum number of nodes", 1) definition.add_positional_optional( "minnodes", "real", "the minimum number of nodes. In hybrid mode, this also defines the number of threads per process", 0) definition.add_optional("cluster", "string", "the name of the cluster", None) definition.add_optional("wavelengths", "real", "boost the number of wavelengths by a certain factor", None) definition.add_optional( "packages", "real", "boost the number of photon packages by a certain factor", None) # Flags definition.add_flag("manual", "launch and inspect job scripts manually") definition.add_flag( "keep", "keep the output generated by the different SKIRT simulations") # -----------------------------------------------------------------
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) definition.add_flag("plot", "do plotting", False) definition.add_optional("fwhm", "positive_real", "FWHM in pixels", 5.) definition.add_optional("shape", "integer_tuple", "shape", (300, 500)) definition.add_optional("nsources", "positive_integer", "number of sources", 100) definition.add_optional("flux_range", "real_range", "range of flux of sources", "500>1000", convert_default=True) definition.add_optional("noise_stddev", "real", "stddev of noise", 2.) definition.add_optional("constant_sky", "real", "constant sky value", 5.)
# Import standard modules import StringIO # Import the relevant PTS classes and modules from pts.core.prep.smile import SKIRTSmileSchema from pts.core.tools import formatting as fmt from pts.core.tools import stringify from pts.core.basics.configuration import ConfigurationDefinition, write_definition, parse_arguments # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() definition.add_positional_optional("match", "string", "only show types with names that contain this string") definition.add_flag("definitions", "format the properties for each item as a configuration definition") # Parse config = parse_arguments("skirt_items", definition) # ----------------------------------------------------------------- # Create the SKIRT smile schema smile = SKIRTSmileSchema() print("") # Loop over the concrete types for name in smile.concrete_types: if config.match is not None and config.match not in name: continue
# Import the relevant PTS classes and modules from pts.core.prep.uninstaller import Uninstaller from pts.core.remote.host import find_host_ids from pts.core.basics.log import log 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")
from pts.evolve.solve.extremizer import genetic_definition # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) # Optional settings definition.add_optional("nwavelengths", "positive_integer", "number of wavelengths for the reference simulation", 50) definition.add_optional("npackages", "positive_integer", "number of photon packages per wavelength for the reference simulation", int(1e5)) definition.add_optional("dust_grid_relative_scale", "real", "smallest scale of the dust grid relative to the pixelscale of the input maps", 2.) definition.add_optional("dust_grid_min_level", "positive_integer", "level for the dust grid", 2) definition.add_optional("dust_grid_max_mass_fraction", "positive_real", "max mass fraction for the dust grid", 1e-6) # Flags definition.add_flag("transient_heating", "enable transient heating", False) definition.add_flag("selfabsorption", "enable dust selfabsorption", False) # For remote execution definition.add_optional("host_ids", "string_list", "remote hosts to use for heavy computations and simulations", choices=find_host_ids()) definition.add_flag("attached", "launch remote executions in attached mode", False) # Fitting definition.add_optional("ngenerations", "positive_integer", "number of generations", 5) definition.add_optional("nsimulations", "even_positive_integer", "number of simulations per generation", 30) definition.add_optional("npackages_fitting", "positive_integer", "number of photon packages for each fitting simulation", int(1e4)) # Free parameters definition.add_optional("free_parameters", "string_list", "free parameter labels", choices=possible_free_parameters, default=default_free_parameters) definition.add_optional("relative_range_initial", "real_range", "relative range for generating the initial parameter values", default="0.3>3", convert_default=True) definition.add_optional("relative_range_fitting", "real_range", "relative range of the free parameter values for the fitting", default="0.1>20", convert_default=True)
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition() # Add optional settings definition.add_positional_optional("remote", "string", "remote host on which to uninstall", choices=find_host_ids()) 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") # -----------------------------------------------------------------
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() # Add required definition.add_required("remote", "string", "name of the remote host", choices=find_host_ids()) definition.add_positional_optional("id", "positive_integer", "simulation ID") definition.add_optional("name", "string", "simulation name") # Additional relative error definition.add_optional("additional_error", "percentage", "additional percentual error for the observed flux points") # Flags definition.add_flag("write", "write the results", True) # -----------------------------------------------------------------
# ----------------------------------------------------------------- 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:
# ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create definition = ConfigurationDefinition() # Commands to be run definition.add_optional("commands", "string_list", "commands to be run in interactive mode") # Interactive mode definition.add_flag("interactive", "use interactive mode", default=None) # ----------------------------------------------------------------- # Showing definition.add_flag("show", "show stuff", True) definition.add_flag("show_components", "show the model components", False) # Plotting definition.add_flag("plot", "do plotting", True) # Writing definition.add_flag("write", "do writing", True) # -----------------------------------------------------------------
"minimum depth level for binary trees", 9) definition.sections["dg"].add_optional("octtree_min_level", "integer", "minimum depth level for octrees", 3) definition.sections["dg"].add_optional("max_mass_fraction", "real", "maximum mass fraction in each cell", 0.5e-6) definition.sections["dg"].add_optional( "scale_heights", "real", "number of times to take the dust scale height as the vertical radius of the dust grid", 15.) # ----------------------------------------------------------------- # Whether quality has to be calculated definition.add_flag("check_dust_grid_quality", "check the quality of the dust grid in various ways", True) # ----------------------------------------------------------------- # Whether model has to be adapted definition.add_flag( "adapt", "adapt the parameters of the chosen model (from model suite origin, not from fitting)", True) # ADVANCED: specify the model name on the command line definition.add_optional( "model_name", "string", "name of the model (from the model suite) to use (only specify when origin is 'model')" )
# ** 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() definition.add_positional_optional("host_ids", "string_list", "remote host(s)", choices=find_host_ids(), default=find_host_ids()) # Add optional definition.add_optional("not_remotes", "string_list", "skip these remote hosts", choices=find_host_ids()) # Add flag definition.add_flag("show", "show the versions on the terminal", True) definition.add_flag("one_attempt", "only perform one attempt at connecting to a remote") # -----------------------------------------------------------------
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) # ----------------------------------------------------------------- # Do plot definition.add_flag("plot", "do plotting", True) # Plotting sections definition.add_section("plotting", "plotting options") definition.sections["plotting"].add_optional("interval", "string", "interval", "minmax") definition.sections["plotting"].add_flag("contours", "show contours", False) definition.sections["plotting"].add_optional("ncontours", "positive_integer", "number of contour levels", 5) definition.sections["plotting"].add_optional("contours_color", "string", "color for the contour lines", "white") definition.sections["plotting"].add_optional("minmax", "real_pair", "plotting minimum and maximum value") # -----------------------------------------------------------------
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") # Add features
# -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) definition.add_flag("plot", "do plotting", False) definition.add_flag("rotate", "rotation", True) definition.add_optional("nrandom_sources", "positive_integer", "number of random sources", 100) definition.add_flag("vary_fwhm", "vary the FWHM slightly for each star", True) definition.add_flag("add_catalogued_sources", "add catalogued sources", False) definition.add_optional("point_source_catalogs", "string_list", "point source catalogs", ["II/246"]) definition.add_optional("nfilters_stars", "positive_integer", "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"])
# 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) # Get remote python session remote_python = remote.start_python_session(assume_pts=False)
# 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") # Interactive mode definition.add_flag("interactive", "use interactive mode", default=None) # Offline? definition.add_flag("offline", "offline mode") # Dry: don't actually launch any simulation
# ----------------------------------------------------------------- # 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 definition.add_flag("show", "show the results", True) definition.add_flag("plot", "plot the expected memory scaling", False) # -----------------------------------------------------------------
dust_grid_types = ["cartesian", "bintree", "octtree"] default_dust_grid_type = "bintree" # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition(log_path="log", config_path="config") # Name of the representation if suite.has_representations: definition.add_required("name", "string", "name for the representation", forbidden=suite.representation_names) else: definition.add_optional("name", "string", "name for the representation", default="highres") # Name of the model for which to create the representation if suite.no_models: raise RuntimeError("No models found: first run build_model to create a new model") elif suite.has_single_model: definition.add_fixed("model_name", "name of the model", suite.single_model_name) else: definition.add_required("model_name", "string", "name of the model", choices=suite.model_names) # Dust grid properties definition.add_section("dg", "settings for the dust grid") definition.sections["dg"].add_optional("grid_type", "string", "type of dust grid", default_dust_grid_type, choices=dust_grid_types) definition.sections["dg"].add_optional("scale", "real", "number of image pixels to take as the minimum scale in the model (can also be a certain fraction of a pixel)", 0.5) definition.sections["dg"].add_optional("bintree_min_level", "integer", "minimum depth level for binary trees", 9) definition.sections["dg"].add_optional("octtree_min_level", "integer", "minimum depth level for octrees", 3) definition.sections["dg"].add_optional("max_mass_fraction", "real", "maximum mass fraction in each cell", 0.5e-6) definition.sections["dg"].add_optional("scale_heights", "real", "number of times to take the dust scale height as the vertical radius of the dust grid", 10.) # Whether quality has to be calculated definition.add_flag("check_dust_grid_quality", "check the quality of the dust grid in various ways", True) # -----------------------------------------------------------------
# Import standard modules import numpy as np # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments from pts.magic.core.image import Image from pts.core.tools import filesystem as fs from pts.core.basics.log import log # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() definition.add_required("file_path", "file_path", "path of the image") definition.add_required("factor", "real", "multiplication factor") definition.add_flag("backup", "make a backup of each image that is multiplied", False) config = parse_arguments("multiply", definition) # ----------------------------------------------------------------- # BACKUP FIRST if config.backup: # Inform the user log.info("Making a backup of the original image ...") # Determine new filepath and copy new_filepath = fs.appended_filepath(config.filepath, "_backup") fs.copy_file(config.filepath, new_filepath) # -----------------------------------------------------------------
# -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.evolve.solve.extremizer import genetic_definition # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) # Settings #definition.add_optional("nruns", "positive_integer", "number of runs", 2) definition.add_optional("ngenerations", "positive_integer", "number of generations", 10) definition.add_optional("nindividuals", "even_integer", "number of individuals per generation", 100) # Genetic settings definition.import_section("genetic", "genetic algorithm settings", genetic_definition) # Flags definition.add_flag("plot", "plot", True) # -----------------------------------------------------------------
# Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.magic.core.cutout import interpolation_methods # ----------------------------------------------------------------- default_method = "pts" default_interpolation_method = "pts" # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() definition.add_required("image", "string", "name of the input image") definition.add_required("regions", "string", "name of the regions file over which to interpolate") definition.add_flag("write_mask", "write out the mask") definition.add_optional("color", "string", "only interpolate over the shapes with this color") definition.add_optional("ignore_color", "string", "ignore shapes with this particular color") definition.add_optional("shapes", "string_list", "only interpolate over these kinds of shapes") definition.add_optional("input", "string", "name of the input directory", letter="i") definition.add_optional("output", "string", "name of the output directory", letter="o") definition.add_optional("method", "string", "interpolation method to use", default=default_method) definition.add_optional("interpolation_method", "string", "interpolation method", default_interpolation_method, choices=interpolation_methods) definition.add_flag("sigma_clip", "apply sigma clipping before interpolation", True) definition.add_optional("source_outer_factor", "real", "outer factor", 1.4) definition.add_flag("plot", "plot after interpolation", False) definition.add_flag("replace", "allow the original image to be replaced", False) definition.add_flag("backup", "backup if replaced", True) definition.add_optional("backup_suffix", "string", "backup suffix", "backup") # -----------------------------------------------------------------
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) definition.import_section("batch", "batch analysis options", batch_definition) # Remove certain settings from the sections definition.sections["basic"].remove_positional_optional("remote")
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") # Output definition.add_optional("output", "directory_path", "output directory")
#!/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() # The galaxy name definition.add_required("galaxy_name", "string", "galaxy name") # Flags definition.add_flag("write", "write the components and properties", False) definition.add_flag("show", "show the parameters", True) # The output directory definition.add_optional("output", "directory_path", "output directory", letter="o") # -----------------------------------------------------------------
# ----------------------------------------------------------------- # Create the definition definition = ConfigurationDefinition() # Select files definition.add_optional("contains", "string_list", "only files whose name contain one of these strings") # Options definition.add_optional("name", "string", "rebin to this name") definition.add_optional("wcs", "file_path", "path to the file from which to take the WCS") # Flags definition.add_flag("backup", "make backups", True) # Parse the command line arguments config = parse_arguments("rebin", definition) # ----------------------------------------------------------------- # Load frame list frames = NamedFrameList.from_directory(config.path, contains=config.contains) # ----------------------------------------------------------------- # Rebin if config.name is not None: frames.rebin_to_name(config.name) elif config.wcs is not None: wcs = CoordinateSystem.from_file(config.wcs)
# 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) # Backup existing wavelength grids definition.add_flag("backup", "backup existing wavelength grids", True)
# Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create definition definition = ConfigurationDefinition(write_config=False) # Number of frames definition.add_optional("nframes", "positive_integer", "number of frames", 2) # Size of frames definition.add_optional("npixels", "positive_integer", "number of pixels of the frames", 500) # Number of sources definition.add_optional("nrandom_sources", "positive_integer", "number of point sources", 100) # Flags definition.add_flag("vary_fwhm", "vary the FWHM", False) # PSF model definition.add_fixed("psf_model", "psf model", "gaussian") definition.add_optional("noise_stddev", "real", "stddev of noise", 5.) # -----------------------------------------------------------------
# Add prequired definition.add_required("ski", "file_path", "name or path of the ski file") # Add optional argument definition.add_optional("input", "directory_path", "path to the input directory") # Add required definition.add_required("nnodes", "integer", "number of nodes") definition.add_required("nsockets", "integer", "number of sockets per node") definition.add_required("ncores", "integer", "number of cores per socket") definition.add_required("memory", "real", "available virtual memory per node") # Add flags definition.add_flag("mpi", "mpi available", True) definition.add_flag("hyperthreading", "use hyperthreading", False) definition.add_optional("threads_per_core", "integer", "number of hyperthreads per core") # Add optional definition.add_optional( "ncells", "integer", "number of dust cells (relevant if ski file uses a tree dust grid)") definition.add_optional( "nwavelengths", "integer", "number of wavelengths (relevant if ski file uses input file)") # Flags definition.add_flag("show", "show the parallelization", True)
#!/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") # -----------------------------------------------------------------
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.extract.timeline import TimeLineExtractor, TimeLineTable from pts.core.plot.timeline import TimeLinePlotter from pts.core.tools import filesystem as fs from pts.core.basics.configuration import ConfigurationDefinition, ConfigurationReader # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() # Add flags definition.add_flag("table", "save the extracted timeline table") # Get configuration reader = ConfigurationReader("plottimeline") config = reader.read(definition) # ----------------------------------------------------------------- # Look for a file in the current working directory that contains extracted timeline information timeline_table_path = fs.join(fs.cwd(), "timeline.dat") if fs.is_file(timeline_table_path): table = TimeLineTable.from_file(timeline_table_path) # If extracted timeline information is not present, first perform the extraction else:
# ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import smb_host_ids # ----------------------------------------------------------------- default_host_name = "www" # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition(log_path="log", config_path="config") # Upload definition.add_optional("host_name", "string", "remote host name", default_host_name, choices=smb_host_ids()) # Flags definition.add_flag("regenerate", "regenerate the pages", False) definition.add_flag("replot", "make plots again", False) # -----------------------------------------------------------------
# ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.magic.tools.catalogs import stellar_catalog_descriptions # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() definition.add_flag( "use_frame_fwhm", "If possible, avoid the fitting procedure and use the FWHM defined by the frame", True) definition.add_optional("input_path", "directory_path", "path to the input directory") definition.add_optional("output_path", "directory_path", "path to the output directory") definition.add_flag("track_record", "track record", False) definition.add_flag("plot_track_record_if_exception", True) definition.add_optional("manual_region", "file_path", "manual star region") definition.add_flag("remove", "remove stars from the frame", True) definition.add_flag("find_saturation", "find saturated stars", True) # ----------------------------------------------------------------- # Settings for fetching the catalogs definition.add_section("fetching", "fetching")
# 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") # ----------------------------------------------------------------- definition.add_flag("update", "update the analysis options", True)
# Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids from pts.core.config.analyse_simulation import definition as analysis_definition # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition(write_config=False) # Add positional optional definition.add_positional_optional("host_ids", "string_list", "name of the remote host(s) for which to show/retrieve simulations and tasks", choices=find_host_ids()) definition.add_positional_optional("ids", "string_integer_list_dictionary", "simulation IDs for the different remote hosts") # Add flag definition.add_flag("show_progress", "show the progress of the simulation that is still running (only if there is just one)", False) definition.add_flag("debug_output", "show all simulation output in debug mode") # ----------------------------------------------------------------- definition.add_flag("retrieve", "retrieve finished simulations", True) definition.add_flag("analyse", "analyse retrieved simulations", True) # ----------------------------------------------------------------- # Crashed definition.add_flag("check_crashed", "check whether crashed simulations have the necessary output, if so, retrieve them") definition.add_optional("retrieve_crashed", "string_integer_list_dictionary", "retrieve crashed simulations for these hosts and simulation IDs") definition.add_flag("check_data", "for crashed simulations, check whether the simulation data is valid") # -----------------------------------------------------------------
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** # Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition # ----------------------------------------------------------------- # Create the configuration definition = ConfigurationDefinition() # Number of processes to use definition.add_optional("nprocesses", "positive_integer", "number of parallel processes", 8) # Flags definition.add_flag("write", "write results", True) # -----------------------------------------------------------------
# ***************************************************************** # 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: definition.add_optional("python_name", "string_no_spaces", "name for the python environment for PTS (also the alias for the python executable)", "python_pts") definition.add_optional("pip_name", "string_no_spaces", "name for the pip alias", "pip_pts") definition.add_optional("jupyter_name", "string_no_spaces", "name for the jupyter executable", "jupyter_pts") definition.add_optional("python_version", "string", "version number for python", "2.7")
definition.add_fixed("host_ids", "remote host_ids", []) # Add optional definition.add_optional("pts_repo_name", "string", "PTS repository name to deploy remotely", "origin", choices=introspection.pts_git_remotes()) definition.add_optional("skirt_repo_name", "string", "SKIRT repository name to deploy remotely", "origin", choices=introspection.skirt_git_remotes()) # Add flags definition.add_flag("local", "also deploy locally", True) definition.add_flag("skirt", "deploy SKIRT", True) definition.add_flag("pts", "deploy PTS", True) definition.add_flag("check", "check versions after deployment", True) definition.add_flag("one_attempt", "only perform one attempt at connecting to a remote") # Also update the dependencies definition.add_flag("update_dependencies", "update the dependencies if possible", False) # Add optional definition.add_optional( "pts_on", "string_list", "hosts on which PTS should be installed (None means all)",
from pts.core.remote.host import find_host_ids from pts.core.tools import introspection from pts.core.tools import filesystem as fs from pts.core.simulation.simulation import RemoteSimulation from pts.core.remote.remote import Remote from pts.core.basics.log import log # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() # Add settings definition.add_positional_optional("remotes", "string_list", "the IDs of the remote hosts for which to clear the simulations", choices=find_host_ids(), default=find_host_ids()) definition.add_positional_optional("ids", "integer_list", "the IDs of the simulations to clear") definition.add_flag("full", "fully clear the simulations, also remove remote simulation directories") # ----------------------------------------------------------------- # Parse the arguments into a configuration config = parse_arguments("clear_tasks", definition, description="Clear PTS tasks for a certain remote host") # ----------------------------------------------------------------- # Loop over the remote hosts for host_id in config.remotes: # Check whether the remote is available if config.full: remote = Remote() if not remote.setup(host_id):
# Import the relevant PTS classes and modules from pts.core.basics.configuration import ConfigurationDefinition from pts.core.remote.host import find_host_ids # ----------------------------------------------------------------- # Create the configuration definition definition = ConfigurationDefinition() # Add required definition.add_positional_optional("remote", "string", "name of the remote host", choices=find_host_ids()) definition.add_positional_optional("matching", "string", "only adapt settings with a name matching this string") definition.add_positional_optional("ids", "integer_list", "simulation IDs (if none specified, all simulation IDs will be used)") definition.add_optional("names", "string_list", "simulation names") definition.add_flag("from_directories", "use directory names as simulation names") # ----------------------------------------------------------------- # Select certain properties definition.add_optional("contains", "string", "only adapt properties containing this string in their name") definition.add_optional("not_contains", "string", "don't adapt properties containing this string in their name") definition.add_optional("exact_name", "string", "only adapt properties with this exact string as their name") definition.add_optional("exact_not_name", "string", "don't adapt properties with this exact string as their name") definition.add_optional("startswith", "string", "only adapt properties whose name starts with this string") definition.add_optional("endswith", "string", "only adapt properties whose name starts with this string") # ----------------------------------------------------------------- definition.add_optional("types", "string_list", "only adapt properties of these types") definition.add_optional("replace_string", "string_replacement", "replace strings")
# Import standard modules import importlib from collections import defaultdict from inspect import getmembers, isfunction, getdoc # Import the relevant PTS classes and modules from pts.core.tools import formatting as fmt from pts.core.tools import introspection from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments from pts.core.basics.log import setup_log # ----------------------------------------------------------------- definition = ConfigurationDefinition() definition.add_flag("verbose", "verbose output", letter="v") config = parse_arguments("count", definition) # ----------------------------------------------------------------- # Setup log setup_log("ERROR") # ----------------------------------------------------------------- # Lines nlines = 0 nlines_per_file = dict() nlines_per_subproject = defaultdict(int) # Modules