-->

Thursday, January 12, 2012

LaTeX: VIM + Skim

macvim-skim-install.sh is my install script for using MacVim.app with Skim.app.

The agpy wiki page has instructions that are probably more clear; I don't really like the colorscheme / layout of this blog.

You can use synctex to make an editor and viewer work together, but it is far from easy and far harder than it should be. Forward-search is pretty easy, but the latex-suite \ls only works intermittently and is not easily customizable.

I had to do the following:

For VIM->Skim.app (Skim.app is necessary for any of this to work), add these commands to .vimrc:
" Activate skim
map ,v :w<CR>:silent !/Applications/Skim.app/Contents/SharedSupport/displayline -r <C-r>=line('.')<CR> %<.pdf %<CR><CR>
map ,p :w<CR>:silent !pdflatex -synctex=1 --interaction=nonstopmode %:p <CR>:silent !/Applications/Skim.app/Contents/SharedSupport/displayline -r <C-r>=line('.')<CR> %<.pdf %<CR><CR>
map ,m :w<CR>:silent !make <CR>:silent !/Applications/Skim.app/Contents/SharedSupport/displayline -r <C-r>=line('.')<CR> %<.pdf %<CR><CR>
" Reactivate VIM
map ,r :w<CR>:silent !/Applications/Skim.app/Contents/SharedSupport/displayline -r <C-r>=line('.')<CR> %<.pdf %<CR>:silent !osascript -e "tell application \"MacVim\" to activate" <CR><CR>
map ,t :w<CR>:silent !pdflatex -synctex=1 --interaction=nonstopmode %:p <CR>:silent !/Applications/Skim.app/Contents/SharedSupport/displayline -r <C-r>=line('.')<CR> %<.pdf %<CR>:silent !osascript -e "tell application \"MacVim\" to activate" <CR><CR>


The ,m command will reload the file and put your cursor where the text is. ,t will return VIM to the front afterwards.


Going the other way (reverse-search / inverse-search) was MUCH more challenging. The code that does this is on agpy . Reproduced here for posterity (I hope to update the agpy version to deal with tabs). [A few hours later, I HAVE replaced the code. Below are the old applescript version, then the new, vim-based version



#!/bin/bash

file="$1"
line="$2"

[ "${file:0:1}" == "/" ] || file="${PWD}/$file"

# Use Applescript to activate VIM, find file, and load it
# the 'delay' command is needed to prevent command/control/shift from sticking when this
# is activated (e.g., from Skim, where the command is command-shift-click)
#
# key code 53 is "escape" to escape to command mode in VIM
exec osascript \
-e "delay 0.2" \
-e "tell application \"MacVim\" to activate" \
-e "tell application \"System Events\"" \
-e " tell process \"MacVim\"" \
-e " key code 53 "\
-e " keystroke \":set hidden\" & return " \
-e " keystroke \":if bufexists(bufname('$file'))\" & return " \
-e " keystroke \":exe \\\":buffer \\\" . bufnr(bufname('$file'))\" & return " \
-e " keystroke \":else \" & return " \
-e " keystroke \":echo \\\"Could not load file\\\" \" & return " \
-e " keystroke \":endif\" & return " \
-e " keystroke \":$line\" & return " \
-e " end tell" \
-e "end tell"


New code: download link
#!/bin/bash

# Install directions:
# Put this file somewhere in your path and make it executable
# To set up in Skim, go to Preferences:Sync
# Change Preset: to Custom
# Change Command: to macvim-load-line
# Change Arguments: to "%file" %line

file="$1"
line="$2"
debug="$3"

echo file: $file
echo line: $line
echo debug: $debug

for server in `mvim --serverlist`
do
foundfile=`mvim --servername $server --remote-expr "WhichTab('$file')"`
if [[ $foundfile > 0 ]]
then
mvim --servername $server --remote-expr "foreground()"
if [[ $debug ]] ; then echo mvim --servername $server --remote-send ":exec \"tabnext $foundfile\" "; fi
mvim --servername $server --remote-send ":exec \"tabnext $foundfile\" "
if [[ $debug ]] ; then echo mvim --servername $server --remote-send ":$line "; fi
mvim --servername $server --remote-send ":$line "
fi
done

Save that as an executable in your default path (e.g., /usr/local/bin/macvim-load-line) and open Skim.app, go to Preferences:Sync and make the command look like this:

You need to have mvim on your path. mvim comes with MacVim.app, but is NOT installed by default. Install it by doing something like:

cp /Users/adam/Downloads/MacVim-7_3-53/mvim /usr/local/bin/mvim

You'll also need to install WhichTab.vim in your ~/.vim/plugins/ directory. It's available here ( download link ). Here's the source:

function! WhichTab(filename)
" Try to determine whether file is open in any tab.
" Return number of tab it's open in
let buffername = bufname(a:filename)
if buffername == ""
return 0
endif
let buffernumber = bufnr(buffername)

" tabdo will loop through pages and leave you on the last one;
" this is to make sure we don't leave the current page
let currenttab = tabpagenr()
let tab_arr = []
tabdo let tab_arr += tabpagebuflist()

" return to current page
exec "tabnext ".currenttab

" Start checking tab numbers for matches
let i = 0
for tnum in tab_arr
let i += 1
echo "tnum: ".tnum." buff: ".buffernumber." i: ".i
if tnum == buffernumber
return i
endif
endfor

endfunction

function! WhichWindow(filename)
" Try to determine whether the file is open in any GVIM *window*
let serverlist = split(serverlist(),"\n")

"let currentserver = ????
for server in serverlist
let remotetabnum = remote_expr(server,
\"WhichTab('".a:filename."')")
if remotetabnum != 0
return server
endif
endfor

endfunction

Sunday, January 08, 2012

API documentation on agpy

I finally processed agpy through sphinx and made some nice html documentation.

http://agpy.googlecode.com/svn/trunk/doc/html/agpy.html

Wednesday, October 12, 2011

latex: producing a bibliography and paper independently

AG

If you want citations to work, but you don't want your bibliography to show up, try the following:

latex file.tex
bibtex file

comment out \biblography{} line

latex file.tex


If you latex again, it will screw up.

To make an independent bibliography, remove all text and replace all citep/citet/cite commands with \nocite{} in a different document. Remember to usepackage{natbib} etc. You may have to copy over the .bbl file.

Tuesday, August 16, 2011

mercurial merge

AG

My most hated behavior of mercurial:
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
remote: 1 changesets found
running hook post-pull: hg up
abort: crosses branches (merge branches or use --clean to discard changes)
warning: post-pull hook exited with status 255
$ hg merge
abort: outstanding uncommitted changes (use 'hg status' to list changes)
$ hg commit
nothing changed

Solution:
hg merge --force
Hopefully there are other solutions that I'll eventually add to this.

Thursday, August 11, 2011

Wednesday, July 13, 2011

my scipy install...

As far as I was able to reconstruct, my scipy install looked like this when it went well:

mkdir scipy-bin
cp ../scipy-svn/site.cfg .
export PATH=/Users/adam/repos/scipy.git/scipy-bin:$PATH
ln -s /usr/bin/g++-4.0 scipy-bin/g++-4.0
ln -s /usr/bin/g++-4.0 scipy-bin/c++
export CC=/usr/bin/gcc-4.0
ln -s /usr/bin/gcc-4.0 scipy-bin/
ln -s /usr/bin/gcc-4.0 scipy-bin/gcc
ln -s /usr/local/bin/gfortran-4.0 scipy-bin/gfortran-4.0
ln -s /usr/local/bin/gfortran-4.0 scipy-bin/gfortran
ln -s /usr/local/bin/g95 scipy-bin/g95
ln -s /usr/local/bin/i686-apple-darwin8-gfortran-4.2 scipy-bin/
python2.7 setup.py build
python2.7 setup.py install


However, site.cfg included pointers to AMD and UMFPACK that were installed via the incredibly complicated series of steps listed here: http://blog.hyperjeff.net/?p=160

AG

Tuesday, June 28, 2011

P Cygni

P Cygni is a neglected LBV. You search for Eta Carinae on google and get hundreds of epic images of the fella, but nothing of P Cyg! Not even my Fe II image, which is now reproduced here:

Sunday, June 26, 2011

finally got matplotlib to install...

the key is reading the readme, not just the make.osx file.

These commands Just Work:

make -f make.osx PYVERSION=2.6 PREFIX=/Users/adam/repos/mpl_dependencies/ fetch deps mpl_install_std
make -f make.osx PYVERSION=2.7 PREFIX=/Users/adam/repos/mpl_dependencies/ fetch deps mpl_install_std

while, e.g., this one:
make -f make.osx PYVERSION=2.6 PREFIX=/Users/adam/repos/mpl_dependencies/ fetch deps mpl_install
didn't. I guess because that one doesn't actually install anything.

Saturday, June 25, 2011

matplotlib 64 bit installs never work

a clue as to why:
functional ft2font.so:

$ otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so:
/usr/local/lib/libfreetype.6.dylib (compatibility version 10.0.0, current version 10.22.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/local/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)


nonfunctional ft2font.so:

$ otool -L /Users/adam/repos/yt/yt-i386/lib/python2.7/site-packages/matplotlib/ft2font.so
/Users/adam/repos/yt/yt-i386/lib/python2.7/site-packages/matplotlib/ft2font.so:
/Users/adam/repos/yt/yt-i386/lib/libfreetype.6.dylib (compatibility version 13.0.0, current version 13.2.0)
/Users/adam/repos/yt/yt-i386//lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/local/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)


The culprit is the difference between those two (maybe?):

$ file /usr/local/lib/libgcc_s.1.dylib
/usr/local/lib/libgcc_s.1.dylib: Mach-O universal binary with 4 architectures
/usr/local/lib/libgcc_s.1.dylib (for architecture i386): Mach-O dynamically linked shared library i386
/usr/local/lib/libgcc_s.1.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/lib/libgcc_s.1.dylib (for architecture ppc): Mach-O dynamically linked shared library ppc
/usr/local/lib/libgcc_s.1.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64
$ otool -L /usr/local/lib/libgcc_s.1.dylib
/usr/local/lib/libgcc_s.1.dylib:
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.9)

