# Python intro

First of all python is free! Then, I think of python as a super cool programming language that is also a super calculator. It allows you to do higher level math calculations but it can also help find cheaper airplane tickets in the Internet (ask me if you’re interested). Here is a short tutorial to get you started with python after you have installed canopy.

Quick start:

2. Open the Canopy editor and create a new file.
3. Read the following mini tutorial and try some commands in the prompt.
4. Type in the given equations from 1 to 6 and check the results with print statements. Don’t forget to hit run (Ctr + R or Cmd + R).

mini tutorial continued …

variables in python

you can basically use any typical variable name in python such as ‘perigee’ or ‘radius_earth’. Try to give descriptive variable names so your code is easily readable by others.

assign numerical values to variables

it’s as easy as you’d expect

perigee = 418.0


important note: in python 2 an integer number (such as ’18’) is treated differently than a floating number (such as ‘18.0’). To do math with floating numbers in python 2 you can’t have integers in the mix. So that’s why I usually initialize my integer variables with a ‘.0’ at the end so I won’t get strange results. You should try to see what I mean.

math calculations in python

To do math in python is also very simple and as expected

Examples:

Rp = perigee + radius_earth
R = a*(1-e**2)/(1+e*cos(nu))


important note: in python the exponent operator is ‘**’ instead of ‘^’ as in other programming languages. Here is a short list of the operators you  can use in python:

http://www.tutorialspoint.com/python/python_basic_operators.htm

The way you print in python 2 is different from python 3. This example is for python 2:

print 'Period = ',P,' min'


last but not the least: numpy

numpy is a python library that helps you do math. You can read more about it here: http://wiki.scipy.org/Tentative_NumPy_Tutorial

For now you just need to import this python library and use it blindly. On the first line of your script type:

from numpy import *


this will import all the functionality of numpy into your python script. For this tutorial it’s specially useful to be able to use the constant ‘pi’ and also for the function ‘cos’. Otherwise you would have to make your own ‘pi’ and ‘cos’.

Here is the source code to make the magic happen:

#iss orbital speed and period
from numpy import *

perigee = 418.0 #km
apogee  = 426.0 #km
mu_earth = 3.986e5 # km^3/s^2

print 'Radius Perigee: ', Rp, 'km'
print 'Radius Apogee : ', Ra, 'km'

# 1) eccentricity
e = (Ra - Rp)/(Ra + Rp)
print 'eccentricity: ', e

# 2) semimajor axis
a = (Ra+Rp)/2.0
print 'a =', a, ' km'

# 3) mechanical energy
epsilon = -mu_earth/(2*a)

# 4) altitude at nu=90deg
nu = 90*pi/180
R = a*(1-e**2)/(1+e*cos(nu))

print 'R =', R, 'km'

# 5) orbital speed
V = sqrt(2*(mu_earth/R + epsilon))
print("V = {:2f} km/s".format(V))

# 6) orbital period
P  = 2*pi*sqrt(a**3/mu_earth)
print("P = {:.2f} sec = {:.2f} min = {:.2f} hr".format(P, P/60, P/60/60))


# SVN 1.7 for Mac OS Lion

Mac OS Lion comes with SVN 1.6 installed by default. But I needed to install SVN 1.7 to work on a project that uses SVN1.7.

Here is what I did to come trough:

I like using the SVN GUI tool svnX. The current version of the program is: svnX 1.3.3 (http://code.google.com/p/svnx/wiki/Features_1_3). Take a look and download it if you like what you see. It’s free and after you learn how to use it you will love it!. Download here.

The latest version of subversion is 1.7.5 (as today) and it can be found in
http://apache.is.co.za/subversion/

But svnX 1.3.3 is compatible with svn 1.7.4 so we are going to install that rather that the latest svn (1.7.5). Also I because I found some problems with svn 1.7.5.

1) Create a folder where you will put the svn 1.7.4 files. Download and extract the source.

$mkdir ~/Downloads/svn$cd ~/Downloads/svn $curl http://archive.apache.org/dist/subversion/subversion-1.7.4.tar.gz > ./subversion-1.7.4.tar.gz$tar -xvjf subversion-1.7.4.tar.bz2  //to uncompress a bzip2 tar file: .tbz or .tar.bz2 $cd subversion-1.7.4  Configuration setup, Building and install the binary $./configure --prefix=/usr/local $make$sudo make install 
It should now be installed in /usr/local/bin/svn. Check if it got correctly installed.

\$/usr/local/bin/svn --version

Notes:

• You may try to install version 1.7.5 at your risk. Replace ‘subversion-1.7.5.tar.bz2’ with the latest version you find in the above link on the ‘curl’ command.
• You can also install the latest version of subversion using MacPorts

Resources: