Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Week6 - Fix bugs in average squares #138

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9e16337
Add skeleton of earthquakes solution
ageorgou Oct 23, 2020
e1194cc
create plots
kinianlo Oct 29, 2020
3cb8304
add bar for tick centering
kinianlo Oct 31, 2020
cdd65ce
Merge commit '9e1633747457d2168c0064433960de150d451bdf' into main
kinianlo Oct 31, 2020
31eca3d
add times Answers UCL-RITS/rse-classwork-2020#61
kinianlo Oct 31, 2020
c8ce7cd
Add test for times UCL-RITS/rse-classwork-2020#61
kinianlo Nov 1, 2020
86c3261
Add more tests
kinianlo Nov 9, 2020
9884d30
init travis CI
kinianlo Nov 9, 2020
a97001a
fix requirments.txt
kinianlo Nov 9, 2020
456f93f
remove python2.7 from .travis.yml
kinianlo Nov 9, 2020
3207e63
fix requiements
kinianlo Nov 9, 2020
d28de57
update pytest version in requirements.txt
kinianlo Nov 9, 2020
2f3ce2b
update requirements
kinianlo Nov 9, 2020
b6dc388
fix bugs
kinianlo Nov 9, 2020
3c4ee5e
empty requirements.txt
kinianlo Nov 9, 2020
d4e8023
add travis CI status to README
kinianlo Nov 9, 2020
17e9cc9
change status icon to week5 branch
kinianlo Nov 9, 2020
0827a24
update .traivs.yml to include coverage
kinianlo Nov 9, 2020
296435f
add codecov
kinianlo Nov 9, 2020
df84938
fix travis yaml
kinianlo Nov 9, 2020
79dfe29
fix tarvis yaml
kinianlo Nov 9, 2020
eb88676
fix testing bugs
kinianlo Nov 9, 2020
fddf219
Merge commit 'eb886763794cde62eb794e827c815900011b32ac' into testing
kinianlo Nov 9, 2020
6009d1a
Merge branch 'testing' into main
kinianlo Nov 9, 2020
abd688c
change travis badge to main
kinianlo Nov 9, 2020
607f860
delete requirements_conda.txt
kinianlo Nov 9, 2020
90483e1
add codecov badge
kinianlo Nov 9, 2020
9ed24ad
Code and structure for week06 docs exercises
HChughtai Nov 10, 2020
8423020
add gitignore
kinianlo Nov 10, 2020
65870ad
update gitignore
kinianlo Nov 10, 2020
a2e3db0
add iss passes
kinianlo Nov 10, 2020
a86c1f7
remove python 2.7 from travis
kinianlo Nov 10, 2020
b3dbde3
update fixture
kinianlo Nov 19, 2020
492f123
Merge commit '9ed24ad70267877f4e851de7080e6eb3941a17e2' into main
kinianlo Nov 19, 2020
3f813dc
fix doctest bugs
kinianlo Nov 19, 2020
cdafac6
Add docs
kinianlo Nov 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
create plots
  • Loading branch information
kinianlo committed Oct 29, 2020
commit e1194cc5e7d90045b8f78089f088c56348bb0fbe
70 changes: 70 additions & 0 deletions week04/quakes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import requests
import json
import time
import datetime
import matplotlib.pyplot as plt

quakes = requests.get("http://earthquake.usgs.gov/fdsnws/event/1/query.geojson",
params={
'starttime': "2000-01-01",
"maxlatitude": "58.723",
"minlatitude": "50.008",
"maxlongitude": "1.67",
"minlongitude": "-9.756",
"minmagnitude": "1",
"endtime": "2018-10-11",
"orderby": "time-asc"}
)

quakes = json.loads(quakes.text)
print(quakes['features'][0]['properties'].keys())

max_mag = 0
max_quake = None
num_quakes = len(quakes['features'])
for f in quakes['features']:
if f['properties']['mag'] > max_mag:
max_mag = f['properties']['mag']
max_quake = f


year_list = []
mag_dict = {}
years = []
mag_avg = []

for f in quakes['features']:
t = f['properties']['time']
mag = f['properties']['mag']
year = datetime.datetime.fromtimestamp(t/1000).year
year_list.append(year)

if year in mag_dict.keys():
mag_dict[year].append(mag)
else:
mag_dict[year] = [mag]

for k in mag_dict.keys():
years.append(k)
mag_avg.append(sum(mag_dict[k])/len(mag_dict[k]))

plt.hist(year_list, bins=18)
plt.xticks(range(min(year_list), max(year_list)+1))
plt.xlabel('year')
plt.ylabel('frequency')
plt.show()
print(year_list)

plt.plot(years, mag_avg)
plt.xticks(range(min(year_list), max(year_list)+1))
plt.xlabel('year')
plt.ylabel('Average Magnitude')
plt.show()

print(max_mag)
print(max_quake)

print("The biggest quake was in %s (%s), with Mag %s" % (max_quake['properties']['place'],
max_quake['geometry']['coordinates'], max_quake['properties']['mag']))
print("https://www.google.com/maps/search/?api=1&query=%s,%s" % (max_quake['geometry']['coordinates'][1],
max_quake['geometry']['coordinates'][0]))