Thursday, June 23, 2011

Major mac problems

The errors are, in short:
  • Browser stops responding / starts returning "page not found"
    (indicating a failure of mDNSResponder)
  • killing mDNSResponder sometimes brings browser back, but more often
    leads to a partial system freeze (some windows don't respond, can't
    switch between windows except by clicking)
  • /var/log/system.log gets flooded with "too many files open" errors.
  • somewhere in here the Dock fails
  • killing Google Chrome and/or the Dock fails; the process never halts
    (even kill -9 + kill -s SIGCHLD)
  • usually one or two crash reports pop up, at least one of which is for
    crash_reporter
  • system.log stops getting flooded, but the browser and Dock never recover
The only message in system.log that gives me any hint about what might be happening is occasionally a freeze was resolved at the same time as this message: Jun 22 19:02:09 eta Quicksilver[93771]: Multiple Scans Attempted but it doesn't seem to change the situation if quicksilver is open or not. Google has nothing on this issue, either, except for the quicksilver source code, so evidently it has not caused problems for other people system.log was also being flooded with this message:
Jun 23 08:57:19 eta postfix/master[99954]: fatal: open /dev/null: Bad file descriptor
Jun 23 08:57:20 eta com.apple.launchd[1] (org.postfix.master[99954]): Exited with exit code: 1
Jun 23 08:57:20 eta com.apple.launchd[1] (org.postfix.master): Throttling respawn: Will start in 9 seconds
so I disabled my postman:
Jun 23 08:57:27 eta sudo[99955]: adam : TTY=ttys006 ; PWD=/Users/adam/proposals/alma ; USER=root ; COMMAND=/bin/launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist
These errors:
Jun 23 09:06:40 eta Dock[99877]: kCGErrorIllegalArgument: CGSSetWindowTransformAtPlacement: Singular matrix [nan 0.000 0.000 nan]
Jun 23 09:06:40 eta com.apple.Dock.agent[99877]: Thu Jun 23 09:06:40 eta.colorado.edu Dock[99877] : kCGErrorIllegalArgument: CGSSetWindowTransformAtPlacement: Singular matrix [nan 0.000 0.000 nan]
are correlated with opening Chrome windows and/or Chrome's crash_inspector
Jun 23 09:06:09 eta [0x0-0x69e69e].com.google.Chrome[99995]: [99995:24579:485131152128125:ERROR:shared_memory_posix.cc(164)] Creating shared memory in /var/folders/ni/ni+DtdqFGMeSMH13AvkNkU+++TI/-Tmp-/.com.google.chrome.sHcu6r failed: Too many open files in system
This is the problem that really gets me... I think it's crash_inspector's fault.

But there's definitely more going on here than just Chrome. Trying to change default browsers (by opening Safari and opening Preferences) led to a partial Dock crash (?!) in which I can alt-tab but can't see the Dock. Not clear at all what's going on.... argh.

Tuesday, June 21, 2011

Dying Dock

My dock keeps dying. Repeatedly. Over and over.

Only solution so far:

ps -vax | grep -E "Dock|PID"
kill -HUP PID
kill -s SIGCHLD PID


And similarly for problems with Chrome + /usr/sbin/mDNSResponder. They tend to go bad together.... no clues yet from the system logs. Ironically, the crash reporter seems to fail the most often...

Saturday, April 30, 2011

specanpy

AG

There are now 2 clones of PySpecKit:
sPecAnPy
Spectroscopic Toolkit (Astronomy)

Tuesday, March 29, 2011

Why can't numpy do duplicate index assignment

AG

I want to do drizzling with numpy. It should be trivial, but it's impossible (without a for loop, afaik) instead.


In [2]: a = array([1,1,2,2])

In [3]: b = arange(5)

In [4]: b[a] += 1

In [5]: b
Out[5]: array([0, 2, 3, 3, 4])

In [6]: # but b should really be:

In [7]: b[a] += 1

In [8]: b
Out[8]: array([0, 3, 4, 3, 4])

Friday, March 18, 2011

pyspeckit: an astronomical spectroscopic toolkit

Jordan and I have been working on our python-based spectroscopic analysis tool for a while now:
pyspeckit is a pretty awesome, now functional but incomplete (and incompletely documented) tool.

Wednesday, February 02, 2011

pstopng

Following this thread and my need to convert IDL .ps files to .pngs so that I can view them in Mac Preview without having to go through an (often failed) conversion process led to a few discoveries.

First, it is challenging to get ImageMagick's convert to make an opaque background for the .ps file without seriously degrading the resolution. This can be accomplished by passing both the -alpha Off and the -density 300 simultaneously. This is slow, though, and recommendations to speed it up using the -limit area 4096 -limit memory 4096 tags actually made it slower!

However, the thread pointed out that ghostscript can do the conversion directly:
gs -dBATCH -sDEVICE=png16m -r300 -dEPSCrop -dNOPAUSE -sOutputFile=XXX.png XXX.ps

-sDEVICE sets the output to png, -r300 tag sets the density to be 300 pixels/inch, -dEPSCrop is necessary to get the right sized image out (otherwise it defaults to a portrait 8.5x11), and -dBATCH prevents the gs command line from activating after the command is executed. I'm not sure if -dNOPAUSE is necessary, but apparently if you don't activate it you have to do something after every page is processed.

My code to do batch ps-to-png conversion is available at http://code.google.com/p/agpy/source/browse/trunk/agpy/pstopng.

Timing demonstrations (units are seconds, R is 'real' or clock time, 'U' is user time, and 'S' is system time):

/usr/local/bin/convert -density 300 -alpha Off deline_zero_10hz_timestreams_003.ps deline_zero_10hz_timestreams_003.png
TIMING: R: 3.126 U: 2.948 S: 0.084
/usr/local/bin/convert -limit area 4096 -limit memory 4096 -density 300 -alpha Off deline_zero_10hz_timestreams_003.ps deline_zero_10hz_timestreams_003.png
TIMING: R: 3.800 U: 2.970 S: 0.161
gs -dBATCH -sDEVICE=png16m -r300 -dEPSCrop -dNOPAUSE -sOutputFile=deline_zero_10hz_timestreams_003.png deline_zero_10hz_timestreams_003.ps
TIMING: R: 0.801 U: 0.781 S: 0.017

Monday, December 13, 2010

Converting GILDAS-CLASS data cubes (lmv files) to fits

As usual, CLASS documentation is nearly impossible to navigate. At the end of the CLASS "introduction" (gildas-intro.pdf) there is a subtle and obscure reference to the vector\fits command. The conversion is actually relatively straightforward:

vector\fits outfile.fits from infile.lmv



AG

Saturday, November 27, 2010

IDL syntax highlighting in VIM

I've edited my idlang.vim to auto-identify files that start with a semicolon.

Add Line 19:
syn match idlangStatement "^\s*;\s"

Line 61/2 (allow spaces before ;):
syn match idlangComment "\s*[\;].*$" contains=idlangTodo


AG

Monday, November 22, 2010

Mercurial - behave like SVN?

I'm trying to use hooks to make mercurial behave like svn when committing. I like the idea that I can commit changes to my cloned repo while I'm away from the internet, but I never want that behavior when I do have internet access. Therefore, I want to attempt to pull before updating and attempt to push after committing. Every time. I have been consistently very unhappy with the hg merge command.


[hooks]
precommit = hg pull; hg up
postcommit= hg push
post-pull = hg up


However, this doesn't work. precommit freezes with the error
waiting for lock on working directory of [dir] held by [procnum]

and pre-commit results in other errors:

running hook pre-commit: hg pull; hg up
pulling from [source]
searching for changes
no changes found
running hook post-pull: hg up
abort: outstanding uncommitted merges
warning: post-pull hook exited with status 255
abort: outstanding uncommitted merges
warning: pre-commit hook exited with status 255


AG

Wednesday, November 03, 2010

Repositories for observers

I should have posted these a while ago....
casaradio is a subversion repository for folks at The Center for Astrophysics and Space Astronomy at CU Boulder to post radio astronomy related codes. So far, emphasizes single dish (GBT, Arecibo), but will include EVLA, CARMA, and ALMA eventually.
aposoftware is a similar page, but is a mercurial repository and is meant to include instrument-specific software for the Apache Point Observatory 3.5m telescope. Right now includes a TUI script or two and the TSPEC and DIS IRAF-twodspec pipelines.

I'd be remiss to leave out the BGPS pipeline even though it's mentioned on the previous post.

Also, agpy is my personal code repository.

BGPS data paper published

Metalinking! The BGPS paper finally made it onto astro-ph today. It will be published in ApJS before the year's end.

Links to all of the published BGPS papers at the Bolocam Data Team website

