def plot(x, y, type="default", snap="current", sim="current", overplot=False, autoscale=False, xunit="default", yunit="default", xaxis="linear", yaxis="linear", **kwargs): '''Plot particle data as a scatter plot. Creates a new plotting window if one does not already exist. Required arguments: x : Quantity on the x-axis. Must be a string. y : Quantity on the y-axis. Must be a string. Optional arguments: type : The type of the particles to plot (e.g. 'star' or 'sph'). snap : Number of the snapshot to plot. Defaults to 'current'. sim : Number of the simulation to plot. Defaults to 'current'. overplot : If True, overplots on the previous existing plot rather than deleting it. Defaults to False. autoscale : If True, the limits of the plot are set automatically. Can also be set to 'x' or 'y' to specify that only one of the axis has to use autoscaling. If False (default), autoscaling is not used. On an axis that does not have autoscaling turned on, global limits are used if defined for the plotted quantity. xunit : Specify the unit to use for the plotting for the quantity on the x-axis. yunit : Specify the unit to use for the plotting for the quantity on the y-axis. **kwargs : Extra keyword arguments will be passed to matplotlib. ''' simno = get_sim_no(sim) overplot=to_bool(overplot) # If we are plotting all particle species, call plot in turn if type=="all": sim = SimBuffer.get_sim_no(simno) snapobject = SimBuffer.get_snapshot_extended(sim, snap) nspecies = snapobject.GetNTypes() for ispecies in range(nspecies): plot(x,y,snapobject.GetSpecies(ispecies),snap,simno, (overplot or ispecies>0),autoscale,xunit,yunit, xaxis,yaxis,**kwargs) return command = Commands.ParticlePlotCommand(x, y, type, snap, simno, overplot, autoscale, xunit, yunit, xaxis, yaxis, **kwargs) data = command.prepareData(Singletons.globallimits) Singletons.queue.put([command, data]) sleep(0.001)
def get_data(quantity, snap="current",type="default",sim="current",unit="default" ): '''Returns the array with the data for the given quantity. The data is returned scaled to the specified unit Required argument: quantity :The quantity required. Must be a string Optional arguments: type :The type of the particles (e.g. 'star') snap :Number of the snapshot. Defaults to 'current' sim :Number of the simulation. Defaults to 'current' unit :Specifies the unit to use to return the data ''' simno = get_sim_no(sim) sim = SimBuffer.get_sim_no(simno) snapobject = SimBuffer.get_snapshot_extended(sim, snap) nspecies = snapobject.GetNTypes() if type=="all": raise Exception("You requested all particle types to get_data, but we can return only one array!") fetcher=UserQuantity(quantity) unitinfo,data,scaling,label=fetcher.fetch(type=type,snap=snapobject,unit=unit) return data*scaling