Showing posts with label ArsTechnica. Show all posts
Showing posts with label ArsTechnica. Show all posts

Wednesday, May 16, 2012

Latex with Adobe Illustrator

I have been a linux user for a long time but last year I bought a laptop with a digitizer screen and the lack of good results in linux made me switch to Win 7. In the last year, I have learned that a lot of GPL software is ported to Windows and the switch is not painful at all. Problem is that the last update in one of my favorite page editing software: Inkscape has made my figure editing work flow (I never thought I would use this word) stall a little. So, I decided to give Adobe Illustrator a try as CS education is not so expensive. 

Basically, I need to add latex formulas to Illustrator, there's a nice script to do so here. I encountered a minor problem with this script; it seems like page frame is no longer the last element in the pdf compiled by pdflatex. Thus, the formulas generated by the script and imported into Illustrator were lacking the first element and had a full A4page frame. 

The script file is efficiently commented and a quick look into it brought me to Line 66:
for( var i=grp.pageItems[0].pageItems.length-1; --i>=0; )
After a few iterations, I found that the page frame is now the first page item and so the final modified line is:
for( var i=grp.pageItems[0].pageItems.length; --i>=1; )
This fixed my problem and now I have complete latex formulas in Illustrator with just the minimal frame around the object.

I hope this solves your issues too.

Wednesday, February 22, 2012

Latex in Inkscape 0.48

Last time I installed my favorite GPL drawing tool Inkscape, I had to install old version 0.46 instead of new 0.48 because the latex app was not working in the new one. Well, today, being the stupid me with the memory span of a goldfish, I wondered why I had the old and not the new version of Inkscape and, finding no reason for being such a backward computer user in my 5 second memory span, proceeded to update it. You can imagine the result, I was unable to edit latex on any of my figures.

I found this blog with a solution to the problem of latex in Inkscape 0.48, actually it is a very simple solution, and everything is working fine now. The blog is called La Consigna, it is very helpful as it has a lot of technical solutions to issues that a matlab, latex user may find in his daily use/abuse. 

Tuesday, January 3, 2012

I, the DSLR Dummy: Panoramas with Hugin

I have been trying my patience with panoramas in the last months. I have been using a nice GPL stitching software called Hugin that basically does everything by itself. It is trivial to install Hugin in any computer as there are compiled versions for unix, windows and mac. 

In the most basic mode, you select a series of overlapping pictures and let Hugin do its magic. Of course, it is a matter of taking the right pictures or calamity strikes as you can see from one of the first panoramas that I stitched:

Clarke Quay from Brewerkz, Singapore 2011.
These are some six photographs taken from an un-leveled tripod without minding the distance between the  first objects and the camera. I am a lucky guy and the result is not an eye sore but it was sheer luck that the distorted perspective came out somehow right. 

The nice thing about Hugin is that, once you level the tripod for the axis of the camera to coincide with the tripod's axis of rotation and take care for the subject to be far from the lens, it is trivial to get a nice cylindrical  projection panorama:

Harbour Front from Mt. Fabor, Singapore 2011. 
These are some eight photographs taken from a leveled and aligned tripod. Again, it was sheer luck that I got such a nice effect with the sunset at the right.  

But not everything is oats with honey, once you shoot without some stabilization or a scene that has moving parts, such as cars in a city, things get a little bit messy; for example, this one is a composition of ten pictures taken from a standing position without tripod:

Zurich Sea from Grossmunster, Zurich 2011.
I was afraid that my epileptic pulse will screw things up so I took some twenty three shoots; only ten were useful in the composition of this panorama. Even worse, Hugin didn't manage to recognize overlaps and treated the pics as independent. The good thing is that once this happens, Hugin takes you to the control point window automatically, there you can manually input control points on contiguous photographs. It seems like the best approach is to identify two sets of parallel lines, one pair of vertical and one of horizontal lines, in each pair of overlapping pics. It sounds like a hard task, but the fine tune button helps a lot in identifying the right points and it only took me around half an hour to set three hundred control points for the panorama above. I want to think that the result is not that bad after cropping it a little.

In short, for those doing this just for the sake of keeping a memory and having a hobby, or running on a tight budget like me, Hugin is a great option for stitching panoramas. It has a great automatic recognition of control points that does the work for you most of the time—so far I only had to do manual selection of control points in one out of seven panoramas—, a good selection of projection algorithms—I have only played with cylindrical projections so far— and it is for free; if you like and use it, don't forget to make a donation to the Hugin project!

I hope you enjoy your stitching as much as I do. Here are some of the panoramas I have stitched so far. 