And just because I want more linking, here they all are again:
The Bolocam Galactic Plane Survey I. Survey Description and Data Reduction arXiv
The Bolocam Galactic Plane Survey II. Catalog of the Image Data arXiv
The Bolocam Galactic Plane Survey III. Characterizing Physical Properties of Massive Star-Forming Regions in the Gemini OB1 Molecular Cloud arXiv
The Bolocam Galactic Plane Survey IV: λ = 1.1 and 0.35 mm Dust Continuum Emission in the Galactic Center Region

The same set of links is reproduced at the pipeline googlecode page.

Monday, August 16, 2010

Neat new things....

1. sptool is a quick way to compare standards to stellar spectra. Nice, I'd been looking for a tool like that.
2. GNU screen captions are useful especially when working in a screen-within-a-screen environment (who does that, really?)
3. finally got SPLAT to work... turns out I just hadn't reduced my damned data
4. kill -STOP and kill -CONT are really useful ways to pause programs that are sucking up resources if you want to resume them later. Haven't tried this on "real" code yet.

Friday, August 13, 2010

Filled step plots in matplotlib

It's not possible to do a simple filled step plot in matplotlib using default
commands. Workaround:


def steppify(arr,isX=False,interval=0):
"""
Converts an array to double-length for step plotting
"""
if isX and interval==0:
interval = abs(arr[1]-arr[0]) / 2.0
newarr = array(zip(arr-interval,arr+interval)).ravel()
return newarr

plot(xx,yy,linestyle='steps-mid',color='b',linewidth=1.5)
fill_between(steppify(xx[x1:x2],isX=True),
steppify(yy[x1:x2])*0,
steppify(yy[x1:x2]),
facecolor='b',alpha=0.2)

Wednesday, July 28, 2010

Histogram in Google Spreadsheet

It's not easy to make a histogram in google spreadsheets without replicating data. The "countif" function would be great, except it only allows very simple criteria. However, there's a workaround:
=count(Filter('Grades'!V2:V30,'Grades'!V2:V30>0.9))
=count(Filter('Grades'!V2:V30,'Grades'!V2:V30<0.9,'Grades'!V2:V30>0.8))

The Filter() function returns an array, which can be operated on like any other set of cells.

It's still not easy to make a nice-looking histogram, but the output of this process is at least usable.

Friday, July 09, 2010

IDL-to-Python

astrobetter started up an idl-to-python guide on their wiki.

Sunday, June 13, 2010

Ghostscript error?

I've been receiving the following error when attempting to compile (ps2pdf) my w5 outflows paper:

