def do( simDirPath : (str, "SKIRT simulation output directory"), prefix : (str,"SKIRT simulation prefix") = "", instruments : (str,"up to three comma-separated SKIRT instrument names") = "", percentile : (float,"percentile in range [0,100] used to determine maximum surface brightness") = 100, dex : (float,"number of decades in the surface brightness range") = 5, renormalize : (int,"if nonzero, the surface brightness range is determined for each frame separately") = 0, rate : (int,"frame rate of the movie in frames per second") = 7, ) -> "create a movie that runs through all wavelengths in the SKIRT simulation output": import pts.simulation as sm import pts.utils as ut import pts.visual as vis # private function to retrieve the instrument with a specified name from a simulation def instrumentWithName(sim, instrname): instrlist = [ instr for instr in sim.instruments() if instr.name()==instrname ] if len(instrlist) == 0: raise ut.UserError("simulation '{}' does not have instrument '{}'".format(sim.prefix(), instrname)) return instrlist[0] # loop over the simulations to be handled for sim in sm.createSimulations(simDirPath, prefix if len(prefix) > 0 else None): # get a list of the requested instruments (or simply specify the complete simulation) simspec = sim if len(instruments) > 0: simspec = [ instrumentWithName(sim, instrname) for instrname in instruments.split(',') ] # create the movie vis.makeWavelengthMovie(simspec, maxPercentile=percentile, decades=dex, renormalize=renormalize!=0, rate=rate)
def do( simDirPath: (str, "SKIRT simulation output directory"), prefix: (str, "SKIRT simulation prefix") = "", plot: (str, "type of plot: linmap, degmap, degavg, or cirmap") = "linmap", wave: (float, "wavelength of the frame to be plotted; 0 means all frames") = 0, bin: (int, "number of pixels in a bin, in both x and y directions") = 7, dex: (float, "number of decades to be included in the background intensity range (color bar)" ) = 5, ) -> "plot polarization maps for the output of one or more SKIRT simulations": import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix) > 0 else None): vis.plotPolarization( sim, plotLinMap=plot.lower().startswith("lin"), plotDegMap=plot.lower().startswith("degm"), plotDegAvg=plot.lower().startswith("dega"), plotCirMap=plot.lower().startswith("cir"), wavelength='all' if wave == 0 else wave << sm.unit("micron"), binSize=(bin, bin), decades=dex)
def do( simDirPath : (str,"SKIRT simulation output directory"), prefix : (str,"SKIRT simulation prefix") = "", ) -> "plot the planar cuts through the temperature in one or more SKIRT simulations": import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix)>0 else None): vis.plotTemperatureCuts(sim)
def do( simDirPath : (str, "SKIRT simulation output directory"), prefix : (str,"SKIRT simulation prefix") = "", bin : (int,"number of pixels in a bin, in both x and y directions") = 32, ) -> "plot the planar cuts through the magnetic field in one or more SKIRT simulations": import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix) > 0 else None): vis.plotMagneticFieldCuts(sim, binSize=(bin,bin))
def do( simDirPath : (str,"SKIRT simulation output directory"), prefix : (str,"SKIRT simulation prefix") = "", wmin : (float,"smallest wavelength on the horizontal axis, in micron") = 0.1, wmax : (float,"largest wavelength on the horizontal axis, in micron") = 1000., dex : (float,"number of decades to be plotted on the vertical axis") = 5, ) -> "plot the luminosity of and packets launched by one or more SKIRT simulations": import astropy.units as u import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix)>0 else None): vis.plotSources(sim, minWavelength=wmin * u.micron, maxWavelength=wmax * u.micron, decades=dex)
def do( simDirPath: (str, "SKIRT simulation output directory"), prefix: (str, "SKIRT simulation prefix") = "", dex: (float, "number of decades to be included in the density range (color bar)" ) = 5, ) -> "plot the planar cuts through the medium density in one or more SKIRT simulations": import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix) > 0 else None): vis.plotDefaultMediaDensityCuts(sim, decades=dex)
def do( simDirPath : (str,"SKIRT simulation output directory"), prefix : (str,"SKIRT simulation prefix") = "", instr : (str,"instrument name") = "", wmin : (float,"smallest wavelength on the horizontal axis, in micron") = 0.1, wmax : (float,"largest wavelength on the horizontal axis, in micron") = 1000., dex : (float,"number of decades to be plotted on the vertical axis") = 5, ) -> "plot the SEDs produced by one or more SKIRT simulations": import astropy.units as u import pts.simulation as sm import pts.visual as vis for sim in sm.createSimulations(simDirPath, prefix if len(prefix)>0 else None): if len(instr)>0: instrument = [ ins for ins in sim.instruments() if ins.name() == instr ] vis.plotSeds(instrument, minWavelength=wmin * u.micron, maxWavelength=wmax * u.micron, decades=dex) else: vis.plotSeds(sim, minWavelength=wmin * u.micron, maxWavelength=wmax * u.micron, decades=dex)
def do( simDirPath: (str, "SKIRT simulation output directory"), prefix: (str, "SKIRT simulation prefix") = "", type: (str, "type of SKIRT instrument output files to be handled") = "total", name: (str, "name segment that will be added to the image file names") = "", colors: (str, "three comma-separated wavelength values or broadband names defining the R,G,B colors" ) = "", ) -> "create RGB images for surface brightness maps generated by SKIRT instruments": import pts.band as bnd import pts.simulation as sm import pts.utils as ut import pts.visual as vis # get the simulations to be handled sims = sm.createSimulations(simDirPath, prefix if len(prefix) > 0 else None) # parse the colors and handle accordingly # no colors given if len(colors) == 0: if len(name) > 0: raise ut.UserError( "name argument is not supported when colors are not specified") for sim in sims: vis.makeRGBImages(sim, fileType=type) return # get segments segments = colors.split(',') if len(segments) != 3: raise ut.UserError( "colors argument must have three comma-separated segments") # try wavelengths try: wavelengths = [float(segment) for segment in segments] except ValueError: wavelengths = None if wavelengths is not None: tuples = {name: wavelengths << sm.unit("micron")} for sim in sims: vis.makeRGBImages(sim, wavelengthTuples=tuples, fileType=type) return # try bands try: bands = [bnd.BroadBand(segment) for segment in segments] except ValueError: bands = None if bands is not None: contributions = [(bands[0], 1, 0, 0), (bands[1], 0, 1, 0), (bands[1], 0, 0, 1)] for sim in sims: vis.makeConvolvedRGBImages(sim, contributions=contributions, fileType=type, name=name) return raise ut.UserError( "colors argument must specify three wavelengths in micron or three broadband names" )
parser = argparse.ArgumentParser() parser.add_argument("--galaxy") # name of galaxy args = parser.parse_args() galaxy = args.galaxy colors = "SDSS_Z,SDSS_R,SDSS_G" #colors = "PACS_100,SDSS_R,GALEX_NUV" name = "custom_image" type = "total" path = '/scratch/ntf229/RT_fit/resources/SKIRT/'+galaxy+'/maxLevel13/wavelengths601/numPhotons1e9/inc0/dust/dustFraction0.2/maxTemp16000/' os.chdir(path) # get the simulations to be handled sims = sm.createSimulations(path, None) # get segments segments = colors.split(',') if len(segments) != 3: raise ut.UserError("colors argument must have three comma-separated segments") bands = [ bnd.BroadBand(segment) for segment in segments ] #contributions = [ (bands[0], 1, 0, 0), (bands[1], 0, 1, 0), (bands[1], 0, 0, 1) ] # original contributions = [ (bands[0], 1, 0, 0), (bands[1], 0, 1, 0), (bands[2], 0, 0, 1) ] # altered from original for sim in sims: #vis.makeConvolvedRGBImages(sim, contributions=contributions, fileType=type, name=name, decades=6) makeConvolvedRGBImages(sim, contributions=contributions, fileType=type, name=name, decades=6) os.system("mv sph_i00_total_custom_image.png "+image_path+galaxy+"_image.png")