Tuesday, March 23, 2010

Useful Mac OS X tools for scientists/astronomers

Here are some of my preferred tools when doing science using Mac OS X. I previously had a PC laptop with Linux (Ubuntu) and Windows (Vista) and made a very smooth transition to Mac OS X. I found replacements for all the tools that I used before. Disclaimer: I am an astrophysicist, so the software listed here is biased in that respect.

You can find more resources in my delicious list of mac+astronomy links, including where to get IRAF for example.

TeX Live
LaTeX distribution

TeXshop
LaTeX editor (comes with TeX Live)

LaTeXit
Equation editor (comes with TeX Live)
Uses LaTeX for creating equations that can be exported as PDF, PNG. Equations can be dragged and dropped in other applications. Unfortunately the drag and drop does not work with OpenOffice.

TextWrangler
Useful for editing source code in different programming languages and codifications.

MacPorts
Package of command-line open source software (like Fink), which is an updated version of DarwinPorts. Need Python, gawk, wget, aspell? Use Macports. The functionality is quite similar to Debian's apt-get for installing software. port search [software] searches for available software. sudo port install [software] downloads, compiles and install new software and its dependencies for your architecture.

Quicksilver
Quick way of launching applications. Press Ctrl+Spacebar and type the first few letters of the application you want to launch.

Spotlight
The builtin Spotlight (Cmd+Spacebar) is very handy when searching for papers/documents scattered through your HD. Functionality similar to Google Desktop.

Dropbox
Quite handy way to sync files between home and work. It creates a dropbox folder in your home. Each file you drop there is automatically synced over the internet in all the computers where you installed dropbox. Join it via this link and you will get more space than usual (and I will get a little bonus).

iWork's Keynote: For talks
I had been using OpenOffice Impress for a long time to prepare talks, but gave up on it. Reasons:
  • Unstable when editing large presentations containing lots of slides/plots. Crashes commonly in linux/mac.
  • Talks do not maintain their structure when you open them in different platforms (e.g., creates the talk in linux, then opens in mac).
  • Gets slower as the size of the presentation increases. Especially slow in Mac.
For these reasons, I switched to Keynote. Note: the last version of OpenOffice Impress that I used to prepare my talks was 3.0.

Synkron
Sync files between folders locally.

KeePassX
Cross-platform password databases. Work with a master password.

Inkscape
Work with illustrations, edit PDF files. It's a "free version" of Adobe Illustrator. Allows you to edit the figures in a PDF paper, for example, and export them to a talk.

Wine
To run windows programs. You can install it using MacPorts.

Other suggestions

Picasa
I personally prefer Picasa over iPhoto, but that's of course a matter of taste.

Adium
IM client which supports tons of networks, including MSN, Google Talk, AIM etc. Mac's version of Pidgin.

VirtualBox
Virtualization software, i.e. you can use this to run Windows XP or Ubuntu in a separate windows.


Changelog:
  • Apr 21 2010: Added textwrangler to the list.

Monday, March 8, 2010

Select fits files based on header keyword

The task of selecting a list of fits files based on some header keyword value is much easier to do with the IRAF task hselect. Although this example is very useful for understanding how to use pyfits and the sys module for passing parameters via command line (like bash our Perl's @ARGV).
#!/usr/bin/python

import sys
import pyfits
import re

for file in sys.argv[1:]: #exclude the first element of sys.argv
hdulist = pyfits.open(file) #open fits
key = hdulist[1].header['OBJECT'] #reads a keyword from the fits header
if (re.search('standard',key)): #search the keyword value for some string
print file

To execute just run on the command line:

# python script.py file1 file2 ...

or

# chmod +x script.py
# ./script.py file1 file2 ...

All bash's wildcards (*, ?, etc) are accepted.

Wednesday, March 3, 2010

How to know how many slots of memory are used (or free)?

My last linux trouble was  to discover how many memory slots were free in my CPU without opening it.

The solution to this problem comes from Lamarque Souza: 
all you need is to run dmidecode | grep -A 8 'Memory' as root, or on ubuntu:


sudo dmidecode | grep -A 8 'Memory'

Note: For more information remove the -A 8 from the grep command.

If it works correctly you should get something like the below. What you can see is that there are 4 slots for memory, and 2 of them have memory installed ( look at: Memory Device).

Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 8 GB
    Error Information Handle: Not Provided
    Number Of Devices: 4

Handle 0x0015, DMI type 19, 15 bytes
Memory Array Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x000FFFFFFFF
    Range Size: 4 GB
    Physical Array Handle: 0x0014
    Partition Width: 0

Handle 0x0016, DMI type 17, 27 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 2048 MB
    Form Factor: DIMM
    Set: None
    Locator: J1MY
--
Memory Device
    Array Handle: 0x0014
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 2048 MB
    Form Factor: DIMM
    Set: None
    Locator: J2MY
--
Memory Device
    Array Handle: 0x0014
    Error Information Handle: Not Provided
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: J3MY
--
Memory Device
    Array Handle: 0x0014
    Error Information Handle: Not Provided
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: J4MY
 
Locations of visitors to this page