Sunday, September 25, 2011

Getting a high quality eps from your data

In all these years plotting data, I have tried many methods. The one I am most satisfied with is gnuplot. This free program can generate anything one has ever dream of from data. In the past, I used to have basic scripts for my favourite types of graphs; problem is, I'm not that patient any more. Still, I'm not ready to pay the big bucks needed to buy a fancy point and click plotting software and, above all, I'm not interested in illegal software.

This is my situation I usually generate my final data from FORTRAN. Usually, universities and research centres provide Matlab or Mathematica licences for us. I have tried doing figures with Matlab, but I found it quite primitive and, typically, I ended up investing as much time as it took to modify one of my old gnuplot scripts. So, I started using Mathematica to load my data from text files and generate my figures.

Important things to have in mind:
  • A typical one column figure has a size of 3 3/8 inches; say Phys. Rev., J. Opt. Soc. Am. or J. Phys. journals.
  • Typical figure sizes are one, one and a half, and two columns.
  • Usually, journals ask for high resolution graphics, say 300, 600 or 1200dpi.
Things to remember when preparing figures in Mathematica:
  • Standard image resolution value is 72dpi. One can set this to any value by using the command ImageResolution -> 300, for example.
  • If you are saving in svg file format resolution doesn't matter at all but for determining the size of the image. 
  • Always set your image size according to the resolution you are using, ImageSize->{(3+3/8)*300, Automatic}, for example.
Now, the simplest way to produce a figure is just exporting your figure to eps with the command Export["FigureName.eps", PlotName, ImageResolution->300]. Sometimes this is the best and fastest way to produce an eps. Always keep your fonts around the 12pt size. Do not mind how the image looks in the notebook, always check the final eps to see the figure in its real scale.

For those times when the result is crappy, I would export the figure to svg with the command Export["FigureName.svg", PlotName], for example. Then, I would modify the axis labels, legends, and other text in the figure with Inkscape. Inkscape is free, light, and easy to use and can save your graphics to eps format; it can also generate pure latex or eps+latex output. In the case that the text in the figure is formulas, I would use psfrag to replace dummy strings inserted with Inkscape.

Warning: As of today, if  you use psfrag, download Inkscape v0.46 and do not forget to de-select the convert text to path option in the dialogue for save as eps. The point behind using Inkscape v0.46 is that this is the last version that doesn't use Cairo to convert to eps and still writes text as text in the eps.

Edit: Janus told me today about a plugin for Inkscape that renders latex input into a graphic layer, it is called textext. Thing is, it works almost immediatly with Inkscape v0.46 and delivers wonderful results but I haven't been able to make it work with v0.49 so far. Nevertheless, good bye psfrag!

Friday, July 1, 2011

How to show/hide text in a webpage

Today, I was trying to flex a little bit my weak html/php/javascript muscle; I thought about upgrading my publication list with a show/hide link of citations to my work. As always, whenever I don't have a clue, Google came to the rescue! I found a quite helpful discussion at webdeveloper.com that takes advantage of the css style called display.

As you can see, the script in its simpler form takes two instructions. One is the declaration of a division containing the text that you want to hide/show, this division is declared with the display:block style:

<div id="new_div" style="display: block;">Here goes the text you want to hide/show</div>

The second part of the combo is a javascript that changes the display:block style to display:none:
<a href="#" onclick= "document.getElementById('new_div').style.display =(document.getElementById('new_div').style.display == 'block')?'none':'block';">Click to show/hide the div called "new_div"</a>
Tip Hat: David Harrison's post.

If you follow the webdeveloper.com discussion you will find a way to declare the script at the head section and shortens the command to be put at the a href tag. Also, you will find a post on how to make the divisions invisible at first load.

You can see my publication list for the final result, just click on any of the Cited by links at some of the papers. You can also view the source of my webpage or drop me a comment in case of you need a little bit more help.

Monday, June 20, 2011

Joomla! on Win 7

So, I got the Lenovo x220t and I'm using Win 7 because there's nothing in Linux that compares to MS Office One Note 2010; also, the Linux drivers and the software processing for the tablet input are not nice yet.

Well, Lyx wants to start playing with webpages so I installed Joomla! on the lenovo to start learning how to use it. The hat tip for all the steps and checks goes to my good old friend Orthus who coached me through the installation process. 

