<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5529669963650093738</id><updated>2012-02-01T19:54:23.940+01:00</updated><category term='gnuplot'/><category term='computation'/><category term='gmt'/><category term='Image formats'/><category term='introduction'/><category term='unix tools'/><category term='Imagemagick'/><category term='latex'/><category term='multiplot'/><category term='short tips'/><category term='tr'/><category term='sed'/><category term='regular expresions'/><category term='Fortran'/><category term='awk'/><category term='figures'/><category term='terminal'/><category term='bash script'/><category term='boundary labels'/><category term='MACOSX'/><category term='plotting'/><category term='colors'/><category term='vim'/><category term='cat'/><category term='axis'/><category term='botch'/><title type='text'>Trix &amp; Graphix</title><subtitle type='html'>Computing and plotting tips for GNU users</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-1649544369336029773</id><published>2011-02-11T14:07:00.000+01:00</published><updated>2011-02-11T14:07:14.091+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><title type='text'>Two tips to create comments in programs edited thorough VIM</title><content type='html'>Here are a couple of simple tips to help you in the hard task of programming in VIM (the hard task is to write the code, not to do it in VIM, of course :) )&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Inserting 50 symbols to create a header&lt;/b&gt;&lt;br /&gt;Normaly it is a good idea to remark something within a program using comments. It's just something like&lt;br /&gt;&lt;blockquote&gt;#########################################&lt;br /&gt;# HERE GO IMPORTANT VARIABLES!&lt;br /&gt;#########################################&lt;/blockquote&gt;&lt;br /&gt;In general, writing a large numbers of symbols is not a hard task, but it can be even easier using VIM. You only have to type a character, and repeat the order many times. To do this, use the command&lt;br /&gt;&lt;blockquote&gt;100i#&lt;/blockquote&gt;and press &lt;b&gt;ESC&lt;/b&gt;, and you will get a hundred symbols &lt;b&gt;"#"&lt;/b&gt; all together. Later just push &lt;b&gt;"."&lt;/b&gt; to repeat the last command. You will have exactly 2 lines of 100 symbols having pressed only 7 keys. Oh yeah.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Commenting several lines of code with few commands&lt;/b&gt;&lt;br /&gt;This tip is less silly than the former one, and it may save you a lot of time. Unfortunately I don't know illustrate it, so I'll try to explain in my own words. Imagine you want to comment 20 lines, inserting some character (for example &lt;b&gt;"#"&lt;/b&gt;, but it may be other depending on the language of your choice) in the first column of these lines. To do it in VIM, use the block selection tool by pressing &lt;b&gt;"ctrl+v"&lt;/b&gt; in command mode (remember that "&lt;b&gt;v"&lt;/b&gt; is to use the standard selection, whereas "&lt;b&gt;V"&lt;/b&gt; is the line selection). Then, select the first character, and only the first one!, in every line you want to comment. In this moment, press &lt;b&gt;"I"&lt;/b&gt; (capital &lt;b&gt;"i"&lt;/b&gt;, the lowercase does not work) and type the character that you want to insert in every selected line. At the moment you will only see the change in the first line, but after pressing ESC, all selected lines will be commented automatically.&lt;br /&gt;&lt;br /&gt;I don't even know how I could live without this! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-1649544369336029773?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/1649544369336029773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=1649544369336029773' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/1649544369336029773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/1649544369336029773'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/02/two-tips-to-create-comments-in-programs.html' title='Two tips to create comments in programs edited thorough VIM'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-7972998573875771590</id><published>2011-02-11T13:41:00.000+01:00</published><updated>2011-02-11T13:41:05.501+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='gmt'/><category scheme='http://www.blogger.com/atom/ns#' term='figures'/><title type='text'>Converting eps to pdf</title><content type='html'>In most Unix-like systems there is a tool called &lt;b&gt;epstopdf&lt;/b&gt;. It is very simple, but incredibly useful for preparing figures for a LaTeX document. Nevertheless there are some cases in which this tool is not present in your system by default. For example Snow Leopard, the SO of Mac, does not provide it. If I remember correctly, this tool is also missing in Ubuntu, and I guess that this can be the case in many other Linux distributions. There are other cases in which although the tool is present, it does not work properly, and you get unexpected results with the warning message:&lt;blockquote&gt;==&amp;gt; Warning: BoundingBox not found!&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;In this case, the problem is because you are using a too old version of this program.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have had problems in the past looking for a newer version, since you get a lot of garbage when searching&amp;nbsp;&lt;b&gt;epstopdf&lt;/b&gt; in google. Hence, this post is a simple hint to help you getting the program. Hopefully someone in the future will reach this post through google and will save a lot of time :)&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The solution is simple: just go to the &lt;a href="http://www.ctan.org/tex-archive/support/epstopdf/"&gt;CTAN&lt;/a&gt; page of this software. Actually it is just a perl script. Place it somewhere and add the location of the script to your PATH. That's all folks.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-7972998573875771590?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/7972998573875771590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=7972998573875771590' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7972998573875771590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7972998573875771590'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/02/converting-eps-to-pdf.html' title='Converting eps to pdf'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-3558460420137360279</id><published>2011-02-08T11:22:00.001+01:00</published><updated>2011-02-08T11:25:02.984+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='short tips'/><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><title type='text'>Improving the search in VIM</title><content type='html'>Here are a couple of tips to improve the searching engine in &lt;a href="http://ontublog.blogspot.com/search/label/vim"&gt;VIM&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;First of all, searching patterns in VIM is quite simple. In command mode, use the&lt;br /&gt;&lt;blockquote&gt;/&amp;nbsp;&lt;/blockquote&gt;command. You can use regular expressions too. For example&lt;br /&gt;&lt;blockquote&gt;/^foo&amp;nbsp;&lt;/blockquote&gt;searches for the text "foo" in the beginning of a line. You can use very complex regular expresions, whose explanation if far away from the scope of this blog.&lt;br /&gt;&lt;br /&gt;The searching commands in VIM takes the focus of the cursor to the next match going downward within the text. If you want to go to the next match, use the command&lt;br /&gt;&lt;blockquote&gt;n&lt;/blockquote&gt;Similarly,&lt;br /&gt;&lt;blockquote&gt;N&amp;nbsp;&lt;/blockquote&gt;takes you to the former match. The command&lt;br /&gt;&lt;blockquote&gt;?&lt;/blockquote&gt;&amp;nbsp;makes the same than "/" but in the opposite direction, this is from the end of the file to the beginning.&lt;br /&gt;&lt;br /&gt;Besides these commands, you can configure some of the behaviour of VIM when searchig patterns by adding some lines to the &lt;b&gt;.vimrc&lt;/b&gt; file. For example&lt;br /&gt;&lt;blockquote&gt;set incsearch&lt;/blockquote&gt;search in the text meanwhile you are typing, without waiting you to press enter. Another interesting feature is&lt;br /&gt;&lt;blockquote&gt;set hlsearch&lt;/blockquote&gt;which highlight the found text. This is very usefull when debuggingg scripts, since you have a very convenient way to taking a look at the patters you want in a given moment.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-3558460420137360279?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/3558460420137360279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=3558460420137360279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3558460420137360279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3558460420137360279'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/02/improving-search-in-vim.html' title='Improving the search in VIM'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-6918609305599626800</id><published>2011-02-02T17:19:00.000+01:00</published><updated>2011-02-02T17:19:14.203+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MACOSX'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal'/><title type='text'>Changing the colours in the output of "ls" command</title><content type='html'>During the last weeks I'm working quite often with Mac OSX. However I normally use a lot the terminal, but the default terminal in this OS is quite lame. Thus, I recommend to use the program &lt;a href="http://iterm.sourceforge.net/"&gt;iTerm&lt;/a&gt;. This terminal has some interesting features, which I don't want to discuss in detail. Take a look and decide yourself!&lt;br /&gt;&lt;br /&gt;However there is an interesting feature which is not activated by default in this OS (and has nothing to do with the terminal program you use). It is the use of fancy colours according to the type of file when listing the content of a directory through the command &lt;b&gt;ls&lt;/b&gt;. This is a very important feature, very useful to easily identify the kind of files you have into a directory. In fact, it has few to do with the fancy aspect, but with how comfortable you feel yourself working in a terminal.&lt;br /&gt;&lt;br /&gt;To allow the use of colours you have to use the &lt;b&gt;-G&lt;/b&gt; option. Nevertheless&amp;nbsp;having to write this every time&amp;nbsp;is a pain (you would type it a thousand times every day!). It's much easier to use an alias in the &lt;b&gt;.bass_profile&lt;/b&gt; in your home&lt;br /&gt;&lt;blockquote&gt;alias ls="ls -G"&lt;/blockquote&gt;Finally, in order to customize these coulours, you have to use the environment variable &lt;b&gt;LSCOLOR&lt;/b&gt;. To do so, you only have to add also this line to the &lt;b&gt;.bash_profile&lt;/b&gt; in your home:&lt;br /&gt;&lt;blockquote&gt;export LSCOLORS="exfxcxdxcxegedabagacad"&lt;/blockquote&gt;But what in the hell means that line? Well, I could explain it in detail but... finally I would only sumarize the content of the man page of &lt;b&gt;ls&lt;/b&gt;. So here I copy the explanations you may need, directly taken from this man page:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;LSCOLORS        The value of this variable describes what color to use for which attribute&lt;br /&gt;when colors are enabled with CLICOLOR.  This string is a concatenation of&lt;br /&gt;pairs of the format fb, where f is the foreground color and b is the back-&lt;br /&gt;ground color.&lt;br /&gt;&lt;br /&gt;The color designators are as follows:&lt;br /&gt;&lt;br /&gt;a     black&lt;br /&gt;b     red&lt;br /&gt;c     green&lt;br /&gt;d     brown&lt;br /&gt;e     blue&lt;br /&gt;f     magenta&lt;br /&gt;g     cyan&lt;br /&gt;h     light grey&lt;br /&gt;A     bold black, usually shows up as dark grey&lt;br /&gt;B     bold red&lt;br /&gt;C     bold green&lt;br /&gt;D     bold brown, usually shows up as yellow&lt;br /&gt;E     bold blue&lt;br /&gt;F     bold magenta&lt;br /&gt;G     bold cyan&lt;br /&gt;H     bold light grey; looks like bright white&lt;br /&gt;x     default foreground or background&lt;br /&gt;&lt;br /&gt;Note that the above are standard ANSI colors.  The actual display may differ&lt;br /&gt;depending on the color capabilities of the terminal in use.&lt;br /&gt;&lt;br /&gt;The order of the attributes are as follows:&lt;br /&gt;&lt;br /&gt;1.   directory&lt;br /&gt;2.   symbolic link&lt;br /&gt;3.   socket&lt;br /&gt;4.   pipe&lt;br /&gt;5.   executable&lt;br /&gt;6.   block special&lt;br /&gt;7.   character special&lt;br /&gt;8.   executable with setuid bit set&lt;br /&gt;9.   executable with setgid bit set&lt;br /&gt;10.  directory writable to others, with sticky bit&lt;br /&gt;11.  directory writable to others, without sticky bit&lt;br /&gt;&lt;br /&gt;The default is "exfxcxdxbxegedabagacad", i.e. blue foreground and default&lt;br /&gt;background for regular directories, black foreground and red background for&lt;br /&gt;setuid executables, etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-6918609305599626800?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/6918609305599626800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=6918609305599626800' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/6918609305599626800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/6918609305599626800'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/02/changing-colours-in-output-of-ls.html' title='Changing the colours in the output of &quot;ls&quot; command'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-5151151841571912007</id><published>2011-01-31T10:46:00.003+01:00</published><updated>2011-02-02T17:21:46.562+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><title type='text'>Forcing vim to remember the cursor position</title><content type='html'>In some VIM installations this awesome editor does not remember the last cursor position in the former edition of a file. Of course, this can be a pain. Here is a small tip to solve this problem. You only need to copy this code into your &lt;b&gt;.vimrc&lt;/b&gt; file&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;" Uncomment the following to have Vim jump to the last position when&lt;/div&gt;&lt;div&gt;" reopening a file&lt;/div&gt;&lt;div&gt;if has("autocmd")&lt;/div&gt;&lt;div&gt;au BufReadPost * if line("'\"") &amp;gt; 0 &amp;amp;&amp;amp; line("'\"") &amp;lt;= line("$")&lt;/div&gt;&lt;br /&gt;&lt;div&gt;\| exe "normal g'\"" | endif&lt;/div&gt;&lt;div&gt;endif&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-5151151841571912007?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/5151151841571912007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=5151151841571912007' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/5151151841571912007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/5151151841571912007'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/01/force-vim-remembering-cursor-position.html' title='Forcing vim to remember the cursor position'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-8974180599414824411</id><published>2011-01-28T14:04:00.006+01:00</published><updated>2011-02-02T16:34:14.695+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal'/><title type='text'>Customizing the Unix prompt</title><content type='html'>This is a very fast post about the prompt (basically this is an auto-remainder for myself xD). &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The appearance of the prompt in an Unix terminal is determined by the environment variable &lt;b&gt;PS1&lt;/b&gt;. You can (you have to) modify it if you want to change the prompt. It is easy to take a look at the current value of variable: just type in an open terminal&lt;br /&gt;&lt;blockquote&gt;echo $PS1&lt;/blockquote&gt;and here is it. The prompt that I'm currently using is this one:&lt;div&gt;&lt;blockquote&gt;PS1='$(tput setaf 1)\u@\h $(tput setaf 2)\w&gt; $(tput setaf 0)'&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;There are a number of commands very useful to depict important information. In my example &lt;b&gt;\h&lt;/b&gt; shows the name of the host, whereas &lt;b&gt;\u&lt;/b&gt; is the user and &lt;b&gt;\w&lt;/b&gt; is the current working path. The commands &lt;b&gt;tput&lt;/b&gt; &lt;b&gt;setaf&lt;/b&gt; change the color. Take a look to the man pages of &lt;b&gt;tput&lt;/b&gt; and &lt;b&gt;terminfo&lt;/b&gt; to learn more.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Of course there are many more options. &lt;a href="http://news.softpedia.com/news/How-to-Customize-the-Shell-Prompt-40033.shtml"&gt;Here&lt;/a&gt; there is a more complete reference in this respect. By the way, it is a good idea to modify this variable in the .bash_profile file in your home directory :)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-8974180599414824411?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/8974180599414824411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=8974180599414824411' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8974180599414824411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8974180599414824411'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2011/01/customizing-unix-prompt.html' title='Customizing the Unix prompt'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-6877814630411998356</id><published>2010-06-12T17:52:00.004+02:00</published><updated>2010-06-20T19:30:52.564+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><category scheme='http://www.blogger.com/atom/ns#' term='Fortran'/><title type='text'>Reading a file until it ends</title><content type='html'>It is a commont task that you have to read some information from a file to perform some calculations. This uses to be done inside a loop. The problem is that many times you don't know how many lines the file has, so you can't use a counter as the condition to stop reading. Or maybe you know, but you don't want to pass that information to the program every time you run it. In this post I'm showing how to "teach" a Fortran and Bash program to read until it reach the end of the file. &lt;div&gt;&lt;br /&gt;&lt;b&gt;Fortran version &lt;/b&gt;&lt;br /&gt;In fortran, you have to use the option iostat when you use the read function. By doing so, there is an integer variable (ierr in the example below) that contains the output code of the last read action. If it is different to 0, it means that the end of the files has been reached (or something even worse). I think the example is self explanatory &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;program readtotheend&lt;/div&gt;&lt;div&gt;implicit none&lt;br /&gt;integer :: i, ierr, number&lt;br /&gt;open(unit=10,file='filein.asc',status='old',action='read')&lt;br /&gt;ierr=0&lt;/div&gt;&lt;div&gt;i=0&lt;/div&gt;&lt;div&gt;do while(ierr.eq.0)&lt;/div&gt;&lt;div&gt; i=i+1 &lt;/div&gt;&lt;div&gt;read(10,*,iostat=ierr),number &lt;/div&gt;&lt;div&gt;print*, 'Element', i, number&lt;/div&gt;&lt;div&gt;enddo&lt;/div&gt;&lt;div&gt;close(unit=10)&lt;br /&gt;print*, 'Reading finished', i-1, 'lines'&lt;br /&gt;end program &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;b&gt;Bash version &lt;/b&gt;&lt;br /&gt;The Bash version of this idea is to use a while loop and feed it with the input file &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;blockquote&gt;set -ex&lt;br /&gt;while read number; do&lt;br /&gt;# Here you can do whatever you want to do with the variable, which is stored in the variable number&lt;br /&gt;done &lt; filein.asc&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;This is a really elegant solution to perform some operation to all the lines of a file.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-6877814630411998356?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/6877814630411998356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=6877814630411998356' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/6877814630411998356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/6877814630411998356'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2010/06/it-is-commont-task-that-you-have-to.html' title='Reading a file until it ends'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-4492776237094088190</id><published>2010-06-12T16:50:00.005+02:00</published><updated>2010-06-12T16:54:54.129+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='computation'/><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><title type='text'>Generating random numbers within a Bash script</title><content type='html'>Unix systems has their own random numgers generator. It can be employed, for instance, to generate a sequence of random numbers inside a Bash script. The only thing that has to be done is to use the internal function $RANDOM&lt;br /&gt;&lt;br /&gt;The next example illustrates the idea:&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;set -ex &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;for i in $(jot 100 1 1); do&lt;/div&gt;&lt;div&gt;  echo $RANDOM &gt;&gt; file&lt;/div&gt;&lt;div&gt;done&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-4492776237094088190?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/4492776237094088190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=4492776237094088190' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4492776237094088190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4492776237094088190'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2010/06/generating-random-numbers-with-bash.html' title='Generating random numbers within a Bash script'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-8613350993318908733</id><published>2009-12-01T09:32:00.004+01:00</published><updated>2009-12-01T09:39:33.396+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Fortran'/><title type='text'>Switch in Fortran 90</title><content type='html'>A very quick post... I have just found out the Fortran 90 syntax for the equivalent of the &lt;b&gt;switch&lt;/b&gt; command in C or &lt;b&gt;case&lt;/b&gt; in Bash.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;selectcase(var)&lt;br /&gt;  case(a)&lt;br /&gt;  print*, 'var=', a &lt;br /&gt;  case(b) &lt;br /&gt;  print*, 'var=', b&lt;br /&gt;end select&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-8613350993318908733?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/8613350993318908733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=8613350993318908733' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8613350993318908733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8613350993318908733'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/12/switch-in-fortran-90.html' title='Switch in Fortran 90'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-706361554758125715</id><published>2009-10-26T15:30:00.005+01:00</published><updated>2009-10-26T15:46:25.733+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='awk'/><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='tr'/><title type='text'>Columns to rows and vice versa in ASCII files</title><content type='html'>Imagine you have a table with data within an ASCII file. Let's asume your table is homogenious (otherwise you can take a look at this &lt;a href="http://ontublog.blogspot.com/2009/10/tips-for-cleaning-up-ascii-file.html"&gt;post&lt;/a&gt;. You may want to turn it into just one row, or just one column. I'm going to explain how to do it in two different ways using two different Unix tools: &lt;span style="font-weight: bold;"&gt;awk&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;tr&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;- tr version:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the easiest way. In order to turn the file into just one row, the "\n" characters have to be removed. This can be done with the command:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;tr "\n" " " &lt; filein.asc &gt; fileout.asc&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Similarly, in order to turn the file into a column you can change the "\n" characters as field separator:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;tr " " "\n" &lt; filein.asc &gt; fileout.asc&lt;br /&gt;&lt;/filein.asc&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;- awk version&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Focusing now in the awk version, you can use&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;awk '{for(i=1;i&lt;=NF;i++) print $i}' filein.asc &gt; fileout.asc&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;in order to turn the file into a column, or&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;awk '{for(i=1;i&lt;=NF;i++) printf "%s ", $i}' filein.asc &gt; fileout.asc&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;to turn the file into just one row.&lt;br /&gt;&lt;br /&gt;Easy, isn't?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-706361554758125715?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/706361554758125715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=706361554758125715' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/706361554758125715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/706361554758125715'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/columns-to-rows-and-vice-versa-in-ascii.html' title='Columns to rows and vice versa in ASCII files'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-5374311997692527048</id><published>2009-10-26T12:28:00.011+01:00</published><updated>2009-10-26T13:02:15.936+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='awk'/><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><category scheme='http://www.blogger.com/atom/ns#' term='tr'/><title type='text'>Tips for cleaning up an ascii file</title><content type='html'>Suposse you have a table in ASCII file such as this one:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;element1x1 element1x2   element1x3&lt;br /&gt;&lt;br /&gt;element2x2      element2x2      element2x3&lt;br /&gt;&lt;br /&gt;element3x1,   element3x2,   element3x3&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;It's full of undesirable heterogeneities: tabs, comma instead of just spaces as columns delimiters, undesired spaces, empty lines... How can you homogenize this file using simple command-line Unix tools?&lt;br /&gt;&lt;br /&gt;Well, the first thing is to remove the tabs. This is easy using the &lt;span style="font-weight: bold;"&gt;tr&lt;/span&gt; tool, which substitutes some character by others. To remove the tabs just type&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;tr "\t" " " &lt; file.asc &lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and this will return a copy of the file but without tabs through the standard output. Similarly, to remove the "," symbols you can pipe the last command:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;tr "\t" " " &lt; file.asc | tr "," " " &lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Next thing is to remove the emply lines and some undesired spaces. This may be done using &lt;span style="font-weight: bold;"&gt;awk&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; tr "\t" " " &lt; file.asc | tr "," " " | awk '{ if(NF&gt;0) {for(i=1;i&lt;=NF;i++) printf "%s ", $i; printf "\n"}}' &lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Finally, last command adds an undesired space at the end of each line. It can be removed using &lt;span style="font-weight: bold;"&gt;sed&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; tr "\t" " " &lt; file | tr "," " " | awk '{ if(NF&gt;0) {for(i=1;i&lt;=NF;i++) printf "%s ", $i; printf "\n"}}' | sed 's/ $//'&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Well, this is all. The final output you get through the standard output after running this command is&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;element1x1 element1x2 element1x3&lt;br /&gt;element2x2 element2x2 element2x3&lt;br /&gt;element3x1 element3x2 element3x3&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Yes, I know, I have used a lot of tools with few explanations. Maybe in some post in the future I will explain some these tools in more detail...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-5374311997692527048?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/5374311997692527048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=5374311997692527048' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/5374311997692527048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/5374311997692527048'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/tips-for-cleaning-up-ascii-file.html' title='Tips for cleaning up an ascii file'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-4270453689435978626</id><published>2009-10-23T21:29:00.004+02:00</published><updated>2009-10-23T22:27:47.286+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><category scheme='http://www.blogger.com/atom/ns#' term='regular expresions'/><title type='text'>Strings in BASH</title><content type='html'>This post is to show some really nice features I have just found regarding the management of strings in Bash scripts. &lt;b&gt;How have I been abled to live without this? :-)&lt;/b&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Strings index&lt;/b&gt;&lt;/div&gt;&lt;div&gt;An array may be splitted using indexes. The sitanxis is something like ${variable:indx1:elemensts}, where &lt;i&gt;inx1&lt;/i&gt; is the first element on the substring you want to get (the first element is numbered 0, as in C), and &lt;i&gt;elements&lt;/i&gt; in the number of elements you want to remain. Maybe it's easier to understand with some few examples:&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;var="asdf1234"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;echo ${var:0}&lt;/div&gt;&lt;div&gt;asdf1234&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var:4}&lt;/div&gt;&lt;div&gt;1234           &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var:4:1}&lt;/div&gt;&lt;div&gt;1&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var:4:2}&lt;/div&gt;&lt;div&gt;12&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note that ${var:0} is equivalent to ${var}. A really interesting feature is that you may index from the right&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;var="asdf1234"&lt;/div&gt;&lt;div&gt;&lt;div&gt;echo ${var: -2:2}&lt;/div&gt;&lt;div&gt;34&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;b&gt;Note the blank space before the minus sign!!!&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Replacing elements (regular expresions-like)&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Another interesting feature is that you can use Bash to replace some elements of the string. This is a thing that people use to do with sed or awk. Nevertheless for easy tasks the direct form using Bask I'm going to explain may be useful. The sytanxis is ${variable/substringToBeReplaced/stringReplacing/}. Let's see some exmamples:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;var=123ASDF123&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var/123/XY}&lt;/div&gt;&lt;div&gt;XYASDF123&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var//123/XY}&lt;/div&gt;&lt;div&gt;XYASDFXY&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var/23}&lt;/div&gt;&lt;div&gt;1ASDF123&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;As you can see the sintaxis is similar to awk. By default, only the first time that the substring is found from the left it is replaced. Using "//" you can force to replace all the instances of the substring in the main string. Finally, if only one string is specified, it's simply removed (replaced by a null string). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, if you want to replace, but beginning from the right, "%" has to be appended:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;var=123ASDF123&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;echo ${var/#123/XY}&lt;/div&gt;&lt;div&gt;XYASDF123&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;echo ${var/%123/XY}&lt;/div&gt;&lt;div&gt;123ASDFXY&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note that the simbol "#" means "reading from the left". In general it is not necesary as this is the default behaviour.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just two more examples. In order to get the name and the extension of a file:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;var=name.ext&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;echo "The filename is ${var/%.*}"&lt;/div&gt;&lt;div&gt;The filename is name&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;echo "The extension is ${var/#*.}"&lt;/div&gt;&lt;div&gt;The extension is ext&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here you can see that "*" can mean the beginning as well as the end of the string.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I hope it may be useful for you :-).&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-4270453689435978626?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/4270453689435978626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=4270453689435978626' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4270453689435978626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4270453689435978626'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/strings-in-bash.html' title='Strings in BASH'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-7937214086377133699</id><published>2009-10-21T12:20:00.006+02:00</published><updated>2009-10-21T12:31:09.719+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Imagemagick'/><category scheme='http://www.blogger.com/atom/ns#' term='Image formats'/><title type='text'>Removing the transparent background when converting formats in Imagemagick</title><content type='html'>By some reason, the version of Imagemagick I have in my workstation (6.4.3) sets the background to transparent  when I convert &lt;a href="http://en.wikipedia.org/wiki/Encapsulated_PostScript"&gt;EPS&lt;/a&gt; files to &lt;a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics"&gt;PNG&lt;/a&gt; format (for example the EPS files from GMT or gnuplot).&lt;br /&gt;&lt;br /&gt;Although it's in general a desirable feature, sometimes you just want a plain white background. In order to get it, I have found a solution (there must be many others, but this one just works for me), which consists in adding this options:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;convert -layers flatten figure.eps figure.png&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-7937214086377133699?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/7937214086377133699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=7937214086377133699' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7937214086377133699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7937214086377133699'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/remove-transparent-background-in.html' title='Removing the transparent background when converting formats in Imagemagick'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-183009049291049001</id><published>2009-10-18T23:04:00.014+02:00</published><updated>2009-10-21T12:38:25.484+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gmt'/><category scheme='http://www.blogger.com/atom/ns#' term='boundary labels'/><title type='text'>Boundary annotations in GMT</title><content type='html'>In the &lt;a href="http://ontublog.blogspot.com/2009/10/gmt-very-brief-introduction.html"&gt;last  post&lt;/a&gt;, I tried to give a general description of &lt;a href="http://gmt.soest.hawaii.edu/"&gt;GMT&lt;/a&gt;. In the   next few post I'm  going to try to explain, by means of several examples,   some details of  the use of these tools.&lt;br /&gt;&lt;br /&gt;In this first example,  I'm going to use  &lt;span style="background: none repeat scroll 0% 0% transparent; font-weight: bold;" class="J-JK9eJ-PJVNOc"&gt;pscoast&lt;/span&gt; to  create a simple map  of  Europe. Mostly I'm going to focus in how to  customise annotation   boundaries. In the next post I'll explain in more  detail some flags of &lt;span style="background: none repeat scroll 0% 0% transparent; font-weight: bold;" class="J-JK9eJ-PJVNOc"&gt;pscoast&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;This is the output we  want  to get:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_YJHQnk-6NJY/St7eO436eZI/AAAAAAAAAG4/M0WpUHqPtao/s1600-h/map.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 352px;" src="http://2.bp.blogspot.com/_YJHQnk-6NJY/St7eO436eZI/AAAAAAAAAG4/M0WpUHqPtao/s400/map.png" alt="" id="BLOGGER_PHOTO_ID_5394993751002872210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And this is the simple bash script which generates it&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;#!/bin/sh&lt;br /&gt;# Bash script for using GMT&lt;br /&gt;&lt;br /&gt;# Some environment variables&lt;br /&gt;gmtset PAPER_MEDIA a5+&lt;br /&gt;gmtset PAGE_ORIENTATION portrait&lt;br /&gt;gmtset HEADER_FONT_SIZE 18&lt;br /&gt;gmtset PLOT_DEGREE_FORMAT ddd:mm:ssF&lt;br /&gt;gmtset DEGREE_SYMBOL none&lt;br /&gt;&lt;br /&gt;# The only command of this plot&lt;br /&gt;pscoast -Jl15/35/30/60/1:20000000 -R-15/45/35/70 -A0/0/1 -Ba5g5/a5g5nSEW:."Europe": -Ggrey &gt; map.eps&lt;br /&gt;&lt;br /&gt;# To convert the EPS file into png&lt;br /&gt;convert -density 100 map.eps map.png&lt;/blockquote&gt;&lt;br /&gt;The main task is developed by &lt;span style="background: none repeat scroll 0% 0% transparent; font-weight: bold;" class="J-JK9eJ-PJVNOc"&gt;pscoast&lt;/span&gt;, which uses 5  flags (-J, -R, -A, -B and -G). By the way, the order of these flags is  not relevant. Before that, there are some options which controls the  general behaviour of GMT and the aspect of the final result, like fonts  styles, &lt;span style="background: none repeat scroll 0% 0% transparent;" class="J-JK9eJ-PJVNOc"&gt;colors&lt;/span&gt;, formats and so on. Finally &lt;span style="background: none repeat scroll 0% 0% transparent;" class="J-JK9eJ-PJVNOc"&gt;Imagemagick&lt;/span&gt; converts the &lt;a href="http://en.wikipedia.org/wiki/Encapsulated_PostScript"&gt;&lt;span style="background: none repeat scroll 0% 0% transparent;" class="J-JK9eJ-PJVNOc"&gt;EPS&lt;/span&gt;&lt;/a&gt; file to a more friendly &lt;a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics"&gt;&lt;span style="background: none repeat scroll 0% 0% transparent;" class="J-JK9eJ-PJVNOc"&gt;png&lt;/span&gt;&lt;/a&gt; image.&lt;br /&gt;&lt;br /&gt;The explanation of the flags is as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;J&lt;/span&gt; defines the projection, meanwhile &lt;span style="font-weight: bold;"&gt;R&lt;/span&gt; defines the region you want to  plot. Of course, depending on the region you want to plot, you have to  chose the adequate projection. I have chosen the Lambert Conic Conformal  projection, in which you have to set the central coordinates, two true  latitudes and the scale. It's beyond the scope of this blog to explain  the exact meaning of these parameters, sorry. I have chosen  -Jl&lt;span style="font-style: italic;"&gt;15/35/30/60/1:20000000&lt;/span&gt; because 15 degrees East is the central  latitude of the region I have chosen (-R&lt;span style="font-style: italic;"&gt;-15/45/35/70&lt;/span&gt;), and 30 and 60 as  the two true latitude just because they are inside the domain I want to  plot.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;A&lt;/span&gt; is to select whether you want or not to show small water regions, like  lakes. It's a bit confusing and in fact I don't understand it very  well. I just use it with those options as far as I have found out it  removes the lakes...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;G&lt;/span&gt; is to say GMT to plot the land areas. The option grey is just to set  the colour you want. You can also use the &lt;a href="http://en.wikipedia.org/wiki/RGB_color_model"&gt;&lt;span style="background: none repeat scroll 0% 0% transparent;" class="J-JK9eJ-PJVNOc"&gt;RGB&lt;/span&gt;&lt;/a&gt; model,  for example G&lt;span style="font-style: italic;"&gt;255/0/0&lt;/span&gt; is red.&lt;br /&gt;&lt;br /&gt;Finally, &lt;span style="font-weight: bold;"&gt;B&lt;/span&gt; is to specify the boundaries of the plot. It's quite  important to get nice maps. I have used -B&lt;span style="font-style: italic;"&gt;a5g5/a5g5nSEW:."Europe":&lt;/span&gt;,  which may appear to be really complex, but don't worry, isn't so hard  ;-). &lt;span style="font-style: italic;"&gt;a5&lt;/span&gt; says GMT to set the degree label every 5 degrees. &lt;span style="font-style: italic;"&gt;g5&lt;/span&gt; says it to  draw the white-black rectangles every 5 degrees, and also to plot the  inner grid lines along the map. If you use &lt;span style="font-style: italic;"&gt;f&lt;/span&gt; instead of &lt;span style="font-style: italic;"&gt;g&lt;/span&gt;, you removes  the inner grid. I use it twice, &lt;span style="font-style: italic;"&gt;a5g5/a5g5&lt;/span&gt;, because first one is for  horizontal and second for vertical boundaries (if you only set it once,  both horizontal and vertical share same options). Later I add &lt;span style="background: none repeat scroll 0% 0% transparent; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;nSEW&lt;/span&gt;. This is to say in which axis you  want to set degree annotations, lower case means no annotations, and  upper case means annotations. Then, for example, &lt;span style="background: none repeat scroll 0% 0% transparent; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;NsWe&lt;/span&gt; sets annotations only in West and  North. Finally, &lt;span style="font-style: italic;"&gt;:."Europe":&lt;/span&gt; adds a title to the map.&lt;br /&gt;&lt;br /&gt;A last comment regarding the general options of the map. By default,  these are the options. &lt;span style="background: none repeat scroll 0% 0% transparent; font-weight: bold;" class="J-JK9eJ-PJVNOc"&gt;gmtset&lt;/span&gt; allows you to modify  these options. &lt;span style="font-style: italic;"&gt;DEGREE_SYMBOL&lt;/span&gt; &lt;span style="font-style: italic;"&gt;none&lt;/span&gt; disables the degree symbol, and  &lt;span style="font-style: italic;"&gt;PLOT_DEGREE_FORMAT &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% transparent; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;ddd&lt;/span&gt;&lt;span style="font-style: italic;"&gt;:mm:&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% transparent; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;ssF&lt;/span&gt; sets  the degree interval to -180/180 and adds a W instead of the minus  symbol for west coordinates. &lt;span style="font-style: italic;"&gt;HEADER_FONT_SIZE 18&lt;/span&gt; sets to this size the title font and so on.&lt;br /&gt;&lt;br /&gt;This is all. I hope this post is not too confusing. In the next one I'll try to add some more options to &lt;span style="font-weight: bold;"&gt;pscoast&lt;/span&gt; in order to get a more complex map.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-183009049291049001?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/183009049291049001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=183009049291049001' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/183009049291049001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/183009049291049001'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/boundary-anotations-in-gmt.html' title='Boundary annotations in GMT'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_YJHQnk-6NJY/St7eO436eZI/AAAAAAAAAG4/M0WpUHqPtao/s72-c/map.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-8912461298281532945</id><published>2009-10-18T22:15:00.004+02:00</published><updated>2009-10-19T19:22:17.919+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='gmt'/><title type='text'>GMT: a very brief introduction</title><content type='html'>&lt;a href="http://gmt.soest.hawaii.edu/"&gt;GMT&lt;/a&gt; is a set of tools (command line programs) to manipulating geographic data sets, and in particular to create maps. This set of tools are a great example of the philosofy that should follow all the Unix programs: very light, fast and each tools does just one thing, but does it well. &lt;a href="http://gmt.soest.hawaii.edu/gmt/gmt_examples.html"&gt;Here&lt;/a&gt; there are some examples of the kind of things that you can get with these tools. Maybe the bigger problem with GMT is the complexity when using it, the thousand of options and its dark syntax. In this blog I'll try to post some tips &amp;amp; tricks I have found out up to now... I still learn new things every day.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The general way of plotting a map with GMT is to use several tools sequentially. Each tool adds a new detail in the final result. For example, the coastlines are added with &lt;b&gt;pscoast&lt;/b&gt;, shadings are added with &lt;b&gt;grdimage&lt;/b&gt;, some symbols are included later with &lt;b&gt;psxy&lt;/b&gt; and so on. When a command is called, the output of GMT is &lt;a href="http://en.wikipedia.org/wiki/EPS"&gt;EPS&lt;/a&gt; code through the standard output of the terminal. Thus, you have to redirect the output after each call to GMT to the same EPF file (which is, by the way, an ASCII file). As you can understand, in order to work sucessfully with GMT, &lt;b&gt;bash scripting is mandatory.&lt;/b&gt; Otherwise, you will become mad after just 10 minutes using it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The syntax is nevertheless quite complex. In the next posts I'll explain some details about it. Anyway, the best place to learn about GMT is, as could be expected in a Unix program, the man pages. Just as a general comment, the syntax is something like:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;command -Flag1Options -Flag2Options &gt; file.eps&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;where &lt;i&gt;command&lt;/i&gt; is one of the many GMT tools. &lt;i&gt;Flag1&lt;/i&gt; and &lt;i&gt;Flag2&lt;/i&gt; can be -D, -O, -B,... there are tens of flags which deppend on the exact tool. Finally, &lt;i&gt;Options&lt;/i&gt; are the many options you can use for each flag. &lt;b&gt;It's important to note that there is no space between the flag and the option&lt;/b&gt;. For example you have to use -Aa0tf10 instead of -A a0 t f10. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well, I know, it's very complicated. I'll put some examples in the next posts...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-8912461298281532945?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/8912461298281532945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=8912461298281532945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8912461298281532945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8912461298281532945'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/gmt-very-brief-introduction.html' title='GMT: a very brief introduction'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-2464888552321662770</id><published>2009-10-07T14:01:00.003+02:00</published><updated>2009-10-07T14:18:17.159+02:00</updated><title type='text'>La Ciencia en España no necesita tijeras</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://farm3.static.flickr.com/2488/3973473121_e76fde787c_o.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 567px; height: 567px;" src="http://farm3.static.flickr.com/2488/3973473121_e76fde787c_o.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Ésta es mi modestia aportación a la iniciativa "La Ciencia en España no necesita tijeras" propuesta por &lt;a href="http://aldea-irreductible.blogspot.com/2009/10/la-ciencia-en-espana-no-necesita.html"&gt;La aldea irreductible&lt;/a&gt;.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;Mi argumento será del tipo del que les interesan a los políticos: ECONÓMICO. Vamos a ver, ¿de qué cojones sirve que el estado se gaste un montón de dinero en formar a doctorandos, si luego no hay un proyecto científico serio en España para dar plaza a esta gente? ¿Qué pasa si recortan el presupuesto para nuevos proyectos? que cuando termine el doctorado (y como yo otros cuantos miles de estudiantes de doctorado) me quedan dos opciones:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- me voy al extranjero a seguir con mi carrera científica, en cuyo caso el estado se ha gastado mucho dinero en formarme para mandarme a que se beneficio otro país de mi formación&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- me voy a la paro. En este caso, de todas formas tendré que seguir cobrando del estado, con la diferencia de que ahora me tocaré los cojones. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;En cualquier caso, la Ciencia en España no necesita tijeras, sino una inversión continuada y a más largo plazo que el que marcan los putos 4 años electorales. La ciencia no se hace al ritmo que marcan los ciclos políticos ni económicos, e intentar forzar eso es estrangularla.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-2464888552321662770?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/2464888552321662770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=2464888552321662770' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/2464888552321662770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/2464888552321662770'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/la-ciencia-en-espana-no-necesita.html' title='La Ciencia en España no necesita tijeras'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-8342958110035311743</id><published>2009-10-05T19:37:00.005+02:00</published><updated>2009-10-05T22:42:54.811+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='multiplot'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><title type='text'>Plots inside other plots with Gnuplot</title><content type='html'>&lt;div&gt;This is another post when I'm going to try to explain how to use the multiplot environment. In this case, I'm going to use the multiplot environment, but setting the position of the plots "by hand" in order to get the effect of one plot inside other. This may be useful if you want to show some detail of a small part of the general plot. This is the final result:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_YJHQnk-6NJY/SsovEsnzmHI/AAAAAAAAAFs/tY1ZmWVuSjs/s1600-h/multiplot2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 280px;" src="http://2.bp.blogspot.com/_YJHQnk-6NJY/SsovEsnzmHI/AAAAAAAAAFs/tY1ZmWVuSjs/s400/multiplot2.png" alt="" id="BLOGGER_PHOTO_ID_5389171661846321266" border="0" /&gt;&lt;/a&gt;Well, the overall idea is the same than in &lt;a href="http://ontublog.blogspot.com/2009/10/array-of-plots-in-gnuplot.html"&gt;this other post&lt;/a&gt;, but in this case I won't use the automatic layout. In order to set the size and position of the plot manually, you have to use the parameters &lt;span style="font-weight: bold;"&gt;size&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;origin&lt;/span&gt;, respectively. You have to know that the &lt;span style="font-weight: bold;"&gt;units of these commands are the size of the whole figure&lt;/span&gt;, and first number refers to x axis. Then for example, &lt;span style="font-weight: bold;"&gt;set size 1,1&lt;/span&gt; means use the whole figure as the size of the plot. Analogously, &lt;span style="font-weight: bold;"&gt;set origin 0.5,0.5&lt;/span&gt; sets the bottom left corner of the plot in the centre of the figure.&lt;br /&gt;&lt;br /&gt;Other example: if you want to insert two plots, one over the other, you could &lt;span style="font-weight: bold;"&gt;set size 1,0.5&lt;/span&gt; in order to reduce the vertical size to half the total, and then use &lt;span style="font-weight: bold;"&gt;set origin 0,0.5&lt;/span&gt; before plotting the second graph.&lt;br /&gt;&lt;br /&gt;This is the code to generate the figure above. I have plotted also a rectangle and an arrow. You can skip that, it's not really important, but I just wanted to show some more capabilities of Gnuplot.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;gnuplot &lt;&lt; TOEND&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set terminal postscript eps color enhanced&lt;/div&gt;&lt;div&gt;set output 'multiplot2.eps'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#set ytics 0.25&lt;/div&gt;&lt;div&gt;#set format y "%.2f"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set multiplot&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;# Bigger plot options&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set yrange [-4:5]&lt;/div&gt;&lt;div&gt;set size 1,1 &lt;/div&gt;&lt;div&gt;set origin 0,0&lt;/div&gt;&lt;div&gt;set title 'Whole plot'&lt;/div&gt;&lt;div&gt;set xlabel 'time/s'&lt;/div&gt;&lt;div&gt;set ylabel 'variable/m'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;### This is to plot the square. You can skip this ###&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set arrow from 1.1,-0.9 to 1.0,0.3 lw 1 back filled&lt;/div&gt;&lt;div&gt;set arrow from 0.9,-3 to 1.5,-3 lw 1 front nohead &lt;/div&gt;&lt;div&gt;set arrow from 0.9,-1 to 1.5,-1 lw 1 front nohead&lt;/div&gt;&lt;div&gt;set arrow from 0.9,-1 to 0.9,-3 lw 1 front nohead&lt;/div&gt;&lt;div&gt;set arrow from 1.5,-1 to 1.5,-3 lw 1 front nohead&lt;br /&gt;&lt;/div&gt;&lt;div&gt;###################################&lt;br /&gt;&lt;br /&gt;# This plots the big plot&lt;br /&gt;&lt;/div&gt;&lt;div&gt;plot 'datos.dat' w l lt 1 lc 3 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;# Now we set the options for the smaller plot&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set size 0.6,0.4 &lt;/div&gt;&lt;div&gt;set origin 0.2,0.5&lt;/div&gt;&lt;div&gt;set title 'Zoom'&lt;/div&gt;&lt;div&gt;set xrange [0.9:1.5]&lt;/div&gt;&lt;div&gt;set yrange [-3:-1]&lt;/div&gt;&lt;div&gt;set xlabel ""&lt;/div&gt;&lt;div&gt;set ylabel ""&lt;/div&gt;&lt;div&gt;unset arrow&lt;/div&gt;&lt;div&gt;set grid&lt;br /&gt;&lt;br /&gt;# And finally let's plot the same set of data, but in the smaller plot&lt;br /&gt;&lt;/div&gt;&lt;div&gt;plot 'datos.dat' w l lt 1 lc 3 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# It's important to close the multiplot environment!!!&lt;br /&gt;unset multiplot&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;TOEND&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-8342958110035311743?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/8342958110035311743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=8342958110035311743' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8342958110035311743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/8342958110035311743'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/plots-inside-other-plots-with-gnuplot.html' title='Plots inside other plots with Gnuplot'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_YJHQnk-6NJY/SsovEsnzmHI/AAAAAAAAAFs/tY1ZmWVuSjs/s72-c/multiplot2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-3724216872786862551</id><published>2009-10-05T19:24:00.005+02:00</published><updated>2009-10-05T22:20:31.521+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='multiplot'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><title type='text'>Array of plots in Gnuplot</title><content type='html'>&lt;div&gt;In this post I will explain how to create an array of plots. This may be useful for example if you need to merge several plots in the same figure in a paper. Within this post, by &lt;span style="font-style: italic;"&gt;figure&lt;/span&gt; I will mean a file which in general may contain several independent plots. The aim of this post is to explain how to get the next figure:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_YJHQnk-6NJY/SsosIW_k7qI/AAAAAAAAAFk/tCQWyBtzIT8/s1600-h/multiplot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 280px;" src="http://2.bp.blogspot.com/_YJHQnk-6NJY/SsosIW_k7qI/AAAAAAAAAFk/tCQWyBtzIT8/s400/multiplot.png" alt="" id="BLOGGER_PHOTO_ID_5389168426225036962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For this purpose, gnuplot has the multiplot environment. To use it, you just have to type &lt;span style="font-weight: bold;"&gt;multiplot&lt;/span&gt; once you are already in gnuplot. From that moment on, each time you type the command &lt;b&gt;plot&lt;/b&gt;, you will get a new plot added to the same figure. You have to take into account that every new plot is independent of the former ones. This means that you can (or you have to) reset again all parameters you want to change for the next plot. If you don't reset them, they will remain as in the previous call to &lt;span style="font-weight: bold;"&gt;plot&lt;/span&gt; command. For example, if you set xlabel to "variable x", all plots will have in common this label for their x axis. Of course you can change this by just typing sex xlabel "whatever" &lt;span style="font-weight: bold;"&gt;always before to use the next plot command&lt;/span&gt;. For this reason, it's a good idea to set all common parameters to every plots in the figure before initiating the multiplot environment.&lt;br /&gt;&lt;br /&gt;I think the next example is quite self-explanatory, so just one thing has to be remarked. In the multiplot environment you can use an automatic layout for the plots or a manual one. If you want to create a regular array of plots, it makes more sense to use the first option. In the next post I will put an example of how to use the manual approach for a more complex result.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;gnuplot &lt;&lt; TOEND&lt;br /&gt;&lt;div&gt;&lt;div&gt;set terminal postscript eps color enhanced&lt;/div&gt;&lt;div&gt;set output 'multiplot.eps'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# Some common options&lt;/div&gt;&lt;div&gt;set xrange [-pi:pi]&lt;/div&gt;&lt;div&gt;set mxtics 2&lt;/div&gt;&lt;div&gt;set ytics 0.25&lt;/div&gt;&lt;div&gt;set xtics ("-{/Symbol p}" -pi, "-{/Symbol p}/2" -pi/2, "0" 0,"{/Symbol p}/2" pi/&lt;/div&gt;&lt;div&gt;2, "{/Symbol p}" pi)&lt;/div&gt;&lt;div&gt;set format y "%.2f"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set grid&lt;br /&gt;&lt;br /&gt;# This begins the multiplot environment. This example uses a 2x2 regular layout&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set multiplot layout 2,2 title 'Using layout 2x2&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;# Now, every time I use the plot command, I will get a new plot&lt;br /&gt;# in the correct position acording to the selected layout&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set title 'Plot 1'&lt;/div&gt;&lt;div&gt;plot sin(1*x) w l lt 1 lc 1 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set title 'Plot 2'&lt;/div&gt;&lt;div&gt;plot sin(2*x) w l lt 1 lc 2 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set title 'Plot 3'&lt;/div&gt;&lt;div&gt;plot sin(3*x) w l lt 1 lc 3 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set title 'Plot 4'&lt;/div&gt;&lt;div&gt;plot sin(4*x) w l lt 1 lc 4 lw 3 t ''&lt;/div&gt;&lt;div&gt;&lt;br /&gt;# It is important to close the multiplot environment before leave!!!&lt;br /&gt;&lt;/div&gt;&lt;div&gt;unset multiplot&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;TOEND&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-3724216872786862551?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/3724216872786862551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=3724216872786862551' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3724216872786862551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3724216872786862551'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/10/array-of-plots-in-gnuplot.html' title='Array of plots in Gnuplot'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_YJHQnk-6NJY/SsosIW_k7qI/AAAAAAAAAFk/tCQWyBtzIT8/s72-c/multiplot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-4443576763236568240</id><published>2009-09-22T22:39:00.010+02:00</published><updated>2009-09-23T09:54:27.530+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='colors'/><category scheme='http://www.blogger.com/atom/ns#' term='axis'/><title type='text'>Complex axis in Gnuplot</title><content type='html'>&lt;div style="text-align: left;"&gt;This post is to show the great flexibility of gnuplot regarding axis format. I'm going to explain some commands to get the next graph:&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_YJHQnk-6NJY/Srk2-R2pdbI/AAAAAAAAAFc/duyF0qvWQ8g/s1600-h/borders.png"&gt;&lt;img src="http://2.bp.blogspot.com/_YJHQnk-6NJY/Srk2-R2pdbI/AAAAAAAAAFc/duyF0qvWQ8g/s400/borders.png" alt="" id="BLOGGER_PHOTO_ID_5384395273070540210" style="cursor: pointer; width: 400px; height: 280px;" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;Yeah, I know, may be it's the most ugly and pointless plot ever. Nevertheless, it's a complex one, and it's not easy to get. That's the point ;-)&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First of all, it's important to note that every plot has 4 different and independent axis called &lt;span style="font-weight: bold;"&gt;x&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;y&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;x2&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;y2&lt;/span&gt;, respectively for bottom, left, top and right. Furthermore, each axis if the combination of three elements: the border (a straight line), the tics (short lines perpendicular to the border) and the tic labels (normally a number seting a value for the tic). The idea is that you can change every one of these elements separately.&lt;br /&gt;&lt;br /&gt;Let's begin with the border. The border of the graph is just a square containing the plot. You can set or unset separately each one of the 4 borders, so it's easy to understand that you have 2x2x2x2=16 possibilities. To select what borders you want, gnuplot uses something like binary numaration. Each border has associated a power of two: 1, 2, 4 and 8 for bottom, left, top and right, respectively, like in the figure. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;img src="http://4.bp.blogspot.com/_YJHQnk-6NJY/Srk24JwAJYI/AAAAAAAAAFU/DKIjE65gF50/s400/gnuplot_borders.png" alt="" id="BLOGGER_PHOTO_ID_5384395167815968130" style="cursor: pointer; width: 300px; height: 233px;" border="0" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So for example if you want to set only the top border, you have to type:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;set border 4&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Other examples: if you want to set top and bottom borders, you have to sum both numbers, 4+1=5 and type set border 5. For the same reason, 0 sets no border, and 15 sets the four borders. Easy, isn't?&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we are ready to go to tics. Tics and borders may be set or unset independently. So for example if you unset the top border, the &lt;span style="font-weight: bold;"&gt;y2&lt;/span&gt; tics will still remain, so you can get unexpected results. To unset a tic set, you have to use the &lt;span style="font-weight: bold;"&gt;unset&lt;/span&gt; command, like for example&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;unset xtics&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;The same for &lt;span style="font-weight: bold;"&gt;ytics&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;x2tics&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;y2tics&lt;/span&gt;. By default, the 4 sets of tics are enabled.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Once you know in which axis you want to have tics, it's the moment to set how many you want. There are several ways of setting tics, and of course you can set the number of tics in each axis separately.&lt;br /&gt;&lt;br /&gt;You can specify only the  spacing between them, leaving the initial and final one to be set automatically by gnuplot by typing&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;set xtics 20&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;On the other hand, you  can also specify the initial, final and the spacing by:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;set  xtics 20,1,30&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Finally you can set the tics  "by hand" following this syntax&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;set xtics ("one"  1, "two" 2, "3" 3, "{/Symbol p}" pi)&lt;/blockquote&gt;Where the string between quotes is the tic label to be  set, and the number is the position of the label in the axis. This last options is really useful if you are dealing with a really complex and custimized plot.&lt;br /&gt;&lt;br /&gt;A last note about tics and borders is that they all share the same line style. You can specify it like any other line options, like for example&lt;br /&gt;&lt;blockquote&gt;set border 12 ls 2 lw 3 lc 3&lt;/blockquote&gt;&lt;/div&gt;This command will unset bottom and left boders. The rest will be, as well as the tics, dashed blue lines, 3 pixels width.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;Let's now focus in the format of the tic labels. One important point to have into account is that if you want to unset only the labels, but keeping the tics, you can do it by changing the axis format to  empty:&lt;div&gt;&lt;blockquote&gt;set format x ""&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;And  of course analogously for the others 3 axis. By default &lt;span style="font-weight: bold;"&gt;x2&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;y2&lt;/span&gt; axis  have this format. Regarding the formatting, you may set how numbers are displayed  following C conventions, like for example&lt;div&gt;&lt;blockquote&gt;set  x2tics "%02g"&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;and so on. There are plenty of places in internet where this convention is explained.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Other interesting options are &lt;span style="font-weight: bold;"&gt;offset&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;rotate&lt;/span&gt;. With these options you can shift the label of the tics and to rotate them, which is not an easy effect to get in other programs. A example of these is shown in the final example.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, you can also change the color of the labels of the tics using the &lt;span style="font-weight: bold;"&gt;textcolor&lt;/span&gt; option, like&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;set x2tics textcolor lt 2&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Well, I know, I have explained a lot of options, and not very much in detail. But rebember that all these options, and much more, are explained in the gnuplot interactive help. The idea of this post was to demonstrate to those who think gnuplot is lame that they are wrong.&lt;br /&gt;&lt;br /&gt;Now I'll sumarize some of these concepts with the code to get of the initial example. &lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;gnuplot &lt;&lt; TOEND&lt;br /&gt;&lt;div&gt;# Setting the output file&lt;/div&gt;&lt;div&gt;set terminal postscript eps color enhanced "Helvetica" 20&lt;/div&gt;&lt;div&gt;set output 'borders.eps'&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# Setting the top an right border (4+8=12).&lt;br /&gt;#We change also the color and line style&lt;/div&gt;&lt;div&gt;set border 12 ls 2 lw 3 lc 3&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# Setting the margins (distance between borders&lt;br /&gt;#of the graph and the borders of the image)&lt;/div&gt;&lt;div&gt;set tmargin 5&lt;/div&gt;&lt;div&gt;set bmargin 5&lt;/div&gt;&lt;div&gt;set lmargin 5&lt;/div&gt;&lt;div&gt;set rmargin 15&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# Setting the xtics &lt;/div&gt;&lt;div&gt;unset xtics&lt;/div&gt;&lt;div&gt;set x2tics ("-{/Symbol p}"-pi, -1, 0, "one" 1, 2, "three" 3, 4, 5, 6) textcolor &lt;/div&gt;&lt;div&gt;lt 2&lt;/div&gt;&lt;div&gt;set x2label "x2 axis"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# Setting the ytics&lt;/div&gt;&lt;div&gt;unset ytics&lt;/div&gt;&lt;div&gt;set y2tics -1,.2,1 textcolor lt -1 offset 2 rotate by 30&lt;/div&gt;&lt;div&gt;set format y2 "%.2f"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# The rest is just for a boring normal plot&lt;/div&gt;&lt;div&gt;set xrange [-5:5]&lt;/div&gt;&lt;div&gt;set yrange [-1:1]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set title "Pointless but rather complex graph"&lt;/div&gt;&lt;div&gt;plot sin(x) w l lt 1 lc rgb "#FF00FF" lw 6 t ''&lt;/div&gt;&lt;div&gt;TOEND&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;convert -density 100 borders.eps borders.png&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-4443576763236568240?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/4443576763236568240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=4443576763236568240' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4443576763236568240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4443576763236568240'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/complex-axis-in-gnuplot.html' title='Complex axis in Gnuplot'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_YJHQnk-6NJY/Srk2-R2pdbI/AAAAAAAAAFc/duyF0qvWQ8g/s72-c/borders.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-4211677711595448644</id><published>2009-09-20T00:21:00.004+02:00</published><updated>2009-09-20T00:44:09.404+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='awk'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><title type='text'>Uper to lowecase and vice versa</title><content type='html'>I'm going to tell three ways of doing the same task: changing the &lt;a href="http://en.wikipedia.org/wiki/Capitalization"&gt;capitalization&lt;/a&gt;. This is a pretty comon task, and there are many ways of doing it.&lt;br /&gt;&lt;br /&gt;The first way is to use my favourite text editor: &lt;a href="http://www.vim.org/"&gt;Vim&lt;/a&gt;. The idea is to open the file to be modified. Then, select the whole content of the file and push &lt;b&gt;u&lt;/b&gt; to change it to lowercase. Analogously push &lt;b&gt;U&lt;/b&gt; to change it to upercase. To select the whole file, you just have to type &lt;b&gt;ggVG&lt;/b&gt;. The explanation is as follows: the first &lt;b&gt;gg&lt;/b&gt; is to go to the begining of the file, &lt;b&gt;V&lt;/b&gt; is for changing to select lines mode, and &lt;b&gt;G&lt;/b&gt; to go to the end of the file.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This last way is useful (and fast) if you have to change the content of just one file. It is nevertheless less useful if you have to change many files. In these cases, is better to use &lt;b&gt;awk&lt;/b&gt; or &lt;b&gt;sed.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;To use awk (my favourite option) you only have to use the function &lt;b&gt;tolower&lt;/b&gt;, like in this example:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;echo TEXT TO BE CHANGED TO LOWECASE | awk '{print tolower($0)}'&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and similary the function &lt;b&gt;toupper&lt;/b&gt; changes the string to upercase.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This task may also be achieved with &lt;b&gt;sed&lt;/b&gt;. To do it, the command line should be now&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;blockquote&gt;echo text to capitals | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' &lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well, this is all for today. It looks like the sed way is less elegant. The fact is that I'm pretty sure there must be a better way, althought I don't know it yet ;-).&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-4211677711595448644?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/4211677711595448644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=4211677711595448644' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4211677711595448644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4211677711595448644'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/uper-to-lowecase-and-vic-eversa.html' title='Uper to lowecase and vice versa'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-4049157215230973404</id><published>2009-09-19T21:09:00.006+02:00</published><updated>2009-09-20T10:59:18.491+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Imagemagick'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><title type='text'>Simple animations with Imagemagick</title><content type='html'>&lt;a href="http://www.imagemagick.org/"&gt;Imagemagick&lt;/a&gt; allows to generate simple animations (this is, a &lt;a href="http://es.wikipedia.org/wiki/Graphics_Interchange_Formatgif/"&gt;gif&lt;/a&gt; file) by using several input images as frames in a movie. Here I'm going to show the main idea, which it's actually very simple.&lt;br /&gt;&lt;br /&gt;In order to have several images to be mounted in the movie, I have used a bash script together with &lt;a href="http://www.gnuplot.info/"&gt;gnuplot&lt;/a&gt;. This will generate 20 slightly different images of a sinusoidal fuction, little bit shifted between them. This is the code:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;N=20&lt;br /&gt;&lt;br /&gt;# Note the -w option in seq&lt;br /&gt;for i in $(seq -w 1 $N); do&lt;br /&gt;gnuplot &lt;&lt; TOEND&lt;br /&gt;# Setting the output&lt;br /&gt;set terminal postscript eps color "Helvetica" 20&lt;br /&gt;set output 'sin$i.eps'&lt;br /&gt;&lt;br /&gt;# This removes the numbers in the graph and sets the grid&lt;br /&gt;set format x ""&lt;br /&gt;set format y ""&lt;br /&gt;set grid&lt;br /&gt;&lt;br /&gt;# The plot itself&lt;br /&gt;plot sin(x+2*pi/$N*$i) w l lt 1 lc 3 lw 4 t ''&lt;br /&gt;&lt;br /&gt;TOEND&lt;br /&gt;&lt;br /&gt;# Now transform the postscript file into a png one, and remove the eps&lt;br /&gt;convert -density 50 -layers flatten sin$i.eps sin$i.png&lt;br /&gt;rm sin$i.eps&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It's important to note the &lt;span style="font-style: italic;"&gt;"-w"&lt;/span&gt; option in the &lt;span style="font-weight: bold;"&gt;seq&lt;/span&gt; command. This will generate numbers with the correct padding. This is, it will generate the list "01 02 ... 09 10 11 ..." instead of "1 2 ... 9 10 11 ..." which may be a problem when you want to list the resulting files in the correct order to create the movie.&lt;br /&gt;&lt;br /&gt;So now we have 20 png files. To merge them, the &lt;span style="font-weight: bold;"&gt;convert&lt;/span&gt; command may be invoked with just an option to set the delay (in miliseconds) between images.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;convert -delay 10 sin*png animation.gif&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;That's all, it's pretty easi, isn't?&lt;br /&gt;&lt;br /&gt;Ant this is the result:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_YJHQnk-6NJY/SrUu6x2ZBjI/AAAAAAAAAEg/DHNFmgt6rm8/s1600-h/animation.gif"&gt;&lt;img style="cursor: pointer; width: 250px; height: 175px;" src="http://4.bp.blogspot.com/_YJHQnk-6NJY/SrUu6x2ZBjI/AAAAAAAAAEg/DHNFmgt6rm8/s400/animation.gif" alt="" id="BLOGGER_PHOTO_ID_5383260516940056114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;EDIT: By some unknown reason, gif animations doesn't seem to work when I upload them to Picasa. Well, you have to trust me, it evolves with time, and it's even pretty funny ;-).&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;ACTUALIZATION: Using other (my own) web server, I have been abled to upload a real gif animation. With minor changes in the script, this is what I get:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://ciclon.inf.um.es/cosas/animation.gif"&gt;&lt;img src="http://ciclon.inf.um.es/cosas/animation.gif" border="0" alt="" style="cursor: pointer; width: 250px; height: 175px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-4049157215230973404?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/4049157215230973404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=4049157215230973404' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4049157215230973404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/4049157215230973404'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/simple-animations-with-imagemagick.html' title='Simple animations with Imagemagick'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_YJHQnk-6NJY/SrUu6x2ZBjI/AAAAAAAAAEg/DHNFmgt6rm8/s72-c/animation.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-7219105114439847547</id><published>2009-09-12T09:52:00.005+02:00</published><updated>2009-09-12T10:14:34.003+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='plotting'/><title type='text'>Greek letters in gnuplot</title><content type='html'>&lt;a href="http://www.gnuplot.info/"&gt;Gnuplot&lt;/a&gt; is a powerful scientific plotting program. In fact is more powerful than people usually think first time time they use it. May be this is because it has no &lt;a href="http://en.wikipedia.org/wiki/Graphical_user_interface"&gt;GUI&lt;/a&gt;. Instead of that, you have to type commands in a plain &lt;i&gt;boring&lt;/i&gt; terminal.&lt;br /&gt;&lt;br /&gt;Well, in this post I'm going to put an example of how to perform a relatively complex graph, using greek letters and legend. Of course, everything I use here is explained perfectly in the help.&lt;br /&gt;&lt;br /&gt;Gnuplot has several output formats (called terminals). Depending on what you are going to do later with the output you get from the program, you can use one or another (from &lt;a href="http://en.wikipedia.org/wiki/Raster_graphics"&gt;raster&lt;/a&gt; formats like png of jpeg, up to  &lt;a href="http://en.wikipedia.org/wiki/Vector_graphics"&gt;vectorial&lt;/a&gt; ones such as eps or svg). In general I advice to use the terminal &lt;b&gt;postscript&lt;/b&gt;, and later on to export the file to a raster format like png using a images manipulation program like &lt;a href="http://www.imagemagick.org/"&gt;Imagemagick&lt;/a&gt;. I also advice to use the options: &lt;b&gt;eps&lt;/b&gt; (to get encapsulated postscript code), &lt;b&gt;color&lt;/b&gt; (to have colors enabled) and &lt;b&gt;enhanced&lt;/b&gt; (to be able to use advanced postscript options such as greek letters). &lt;div&gt;&lt;div&gt;&lt;br /&gt;To get a greek letter, you have to use the &lt;span style="font-weight: bold;"&gt;postscript&lt;/span&gt; terminal, with the option &lt;span style="font-weight: bold;"&gt;enhanced&lt;/span&gt;. Then, to add the alpha greek letter, you have to type &lt;span style="font-weight: bold; font-style: italic;"&gt;{/Symbol a}&lt;/span&gt;. Analogously for other letters, changing the "a" by other, like "D" for Delta and so on...&lt;br /&gt;&lt;br /&gt;Finally, the thing I like most about Gnuplot is that it's easily scriptable. Here there is a simple script which shows all these ideas in practice (comments are added to make code more readable):&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;gnuplot &lt;&lt; TOEND&lt;br /&gt;# Setting the terminal postscript with the options&lt;br /&gt;set terminal postscript eps color enhanced "Helvetica" 20&lt;br /&gt;&lt;br /&gt;# Setting the output file name&lt;br /&gt;set output 'plot.eps'&lt;br /&gt;&lt;br /&gt;#Setting up the grid and labels&lt;br /&gt;set grid&lt;br /&gt;set title "A simple graphic without LaTeX"&lt;br /&gt;set xrange [-pi:pi]&lt;br /&gt;set xlabel "Angle {/Symbol a}"&lt;br /&gt;set ylabel "{/Symbol Dw}"&lt;br /&gt;set ytics 0.5&lt;br /&gt;set xtics ("{/Symbol p}" -pi, "{/Symbol p}/2" -pi/2, "0" 0, "{/Symbol p}/2" pi/2, "{/Symbol p}" pi)&lt;br /&gt;&lt;br /&gt;# Setting the legend&lt;br /&gt;set key horizontal below height 2&lt;br /&gt;set key box lt 2 lc -1 lw 3&lt;br /&gt;&lt;br /&gt;# The plot itself  (\ is to broke lines)&lt;br /&gt;set size 1,1&lt;br /&gt;plot sin(x)**2 w l lt 1 lc 1 lw 3 t "sin^2({/Symbol a})", \&lt;br /&gt;sin(2*x)/x w l lt 2 lc 3 lw 3 t "sin(2{/Symbol a})/{/Symbol a}", \&lt;br /&gt;sin(x) w l lt 3 lc 2 lw 3 t "sin{/Symbol a})"&lt;br /&gt;TOEND&lt;br /&gt;&lt;br /&gt;convert -density 150 plot.eps plot.png&lt;br /&gt;rm plot.eps&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And this is the result (click to enlarge). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YJHQnk-6NJY/SqtH8km_yjI/AAAAAAAAADU/O0vKjQhotA0/s1600-h/plot.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 224px;" src="http://3.bp.blogspot.com/_YJHQnk-6NJY/SqtH8km_yjI/AAAAAAAAADU/O0vKjQhotA0/s320/plot.png" alt="" id="BLOGGER_PHOTO_ID_5380473285769153074" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well, is not bad, but it's not still wonderful. In a future post I will explain how to use the terminal &lt;span style="font-weight: bold;"&gt;epslatex&lt;/span&gt; to get impressive book-quality results ;-). &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-7219105114439847547?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/7219105114439847547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=7219105114439847547' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7219105114439847547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7219105114439847547'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/greek-letters-in-gnuplot.html' title='Greek letters in gnuplot'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqtH8km_yjI/AAAAAAAAADU/O0vKjQhotA0/s72-c/plot.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-7309219096526954388</id><published>2009-09-08T17:45:00.012+02:00</published><updated>2009-09-10T10:38:00.496+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='botch'/><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><title type='text'>My own (botch) version of LaTeX in blogger</title><content type='html'>There are, as far as I know, at least &lt;a href="http://wolverinex02.googlepages.com/emoticonsforblogger2"&gt;two&lt;/a&gt; &lt;a href="http://yourequations.com/"&gt;different&lt;/a&gt; ways of using &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YJHQnk-6NJY/Sqi3y2QRctI/AAAAAAAAADM/hSL8NuTHvwQ/s1600-h/latex.png"&gt;&lt;img style="cursor: pointer; width: 73px; height: 27px;" src="http://3.bp.blogspot.com/_YJHQnk-6NJY/Sqi3y2QRctI/AAAAAAAAADM/hSL8NuTHvwQ/s320/latex.png" alt="" id="BLOGGER_PHOTO_ID_5379751839079166674" border="0" /&gt;&lt;/a&gt;within blogger. In both cases the idea is the same, and it's similar as in some forums or in the &lt;a href="http://www.amsn-project.net/plugins.php#3"&gt;TeXIM&lt;/a&gt; plugin for &lt;a href="http://www.amsn-project.net/"&gt;AMSN&lt;/a&gt;:&lt;span style="font-style: italic;"&gt; somewhere there is a third part server which uses a LaTeX distribution to generate a dvi file, together with some other tools to convert this file into an image, which can be included in the html code of y&lt;/span&gt;&lt;span style="font-style: italic;"&gt;our blog&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Well, the problem with such solutions is that they &lt;i&gt;parasite&lt;/i&gt; a server developed for this purpose, but this server has few (or not at all) options. In particular, the image you get is only useful with light backgrounds, so you lose freedom for choosing the design of your blog. Just to put an example, this is what I get:&lt;br /&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\int_{0}^{1}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx&lt;br /&gt;=\frac{22}{7}-\pi&lt;/pre&gt;&lt;br /&gt;Lame.&lt;br /&gt;&lt;br /&gt;I have to say, first of all, that I have not found the perfect solution to this problem. Instead of that, my aproach consists in adding the image by hand, using Picasa. Yeah, I know, I know,... it isn't very satisfactory, but if you don't need thousands of equations, it could be good enought. Again, just for example, this is my result:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_YJHQnk-6NJY/Sqiz3RedxVI/AAAAAAAAADE/S3_x61Hvq7I/s1600-h/maxwell.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 290px; height: 217px;" src="http://1.bp.blogspot.com/_YJHQnk-6NJY/Sqiz3RedxVI/AAAAAAAAADE/S3_x61Hvq7I/s320/maxwell.png" alt="" id="BLOGGER_PHOTO_ID_5379747517059417426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Is not bad, isn't it? But the main problem remains unsolved: &lt;span style="font-weight: bold;"&gt;how to get the image with the equatio&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;n&lt;/span&gt;. Well, here is my solution, a bash script:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;COLOR="0.8,0.8,0.8"&lt;br /&gt;DENSITY=150&lt;br /&gt;&lt;br /&gt;cat &gt; equation.tex &lt;&lt; PART1&lt;br /&gt;\documentclass[12pt]{article}&lt;br /&gt;\usepackage{amsfonts}&lt;br /&gt;\usepackage[usenames]{color}&lt;br /&gt;\definecolor{my_color}{rgb}{$COLOR}&lt;br /&gt;&lt;br /&gt;\begin{document}&lt;br /&gt;\pagestyle{empty}&lt;br /&gt;%\pagecolor{black}&lt;br /&gt;{\color{my_color}&lt;br /&gt;&lt;br /&gt;\begin{eqnarray}&lt;br /&gt;PART1&lt;br /&gt;&lt;br /&gt;cat equation.asc &gt;&gt; equation.tex&lt;br /&gt;&lt;br /&gt;cat &gt;&gt; equation.tex &lt;&lt; PART2&lt;br /&gt;\end{eqnarray}&lt;br /&gt;}&lt;br /&gt;\end{document}&lt;br /&gt;PART2&lt;br /&gt;&lt;br /&gt;latex equation.tex&lt;br /&gt;dvips -f -E -o equation.ps equation.dvi&lt;br /&gt;convert -density $DENSITY equation.ps equation.png&lt;br /&gt;&lt;br /&gt;rm equation.log equation.aux equation.tex equation.dvi equation.ps&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The idea is pretty simple. To use it, you have to type your formula in the file &lt;span style="font-style: italic;"&gt;equation.asc&lt;/span&gt;, in standard latex (rebembering that you are inside a eqnarray environment). Then, by running the script in your computer you get a png file with the equation, which you can upload by hand. The good thing of this aproach is that you can choose the colour of the equation playing around the variable COLOR (setting the colour you want in &lt;a href="http://en.wikipedia.org/wiki/RGB_color_model"&gt;rbg&lt;/a&gt;), as well as with the size of the image changing DENSITY.&lt;br /&gt;&lt;br /&gt;A last thing is that in order to run successfully the script, a &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_YJHQnk-6NJY/Sqi3y2QRctI/AAAAAAAAADM/hSL8NuTHvwQ/s1600-h/latex.png"&gt;&lt;img style="cursor: pointer; width: 73px; height: 27px;" src="http://3.bp.blogspot.com/_YJHQnk-6NJY/Sqi3y2QRctI/AAAAAAAAADM/hSL8NuTHvwQ/s320/latex.png" alt="" id="BLOGGER_PHOTO_ID_5379751839079166674" border="0" /&gt;&lt;/a&gt; distribution and &lt;a href="http://www.imagemagick.org/"&gt;Imagemagick&lt;/a&gt; have to be installed and working in the system you want to run the script.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-7309219096526954388?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/7309219096526954388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=7309219096526954388' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7309219096526954388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7309219096526954388'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/trying-out-latex.html' title='My own (botch) version of LaTeX in blogger'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_YJHQnk-6NJY/Sqi3y2QRctI/AAAAAAAAADM/hSL8NuTHvwQ/s72-c/latex.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-7692409456474292216</id><published>2009-09-07T15:33:00.011+02:00</published><updated>2009-09-09T09:43:55.462+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='unix tools'/><category scheme='http://www.blogger.com/atom/ns#' term='bash script'/><title type='text'>cat and tac</title><content type='html'>Unix-like system are based on a very simple &lt;a href="http://en.wikipedia.org/wiki/Unix_philosophy#Mike_Gancarz:_The_UNIX_Philosophy"&gt;set of ideas&lt;/a&gt;, one of them is: &lt;span style="font-style: italic;"&gt;every program has to solve just one task, and do it right&lt;/span&gt;. Well, this is exactly what does one of the most common tools in Linux: &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Many people use &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt; just for getting the output from an &lt;a href="http://en.wikipedia.org/wiki/Ascii"&gt;ascii&lt;/a&gt; file, in commands like &lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;cat file.asc&lt;/span&gt;&lt;/blockquote&gt;Well, open a file, decode the ascii format and print out a human-readable version in screen is a great thing, but it is not the only thing &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt; can do.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt; may be used to concatenate files, independently of their format. For example&lt;br /&gt;&lt;blockquote&gt;$  &lt;span&gt;cat file1.asc file2.asc &gt; files1-2.asc&lt;/span&gt;&lt;/blockquote&gt;joins both files in another ascii format file.&lt;br /&gt;&lt;br /&gt;Not only ascii files, but it also work with binary ones, for example with metheorological EXTRA format&lt;br /&gt;&lt;blockquote&gt;$  &lt;span&gt;cat file1.ext file2.ext &gt; files1-2.ext&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;But the most powerful feature of &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt; is that it is a text editor. To use it, you have to type:&lt;br /&gt;&lt;blockquote&gt;$ &lt;span&gt;cat &gt; file.txt &lt;&lt; &lt;/span&gt;&lt;eof&gt;&lt;span&gt;EDIT&lt;br /&gt;some text&lt;/span&gt;&lt;br /&gt;&lt;span&gt;you want to add&lt;/span&gt;&lt;br /&gt;&lt;span&gt;into your file&lt;/span&gt;&lt;br /&gt;EDIT&lt;br /&gt;&lt;/eof&gt;&lt;/blockquote&gt;which means something like "take the input of the keyboard and insert it in&lt;span style="font-style: italic;"&gt; file.txt&lt;/span&gt;. Wait until I type again EDIT, which will mean I want you to stop listening".&lt;br /&gt;&lt;br /&gt;This feature is extremely useful for scripting purposes, as you can make scripts which create other scripts and so on. May be I will put some example of this in a (I hope) near future.&lt;br /&gt;&lt;br /&gt;Finally, there exists another command, which I found out few time ago, &lt;span style="font-weight: bold;"&gt;tac&lt;/span&gt;. This programs do exactly the same as &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt;, but from bottom to up. This is, &lt;span style="font-weight: bold;"&gt;tac&lt;/span&gt; may be used for printing a file reversing the order of rows. It may be very useful when you know that the interesting part is at the end of a file.&lt;br /&gt;&lt;br /&gt;BTW. Many people use the command:&lt;br /&gt;&lt;blockquote&gt;$ &lt;span&gt;cat file.txt | grep something&lt;/span&gt;&lt;/blockquote&gt;trying to look for "something" in the file. There is no point to do that. &lt;span style="font-weight: bold;"&gt;grep&lt;/span&gt; is another tool which does not need at all &lt;span style="font-weight: bold;"&gt;cat&lt;/span&gt; to work. The correct form would be:&lt;br /&gt;&lt;blockquote&gt;$  &lt;span&gt;grep something file.txt&lt;/span&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-7692409456474292216?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/7692409456474292216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=7692409456474292216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7692409456474292216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/7692409456474292216'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/cat-and-tac.html' title='cat and tac'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5529669963650093738.post-3525173057902121650</id><published>2009-09-07T14:26:00.005+02:00</published><updated>2009-10-21T12:16:38.396+02:00</updated><title type='text'>A new project: justification</title><content type='html'>Two years ago I started this blog. Well, actually I began it and later  on I forgot it because I thought I had nothing interesting to say. Now  the situation has not changed too much, but I have had a brand new  idea*: I could convert this in something like a list of technical  recipes about Unix commands and related issues, like computing, advanced   scientific plotting and so on.&lt;br /&gt;&lt;br /&gt;The thing is that sometimes I need to know how to do a technical task,  like filtering some lines within an &lt;a href="http://en.wikipedia.org/wiki/ASCII"&gt;&lt;span style="background: none repeat scroll 0% 0%;" class="goog-spellcheck-word"&gt;ascii&lt;/span&gt;&lt;/a&gt; file,  or plot complex graphs  with &lt;a href="http://www.gnuplot.info/"&gt;&lt;span style="background: none repeat scroll 0% 0%;" class="goog-spellcheck-word"&gt;gnuplot&lt;/span&gt;&lt;/a&gt;, or I get an unknown error  when compiling &lt;span style="background: none repeat scroll 0% 0%;" class="goog-spellcheck-word"&gt;fortran&lt;/span&gt;  programs,... in these cases I spend up to a whole day looking for in  Internet how to solve the problem. From now on, every time I solve a  problem, I will publish the solution here, so it may be helpful for  something else, as well as for myself in future (I'm very chaotic).&lt;br /&gt;&lt;br /&gt;  One thing I should explain is why I write so poorly. And the answer is  simple: I don't know English enough. You could ask me &lt;span style="font-style: italic;"&gt;then why do you write in English?&lt;/span&gt;  Well, I want to  learn, and keep practising is a great opportunity to improve my grammar  and increase my vocabulary. That's the only reason.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;* I had the idea when I saw this &lt;a href="http://elmanantialdebits.blogspot.com/"&gt;great blog&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5529669963650093738-3525173057902121650?l=ontublog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ontublog.blogspot.com/feeds/3525173057902121650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5529669963650093738&amp;postID=3525173057902121650' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3525173057902121650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5529669963650093738/posts/default/3525173057902121650'/><link rel='alternate' type='text/html' href='http://ontublog.blogspot.com/2009/09/new-project-justification.html' title='A new project: justification'/><author><name>Ontureño</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_YJHQnk-6NJY/SqTjtFtsqGI/AAAAAAAAAAM/_m5TfPs8fNw/S220/avatar.png'/></author><thr:total>1</thr:total></entry></feed>
