Ejemplo n.º 1
0
    def __init__(self, main_path, tex_title, experiment_instance, force_recalc=False):
        """
        This class uses constructors to build up a data set from the raw v3d files, perform all processing,
        create figures, and compile a publication ready .tex file from all the arguments. It places all outputs
        in the texdocs/figs directory. All tex files in the texdocs/figs/tex have their corresponding figures

        :param main_path:           filepath to main.tex
        :param tex_title:           title for this tex file. will be placed in texdocs/figs/tex
        :param experiment_instance: an experiment instance created by construct_experiments
        :param force_recalc:
        :return:
        """

        # invoke parent class init and add a few other attributes
        main_dir = os.path.dirname(os.path.abspath(main_path))
        self.experiment_id = experiment_instance.experiment_id
        self.tex_title = tex_title
        self.figure_dir = os.path.join(main_dir, "figs/{0}".format(self.tex_title))
        if not os.path.exists(self.figure_dir):
            os.mkdir(self.figure_dir)
        TeXWriter.__init__(self, main_path, os.path.join(main_dir, "figs/tex/{0}.tex".format(self.tex_title)))

        # ensure inputs are properly formatted
        if not isinstance(experiment_instance, Experiment):
            raise Exception("invalid input for experiment instance")

        self.experiment = experiment_instance
        self.axial_vortex = self.experiment.axial_vortex
Ejemplo n.º 2
0
    def add_quiver_plot(self, caption, width, write_unique=False):
        """
        Adds a quiver plot to the texdoc, has no special arguments.

        :param caption:         Tex caption to add to figure
        :param width:           the width of the plot on the page such as '5in'
        :param write_unique:    set True to write a tex file for this individual figure.
        """

        create_kwargs = {}  # no interesting kwargs at the moment
        create_from_function = self.axial_vortex.quiver_plot

        figure_filename = "{0}_quiver.jpg".format(self.tex_title)
        figure_path = os.path.join(self.figure_dir, figure_filename)
        TeXWriter.add_figure(self, figure_path, caption, width, create_from_function, create_kwargs)
Ejemplo n.º 3
0
    def _write_or_log(self, figure_path, caption, width, create_from_function, create_kwargs, write_unique):

        if write_unique:
            head, tail = os.path.split(figure_path)
            texfile_path = os.path.join(head, ".".join(tail.split(".")[:-1] + ["tex"]))
            tw = TeXWriter(self.main_path, texfile_path)
            tw.add_figure(figure_path, caption, width, create_from_function, create_kwargs)
            tw.write()

        TeXWriter.add_figure(self, figure_path, caption, width, create_from_function, create_kwargs)