The first step towards getting a functional Joomla! in your Win 7 is to install Apache, mySQL and PHP. The good news is that there's a nice installer that solves all troubles: XAMPP.

  1. Go to Apache Friends and get the stable release of XAMPP.
  2. Right click on the file and choose: install as administrator.
  3. Follow the instructions and choose the directory of installation, typically c:\xampp
  4. Go to c:\xampp\php\ double click on the file named: php.ini, the notebook should open.  
  5. Search for the line containing: error_reporting
  6. Check that it says: error_reporting = E_ALL & ~E_NOTICE
  7. Save and close.
  8. Create a folder named: c:\xampp\mywebpage  you will need it.
  9. Go to Joomla! and get the latest stable release.
  10. Double click in the downloaded zip file and extract the contect to: c:\xampp\mywebpage\
Ready. You have all the packages installed. It's time to configure everything!
  1. Go to Start: Apache Friends: XAMPP (Sometimes an error message appear, do not mind it)
  2. Start the MySQL and the PHP services.
  3. Open your browser and type http://localhost/phpmyadmin/
  4. Fill the data for a new database, newdatabase, and create it.
  5. Open a new tab in your browser and type http://localhost/mywebpage/
  6. Follow the installing instructions for Joomla!
  7. When it asks you for the name of the webpage and database put the names you used for mywebpage and newdatabase, for the user name use admin and leave the password blank unless you set a password on step 4.
  8. If you want, choose to install some filler data. Finish the installation.
  9. Open the File Manager, go to c:\xampp\mywebpage\ and delete the folder named installation.
  10. Open a new tab and type: http://localhost/mywebpage/  you should see the Joomla!: Welcome to the Frontpage.
Now, you can start thinkering with Joomla's templates.

Friday, June 10, 2011

Win 7 for Linux users

I just got my new laptop ---I broke the screen of the old one by falling while walking with it on my hands. As it is a tablet (Lenovo x220t), I'm keeping Windows 7 due to the beautiful MS Office One Note. Now, I haven't used Windows in more than 10 years, so I thought that there might be someone there in a similar situation that could benefit from my current experience. 

Really important things to do once you get your fresh Windows 7 install, 
  1. Be paranoid! The first thing to install is an antivirus. Go to Microsoft Security Essentials, download and run it. Follow the instructions.
  2. Be hip! Go to Start (The Windows icon in the bottom-left corner), search for Windows Update, click on it and relax while your system gets updated. You may have to restart once and run it again.
  3. Be prepared! Go to Start, search for Backup and Restore, click on it  and follow the instructions to create a backup of your fresh install.
Hereby, it is all about what you need. I'm going to start with all those things that most people use and need everyday---for free!
  1. Summon the Intertubes! Go to Google Chrome webpage, download the installer and run it. Follow the instructions.
  2. Secure the Intertubes! If you are a little bit paranoid, like yours truly, you may want to set Google Chrome to use Secure Socket Layer (SSL)---nowadays most of use do internet banking. Click on the wrench at the right of the address bar, select options, under the bonnet, verify that the SSL options are checked on.
  3. Say Cheese! Lets keep on with Google. Go to Google Picasa webpage, download the installer and run it. Follow the instructions. You can even import your online folders to your fresh system.
  4. And do something funny! Pictures are usually not enough, so lets install a very nice media player that usually has no problems at all with codecs. Go to Videolan webpage, download VLC and run it. Follow the instructions, and you will have THE media player. 
  5. Do not close your eyes! Nowadays, everything is Flash. Go to Adobe Flash Player webpage. Download the installer and run it. Follow the instructions.
  6. Just feel the vibe! There's a very nice audio player, that usually has no problems with codecs. Go to Foobar webpage, do not get confused with all the adds asking for a click to download something that is not the latest version of foobar, download the installer and run it. Follow the instructions.
  7. Get your coffee cup ready! Java is sometimes needed for those fancy webpages with proprietary controllers. Go to Java webpage, download the installer and run it. Follow the instructions and don't forget to verify your version at the end.
  8. And prepare to work! Now, here it is about your choosing of buying a MS Office license for some $150 USD or go to Open Office webpage. Download the installer and run it. Follow the instructions and you will have a free functional productivity suite that can do most of what MS Office does.
