{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "import csv" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ ], "source": [ "f = open(\"slr_sla_gbl_free_txj1j2_90.csv\")\n", "csv_f = csv.reader(f)\n", "#for row in csv_f:\n", " # print (row)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "https://newcircle.com/s/post/1572/python_for_beginners_reading_and_manipulating_csv_files#opening-a-csv-file" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "#data = [[row[0], eval(row[12]), eval(row[26])] for row in csv_f]\n", "#print (data)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [ ], "source": [ "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ ], "source": [ "#df = pd.read_csv(\"slr_sla_gbl_free_txj1j2_90.csv\", error_bad_lines=False)\n", "#df" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "data = pd.read_csv('slr_sla_gbl_free_txj1j2_90.csv', skiprows=5, index_col = 0)\n", "#data" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "http://stackoverflow.com/questions/18039057/python-pandas-error-tokenizing-data\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "http://chrisalbon.com/python/pandas_dataframe_importing_csv.html" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TOPEX/Poseidon
year
1993.0123-14.42
1993.0407-19.08
1993.0660-23.42
1993.0974-26.77
1993.1206-23.45
1993.1493-17.81
1993.1765-16.06
1993.2037-15.23
1993.2307-19.07
1993.2851-20.94
1993.3123-13.81
1993.3394-14.42
1993.3665-12.39
1993.3937-18.45
1993.4208-20.75
1993.4480-18.25
1993.4751-15.30
1993.5021-10.97
1993.5294-11.99
1993.5837-21.31
1993.6117-18.61
1993.6381-14.99
1993.6652-11.88
1993.6923-14.95
1993.7189-20.99
1993.7466-21.57
1993.7738-17.33
1993.8009-15.34
1993.8553-15.71
1993.8824-20.20
......
2015.0308NaN
2015.0579NaN
2015.0850NaN
2015.1122NaN
2015.1394NaN
2015.1664NaN
2015.1936NaN
2015.2207NaN
2015.2479NaN
2015.2750NaN
2015.3023NaN
2015.3293NaN
2015.3565NaN
2015.3837NaN
2015.4108NaN
2015.4380NaN
2015.4650NaN
2015.4923NaN
2015.5194NaN
2015.5465NaN
2015.5736NaN
2015.6009NaN
2015.6280NaN
2015.6551NaN
2015.6823NaN
2015.7094NaN
2015.7366NaN
2015.7637NaN
2015.8723NaN
2015.8995NaN
\n", "

1060 rows × 1 columns

\n", "
" ], "text/plain": [ " TOPEX/Poseidon\n", "year \n", "1993.0123 -14.42\n", "1993.0407 -19.08\n", "1993.0660 -23.42\n", "1993.0974 -26.77\n", "1993.1206 -23.45\n", "1993.1493 -17.81\n", "1993.1765 -16.06\n", "1993.2037 -15.23\n", "1993.2307 -19.07\n", "1993.2851 -20.94\n", "1993.3123 -13.81\n", "1993.3394 -14.42\n", "1993.3665 -12.39\n", "1993.3937 -18.45\n", "1993.4208 -20.75\n", "1993.4480 -18.25\n", "1993.4751 -15.30\n", "1993.5021 -10.97\n", "1993.5294 -11.99\n", "1993.5837 -21.31\n", "1993.6117 -18.61\n", "1993.6381 -14.99\n", "1993.6652 -11.88\n", "1993.6923 -14.95\n", "1993.7189 -20.99\n", "1993.7466 -21.57\n", "1993.7738 -17.33\n", "1993.8009 -15.34\n", "1993.8553 -15.71\n", "1993.8824 -20.20\n", "... ...\n", "2015.0308 NaN\n", "2015.0579 NaN\n", "2015.0850 NaN\n", "2015.1122 NaN\n", "2015.1394 NaN\n", "2015.1664 NaN\n", "2015.1936 NaN\n", "2015.2207 NaN\n", "2015.2479 NaN\n", "2015.2750 NaN\n", "2015.3023 NaN\n", "2015.3293 NaN\n", "2015.3565 NaN\n", "2015.3837 NaN\n", "2015.4108 NaN\n", "2015.4380 NaN\n", "2015.4650 NaN\n", "2015.4923 NaN\n", "2015.5194 NaN\n", "2015.5465 NaN\n", "2015.5736 NaN\n", "2015.6009 NaN\n", "2015.6280 NaN\n", "2015.6551 NaN\n", "2015.6823 NaN\n", "2015.7094 NaN\n", "2015.7366 NaN\n", "2015.7637 NaN\n", "2015.8723 NaN\n", "2015.8995 NaN\n", "\n", "[1060 rows x 1 columns]" ] }, "execution_count": 16, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data.ix[1993.0123:2015.8995, ['TOPEX/Poseidon']]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "-1.54" ] }, "execution_count": 14, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].median()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "-1.281545454545453" ] }, "execution_count": 15, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].mean()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "http://stackoverflow.com/questions/29778636/median-of-pandas-dataframe" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "11.788058796093676" ] }, "execution_count": 16, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].std()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "24.120000000000001" ] }, "execution_count": 24, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].max() #6" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "-26.77" ] }, "execution_count": 25, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].min() #Level started negative and has risen slowly over the years" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "440" ] }, "execution_count": 15, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['TOPEX/Poseidon'].count() #4" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Jason-1
94539.96
946NaN
94743.47
\n", "
" ], "text/plain": [ " Jason-1\n", "945 39.96\n", "946 NaN\n", "947 43.47" ] }, "execution_count": 17, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data.ix[945:947, ['Jason-1']]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [ { "data": { "text/plain": [ "305 2.42\n", "308 8.32\n", "309 10.29\n", "310 11.01\n", "312 8.26\n", "314 5.32\n", "316 6.44\n", "317 5.33\n", "320 9.25\n", "321 6.50\n", "323 8.03\n", "324 6.34\n", "326 7.92\n", "327 7.57\n", "328 3.85\n", "329 5.05\n", "330 9.11\n", "331 8.31\n", "332 8.93\n", "333 10.96\n", "334 12.21\n", "336 13.02\n", "337 9.42\n", "340 7.29\n", "341 9.19\n", "344 11.00\n", "345 7.30\n", "348 12.35\n", "349 14.61\n", "351 6.30\n", " ... \n", "918 39.07\n", "920 38.77\n", "922 37.31\n", "924 41.24\n", "926 40.09\n", "928 39.00\n", "930 41.69\n", "931 40.68\n", "933 40.65\n", "936 39.99\n", "938 40.32\n", "939 37.42\n", "941 40.68\n", "943 41.84\n", "945 39.96\n", "947 43.47\n", "949 41.66\n", "951 41.57\n", "953 41.60\n", "957 39.96\n", "958 40.62\n", "959 42.35\n", "960 39.86\n", "962 36.01\n", "964 37.93\n", "965 43.84\n", "968 43.22\n", "970 41.07\n", "972 36.34\n", "974 32.88\n", "Name: Jason-1, dtype: float64" ] }, "execution_count": 4, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].dropna()" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "21.3" ] }, "execution_count": 18, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].median()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "21.87150485436892" ] }, "execution_count": 19, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].mean()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "9.17064857558141" ] }, "execution_count": 20, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].std()" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "43.840000000000003" ] }, "execution_count": 26, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].max() #6" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "-3.3700000000000001" ] }, "execution_count": 27, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].min() #slow increase in values" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "412" ] }, "execution_count": 14, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'].count() #4" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "34.32" ] }, "execution_count": 21, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].median()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "34.92374531835205" ] }, "execution_count": 22, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].mean()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "8.815705537014296" ] }, "execution_count": 23, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].std()" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "55.890000000000001" ] }, "execution_count": 28, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].max() #6" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "19.969999999999999" ] }, "execution_count": 29, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].min() #Started around 20, slowly over years increased to 50s" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "267" ] }, "execution_count": 13, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-2'].count() #4" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 1062 entries, 0 to 1061\n", "Data columns (total 4 columns):\n", "year 1062 non-null float64\n", "TOPEX/Poseidon 440 non-null float64\n", "Jason-1 412 non-null float64\n", "Jason-2 267 non-null float64\n", "dtypes: float64(4)\n", "memory usage: 33.3 KB\n" ] } ], "source": [ "data.info()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "1)Purpose of measurements, why millions were spent on them:" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "TOPEX/Poseidon:" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Mapping ocean surface topography, looking at sea level" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "\"TOPEX/Poseidon' radar altimeter provided the first continuous global coverage of the surface topography of the oceans.\"" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "\"TOPEX/Poseidon provided measurements of the surface height of 95 percent of the ice-free ocean to an accuracy of 3.3 centimeters.\"" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Ocean circulation patterns, and climate can also be better understood by this." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Jason-1:" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Continuation of researching ocean topography...So is Jason-2" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "2) Methods" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Altimeter= \"An altimeter or an altitude meter is an instrument used to measure the altitude of an object above a fixed level.\"" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "https://en.wikipedia.org/wiki/Altimeter" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Uses radar to get distance" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/projects/anaconda3/lib/python3.5/site-packages/numpy/lib/function_base.py:3834: RuntimeWarning: Invalid value encountered in percentile\n", " RuntimeWarning)\n" ] }, { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TOPEX/PoseidonJason-1Jason-2
count440.000000412.000000267.000000
mean-1.28154521.87150534.923745
std11.7880599.1706498.815706
min-26.770000-3.37000019.970000
25%NaNNaNNaN
50%NaNNaNNaN
75%NaNNaNNaN
max24.12000043.84000055.890000
\n", "
" ], "text/plain": [ " TOPEX/Poseidon Jason-1 Jason-2\n", "count 440.000000 412.000000 267.000000\n", "mean -1.281545 21.871505 34.923745\n", "std 11.788059 9.170649 8.815706\n", "min -26.770000 -3.370000 19.970000\n", "25% NaN NaN NaN\n", "50% NaN NaN NaN\n", "75% NaN NaN NaN\n", "max 24.120000 43.840000 55.890000" ] }, "execution_count": 3, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data.describe()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "jason1 = data['Jason-1'].dropna()\n", "#jason1" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": true }, "outputs": [ ], "source": [ "j1meansum = 0.0;\n", "j1count = 0;" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.0\n" ] } ], "source": [ "print (j1meansum)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "9011.06\n", "412\n" ] } ], "source": [ "j1meansum = 0.0;\n", "j1count = 0;\n", "for x in jason1:\n", " j1meansum += x\n", " j1count +=1\n", "print(j1meansum)\n", "print(j1count)" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "21.8715048544\n" ] } ], "source": [ "j1mean = j1meansum / j1count\n", "print (j1mean)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "34565.42686699028\n" ] } ], "source": [ "j1sum = 0.0;\n", "for x in jason1:\n", " j1sum = float(j1sum) + float((x-j1mean)**2)\n", "print (j1sum)" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "9.159512386196605" ] }, "execution_count": 50, "metadata": { }, "output_type": "execute_result" } ], "source": [ "j1std = float(np.sqrt(j1sum/j1count))\n", "j1std" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "43.84\n", "-3.37\n" ] } ], "source": [ "jason1 = data['Jason-1'].dropna()\n", "maxlist = -1000\n", "minlist = 1000000\n", "j1count = 0\n", "#orderlist = []\n", "for x in jason1:\n", " if (x > maxlist):\n", " maxlist = x\n", " #orderlist.append(x)\n", " if (x < minlist):\n", " minlist = x\n", " #orderlist.insert(0, x)\n", " x += 1\n", " \n", "print (maxlist)\n", "print (minlist)\n", "#print (orderlist)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "ename": "TypeError", "evalue": "list indices must be integers or slices, not numpy.float64", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mn\u001b[0m \u001b[0;32min\u001b[0m \u001b[0morderlist\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0morderlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0morderlist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0morderlist\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mTypeError\u001b[0m: list indices must be integers or slices, not numpy.float64" ] } ], "source": [ "orderlist = []\n", "for x in jason1:\n", " if (orderlist == []):\n", " orderlist.append(x)\n", " else:\n", " for n in orderlist:\n", " if (x >= orderlist[n]):\n", " orderlist.insert(n, x)\n", "print (orderlist)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "nan" ] }, "execution_count": 15, "metadata": { }, "output_type": "execute_result" } ], "source": [ "data['Jason-1'][2015.8995]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "year\n", "2003.3300 -3.37\n", "2002.0537 2.42\n", "2002.4340 3.85\n", "2002.4611 5.05\n", "2002.1898 5.32\n", "Name: Jason-1, dtype: float64" ] }, "execution_count": 18, "metadata": { }, "output_type": "execute_result" } ], "source": [ "jason1.head()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "orderlist = jason1.sort()\n", "print(orderlist)" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": true }, "outputs": [ ], "source": [ "orderlist = d" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/ifstatements.html" ] }, { "cell_type": "code", "execution_count": 83, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "def Jomeanstd(name):\n", " \"return standard deviation and mean of column 'name'\"\n", " \n", " numbers = data[name].dropna() ##getting rid of naN\n", " meansum = 0.0;\n", " countlist = 0;\n", " sumlist = 0.0;\n", " for x in numbers: ## counting how many are in list and adding up all values\n", " meansum += x\n", " countlist += 1\n", " meanlist = meansum/countlist ##gives the mean of the list\n", " #print (name, \" mean:\", meanlist)\n", " for x in numbers: ###adding up the sum of the squares of x_1-mean\n", " sumlist = float(sumlist) + float((x-meanlist)**2)\n", " stdlist = float(np.sqrt(sumlist/countlist))\n", " print (name, \" mean:\", meanlist)\n", " print (name, \" std:\", stdlist)\n", " return (meanlist, stdlist)" ] }, { "cell_type": "code", "execution_count": 86, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "TOPEX/Poseidon mean: -1.28154545455\n", "TOPEX/Poseidon std: 11.774655654981524\n", "Jason-1 mean: 21.8715048544\n", "Jason-1 std: 9.159512386196605\n", "Jason-2 mean: 34.9237453184\n", "Jason-2 std: 8.799181238443293\n" ] } ], "source": [ "ToPomean, ToPostd = Jomeanstd('TOPEX/Poseidon')\n", "J1mean, J1std = Jomeanstd('Jason-1')\n", "J2mean, J2std = Jomeanstd('Jason-2')" ] }, { "cell_type": "code", "execution_count": 87, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "43.743009708737837" ] }, "execution_count": 87, "metadata": { }, "output_type": "execute_result" } ], "source": [ "J1mean*2" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "https://explorable.com/calculate-standard-deviation" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "https://wiki.python.org/moin/ForLoop" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "3) Units are mm and years?" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "5) Data is arranged in a csv, with commas being the delimiter separating the values. There is also a rather large header." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "8) To make a clear concise form, put the data into a table, probably using pandas" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "10) What is the standard?" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": true }, "outputs": [ ], "source": [ ] } ], "metadata": { "kernelspec": { }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 4 }