def extract_memory_cwd(): """ This function ... :return: """ from pts.core.simulation.simulation import createsimulations # Create a SkirtSimulation object based on a log file present in the current working directory simulation = createsimulations(single=True) # Extract return extract_memory(simulation)
def extract_progress_cwd(): """ Thisf unction ... :return: """ from pts.core.simulation.simulation import createsimulations # Create a SkirtSimulation object based on a log file present in the current working directory simulation = createsimulations(single=True) # Create a new ProgressExtractor instance extractor = ProgressExtractor() # Run the extractor and get the table extractor.run(simulation) table = extractor.table # Return the progress table return 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: # Create a SkirtSimulation object based on a log file present in the current working directory simulation = createsimulations(single=True) # Create a new TimeLineExtractor instance extractor = TimeLineExtractor() # Run the extractor and get the timeline table table = extractor.run(simulation) # ----------------------------------------------------------------- if config.table and not fs.is_file(timeline_table_path): table.saveto(timeline_table_path) # ----------------------------------------------------------------- # Determine the path to the plotting directory
from pts.core.plot.wavemovie import makewavemovie # ----------------------------------------------------------------- # a value of None means that the axis is autoscaled; # alternatively specify a range through a tuple with min and max values xlim = None ylim = None #xlim = ( 5e-2, 1e3 ) #ylim = ( 1e-13, 1e-9 ) # the percentile values, in range [0,100], used to clip the luminosity values # loaded from the fits files; the default values are 30 and 100 respectively from_percentile = 30 to_percentile = 100 # ----------------------------------------------------------------- print "Starting makewavemovie..." # get the command-line argument specifying the simulation(s) argument = sys.argv[1] if len(sys.argv) > 1 else "" # construct the list of simulation objects and make the movies for simulation in createsimulations(argument): makewavemovie(simulation, xlim=xlim, ylim=ylim, from_percentile=from_percentile, to_percentile=to_percentile) print "Finished makewavemovie" # -----------------------------------------------------------------
# Ensure Python 3 compatibility from __future__ import absolute_import, division, print_function # Import the relevant PTS classes and modules from pts.core.simulation.simulation import createsimulations from pts.core.plot.grids import plotgrids from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments # ----------------------------------------------------------------- # Create configuration definition definition = ConfigurationDefinition() definition.add_positional_optional("simulation", "string", "simulation specification", default="") definition.add_optional("linewidth", "positive_real", "line width", 0.1) definition.add_optional("maxlevel", "positive_integer", "maximum tree level") # Read the command line arguments config = parse_arguments("plotgrids", definition, description="Unmount a remote mounted with PTS") # ----------------------------------------------------------------- print("Starting plotgrids...") # construct the list of simulation objects and make the plots for simulation in createsimulations(config.simulation): plotgrids(simulation, linewidth=config.linewidth, maxlevel=config.maxlevel) print("Finished plotgrids") # -----------------------------------------------------------------
parser.add_argument("-ncb", "--noColBar", action="store_true", default = False, help="Plot the colorbar(s) separately. Helpful for combining multiple plots, together with --vertRange.") parser.add_argument("-pay", "--polAvY", action="store_true", default = False, help="Plot the polarization degree integrated over y-direction for all x-pixels") parser.add_argument("-ppdm", "--plotPolDegMap", action="store_true", default = False, help="Plot the polarization degree map as a separate picture") parser.add_argument("-e", "--export", action="store_true", default = False, help="Exports data files in addition to the plots.") circPol_parser = parser.add_mutually_exclusive_group(required=False) circPol_parser.add_argument("-pc", '--plotCircular', dest='plotCircular', action='store_true', help="Plot the circular polarization maps. Default: automatic") circPol_parser.add_argument("-npc", '--no-plotCircular', dest='plotCircular', action='store_false', help="Do not plot the circular polarization maps. Default: automatic") parser.set_defaults(plotCircular=None) parser.add_argument("-npl", "--no-plotLinear", action="store_false", default = True, help="Do not plot the linear polarization maps.") args = parser.parse_args() binsize = (args.binx, args.biny) # construct the list of simulation objects and make the plots for simulation in createsimulations(args.simulation): print "Starting plotpolarization for simulation '" + simulation.prefix() + "'", plotpolarization(simulation, instrumentList=args.instrument, binsize=binsize, wavelength=args.wavelength, polAvY=args.polAvY, export=args.export, degreeLength=args.scale, vertRange=args.vertRange, noColBar=args.noColBar, plotCircular=args.plotCircular, plotPolDegMap=args.plotPolDegMap, plotLinear=args.no_plotLinear) end = time.time() print "Finished plotpolarization in {0:0.2f} s".format(end-start) # -----------------------------------------------------------------
help='Instrument(s) to be plotted. Default:all') parser.add_argument("-w", "--wavelength", default='all', help='Wavelength to be plotted, in micron. Default:all') parser.add_argument("-x", "--binx", type = int, default = 10, help = "Binning range in x-direction. Default:10") parser.add_argument("-y", "--biny", type = int, default = 10, help = "Binning range in y-direction. Default:10") parser.add_argument("-sc", "--scale", nargs=2, type = float, metavar=('d', 's'), default = [None,None], help = "Scale of polarization segments. [degree, length]. Default:[None,None] (automatic)") parser.add_argument("-vr", "--vertRange", nargs=2, type = float, metavar=('min', 'max'), default = [None,None], help = "Range of the background plot. [min, max]. Default:[None, None] (automatic)") parser.add_argument("-ncb", "--noColBar", action="store_true", default = False, help="Plot the colorbar(s) separately. Helpful for combining multiple plots, together with --vertRange.") parser.add_argument("-pay", "--polAvY", action="store_true", default = False, help="Plot the polarization degree integrated over y-direction for all x-pixels") parser.add_argument("-e", "--export", action="store_true", default = False, help="Exports data files in addition to the plots.") args = parser.parse_args() binsize = (args.binx, args.biny) # construct the list of simulation objects and make the plots for simulation in createsimulations(args.simulation): print "Starting plotpolarization for simulation '" + simulation.prefix() + "'", plotpolarization(simulation, instrumentList=args.instrument, binsize=binsize, wavelength=args.wavelength, polAvY=args.polAvY, export=args.export, degreeLength=args.scale, vertRange=args.vertRange, noColBar=args.noColBar) end = time.time() print "Finished plotpolarization in {0:0.2f} s".format(end-start) # -----------------------------------------------------------------
# Get the configuration reader = ConfigurationReader("plotmemory") config = reader.read(definition) # ----------------------------------------------------------------- # Look for a file in the current working directory that contains extracted memory information memory_table_path = fs.join(fs.getcwd(), "memory.dat") if fs.is_file(memory_table_path): table = MemoryUsageTable.from_file(memory_table_path) # If extracted memory information is not present, first perform the extraction else: # Create a SkirtSimulation object based on a log file present in the current working directory simulation = createsimulations(single=True) # Create a new MemoryExtractor instance extractor = MemoryExtractor() # Run the extractor and get the memory table table = extractor.run(simulation) # ----------------------------------------------------------------- if config.table and not fs.is_file(memory_table_path): table.saveto(memory_table_path) # ----------------------------------------------------------------- # Determine the path to the plotting directory plot_path = fs.join(fs.cwd())