PlotterManager
- class PlasmaCalcs.plotting.plotter_manager.PlotterManager
Bases:
objectclass to help with managing plotters.
Methods
get_plotter(name[, who])gets the Plotter associated with this name and who.
get_plotters([who, kind, name, all_whos, ...])return list of all plotters associated with these inputs.
plot(name[, who, save, show, close])makes a single plot using the relevant plotter.
save_plots([kind, who, name, all_whos, ...])saves all plots from plotters associated with these inputs.
Attributes
KNOWN_PATTERNSKNOWN_PLOTTERSKNOWN_SETTERSKNOWN_VARSUNIQUE_PLOTTERScls_behavior_attrsknown_patternknown_plotterknown_setterknown_var- get_plotter(name, who=UNSET)
gets the Plotter associated with this name and who.
Roughly equivalent: self.KNOWN_PLOTTERS[(name, who)]name: str or Plottername of the plotter to use, or a Plotter instance.who: UNSET, None, or strperson associated with the plotter.UNSET –> use the plotter with this name; crash if found multiple same-named plotters.see also: self.get_plotters(), which is good if you don’t know ‘who’, or want multiple plotters.
- get_plotters(who=UNSET, kind=UNSET, *, name=None, all_whos=UNSET, all_kinds=UNSET, skip_who=[], skip_kinds=[], min_cost=None, max_cost=None, sortby=None, returns='plotters')
return list of all plotters associated with these inputs.
If called with no inputs, just returns a copy of self.UNIQUE_PLOTTERS.who: UNSET, None, str, or list.person associated with the plotter.UNSET –> include plotters regardless of ‘who’.None –> require len(plotter.who) == 0.str –> require this name to be in plotter.who.list –> require at least one of these to be in plotter.who(or, if None in list, allow len(plotter.who)==0, too)kind: UNSET, str, or list.kind associated with the plotter.UNSET –> include plotters regardless of ‘kind’.str –> require this kind to be in plotter.kinds.list –> require at least one of these to be in plotter.kinds.name: None or strplotter name. E.g. ‘deltafrac_n’.None –> include all plotters regardless of ‘name’.all_whos: UNSET or list.include only plotters with ALL of these people in plotter.who.all_kinds: UNSET or str.include only plotters with ALL of these kinds in plotter.kinds.skip_who: listexclude plotters with any of these people in plotter.who.skip_kinds: listexclude plotters with any of these kinds in plotter.kinds.min_cost: None or numberexclude plotters with cost < min_cost.None –> no minimum.max_cost: None or numberexclude plotters with cost > max_cost.None –> no maximum.sortby: None or ‘cost’tells how to sort the result (if returns==’plotters’).None –> keep in order they appear in self.UNIQUE_PLOTTERS.‘cost’ –> sort by plotter.cost values.returns: ‘plotters’, ‘names’, ‘who’, ‘kind’, or ‘kinds’‘plotters’ –> returns list of plotters‘names’ –> returns set of all names associated with at least 1 plotter in result.‘who’ –> returns set of all people associated with at least 1 plotter in result.‘kind’ or ‘kinds’ –> returns set of all kinds associated with at least 1 plotter in result.
- plot(name, who=UNSET, *, save=False, show=False, close=False, **kw_plotter)
makes a single plot using the relevant plotter.
name: str or Plotter
name of the plotter to use, or a Plotter instance.(if Plotter, use directly and ignore ‘who’ input.)who: UNSET, None, or strperson associated with the plotter.UNSET –> use the plotter with this name; crash if found multiple same-named plotters.save: bool, str, or dict.whether to save figure after calling plotter.str –> filename=save.format(name=name, savename=savename), instead of default filename=name.dict –> pass to saver as kwargs. Use kwarg ‘dst’ to also provide filename.if plotter.ani, saver is movie_obj.ani(), else saver is plt.savefig().show: boolwhether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)close: boolwhether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)additional kwargs go to plotter.plot(…)see also: self.get_plotters(), self.save_plots().
- save_plots(kind=UNSET, who=UNSET, *, name=None, all_whos=UNSET, all_kinds=UNSET, skip_who=[], skip_kinds=[], min_cost=None, max_cost=None, dst='{savename}', save_log=True, log_extras=[], kw_save={}, bbox_inches=UNSET, dpi=UNSET, show=False, close=True, print_freq=0, **kw_plotter)
saves all plots from plotters associated with these inputs.
returns dict of {plotter: plotter result} for all plotters called.Consider checking self.get_plotters() first to learn which plotters will be included.For choosing which plotters to include:kind: UNSET, str, or list.kind associated with the plotter.UNSET –> include plotters regardless of ‘kind’.str –> require this kind to be in plotter.kinds.list –> require at least one of these to be in plotter.kinds.who: UNSET, None, str, or list.person associated with the plotter.UNSET –> include plotters regardless of ‘who’.None –> require len(plotter.who) == 0.str –> require this name to be in plotter.who.list –> require at least one of these to be in plotter.who(or, if None in list, allow len(plotter.who)==0, too)name: None or strplotter name. E.g. ‘deltafrac_n’.None –> include all plotters regardless of ‘name’.all_whos: UNSET or list.include only plotters with ALL of these people in plotter.who.all_kinds: UNSET or str.include only plotters with ALL of these kinds in plotter.kinds.skip_who: listexclude plotters with any of these people in plotter.who.skip_kinds: listexclude plotters with any of these kinds in plotter.kinds.min_cost: None or numberexclude plotters with cost < min_cost.None –> no minimum.max_cost: None or numberexclude plotters with cost > max_cost.None –> no maximum.For plotting:dst: strwhere to save plots to. Hit by dst.format(name=plotter.name, savename=plotter.savename).if not abspath, save to os.path.join(self.unique_notes_dirname, dst) if possible,else save to dst within current directory.save_log: bool or strwhether to save a log of plot progress to _save_plots_log.txt file.str –> save to this file name. If not abspath, put it in dir implied by dst (see above).The log tells current datetime, version info about PlasmaCalcs, and plot timing updates.log_extras: list of strextra lines to put in the log “header”, if doing save_log.kw_save: dictkwargs to pass to plotter.save(…)bbox_inches: UNSET or any valueif provided, added to kw_save.dpi: UNSET or any valueif provided, added to kw_save.show: boolwhether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)close: boolwhether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)additional kwargs go to plotter.plot(…)Misc:print_freq: numberminimum seconds between printing progress updates.-1 –> never print; 0 –> always print.see also: self.get_plotters(), self.plot().