Git difftool works with LaTeX documents.

Here is the story for me to compose my PhD thesis that is organised in Github and texted using LaTeX. The problem is how to track the changing when the thesis is changed using Git. This is pretty much similar with the modification tracking mechanism in Microsoft’s word. The difficult point here is that the whole thesis is stored in Github. The tools such as ‘texdiff’ and ‘latexdiff’ work on the two distinct files stored in the hard disk. In other to show differences of a file between two different versions, Git’s difftool should be employed.

Therefore, required tools are:

  • git-difftool
  • latexdiff (texdiff requires wdiff installed. However no wdiff installed in my Mac)

The main idea is that, using git-difftool and latexdiff tools to produce new tex files with tracked modification information into a temporary directory, which are included in a new ‘report.tex’ file to produce a tracked pdf thesis. (The new ‘report.tex’ file should be renamed)

The following steps demonstrate how to produce tracked pdf file after the thesis is changed:

  1. Configuration of git-difftool: git-difftool is supposed to invoke GUI comparison tool for a file between its two versions. Now, I want to bypass GUI tool’s invocation to a script that produces tex file with tracking information into a temporary directory.
  2. Configuration of latexdiff: latexdiff inserts some comment tags into tex files. However, these tags is undefined. Therefore, the preamble should be inserted into the main tex file: %DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
    %DIF UNDERLINE PREAMBLE %DIF PREAMBLE
    \RequirePackage[normalem]{ulem} %DIF PREAMBLE
    \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
    \providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
    \providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
    %DIF SAFE PREAMBLE %DIF PREAMBLE
    \providecommand{\DIFaddbegin}{} %DIF PREAMBLE
    \providecommand{\DIFaddend}{} %DIF PREAMBLE
    \providecommand{\DIFdelbegin}{} %DIF PREAMBLE
    \providecommand{\DIFdelend}{} %DIF PREAMBLE
    %DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
    \providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
    \providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
    \providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
    \providecommand{\DIFaddendFL}{} %DIF PREAMBLE
    \providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
    \providecommand{\DIFdelendFL}{} %DIF PREAMBLE
    %DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
  3. Create a new version ‘report.tex’ file:
  4. Produce PDF file with tracked modification information:

Problems:

The first problem is the configuration of latexdiff. I used dmath to represent mathematic equations. However, latexdiff recognises only equation and displaymath tags. I have to make a new config file to include dmath into the environment variable “MATHENV” in order to prevent compile errors. I have tried to use a configuration file. But it failed. So I just put this configuration information as a option in latexdiff command. Then it worked.

Posted in Tool Usage | Tagged , , | Leave a comment

Problem of Pandas resampling

https://github.com/pydata/pandas/issues/4197

Here demonstrated the exactly same problem with mine. If the resampling frequency can not be divided completely by the duration of the whole data set , the start time would be extremely strange with unpredictable base. In my work, this problem will be ignored. Here is just a reminder for this important issue in my work.

Posted in Uncategorized | Tagged , | Leave a comment

Problem Solving: Plotting Pandas DataFrame with DatetimeIndex to a figure with Time Elapse x-axis

This is only a representation issue of plotting using Canopy. When the time related data is plotted using matplotlib, the time index is represented as a timestamp. However, in my experiment, different experiment was performed in different time duration in each day. For uniformity reason, it is a better idea to plot figures using experiment elapse time instead of any specific time stamps. The central problem is that: in conventional matplotlib and pandas time series data plotting, time index is represented as time stamps; I want to convert this time stamp to elapse time, with pandas’ built-in time resampling function for further processing of data.

First Try: I want to convert the DatetimeIndex directly to some kind of Elapse time Index. 

However, I could not find any built-in pandas appropriated index type for representation of Elapse time Index. 

 

Second Try: I want to just convert the representation of each time point in a figure without changing of DatetimeIndex in data Series.

 

Posted in Uncategorized | Leave a comment

Plotting using matplotlib in Canopy

In Python’s world, most plotting tasks were completed using matplotlib. It was developed to provide similar plotting functions as Matlab in Python. In this case, there are some Matlab compatible functions for any researchers moving from Matlab part. However, matplotlib provides also object-oriented functions due to the OO features inherited from Python. I was totally confused when I contact with the matplotlib firstly, because too many functions are available to accomplish the same task. 

If some functions were treated according to the OO perspective, it would be more easier to distinguish those functions and plotting in different considerations cause the different intentions. 

Posted in Uncategorized | Tagged , | Leave a comment

Choice between Canopy and Matlab

I have experience of using both Canopy and Matlab for data processing. I wanted to choose a Swiss-knife-like tool for all my works of data processing and plotting. However, it doesn’t seem that easy by choosing any of them. 

Canopy is a python-based environment with very powerful functions benefited from the Python. Data is quite easily processed using Canopy. However, the plotting is not quite satisfied by using ‘matplotlib’. 

Matlab is a more commercial choice with release level quality. However, it’s data importing and exporting process are not in that high satisfied level. Moreover, I need to remind the basic syntax and the semantic of Matlab.

More detailed Pros and Cons would be updated in this article according to my usage of them.

Posted in Uncategorized | Tagged , , | Leave a comment