{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2.18 Programming for Geoscientists class test - 14:00-16:00 17th December 2015" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#Test instructions\n", "\n", "* This test contains **4** questions each of which should be answered.\n", "* Write your program in a Python cell just under each question.\n", "* You can write an explanation of your solution as comments in your code.\n", "* You should work with the two data files ([VostokStation.txt](https://raw.githubusercontent.com/ggorman/Introduction-to-programming-for-geoscientists/master/notebook/data/VostokStation.txt) and [last_months_earthquakes.csv](https://raw.githubusercontent.com/ggorman/Introduction-to-programming-for-geoscientists/master/notebook/data/last_months_earthquakes.csv)) in their original form. They must **not** be modified.\n", "* In each case your solution program must fulfil all of the instructions - please check the instructions carefully and double check that your program fulfils all of the given instructions.\n", "* Save your work regularly.\n", "* At the end of the test you should email your IPython notebook document (i.e. this document) to [Christian T. Jacobs](http://www.imperial.ac.uk/people/c.jacobs10) at c.jacobs10@imperial.ac.uk **and also** [Gerard J. Gorman](http://www.imperial.ac.uk/people/g.gorman) at g.gorman@imperial.ac.uk" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Question 1\n", "\n", "1. Generate $x$ coordinates between $1$ and $2$ (inclusive) with spacing $0.01$. The coordinates are given by the formula $x_i = 1 + ih$ where $h=0.01$ and $i$ runs over integers $0,1,...,100$. Compute the $x_i$ values and put them into a python *list*. Use a *for* loop and append each new $x_i$ value to a list that is initially empty.\n", "2. Use a formatted print statement to print out all the values in the list." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##Question 2\n", "\n", "The longitudinal wave velocity in a material is given by the equation:\n", "$$V_p = \\sqrt{\\frac{k+4\\mu/3}{\\rho}},$$\n", "where $V_p$ is the longitudinal wave velocity, $k$ is the bulk modulus, $\\mu$ is the shear modulus and $\\rho$ is the density. The shear wave velocity is given by the equation:\n", "$$V_s = \\sqrt{\\frac{\\mu}{\\rho}},$$\n", "where $V_s$ is the shear velocity.\n", "\n", "1. Write a *function* that takes as arguments $k$, $\\mu$ and $\\rho$, and returns $V_p$ and $V_s$.\n", "2. Use this function to calculate the longitudinal and shear wave velocities for quartz, clay and water using parameters from the table below. Print out the results using a formatted print statement.\n", "\n", "| Material | Shear modulus (GPa) | Bulk modulus (GPa) | Density (kg/m^3)|\n", "|------------------------|---------------------|--------------------|-----------------|\n", "|Quartz | 44 | 38 | 2650 | \n", "|Clay | 6.85 | 20.9 | 2580 |\n", "|Water | 0 | 2.29 | 1000 |\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 3\n", "\n", "The file [VostokStation.txt](data/VostokStation.txt) in the library data folder contains data derived from ice core data at Vostok Station. Each line contains the age of the ice, temperature at which the ice formed, the concentration of carbon dioxide and concentration of methane.\n", "\n", "1. Write a program to read in the data and store each column in its own array.\n", "2. Create three plots: temperature versus years; carbon dioxide level versus years; and methane level versus years." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 4\n", "\n", "The file [last_months_earthquakes.csv](data/last_months_earthquakes.csv) in the data folder contains a list of earthquakes from around the world over the past month. Each field is delimited by a comma.\n", "\n", "1. Write a program that reads in the latitude-longitude coordinates, the depth and the magnitude (written as \"mag\" in the header) of each earthquake.\n", "2. Use the coordinates to plot the position of each earthquake as an individual point.\n", "3. Ensure that the x-axis is bounded between -180 and 180, and the y-axis is bounded between -90 and 90.\n", "4. Compute the mean earthquake depth and magnitude.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.2" } }, "nbformat": 4, "nbformat_minor": 1 }