Now, my line of work requires some fidgeting with figures and a special formatting system called Latex. What follows are those programs related to my work.
  1. MiKTeX is a very complete distribution of latex for windows. Go to MiKTeX webpage, look for the latest release, as of today v2.9. I recommend you downloading the Basic MiKTeX 32 bit Installer as I got troubles with the 64 bit version---the on-the-fly installer of styles and classes never worked.
  2. TexMaker is a free and very solid latex editor. It may not win a beauty pageant but it gets the work done. You can download the latest version at TexMaker webpage,  run it and follow the instructions.
  3. The Gimp is a free image manipulation program that competes with Photoshop---actually, in my standard, The Gimp wins as it is for free. There's a working Windows installer here or you can get the source files at The Gimp homepage. Whatever you choose, just follow the instructions.
  4. Inkscape is a scalable vector graphics editor; you may be interested in this if you use Illustrator often. Go to Inkscape webpage, download the windows installer and you know the drill.
  5. PythoniPythonwxPython, NumPy, SciPy, Matplotlib, and Python Toolkit are a great combination for producing quick numerical routines for your everyday physics problems. Just follow the links in the order presented here and make sure that you choose the adequate version of each one. iPython is a nice IDE for quick scripts and running proper scripts. Python Toolkit looks and feels like Matlab a few years ago, which is very good for a free product.
And I think that is it for now. I hope you find this helpful.

Update 12/25/2011:

Lately, I found myself using more and more the following free software:
  1. Magic ISO is an almost free ISO burner and mounter, for some reason Windows 7 didn't come with a mount app and this is a nice supplement to the file manager. In order to mount ISO files it will ask you to install Magic Disc, it is just a matter of following the instructions and, then, mounting a ISO file is just a right click away.
  2. Adobe Digital Editions is the free library manager and DMR enforcer from Adobe. It allows you to download the epubs associated to those acm files you get whenever you buy an ebook. It has a nice interface and it basically works with almost any epub ereader. 
  3. Raw Therapee is a free RAW image file developer, it has very useful basic preset and a nice batch processing utility. I have developed all of my latest photos with this software and I'm very happy with the result. 

Monday, November 8, 2010

Tunning your Latex in a Linux box

Whenever I install Latex, in particular the texmf installation that comes with Ubuntu, I always end up missing some style, class and bibliography files. In order to fix this, I always do the following:

  1. Copy the files' directories that I'm missing to /usr/share/texmf/tex/latex/ for styles (*.sty) and classes (*.cls); and to /usr/sare/texmf/bibtex/bst/ for bibliographic styles (*.bbt, *.bst)
  2. Make sure the directories are accessible for all users: chmod 755 -r /usr/share/texmf/tex/latex/ /usr/sare/texmf/bibtex/bst/
  3. Reload texmf with: sudo texhash
This always works for me whenever I do a fresh install and have to install the proprietary classes and styles from OSA, IOP and APS.

Revtex 4.1 needs particular attention in Ubuntu, as the natbib package in the current distro is the old natbib. In order to make available the new natbib I do the following:

  1. Download natbib.ins and natbib.dtx and all the .bst files from http://tug.ctan.org/tex-archive/macros/latex/contrib/natbib/
  2. Compile the instaler: latex natbib.ins
  3. Copy the result to a natbib folder in /usr/share/texmf/tex/latex/ for styles (*.sty) and /usr/sare/texmf/bibtex/bst/ for bibliographic styles (*.bbt, *.bst)
  4. Make sure the directories are accessible for all users.
  5. Reload texmf with: sudo texhash

Now, everything should be ready to use the nice features of natbib in Revtex4-1 like \cite{SomeCite, *SomeOtherCite} in order to put SomeCite and SomeOtherCite in the same reference number without having to do it by hand.

I hope you find this helpful.

Monday, March 22, 2010

Keeping processes running after logging out from a remote server

Sometimes, the workstation at my desk is not enough for running a simulation and simultaneous on-line procrastination; enter the workstation or the cluster of our theoretical optics group.

While a cluster usually has a queue manager, a workstation usually lacks this software. In our case, both cluster and workstation lack a queue manager. Now, a queue manager usually keeps a process running in the remote server no matter what your logged status is. How to do the same without a queue manager? The answer is simple: nohup.

For simplicity's sake, I'm using an SSH connection to a linux machine if I want to leave a process running at the server and then log out I use the command:


nohup command_to_run &

Note that the ampersand symbol has to be issued in order to send the process to the background.

Say, for example, I want to leave the compiled binary file for a fortran program running in the remote server even if I log out:


nohup ./BinFile &


Or a matlab m-file script, please remind yourself to always add an exit command at the end of your script or you will end up with many matlab iddle processes running in the background:


nohup matlab -r MatlabScript.m -nodesktop -nojvm -nosplash &


Or a mathematica m-file function, again remind yourself to add an Exit[] command at the end of your script or you will end up with an iddle mathematica process running in the background:


nohup math -noprompt -run "<<MathematicaFunction.m" &

Usually, all the terminal messages from the processes are written to a file named: nohup.out