From 40da7c8cc19098f21d93e8f1720071a64759f9ee Mon Sep 17 00:00:00 2001 From: Pedram Ashofteh Ardakani Date: Sun, 3 May 2020 14:16:41 +0430 Subject: Remove extra spacing before and after code blocks Until now, the extra space made the padding look too big. * Changed this HTML code convention: ```html

some code
``` * to this: ```html
some code
``` And the extra space is gone. --- tutorial.html | 135 ++++++++++++++++++---------------------------------------- 1 file changed, 42 insertions(+), 93 deletions(-) (limited to 'tutorial.html') diff --git a/tutorial.html b/tutorial.html index 1439f10..aaef7c7 100644 --- a/tutorial.html +++ b/tutorial.html @@ -122,20 +122,16 @@ reproduce/software/config/installation/TARGETS.mk and add to the top-level-python line, the word matplotlib.

-

-# Python libraries/modules.
-                    top-level-python    = astropy matplotlib
-                
+
# Python libraries/modules.
+                    top-level-python    = astropy matplotlib

After that, run the configure step again with the option -e to continue using the same configuration options given before (input and build directories). Also, run the prepare and make steps:

-

-./project configure -e
+                
./project configure -e
 ./project prepare
-./project make
-                
+./project make

Open 'paper.pdf' and see if everything is fine. Note that now, Matplotlib is appearing in the software appendix at the end of the document.

@@ -151,14 +147,12 @@ Finally, as this is the very first commit of the project, tag this as the zero-th version.

-

-git status         # See which files have been changed.
+                
git status         # See which files have been changed.
 git diff           # See the lines you have modified.
 git add -u         # Put all tracked changes in staging area.
 git status         # Make sure everything is fine.
 git commit         # Your first commit, add a nice description.
-git tag -a v0.0    # Tag this as the zero-th version of your project.
-                
+git tag -a v0.0 # Tag this as the zero-th version of your project.

Now, have a look at the Git history of the project. Note that the local master branch is one commit above than the remote origin/master branch. @@ -166,11 +160,9 @@ git tag -a v0.0 # Tag this as the zero-th version of your project. with the next commands. Since you had setup your master branch to follow origin/master, you can just use git push.

-

-git log --oneline --decorate --all --graph   # Have a look at the Git history.
+                
git log --oneline --decorate --all --graph   # Have a look at the Git history.
 git push                                     # Push the commit to the remote/origin.
-git push --tags                              # Push all tags to the remote/origin.
-                
+git push --tags # Push all tags to the remote/origin.

Now it is time to start including your own scripts to download and make the analysis of the data. It is important to bear in mind that the goal of this @@ -205,9 +197,7 @@ git push --tags # Push all tags to the remote/origi into the bash directory. Since there is any python directory, create it with the following command.

-

-mkdir reproduce/analysis/python
-                
+
mkdir reproduce/analysis/python

After that, you need the Python script itself. The code is very simple: it will take an input file containing two columns (year and population), the @@ -217,8 +207,7 @@ mkdir reproduce/analysis/python into the directory generated in the above step (reproduce/analysis/python).

-

-# Make a linear fit of an input data set
+                
# Make a linear fit of an input data set
 # This Python script makes a linear fitting of a data consisting in time and
 # population. It generates a figure in which the original data and the
 # fitted curve is plotted.  Finally, it saves the fitting parameters.
@@ -299,9 +288,7 @@ np.savetxt(ofile, params, fmt='%.3f')
                 

As it can be seen, this Python script (linear-fit.py) is designed to be invoked from the command line in the following way.

-

-python /path/to/linear-fit.py /path/to/input.dat /path/to/output.dat /path/to/figure.pdf
-                
+
python /path/to/linear-fit.py /path/to/input.dat /path/to/output.dat /path/to/figure.pdf

/path/to/input.dat is the input data file, /path/to/output.dat is the output data file (with the fitted parameters), and /path/to/figure.pdf is @@ -315,21 +302,17 @@ python /path/to/linear-fit.py /path/to/input.dat /path/to/output.dat /path/to/fi information, comments or clarify any step. After that, add the files and commit the work. Finally, push the commit to the remote/origin.

-

-git status                                       # See which files you have changed.
+                
git status                                       # See which files you have changed.
 git diff                                         # See the lines you have added/changed.
 git add reproduce/analysis/python/linear-fit.py  # Put all tracked changes in staging area.
 git commit                                       # Commit, add a nice descriptions.
-git push                                         # Push the commit to the remote/origin.
-                
+git push # Push the commit to the remote/origin.

Check that everything is fine having a look at the Git history of the project. Note that the master branch has been increased in one commit, while the template branch is behind.

-

-git log --oneline --decorate --all --graph  # See the `Git` history.
-                
+
git log --oneline --decorate --all --graph  # See the `Git` history.

In short: in this section you have included a Python script that will be used for making the linear fitting.

@@ -355,8 +338,7 @@ git log --oneline --decorate --all --graph # See the `Git` history. analysis. Save this Makefile in the dedicated directory (reproduce/analysis/make) with the name getdata-analysis.mk. In that Makefile, paste the following code.

-

-# Download data for the tutorial
+                
# Download data for the tutorial
 #
 # In this Makefile, data for the tutorial is downloaded.
 #
@@ -384,8 +366,7 @@ wget http://akhlaghi.org/data/template-tutorial/ESP.dat -O $@
 # It is very important to mention the address where the data were
 # downloaded in the final report.
 $(mtexdir)/getdata-analysis.tex: $(pop-data) | $(mtexdir)
-echo "\newcommand{\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@
-                
+echo "\newcommand{\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@

Have a look at this Makefile and see the different parts. The first line is a descriptive title. Below, include your name, contact email, and finally, the copyright. Please, take your time in order to add all relevant @@ -396,10 +377,8 @@ echo "\newcommand{\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@ different parts. Then, you have the Make rule to download the data. Remember the general structure of a Make rule:

-

-TARGETS: PREREQUISITES
-RECIPE
-                
+
TARGETS: PREREQUISITES
+RECIPE

In a rule, it is said how to construct the TARGETS from the PREREQUISITES, following the RECIPE. Note that the white space at the @@ -408,10 +387,8 @@ RECIPE

Now you can see this structure in our particular case:

-

-(pop-data): | $(indir)
-wget http://akhlaghi.org/data/template-tutorial/ESP.dat -O $@
-                
+
(pop-data): | $(indir)
+wget http://akhlaghi.org/data/template-tutorial/ESP.dat -O $@

Here we have:

@@ -439,10 +416,8 @@ wget http://akhlaghi.org/data/template-tutorial/ESP.dat -O $@ consequence, they will be TeX macros in which relevant information to be included into the final paper are saved . Here, you are saving the URL.

-

-(mtexdir)/getdata-analysis.tex: $(pop-data) | $(mtexdir)
-echo "\\newcommand{\\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@
-                
+
(mtexdir)/getdata-analysis.tex: $(pop-data) | $(mtexdir)
+echo "\\newcommand{\\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@

In this final rule we have:

@@ -469,13 +444,11 @@ echo "\\newcommand{\\popurl}{http://akhlaghi.org/data/template-tutorial}" > $ reproduce/analysis/make/top-make.mk Makefile. There it is defined which Makefiles have to be executed. You have to end up having:

-

-makesrc = initialize \
+                
makesrc = initialize \
 download \
 getdata-analyse \
 delete-me \
-paper
-                
+paper

As allways, read carefully all comments and information in order to know what is going ong. Also, add your own comments and information in order to @@ -483,9 +456,7 @@ paper fine, now the project is ready to download the data in the make step. Try it!

-

-./project make
-                
+
./project make

Hopefully, it will download and save the file into the folder called inputs under the build-directory. Check that it is there, and also have @@ -528,34 +499,26 @@ paper generated for downloading the data. But, before this, define the directory in which the target is going to be saved.

-

-odir = $(BDIR)/fit-parameters
-                
+
odir = $(BDIR)/fit-parameters

This is a folder under the build-directory called fit-parameters. After that, define the target: a plain text file in which the linear fit parameters are saved (by the Python script). Put it into the previously defined directory. As the data is from Spain, name it ESP.txt.

-

-param-file = $(odir)/ESP.txt
-                
+
param-file = $(odir)/ESP.txt

Now, include a rule to construct the output directory odir. This is necessary because this directory is needed for saving the file ESP.txt.

-

-(odir):
-mkdir $@
-                
+
(odir):
+mkdir $@

With all the previous definitions, now it is possible to set the rule for making the analysis:

-

-(param-file): $(indir)/ESP.dat | $(odir)
-python reproduce/analysis/python/linear-fit.py $< $@ $(odir)/ESP.pdf
-                
+
(param-file): $(indir)/ESP.dat | $(odir)
+python reproduce/analysis/python/linear-fit.py $< $@ $(odir)/ESP.pdf

In this rule you have:

@@ -585,37 +548,29 @@ python reproduce/analysis/python/linear-fit.py $< $@ $(odir)/ESP.pdf rule, define a couple of bash variables (a and b) that are the fitted parameters extracted from the prerequisite. For a:

-

-a=$$(cat $< | awk 'NR==1{print $1}')
-                
+
a=$$(cat $< | awk 'NR==1{print $1}')

Similarly, for obtaining the parameter b (which is in the second row):

-

-b=$$(cat $< | awk 'NR==2{print $1}')
-                
+
b=$$(cat $< | awk 'NR==2{print $1}')

Then you have to specify the new TeX commands for these two parameters, just write them as it was done before for the URL:

-

-echo "\newcommand{\afitparam}{$$a}" >> $@
-echo "\newcommand{\bfitparam}{$$b}" >> $@
-                
+
echo "\newcommand{\afitparam}{$$a}" >> $@
+echo "\newcommand{\bfitparam}{$$b}" >> $@

So, at the end you will have the final rule like this:

(mtexdir)/getdata-analysis.tex: $(param-file) | $(mtexdir) -

-echo "\\newcommand{\\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@
+                
echo "\\newcommand{\\popurl}{http://akhlaghi.org/data/template-tutorial}" > $@
 
 a=$$(cat $< | awk 'NR==1{print $1}')
 b=$$(cat $< | awk 'NR==2{print $1}')
 
 echo "\newcommand{\afitparam}{$$a}" >> $@
-echo "\newcommand{\bfitparam}{$$b}" >> $@
-                
+echo "\newcommand{\bfitparam}{$$b}" >> $@

Important notes: you have to use two $ in order to use the bash $ character inside of a Make rule. Also, note that you have to put >> in @@ -626,8 +581,7 @@ echo "\newcommand{\bfitparam}{$$b}" >> $@

With all the above modifications, you are ready to obtain the fitting parameters. If you add the necessary comments and information, the final Makefile would look similar to:

-

-# Download data and linear fitting for the tutorial
+
# Download data and linear fitting for the tutorial
 # In this Makefile, data for the tutorial is downloaded. Then, a Python
 # script is used to make a linear fitting. Finally, fitted parameters as
 # well as the URL is saved into a TeX macro.
@@ -677,17 +631,14 @@ a=$$(cat $< | awk 'NR==1{print $1}')
 b=$$(cat $< | awk 'NR==2{print $1}')
 
 echo "\newcommand{\afitparam}{$$a}" >> $@
-echo "\newcommand{\bfitparam}{$$b}" >> $@
-                
+echo "\newcommand{\bfitparam}{$$b}" >> $@

Have look at this Makefile and note that it is what it has been described above. Take your time for making useful comments and modifying whatever you think it is necessary. If everything is fine, now the project is ready to download the data and make the linear fitting. Try it!

-

-./project make
-                
+
./project make

Hopefully, now you will have the fitted parameters into the build-directory/fit-parameters/ESP.txt file, and the figure in the same @@ -721,11 +672,9 @@ echo "\newcommand{\bfitparam}{$$b}" >> $@ and add the following paragraph just at the beginning of the abstract section.

-

-By following the steps described in the tutorial, I have been able to obtain this reproducible paper!
+                
By following the steps described in the tutorial, I have been able to obtain this reproducible paper!
 The project is very simple and it consists in download a file (from \popurl), and make an easy linear fit using a Python script.
-The linear fitting is $y=a*x+b$, with the following parameters: $a=\afitparam$ and $b=\bfitparam$
-                
+The linear fitting is $y=a*x+b$, with the following parameters: $a=\afitparam$ and $b=\bfitparam$

As you can see, the TeX definitions done before in the Makefiles, are now included into the paper: \popurl, \afitparam, and \bfitparam. If you -- cgit v1.2.1