Degrees to steradians

I quite often find myself wanting to convert from square degrees to [steradians] (SI unit
for solid angle), its simple but I waste too much time doing it (just recalling if its pi/180 or the otherway etc), so I’ve wrote a PHP function to do it – [deg2sr.php]. Oh, I’ve also wrote a python implementation of this:

#!/usr/bin/python
#usage: deg2sr.py -v 0  #convert square degrees to steradians.
import string, sys, math, scipy, numpy, pylab, os
from numpy import *
values_pass = sys.argv[2:]  #return value passed to script
deg = (double(values_pass[0]))
sr = ((pi/180)**2)*deg
print deg, sr

Simply copy this and save it and run as deg2sr.py -v 10 (where 10 is the number of square degrees).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: