<jupyter_start><jupyter_text>Practice Problems Lecture 8Answer each number in a separate cellRename this notebook with your last name and the lecture   ex. Cych_B_08    Turn-in this notebook on Canvas.   1.  Adding notes in matplotlib.pyplot    - Similar to the lecture:        - Read the file 'Datasets/seismicRecord/earthquake.txt'into a pandas DataFrame        - Change the units of the x-axis to time in minutes    - Make a plot of velocity against time        - Include a label for the x and y-axis.         - Plot the line red        - Use **help( )** to learn about the matplotlib function **title( )** then add this title: 'Earthquake observed at Pinyon Flat Observatory'    - Add a note        - Place the note at x = 4 and y = 170000         - Write the text 'P-S delay interval'        - Color the text blue        - rotate the text so that it is vertical (hint: use rotation = 90)2. Panda DataFrames    - Import the file 'Datasets/TravelTimeDelta/DeltaTime.txt' into a panda DataFrame    - Get acquainted with the DataFrame:        - print out the name of the columns        - print out the first few lines of the DataFrame        - change the column headers         - print out the new column headers    - Convert the P wave arrival from minutes and seconds to decimal minutes. Add the P wave arrival, in decimal minutes, to the data frame    - Calculate the S wave arrival by:        1. Converting S-P to decimal minutes        2. Adding P in decimal minutes to S-P in decimal minutes     3. Additional matplotlib.pyplot practice    - Plot Degrees against decimal minutes for both the Primary wave arrival and the Secondary wave arrival    - Color the primary wave green and label it "P wave"    - Color the shear wave blue and label it "Shear wave"    - Add a legend in the lower right hand corner of your figure     - Add a title to your figure     - Add a label to the x and y axis     - Save the figure    - Remove the legend from your plot. Insert the text  "Primary wave" and "Shear wave" above the appropriate line    - Save the new figure<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
EQ=np.loadtxt('../Datasets/seismicRecord/earthquake.txt') # read in data
time_units=np.arange(len(EQ)) # makes an array of arbitrary time units same length as data
minutes = time_units/1200
plt.plot(minutes, EQ,'r-') # plots as a red line
plt.xlabel('Time (Minutes)') # puts a label on the X axis
plt.ylabel('Velocity'); # puts a label on the Y axis
plt.title('Earthquake observed at Pinyon Flat Observatory');
plt.text(4,10000,'P-S delay interval', rotation = 90, c='b', va='bottom')
help(plt.text)
import pandas as pd

travel_time = pd.read_csv('../Datasets/TravelTimeDelta/DeltaTime.txt',
                          delim_whitespace=True,skiprows=2,header=0)
import os
#os.getcwd()
%pycat 'lats.txt'
#os.chdir('C:/Users/bjpd/Documents/GitHub/Python-for-Geosciences/Practice_Problems')
help(pd.read_csv)
travel_time.describe()
print(travel_time)
travel_time[['Deg','S']]
list(travel_time.columns)
col_dict = {'Deg':'Degrees', 'M':'P_wave_min','S':'P_wave_sec', 'M.1': 'S-P_min', 'S.1':'S-P_sec' 
           }
travel_time = travel_time.rename(columns = col_dict)
list(travel_time.columns)<jupyter_output><empty_output><jupyter_text>calculate decimal minutes for P wave<jupyter_code>travel_time['P_decimal_minutes'] = travel_time['P_wave_min'] + travel_time['P_wave_sec']/60
travel_time.head()
travel_time['S-P_decimal_minutes'] = travel_time['S-P_min'] + travel_time['S-P_sec']/60
travel_time.head()
travel_time['S-P_dec_min'] = (travel_time['S-P_min'] + travel_time['S-P_sec']/60)
travel_time.head()<jupyter_output><empty_output><jupyter_text>Let's check out the difference in output from different bracket on a DF.<jupyter_code>mything = travel_time[['S-P_sec']]
type(mything)
mything = travel_time['S-P_sec']
type(mything)<jupyter_output><empty_output><jupyter_text>Now we'll calculate the decimal minutes version of S-P time<jupyter_code>travel_time['S-P_dec_min'] = (travel_time['S-P_min'] + travel_time['S-P_sec']/60)
travel_time['S-arr_dec_min'] = (travel_time['S-P_min'] + travel_time['S-P_sec']/60) + travel_time['P_decimal_minutes']
travel_time.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10365997638724911, 'fraction_numerical': 0.010153482880755607, 'mean_word_length': 4.0488676996424315, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '645723', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1325, 'n_words': 446, 'path': 'Practice_Problems/Lecture_08_Practice_Problems-KEY.ipynb', 'repo_name': 'percyd/Python-for-Geosciences', 'size': '4235'}