Error: /rangecheck in --get--
Operand stack:
pdfmark --dict:20/25(ro)(L)-- --nostringval-- 50
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1878 1 3 %oparray_pop 1877 1 3 %oparray_pop 1861 1 3 %oparray_pop 1755 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- %finish_show --nostringval-- --nostringval-- 8 6 1 --nostringval-- (pdf_text_enum_t) %op_show_continue --nostringval--
Dictionary stack:
--dict:1153/1684(ro)(G)-- --dict:0/20(G)-- --dict:71/200(L)-- --dict:125/300(L)-- --dict:44/200(L)-- --dict:138/224(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 267478928
GPL Ghostscript 8.71: Unrecoverable error, exit code 1

I get the same error with Ghostscript 8.64, but on my laptop, using the fink version, it works. Similarly, there are errors with the postscript, so I'm led to believe it's an error in latex:

$ latex --version
pdfTeX 3.1415926-1.40.10-2.2 (TeX Live 2009)
kpathsea version 5.0.0
Copyright 2009 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.2.39; using libpng 1.2.39
Compiled with zlib 1.2.3; using zlib 1.2.3
Compiled with xpdf version 3.02pl3

No idea what the cause is but it's time to start documenting steps and looking for a workaround. Compiling on the lappy isn't a good option.

Wednesday, May 26, 2010

EVLA information

It has been really hard to find EVLA information like beam size, largest angular scale, sensitivity, etc. on the VLA pages because all of the google searches point to old VLA information. The most useful and recent EVLA information on beam size and largest angular scale is here

Tuesday, May 25, 2010

usetex failure in latex documents

When I use matplotlib's internal tex (rcParams['text.useTex']=False), the postscript files generated cause errors that look like this when you try to ps2pdf them:


ps2pdf h2co_pilot.ps
Error: /rangecheck in --get--
Operand stack:
--dict:20/25(ro)(L)-- --nostringval-- 71
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop 1739 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- %finish_show --nostringval-- --nostringval-- 9 6 0 --nostringval-- (pdf_text_enum_t) %op_show_continue --nostringval--
Dictionary stack:
--dict:1147/1684(ro)(G)-- --dict:0/20(G)-- --dict:70/200(L)-- --dict:116/300(L)-- --dict:44/200(L)-- --dict:25/42(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 791626
GPL Ghostscript 8.64: Unrecoverable error, exit code 1
make: *** [h2co_pilot.pdf] Error 1


They will not open in MacOS's Preview.app either.

Solution: Make figures with rcParams['text.useTex'] = True

Saturday, May 01, 2010

RATRAN on Mac OS X

Mac OS X doesn't like the defaults built in to RATRAN. It died unhappily with errors like:

ld_classic: can't locate file for: -lcrt0.o
and
ld: warning: in /usr/local/lib//libcfitsio.a, file is not of required architecture


In order to get it to run, I had to do the following:
  1. Install CFITSIO with CFLAGS="-arch x86_64 -arch i386 -g -O2" to /usr/local/lib
  2. Edit the sky/Makefile OPT variable (line 23) to read:
    OPT = -I. -O2 -fno-automatic -arch x86_64
Also, you need to set up system variables:

export RATRAN=/path/to/Ratran
export RATRANRUN=/path/to/Ratran/run

Thursday, April 22, 2010

Gildas CLASS

It's absurdly difficult to find help on GILDAS Class, probably because you can't google "class" and most people probably don't label every piece of code with "GILDAS class".

Anyway, here are some scripts that I refer back to often:

file in August2009BGPS.dat
file out August2009fits.dat multiple
on error "file out August2009fits.dat"
say "READ IN FILES"
define character sourcelist*10[300]
accept sourcelist /column observed_sources.txt
on error "continue"
get 1001
set window -100 160
set mask -400 -100 160 400
set mode x -400 400
set align velocity
for i 1 to 161
say "Working on SOURCE "'i'
find /source 'sourcelist[i]' /telescope "CSO 4GHZ IF1" /offset 0 0 /quality 5
average
on error "@avplot2 'sourcelist[i]' 'i'; next"
base 3
line 0
min
plot
vis
write i
! on error "continue"
next


and


file in araya-2004.cls
find
define character filename*20
for i 1 to 20
say "Working on source "'i'
get next
let filename "araya-2004_"'i'".fits"
say "fits write "'filename'" /mode spectrum"
fits write 'filename' /mode spectrum
next

!file in araya-2002.cls
!find
!define character filename*20
!for i 1 to 42
! say "Working on source "'i'
! get i
! let filename "araya-2002_"'i'".fits"
! say "fits write "'filename'" /mode spectrum"
! fits write 'filename' /mode spectrum
!next

Thursday, April 15, 2010

Montage wrapper

(I'm going to try to gradually shift my blogging to this one...)

I wrote a bash wrapper for Tom Robitaille's montage wrapper to allow fits wildcards.


#!/bin/bash

origdir=`pwd`

#echo $# $*

if [ $# -gt 0 ]
then
for ii in $*
do
if [ ${ii%=*} == 'header' ]
then
/usr/local/bin/montage/mGetHdr ${ii#*=} mosaic.hdr
elif [ ${ii%=*} == 'outfile' ]
then
outfile=${ii#*=}
elif [ `echo $ii | grep =` ]
then
params="$params,${ii%=*}='${ii#*=}'"
elif [ `echo $ii | grep ".fits"` ]
then
files=( ${files[@]} $ii )
fi
done
fi
echo ${files[@]} ${#files}
if [ ${#files} -gt 0 ]
then
mkdir tmp
cp ${files[@]} tmp/
cp mosaic.hdr tmp/
cd tmp/
fi

if [ -f mosaic.hdr ]
then
echo "mosaic.hdr exists, continuing"

dir=`pwd`
echo python -c "import montage; montage.wrappers.mosaic('$dir','$dir/mosaic',header='$dir/mosaic.hdr'$params)"
python -c "import montage; montage.wrappers.mosaic('$dir','$dir/mosaic',header='$dir/mosaic.hdr'$params)"

cd $origdir
if [ -d tmp ]
then
if [ $outfile ]
then
mv tmp/mosaic/mosaic.fits $outfile
else
mv tmp/mosaic mosaic
fi
rm -r tmp
fi

else
echo "mosaic.hdr does not exist. Quitting."
cd $origdir
fi

Sunday, March 28, 2010

IRAF append/prepend/replace

IRAF has special syntax to append/replace, so you can do something like:
imarith *.fits - dark.fits ds_//*.fits
...though I can't remember right now how to do replacement etc.

Thursday, March 18, 2010

command line & escape key

Problem: in both the bash command line and ipython, if I hit escape twice, I can never again do history-search-backwards (i.e. when you type part of a command and type "up" and reverse-search through your command history). Any idea how to fix this?

Friday, March 05, 2010

Rebuilding python from scratch again

I got scipy working a week or two ago, but doing so killed matplotib's tkagg. So, I switched to the MacOSX backend, which worked ok until I realized that the interactive (connect) features of macosx failed miserably. This led me to try to get matplotlib working.... which broke with those awful "symbol not found" errors in ft2font.so and _path.so, which I've determined all have to do with linking to the wrong library files.

The most worrisome part of this process was discovering that a full Time Machine recovery of /usr and /Library/Frameworks and /Library/Python did *not* restore python - it stayed dead with IDENTICAL errors. So there are probably additional layers of hidden links.

The process below is based on hyperjeff's blog post but differs substantially based on Sam Skillman's recommendations and the very big issue I ran into that my /usr/local files appeared to be corrupted. After this install, my path no longer includes /usr/local/bin and /sw has been moved to /_sw... hopefully one of these days I'll be ballsy enough to delete it.

  1. Install python 2.6.4
    1. Needed a clean terminal with no flags set at all. Don't know why - all I had set were a bunch of -arch x86_64 flags.

      export LD_LIBRARY_PATH="/usr/local/lib:/usr/X11/lib"
      ./configure --enable-framework=/Library/Frameworks MACOSX_DEPLOYMENT_TARGET=10.6
      make -j 17
      sudo make install

    2. Reset PYTHONPATH to blank
    3. alias clearflags='export CFLAGS=""; export CCFLAGS=""; export CXXFLAGS=""; export LDFLAGS=""; export FFLAGS="";' to make sure

  2. Install FFTW

    cd ~/tmp
    curl -O http://www.fftw.org/fftw-3.2.2.tar.gz
    tar xf fftw-3.2.2.tar.gz
    cd fftw-3.2.2
    clearflags
    ./configure CC="gcc -arch x86_64" CXX="g++ -arch x86_64" CPP="gcc -E" CXXCPP="g++ -E"
    make -j 17
    sudo make install

  3. Install UMFPACK

    cd ~/tmp
    curl -O http://www.cise.ufl.edu/research/sparse/umfpack/current/UMFPACK.tar.gz
    curl -O http://www.cise.ufl.edu/research/sparse/UFconfig/current/UFconfig.tar.gz
    curl -O http://www.cise.ufl.edu/research/sparse/amd/current/AMD.tar.gz
    tar xf AMD.tar.gz
    tar xf UFconfig.tar.gz
    tar xf UMFPACK.tar.gz
    sed -ibck 's/F77 = f77/F77 = gfortran/' UFconfig/UFconfig.mk
    sed -ibck '299,303s/# //' UFconfig/UFconfig.mk
    cp UFconfig/UFconfig.h AMD/Include/
    cp UFconfig/UFconfig.h UMFPACK/Include/
    cd UMFPACK
    make -j 17
    make hb
    make clean

  4. Install numpy
    1. Set environment variables

      export MACOSX_DEPLOYMENT_TARGET=10.6
      export CFLAGS="-arch x86_64"
      export FFLAGS="-m64"
      export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch x86_64"
      export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/"
      echo "[amd]
      library_dirs = /Users/adam/tmp/AMD/Lib
      include_dirs = /Users/adam/tmp/AMD/Include
      amd_libs = amd

      [umfpack]
      library_dirs = /Users/adam/tmp/UMFPACK/Lib
      include_dirs = /Users/adam/tmp/UMFPACK/Include
      umfpack_libs = umfpack" > site.cfg

    2. Setup & Install

      python setup.py build --fcompiler=gnu95
      sudo python setup.py install

    3. Test: python -c "import numpy"

  5. Install scipy. The important thing is to use g++-4.2 because g++-4.5 doesn't accept the -arch flag. Also, get rid of /sw if it's on your computer at all.

    sudo mv /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpyX
    cd ~/repos/scipy-0.7.1
    python setup.py clean
    rm -rf build
    clearflags
    FFLAGS="-m64" CFLAGS="-arch x86_64 -I/usr/local/include/freetype2 -I/usr/X11/include -L/usr/X11/lib" LDFLAGS="-Wall -undefined dynamic_lookup -bundle -lpng -arch x86_64" CXX="/usr/bin/g++-4.2" CC="/usr/bin/gcc-4.2" python setup.py build
    python setup.py install

    Test the install:

    python -c "import scipy, scipy.fftpack, scipy.interpolate"

    1. Install matplotlib. MAKE SURE /usr/bin/texbin is in front of /usr/local/bin and /sw/bin so that dvipng comes from MacTEX. I also ended up having to remove /usr/local/bin from my path completely

      sudo mv /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpyX
      cd ~/repos/matplotlib-svn
      python setup.py clean
      rm -rf build
      clearflags

    2. Do hyperjeff's recommended edits except don't use /usr/local because it's f'd:
      make.osx:

      MACOSX_DEPLOYMENT_TARGET=10.6
      PREFIX=/usr
      PYTHON=/Library/Frameworks/Python.framework/Versions/Current/bin/python

      ## You shouldn't need to configure past this point (and yet…)

      PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
      CFLAGS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk"
      LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
      FFLAGS="-arch i386 -arch x86_64"

      setup.cfg:

      wxagg = False

    3. Do the install (different from hyperjeff b/c I don't want root)
      sudo make -f make.osx fetch deps
      make -f mpl_build mpl_install
      python setup.py install


  6. Install setuptools
  7. easy_install ipython
  8. install everything else pythonically

Monday, March 01, 2010

Thursday, February 25, 2010

macvim crash

well, it finally happened.... my reliable, trusty editor crashed. That should be impossible. I am ready to call it quits for the week....


Process: MacVim [650]
Path: /Applications/Vim.app/Contents/MacOS/MacVim
Identifier: org.vim.MacVim
Version: 7.2 (49)
Code Type: X86 (Native)
Parent Process: Vim [649]

Date/Time: 2010-02-25 13:12:43.001 -0700
OS Version: Mac OS X 10.6.2 (10C540)
Report Version: 6

Interval Since Last Report: 871676 sec
Crashes Since Last Report: 26
Per-App Interval Since Last Report: 938504 sec
Per-App Crashes Since Last Report: 1
Anonymous UUID: 03159B9E-2257-4E38-8C4A-4D4DAF5641A7

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: 0x000000000000000d, 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x99119480 __CFSetCallback + 0
1 com.apple.CoreFoundation 0x990c78bc ___CFBasicHashFindBucket1 + 444
2 com.apple.CoreFoundation 0x990cfaac CFBasicHashFindBucket + 252
3 com.apple.CoreFoundation 0x990e8293 CFSetGetValue + 131
4 com.apple.AppKit 0x961bae7e -[NSWindow _discardTrackingRect:] + 59
5 com.apple.AppKit 0x961badca -[NSView(NSInternal) _uninstallTrackingArea:] + 123
6 com.apple.AppKit 0x960d2c32 -[NSView(NSInternal) _uninstallRemovedTrackingAreas] + 293
7 com.apple.AppKit 0x960dac40 -[NSView(NSInternal) _updateTrackingAreas] + 646
8 com.apple.CoreFoundation 0x990ea4e0 CFArrayApplyFunction + 224
9 com.apple.AppKit 0x960daefb -[NSView(NSInternal) _updateTrackingAreas] + 1345
10 com.apple.CoreFoundation 0x990ea4e0 CFArrayApplyFunction + 224
11 com.apple.AppKit 0x960daefb -[NSView(NSInternal) _updateTrackingAreas] + 1345
12 com.apple.CoreFoundation 0x990ea4e0 CFArrayApplyFunction + 224
13 com.apple.AppKit 0x960daefb -[NSView(NSInternal) _updateTrackingAreas] + 1345
14 com.apple.AppKit 0x960da8db _handleInvalidCursorRectsNote + 392
15 com.apple.CoreFoundation 0x99135892 __CFRunLoopDoObservers + 1186
16 com.apple.CoreFoundation 0x990f218d __CFRunLoopRun + 557
17 com.apple.CoreFoundation 0x990f1864 CFRunLoopRunSpecific + 452
18 com.apple.CoreFoundation 0x990f1691 CFRunLoopRunInMode + 97
19 com.apple.HIToolbox 0x936f6f0c RunCurrentEventLoopInMode + 392
20 com.apple.HIToolbox 0x936f6bff ReceiveNextEventCommon + 158
21 com.apple.HIToolbox 0x936f6b48 BlockUntilNextEventMatchingListInMode + 81
22 com.apple.AppKit 0x960b0ac5 _DPSNextEvent + 847
23 com.apple.AppKit 0x960b0306 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
24 com.apple.AppKit 0x9607249f -[NSApplication run] + 821
25 com.apple.AppKit 0x9606a535 NSApplicationMain + 574
26 org.vim.MacVim 0x0000238b _start + 209
27 org.vim.MacVim 0x000022b9 start + 41

Thread 1: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x98d0c0ea kevent + 10
1 libSystem.B.dylib 0x98d0c804 _dispatch_mgr_invoke + 215
2 libSystem.B.dylib 0x98d0bcc3 _dispatch_queue_invoke + 163
3 libSystem.B.dylib 0x98d0ba68 _dispatch_worker_thread2 + 234
4 libSystem.B.dylib 0x98d0b4f1 _pthread_wqthread + 390
5 libSystem.B.dylib 0x98d0b336 start_wqthread + 30

Thread 2:
0 libSystem.B.dylib 0x98ce58da mach_msg_trap + 10
1 libSystem.B.dylib 0x98ce6047 mach_msg + 68
2 com.apple.CoreFoundation 0x990f277f __CFRunLoopRun + 2079
3 com.apple.CoreFoundation 0x990f1864 CFRunLoopRunSpecific + 452
4 com.apple.CoreFoundation 0x990f1691 CFRunLoopRunInMode + 97
5 com.apple.Foundation 0x91b24430 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 329
6 com.apple.Foundation 0x91aeb8d8 -[NSThread main] + 45
7 com.apple.Foundation 0x91aeb888 __NSThread__main__ + 1499
8 libSystem.B.dylib 0x98d12fbd _pthread_start + 345
9 libSystem.B.dylib 0x98d12e42 thread_start + 34

Thread 3:
0 libSystem.B.dylib 0x98d04856 select$DARWIN_EXTSN + 10
1 com.apple.CoreFoundation 0x99131ddd __CFSocketManager + 1085
2 libSystem.B.dylib 0x98d12fbd _pthread_start + 345
3 libSystem.B.dylib 0x98d12e42 thread_start + 34

Thread 4:
0 libSystem.B.dylib 0x98d0b182 __workq_kernreturn + 10
1 libSystem.B.dylib 0x98d0b718 _pthread_wqthread + 941
2 libSystem.B.dylib 0x98d0b336 start_wqthread + 30

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00515db0 ebx: 0x990c7711 ecx: 0x00516460 edx: 0xbfffcabc
edi: 0x00001041 esi: 0x00504270 ebp: 0xbfffca38 esp: 0xbfffc99c
ss: 0x0000001f efl: 0x00010246 eip: 0x99119480 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x97a20000

Wednesday, February 17, 2010

Command of the Day

ls | wc

and for when ls * fails

find . -name "*" | xargs -I {} mv {} away/

Tuesday, February 16, 2010

DS9 gaussian fitting

One thing DS9 desperately needs is an interactive gaussian fitter. I have NOT implemented one yet, but it is high on my to do list. Has anyone else (googlers?) tried or succeeded in implementing such a thing? Ideally, something with NO dependencies: if I write one, it will require python, numpy, and probably pyds9 - ick. Straight-up TCL would be very much preferable.

Another attempt to get 64 bit python on Snow Leopard

Sam Skillman posted his attempt to get 64 bit python on snow leopard. It worked, but you need to install python with --enable-framework and NOT --prefix and NOT --enable-universalSDK. It is 64-bit only, not universal: universal causes trouble.

Monday, February 15, 2010

Python 64-bit on Mac OS X 10.6 Snow Leopard

After yesterday's disastrous attempt to install various python packages, I started from scratch. First, I got rid of all of my python frameworks (backed up but removed from the path). Then, I compiled python 2.7 from scratch:

I got some help from http://blog.mahmoudimus.com/2009/12/python-2-6-4-and-twisted-9-on-os-x-10-6-snow-leopard/

./configure --enable-framework --enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk MACOSX_DEPLOYMENT_TARGET=10.6 --with-universal-archs=intel -with-readline-dir=/usr/local
make -j 17
make -j 17 test


make results:
Python build finished, but the necessary bits to build these modules were not found:
_bsddb dl gdbm
imageop linuxaudiodev ossaudiodev
spwd sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


I'm not concerned about these - I don't use any of them and I assume I need to install some other packages to get them to work.

During make test, I had two failures that resulted in "python crash" pop-up boxes:
test_subprocess
.
this bit of output is from a test of stdout in a different process ...
.
this bit of output is from a test of stdout in a different process ...
test_sunaudiodev


Then, I got some malloc errors:
test_io

Testing large file ops skipped on darwin.
It requires 2147483648 bytes and a long time.
Use 'regrtest.py -u largefile test_io' to run it.

Testing large file ops skipped on darwin.
It requires 2147483648 bytes and a long time.
Use 'regrtest.py -u largefile test_io' to run it.
python.exe(22914,0x7fff70d3ebe0) malloc: *** mmap(size=9223372036854775808) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
python.exe(22914,0x7fff70d3ebe0) malloc: *** mmap(size=9223372036854775808) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
python.exe(22914,0x7fff70d3ebe0) malloc: *** mmap(size=9223372036854775808) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
test_ioctl

Sunday, February 14, 2010

Installing Snow Leopard

I'm going to attempt to install snow leopard today. This post will serve as a record of the difficulties I run into.

Things to install (and ensure they are 64-bit):

  • ipython
  • numpy
  • scipy
  • matplotlib
  • stsci-python
  • starlink
  • gfortran
  • latex
  • idl (check)


Things that have happened:

  1. Had to restart again (twice) to install additional updates
  2. My bash command line looked funny - something about bash changed, but I don't know what. The fix was easy: commented out some code from http://pseudogreen.org/blog/set_tab_names_in_leopard_terminal.html that I had been using to set the tab title
  3. My locate db broke. Needed repair: sudo /usr/libexec/locate.updatedb
  4. numpy svn failed to build:
    python setup.py build
    Running from numpy source directory.non-existing path in 'numpy/distutils': 'site.cfg'
    F2PY Version 2_8111
    numpy/core/setup_common.py:86: MismatchCAPIWarning: API mismatch detected, the C API version numbers have to be updated. Current C api version is 4, with checksum 59750b518272c8987f02d66445afd3f1, but recorded checksum for C API version 4 in codegen_dir/cversions.txt is 3d8940bf7b0d2a4e25be4338c14c3c85. If functions were added in the C API, you have to update C_API_VERSION in numpy/core/setup_common.pyc.
    MismatchCAPIWarning)
    blas_opt_info:
    FOUND:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3)]
    extra_compile_args = ['-faltivec', '-I/System/Library/Frameworks/vecLib.framework/Headers']

    lapack_opt_info:
    FOUND:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    define_macros = [('NO_ATLAS_INFO', 3)]
    extra_compile_args = ['-faltivec']

    running build
    running config_cc
    unifing config_cc, config, build_clib, build_ext, build commands --compiler options
    running config_fc
    unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
    running build_src
    build_src
    building py_modules sources
    building library "npymath" sources
    customize NAGFCompiler
    Found executable /usr/local/bin/f95
    customize AbsoftFCompiler
    Could not locate executable f90
    Found executable /usr/bin/f77
    absoft: no Fortran 90 compiler found
    absoft: no Fortran 90 compiler found
    customize IBMFCompiler
    Could not locate executable xlf90
    Could not locate executable xlf
    customize IntelFCompiler
    Could not locate executable ifort
    Could not locate executable ifc
    customize GnuFCompiler
    Found executable /usr/local/bin/g77
    gnu: no Fortran 90 compiler found
    gnu: no Fortran 90 compiler found
    customize Gnu95FCompiler
    Found executable /usr/local/bin/gfortran
    customize Gnu95FCompiler
    customize Gnu95FCompiler using config
    C compiler: gcc -arch i386 -arch ppc -arch ppc64 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

    compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c'
    gcc: _configtest.c
    gcc _configtest.o -o _configtest
    ld: library not found for -lcrt1.10.5.o
    collect2: ld returned 1 exit status
    ld: library not found for -lcrt1.10.5.o
    collect2: ld returned 1 exit status
    failure.
    removing: _configtest.c _configtest.o
    Traceback (most recent call last):
    File "setup.py", line 210, in
    setup_package()
    File "setup.py", line 203, in setup_package
    configuration=configuration )
    File "/Users/adam/repos/numpy-svn/numpy/distutils/core.py", line 186, in setup
    return old_setup(**new_attr)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
    File "/Users/adam/repos/numpy-svn/numpy/distutils/command/build.py", line 37, in run
    old_build.run(self)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/command/build.py", line 134, in run
    self.run_command(cmd_name)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
    File "/Users/adam/repos/numpy-svn/numpy/distutils/command/build_src.py", line 152, in run
    self.build_sources()
    File "/Users/adam/repos/numpy-svn/numpy/distutils/command/build_src.py", line 163, in build_sources
    self.build_library_sources(*libname_info)
    File "/Users/adam/repos/numpy-svn/numpy/distutils/command/build_src.py", line 298, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
    File "/Users/adam/repos/numpy-svn/numpy/distutils/command/build_src.py", line 385, in generate_sources
    source = func(extension, build_dir)
    File "numpy/core/setup.py", line 670, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program


    SOLUTION: Use the Mac OS X 10.6 python (/usr/bin/python). I will do this until I run into another problem. Numpy build successfully
  5. Build/install matplotlib - failed! Completely!
  6. Acquired gcc/gfortran from hpc
  7. Followed instructions from hyperjeff on fortran install...
  8. Get rid of numpy 1.2.1: mv /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/.not_numpy.bak
  9. Try to install scipy. Fail on missing umfpack, follow hyperjeff's instructions (but make sure to edit the site.cfg in scipy, not just the one in numpy)

    Had to add the following code:

    sudo cp AMD/Lib/libamd.a /System/Library/Frameworks/Python.framework/Versions/2.6/lib
    sudo cp UMFPACK/Lib/libumfpack.a /System/Library/Frameworks/Python.framework/Versions/2.6/lib
    sudo cp AMD/Include/amd.h /System/Library/Frameworks/Python.framework/Versions/2.6/include
    sudo cp UFconfig/UFconfig.h /System/Library/Frameworks/Python.framework/Versions/2.6/include
    sudo cp UMFPACK/Include/*.h /System/Library/Frameworks/Python.framework/Versions/2.6/include

  10. Installed fftw from fftw.org with simple ./configure, make, sudo make install - no compiler opts as they killed the install
  11. Get SoundSource from rogueamoeba
  12. Updated istatmenus

Friday, February 12, 2010

PSDs, cross-correlation...

scipy is capable of doing fft-base cross-correlation, convolution, etc., but it requires the stsci package, which is not generally easy to install. For that matter, scipy can be a pain some of the time. So agpy now includes a 2D cross-correlation code and a power spectrum / power spectral density code. These are pure-numpy codes that should be easy to use without any other bothersome dependencies.

EDIT: I have them check for scipy (which can cause crashes if you have a bad scipy install, e.g. 32 bit executables on a 64 bit system) because scipy uses FFTW and numpy appears not to. Also, this code & related stuff has been discussed on astrobetyter

agpy
correlate2d
psds

Thursday, February 04, 2010

Logarithmic Colormap / Other Colormap in Matplotlib

This is kind of a pain to find out:


from matplotlib.colors import LogNorm

im = imshow(.... cmap=... , norm=LogNorm(vmin=clevs[0], vmax=clevs[-1]))


It also works for contours, and can be particularly useful if you only want to display contours at a few levels, but you want the colormap to start at a different point. e.g.:

contour(xx,levels=[2,3,4,5,6,7,8,9,10],norm=matplotlib.colors.Normalize(vmin=0,vmax=10))

will start at light blue instead of dark blue in the default colormap

Wednesday, January 27, 2010

wrapping text around a figure in latex

An example from Devin:

%\begin{wrapfigure}{l}{0.5\textwidth}
% \vspace{-27pt}
% \begin{center}
% \includegraphics[width=0.48\textwidth]{nsf_fig3.ps}
% \end{center}
% \vspace{-27pt}
% \caption{\it{}}
% \vspace{-12pt}
%\end{wrapfigure}
1:16
\usepackage{wrapfig}

Sunday, January 03, 2010

my month of travel

I figure most people spending a month away from home would bring more than a small duffel full of clothes. I was quite satisfied with what I had. The things I missed (as a reminder for next time):
My desktop, eta
My music collection
Powerbars

...nothin else, really

Tuesday, December 15, 2009

Detexify!

for when you can't remember how to draw an angstrom:
detexify

Thursday, November 19, 2009

wget

wget is very useful for acquiring data from, e.g., IRSA, the NASA Infrared Science Archive.

wget -nd -r -l1 -A*g09*_b4_20.fits http://irsa.ipac.caltech.edu/data/IGA/images/

The important elements:
-nd: don't reproduce the host directory structure
-r: recursive. Grab the files referred to by the page, not just the page itself
-l#: number of recursion levels
-A: "accept" wildcard

Wednesday, October 21, 2009

New python software

IDLsave was released on my birthday. It does what you'd expect - read IDL save files into Python.
APLpy has a make_RGB_cube function now that takes care of all the internals of making an RGB image.... haven't tried it yet but I need to because it is awesome.

astro-better post

I contributed to a post on Astro Better asking about mosaicing software.

Sunday, October 18, 2009

#6 on Astro-ph today

IRAS 05358 on astro-ph. Check out my page on the region too.

This week at the Sun

Wednesday, Thursday, Saturday, Sunday @ The Southern Sun: Delicious. The Holler's Haze Smoked Porter is new on tap, and it's delicious. Very smooth, the smoke is pretty subtle (i.e. not overpowering the way most porters are), and it's 6.4%.

Cleveland Brown is back on tap too. It's not as good as I remember, but it will probably be better on nitro.

Still no word on whether the Carne Asada burrito will return.

Friday, October 16, 2009

First paper accepted

My Comps II paper on IRAS 05358+3543 was accepted by ApJ on Wednesday. It will show up on arxiv in a few days and I'll post the link then. Unfortunately, there were significant problems rendering the paper, so I recommend downloading my version.

Also, working on the HISA KDA... I have a nice section of cutouts

Wednesday, October 14, 2009

Galaxy Map

If you're ever interested in seeing a face-on view of the Milky Way, check out the Spitzer press release. This link is very surprisingly hard to find on google.

Wednesday, August 26, 2009

cython vs f2py

I had a go at optimizing some code this past week, and ended up learning to use both cython and f2py.

f2py is much easier to use. If you want to write a function in fortran and use it in python, all you do is write the code and add specifications using comments in the fortran code.

cython is more natural to code. The code style is C/fortran-like: think in terms of loops instead of arrays. The syntax is python-like, which makes coding somewhat clearer and simpler.

For my code, I found that cython was ~10% slower than fortran.

Check out the plfits in:
http://code.google.com/p/agpy/source/browse/#svn/trunk/

Monday, August 17, 2009

How to make a pretty image

The most difficult requirement to satisfy is WCS matching. Each image has to be in exactly the same pixel space in order to overlay them successfully in an image program. The process is generally to use Montage's mProject to project the images into the same plane, then mAdd with a blank map of a given size so that the dimensions in pixels are identical.

Once that's done, I load the images into GIMP. However, GIMP reads .fits files as 256 bit data - which is essentially useless because most (interesting) images have a dynamical range >~1000. So I usually make images emphasizing the faint emission in log scale with the high and low ends cut off (I use DS9 to determine high/low). I make a second copy showing the details of the very bright regions, again in logscale but it ends up being a different log scale - essentially, my transfer function becomes a broken power law.

The tricks in GIMP are numerous, but primarily two:
1. Rotate the color table ~60 degrees
2. Use images as "Layer Masks" (aka alpha layers) on a solid color background

There's also the nice trick when using radio data of using optical or some other wavelength to provide the high-resolution details, while the radio emission provides the intensity.

Saturday, August 15, 2009

FITS manipuation with imagemagick, gimp, etc.

It is possible to convert .fits files to .png, .jpg, etc:
convert -normalize a.fits a.png

To get things to come out nicely, you have to do the scaling essentially by hand in python/idl/iraf. DS9 is only useful for finding out what scaling you want to use; past that it's pretty much not useable.

To make colors look nice in the GIMP, use solid background layers with your image as the alpha mask. Then put your image in with itself as an alpha mask so you can easily control the whiteness (saturation) of the color you've selected.

I'll be blogging about this more as I prep my next entry for the NRAO photo contest.

Friday, August 14, 2009

Acquiring DSS images

This is the way to get DSS images:
ESO's batch downloader

Thursday, August 13, 2009

login shell

to change your default login shell, use chsh

Wednesday, August 12, 2009

Quicksilver sounds

To switch sound source from the command line:
switchaudio

Use this to make scripts such as:

#!/bin/bash
/Users/adam/humor/SwitchAudioSource -s "Built-in Line Output"
afplay /Users/adam/humor/losinghorn.wav
/Users/adam/humor/SwitchAudioSource -s "Built-in Output"


Then make triggers in Quicksilver by:

  1. Go to trigger pane, make new hotkey trigger
  2. press "." to allow you to type a command
  3. make sure the action is "Run"
  4. hook up a hotkey
  5. if it doesn't work, just try again. Persist through crashes, they happen often.



Follow-up: You can also control the volume!
http://discussions.apple.com/thread.jspa?threadID=585781
osascript -e 'set volume output volume 100'

Saturday, July 25, 2009

Sunday, July 12, 2009

Year in review

It's been just over a year since I started this blog. I posted a LOT more than I thought I would. Also, I apparently dropped the tradition of reviewing beers. So I'll start by reviewing some beers!

Mountain Sun Hummingbird - a strong honey-ale (meade-beer?) brewed with orange blossom honey. Slightly darker than a typical Belgian Golden but similar in style. The beer is mildly sweet but very drinkable. Hmm... there are flavors I should mention but they escape me.

Mountain Sun/Avery Van Diemens - brewed with Tasmanian Pepper Berry, this is a very curious, semi-dark beer. When I first sampled it, I tasted a little bit of pepper kick at the end, but couldn't really identify any other flavors. Yesterday I sampled it next to a burrito with some somewhat spicy salsa. Somehow, since my mouth was already sensitized to spiciness, the flavor I got was root beer (sassafras?). It was... odd. Pretty good, but I didn't end up purchasing a glass.

Moving on to code. I don't know why I haven't mentioned this, but with my discovery of svn, I started uploading my code to the webternets: agpy is my Google Code page and includes a number of useful python codes, especially readcol and gaussfitter, which I have tested and used extensively since writing them. Python is still a long way from a cohesive astrolib code base, but with individual contributions, the STSCI development group, and APLpy underway, we're getting closer.

Wednesday, July 08, 2009

SUCCESS! 64 bit python with 64 bit tcl/tk!!!

After a long, tedious process (see previous posts), I got 64 bit python, 64 bit tcl/tk, and 64 bit tkinter all to work! I can now use the TkAgg backend in matplotlib!

Python 64 bit on Mac OS X: Sam Skillman's post

Tcl/Tk 64 bit: a post on the tcl/tk forums

tkinter 64 bit: python bug report 4017 (last two posts give the solution) and my posted solution

Sunday, July 05, 2009

Failure to compile 64 bit gtk on mac os

Attempted to install gtk+-2.17.2 on my mac. Had to install:
glib-2.21.2
which would not let me compile with multiple architectures, and
pkgconfig-0.9.0,
which won't configure because:

configure: configuring in glib-1.2.8
configure: running /bin/sh './configure' --prefix=/usr/local CC= CFLAGS= LDFLAGS= --cache-file=/dev/null --srcdir=.
configure: warning: CC=: invalid host type
configure: warning: CFLAGS=: invalid host type
configure: error: can only configure for one host and one target at a time
configure: error: /bin/sh './configure' failed for glib-1.2.8


which is bs because I don't have any compiler flags set.

So, gtk+ seems hopeless.

UPDATE: 0.9.0 is not the latest version, 0.23.0 is. Dumb version numbering.


GTK is absurd to install. You need:
pkg-config
glib
cairo
pixman
pango (MUST be installed AFTER cairo)
atk
libtiff
libjpg
jpeg2000 - but I just passed a flag to not do this because it didn't install right. --without-libjasper
fontconfig I mean, really? at this point it's just ridiculous....

and finally, it died with this:
checking Pango flags... configure: error:
*** Pango not found. Pango built with Cairo support is required
*** to build GTK+. See http://www.pango.org for Pango information.

which meant that I had to reinstall Pango because I had installed it before Cairo.

I believe this is where the term dependency hell comes from.

Also, I don't think any of these are x86-64 compatible.


Then I'm STILL not done.

PyGTK dies with an import error on dsextras, which a painful google search traces to pygobject. pygobject makes and installs fine.... but then I find out it installed to /usr/local/lib/python2.6/site-packages/gtk-2.0/, which is obviously not on my python path since I installed a framework.

So:
./configure --prefix=/Library/Frameworks/Python.framework/Versions/2.6/
in both pygobject and pygtk.

Oh, guess what? Need pycairo too. What happens there? What you'd guess:
ld warning: in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libcairo.dylib, file is not of required architecture

so when I configure pygtk:

The following modules will be built:

atk
pango

The following modules will NOT be built:

pangocairo
gtk
gtk.glade
gtk.unixprint

Damn. That blows.

python-64 -c "import gtk"
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gtk-2.0/glib/_glib.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gtk-2.0/glib/_glib.so: mach-o, but wrong architecture

FAIL.

Thursday, July 02, 2009

Installing 64 bit tcl/tk on Mac OS X

Everything is described in this post:
http://www.nabble.com/Error-compiling-tk-8.5.7-on-Mac-OS-X-10.5-td23790967.html


But here's a script too:

curl -O 'http://osdn.dl.sourceforge.net/sourceforge/tcl/t{cl,k}8.5.7-src.tar.gz'
for f in t*8.5.7*.gz; do tar zxf $f; done
cd tcl8.5.7/unix/
./configure --enable-framework --enable-64-bit
cd tk8.5.7/unix/
./configure --enable-framework --enable-64-bit
make -j 4 -C tcl8.5.7/unix
make -j 4 -C tk8.5.7/unix
sudo make install -C tcl8.5.7/unix
sudo make install -C tk8.5.7/unix


Concerns:
-might be necessary to do this in the macosx directory for some reason, though Aqua doesn't support 64 bits
-have to recompile python to get _tkinter to work (see a later post)

Monday, June 29, 2009

Make PDFs open with the thumbnails window open

Neat trick I picked up from here:
http://www.ghostscript.com/~ghostgum/pdftips.htm

Add this code:

\special{! /pdfmark
[/View [/XYZ null null 1] % unspecified x and y offset, 100% zoom
/Page 1
/PageMode /UseThumbs % /UseNone /UserOutlines /UseThumbs /FullScreen
/DOCVIEW pdfmark
}

to a LaTeX document (probably near the top) and when you ps2pdf it, it will open the PDF with the thumbnail bar open. This is very useful for proofreading after you latex a file. Of course, xdvi also works well for this, but xdvi is VERY unstable on the Mac. At least adobe, being a native Mac program, doesn't crash as often.

Monday, June 15, 2009

Art mimicing reality

An artist who likes painting astronomical objects:
Marianne Beacham Gallery

Sunday, June 14, 2009

Comps 2 reflections

Comps 2 included some successes and some failures.

The most successful part of my Comps preparation was the Monday talk. The previous talk on Tuesday was somewhat helpful in terms of realizing that I needed larger figure axes, but otherwise provided no useful feedback. The Monday talk allowed me to realize what needed to be done to make my talk accessible to a larger audience.

At the defense, I ended up going only ~40 minutes despite having gone far over time in the Monday version and spending ~5 minutes answering questions from Don and Mike. I think that was a good thing; I didn't need to say anything more even though there was an enormous amount of additional material I could have covered.

The main change I made from Monday to Friday was reorganizing such that I discussed the largest scales first and zoomed in, and I spent much more time discussing the larger context of my work. Unfortunately, I also spent most of the week before the presentation determining the larger context and reading papers. Ideally, I would have done that before handing in the paper.

The closed door Q&A section went OK but not great. There were a few important bits of information related to the IMF that I didn't know off the top of my head - e.g. the ratio of total # of stars to the # of B stars. I got the lowest mass star (.07) confused with the most common star mass (.3). I wasn't particularly able to integrated the IMF on the board either. I didn't remember the Jeans mass-temperature and mass-density relationships but was able to derive them quickly enough.

Probably the biggest problem was dealing with a question about the partition function - specifically how did the partition function come into play in the column density equation. I didn't come up with the right answer at all, and in particular quoted the wrong distribution. However, I think a big part of what they expected to hear was a dependence on temperature AND degeneracy, and I never explicitly mentioned degeneracy. It turned out that the equation I had quoted in both the paper and the talk was correct, but I couldn't come anywhere close to proving that on the spot.

My expected result is therefore a low pass, though it was not made explicit. That's rather unfortunate as it's possible that another month of preparation could have gotten me the high pass, but at the same time, it's well worth having the project done.

Tuesday, June 02, 2009

Most important astronomical publications

I'm interested to hear input on this. Some I know of:
Cardelli, Clayton, Mathis 1989 - determined interstellar extinction law
Kurucz 1993 - possibly a book? Stellar atmosphere calculations

Tuesday, May 26, 2009

public perception of astronomers

Public Perception of Astronomers

While the article has some.... almost-interesting points, I don't agree with the thesis or the suggested methods. I don't really have a problem with the stereotype of astronomers being the old, white, socially inept guy - because for the most part that's a fair assessment. We're scientists, and at least for me and my peers, that's directly correlated with not fitting in to some social circles.

I agree that we should become better communicators in general, but it's silly to think that embracing new technologies (i.e. social networking tools) is going to change the public image of astronomers at all. Personally I hope to see a backlash against social networking and blogs sometime in the next 5 years, but who knows.... after all, I'm writing a blog post.

Monday, May 25, 2009

some comics

http://ableandbaker.net/index.php?comic=198
http://ableandbaker.net/index.php?comic=222
http://ableandbaker.net/index.php?comic=357
http://ableandbaker.net/index.php?comic=396
http://ableandbaker.net/index.php?comic=471
545 "Put on your snuggle trunks and jump in the cuddle pool."
http://ableandbaker.net/index.php?comic=905
http://ableandbaker.net/index.php?comic=922

Thursday, May 07, 2009

Comedic timing has been fixed using quicksilver's command line execution abilities.

Also been playing with dashboard... Safari's new dashboard feature is pretty cool, but also incompetent.  It refreshes every time you reload the dashboard, which is inefficient and makes saving settings impossible.  Also, the gmail compose feature fails miserably.  So, dashboard must die again.

Wednesday, May 06, 2009

Quicksilver and Awesome

Set up f17-19 today to play amusing sounds. Also, recalled that I use ScreenSaverEngine to lock my screen with a shortcut key.

Quicksilver triggers are the way to do it. Mac is stupid w/o quicksilver.

Tuesday, April 21, 2009

Python 64 bit!

I got python 64 bit to compile, but it required a number of tricky steps.

First, this guy has the instructions I followed:
captnswing

However, it didn't work entirely as advertised. I ran the configure as advertised:

./configure --enable-framework=/Library/Frameworks \
--enable-universalsdk=/ \
MACOSX_DEPLOYMENT_TARGET=10.5 \
--with-universal-archs=all \
--with-readline-dir=/usr/local


then the make install, but /usr/local/bin/python pointed to the wrong place, so I replaced the symbolic link in my python path with the correct one:

sudo rm /Library/Frameworks/Python.framework/Versions/2.6/bin/python
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/python-64 /Library/Frameworks/Python.framework/Versions/2.6/bin/python


Now python is 64 bit:

eta ~$ python -c "import sys; print sys.maxint"
9223372036854775807


I haven't checked whether it works yet though...

Update: Had to reinstall with gnu readline installed. Also have to install PyQt4 and might have to recompile numpy...

numpy won't compile with python 2.6.2:
C compiler: gcc -arch i386 -arch ppc -arch ppc64 -arch x86_64 -isysroot / -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

compile options: '-Inumpy/core/include -Ibuild/src.macosx-10.5-universal-2.6/numpy/core/include/numpy -Inumpy/core/src -Inumpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c'
gcc: build/src.macosx-10.5-universal-2.6/numpy/core/src/_sortmodule.c
In file included from numpy/core/include/numpy/ndarrayobject.h:26,
from numpy/core/include/numpy/noprefix.h:7,
from numpy/core/src/_sortmodule.c.src:29:
numpy/core/include/numpy/npy_endian.h:33:10: error: #error Unknown CPU: can not set endianness
lipo: can't figure out the architecture type of: /var/folders/ni/ni+DtdqFGMeSMH13AvkNkU+++TI/-Tmp-//cceaWIvZ.out
In file included from numpy/core/include/numpy/ndarrayobject.h:26,
from numpy/core/include/numpy/noprefix.h:7,
from numpy/core/src/_sortmodule.c.src:29:
numpy/core/include/numpy/npy_endian.h:33:10: error: #error Unknown CPU: can not set endianness
lipo: can't figure out the architecture type of: /var/folders/ni/ni+DtdqFGMeSMH13AvkNkU+++TI/-Tmp-//cceaWIvZ.out
error: Command "gcc -arch i386 -arch ppc -arch ppc64 -arch x86_64 -isysroot / -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Inumpy/core/include -Ibuild/src.macosx-10.5-universal-2.6/numpy/core/include/numpy -Inumpy/core/src -Inumpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c build/src.macosx-10.5-universal-2.6/numpy/core/src/_sortmodule.c -o build/temp.macosx-10.5-universal-2.6/build/src.macosx-10.5-universal-2.6/numpy/core/src/_sortmodule.o" failed with exit status 1


That sucks.

Monday, April 20, 2009

Hosting on my mac

I'm hosting my website off my mac; it should be accessible to the outside world now: eta.colorado.edu.

A few things went into this....

  1. Don't install the fink version. The two versions clash and depending on how you access your computer you could end up looking at entirely different directories (e.g. localhost and eta.colorado.edu referred to different sites for a while)
  2. The configuration file is /private/etc/apache2/httpd.conf
  3. I needed to change DirectoryIndex to index.htm (from index.html)
  4. uncommmented "LoadModule php5_module libexec/apache2/libphp5.so"
  5. had to allow override so that .htaccess files would work.

Wednesday, April 15, 2009

Mac stuff cont'd

Trying to get Apache server to run, and it's just a pain.

I frequently forget how to update the locate database because it's different on macs. Marcos' Mac Singularity has the instructions .

In short:
sudo /usr/libexec/locate.updatedb

Tuesday, April 14, 2009

Google has failed me

So, either no one on the internet has successfully installed 64-bit python on a mac (which I find nothing short of impossible) or google has totally failed. None of the hits for any combination of 64 bit, python, mac, etc. has shown a useful result. Wow.

Monday, April 06, 2009

Caffeine

Caffeine consumption stopped around mid-October. I think it was when I got back from observing so October 20 give or take. Re-started consumption mid-March. Date is hard to say... I think it was Sunday before Spring Break, but hard to say because I still took it easy until ~last week.

Conclusions? I'm probably more tired in the mornings with caffeine than without. Also, probably perform better @ ulty when I'm not addicted. However.... not really conclusive. Just addictive.

Saturday, April 04, 2009

weekend

What did I do this weekend?
-upgraded PyRAF from 1.6.1 to 1.7
-switched matplotlib backends from TkAgg to Qt4
-put up a new article on molecularclouds


So... totally unproductive, but only in an awesome way?

I tried to switch PyRAF from X11 to Aqua a la Ticket 86 on the PyRAF trac site, but it failed with a can't-load error.

Also, updated readcol documentation so that it makes sense. Sam has used it, Robbie might.

Wednesday, April 01, 2009

April 1st, 2009

No April fools' day would be complete without scientists' contributions:

http://arxiv.org/abs/0903.5308
http://arxiv.org/abs/0903.5321
http://arxiv.org/abs/0903.5377

although it's not obvious whether .5308 is actually intended to be humorous

Wednesday, February 25, 2009

Astronomy gets some recognition

First off, this guy does some amazing work, like measuring the galactic rotation curve. He got recognized by the Colbert Report. Sweet.

Wednesday, February 18, 2009

My works featured...

Curiously, one of my wikimedia commons images has been included in this article: http://www.scienceinschool.org/2008/issue10/tamaradavis, though the image has little to do with the subject in question. Noodle (can't remember her real name... that's sad on my part) is in the picture. Neat!

This might not be something to be proud of:
http://www.denverptc.org/denver.html

GC was featured in:
http://www.strudel.org.uk/blog/astro/000855.shtml

Thursday, January 22, 2009

ps2pdf keep resolution, crop to bounding box

ps2pdf -dEPSCrop -dAutoRotatePages=/None -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dUseFlateCompression=true l007_displaycrop.ps
ref: this post

Making a postscript plot of a gigantic fits image


map = readfits('MOSAIC.fits',hdr)

crpix1 = sxpar(hdr,'CRPIX1')
crpix2 = sxpar(hdr,'CRPIX2')
crval1 = sxpar(hdr,'CRVAL1')
crval2 = sxpar(hdr,'CRVAL2')
cd1_1 = sxpar(hdr,'CD1_1')
cd2_2 = sxpar(hdr,'CD2_2')

x = lindgen(n_e(map[*,0]))
y = lindgen(n_e(map[0,*]))
l = (x-crpix1)*cd1_1+crval1-360
b = (y-crpix2)*cd2_2+crval2

imdisp,map,/axis,xrange=[max(l),min(l)],yrange=[min(b),max(b)],range=[-1,8]


This code makes use of imdisp.pro.

Wednesday, January 14, 2009

MOSAIC data reduction

MOSAIC reduction is very difficult.
http://www.noao.edu/noao/noaodeep/ReductionOpt/frames.html has the official instructions.

Important things:
Have the latest version of MSCRED and MSCDB installed. Both will give cryptic errors or "cannot open file" errors (because the files don't exist) otherwise.



mscred
setinstrument kpno CCDMosaThin1
msccmatch obj09*.fits coords="!mscgetcat $I $C" search=60 rsearch=1 nfit=30 accept=yes interactive=no fit=no

Tuesday, January 13, 2009

Site visits, comps


Amusing - visits to my site increased steadily leading up to Jan 9, then crashed precipitously.

Saturday, December 27, 2008

LaTeX: replace double quotes with tex quotes

People often make the mistake of putting " in place of `` in LaTeX documents. To repair this, the only easy solution is something like:
s/\(\s\)"/\1``/g
in VIM or sed.

I've seen alternate solutions posted but they're all too complicated. One recommendation was to switch to XeTeX, which sounds like overkill, and others all stated that a complicated perl script is required. The latter is technically true, but why isn't such a thing readily available?

Any other ideas?

Thursday, December 11, 2008

skill set

is it a marketable skill that I can bring down almost any computer system I'm given access to entirely unintentionally?

Friday, December 05, 2008

post rate

my post rate is too low I need to up it so that my front page doesn't show the same posts any more

Wednesday, December 03, 2008

scary

I think this is my worst nightmare:
http://antwrp.gsfc.nasa.gov/apod/ap081203.html

LA. Not the smiley.

Monday, November 24, 2008

.inputrc

New unix stuff!

This is, again, stuff I'd searched for forever but never found the right collection of terms. This is what bash readline is REALLY all about.

if you make an inputrc file, you can get awesome readline capabilities (similar to ipython). This post at lifehacker showed me how to do it. This site has a more complete description of how to use readline/inputrc.

Even better: VI command line editing .

There's also something called magic space but I don't know what purpose it serves all the time... it will replace 'magic' characters like !* and !& and !! with whatever command they represent if you hit space immediately after typing them (explained better here).

Wow. Awesome.

Thursday, November 20, 2008

MOVIES!

Making movies is surprisingly difficult. No matter what language you use, apparently true movie files can only be made by stringing together images, i.e. there is no native movie-producing feature. Gnuplot can do some simple animations but to do anything sophisticated you need to start delving into variables, and for that I switch to a real language.

So, I returned to python. As usual, it took no more than a few hours of coding and learning to come up with something. But it bothers me that it took that long: I still think python is most deficient in its failure to create a default column-text reader like 'readcol' in IDL. I can't complain that much, though: I wrote my own in about 5 minutes.

Anyway, the key is to use the .set_xdata and .set_ydata functions of a plot to update a canvas. I still don't have nearly as high a plotting speed as I'd like, but it works alright if I don't display to screen. Probably a different backend would be more effective but I don't like to mess with backends.

I use savefig(filename,dpi=50) to reduce the image quality so that it's easier for the animator to handle.

ImageMagick's convert can be used to stitch any kind of image into a movie given that you've installed an mpeg2 encoder (fink gave me mpeg2vidcodec ). The command is very simple:

convert -size 300x300 *.png movie.mpg


I had to use a smaller image size because a series of 1000x12kb files somehow chomped ~6-8 GB of RAM and swap space.

Monday, November 17, 2008

Screen cont'd

Guide to screen

Particularly useful features:

Scrollback:

ctrl-a [
[scroll keys]


Switch to a numbered screen (doesn't work for me so far):

ctrl-a [number]

Sunday, November 16, 2008

Ultimate today

We went 2-1 in the tournament, losing the final in a windy game on universe point, 15-14. We won the first game 13-5 or 13-6, and the second by a similarly wide margin. I think I scored 15-20 points on the day and threw an additional few. 2-3 drops and 3-4 throwaways to balance that out. Pretty good on the whole for what was probably my last ultimate of the season.

Of course, that made me very exhausted for the review session this evening. Oh well, I think it worked out. I need to remember to come up with (and post!) a clear explanation of why you can use that silly little triangle to come up with the translation between angle on the sky and image size.

Thursday, November 13, 2008

BASH discoveries, readline questions

1. shopt -p
Maybe my hostname completion worked and then stopped working because the bash option hostcomplete was not set. Duh! Why? I don't know. Anyway, shopt -s hostcomplete solves the problem.

nocaseglob is also pretty cool (case insensitive tab completion)

2. it's really hard to search for readline stuff on google. Can anyone explain to me how BASH readline works? I would REALLY like to make bash readline work like ipython, in which you can start typing a command and hit the 'up' key to search through the history for anything beginning with the stuff you've typed up to that point. But I can't even find documentation for the ipython readline! Any hints, anyone?

3. my desktop at work blocks ssh connections. I can ssh into some computers and then into it, but not directly into it.

...as usual, I made a list where not-a-list would have sufficed, and I had to add the last thing because a 2-item list is dumb.

Wednesday, November 12, 2008

Why do astronomers have such a strong presence on the web?

I'm not making this a complete post, just a few examples of blogs and websites I'm aware of. But we do have a strong presence on the web - astronomers have an unusually high google ranking etc. Is it just because 'we' were here first ('we' excludes me, I'm just jumping on the bandwagon and getting a free ride)?

Examples:
Pamela Gay
Dr Lisa

Science writers who write on astronomy:
Dave Mosher