This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Opens the image to be processed | |
Circle = imread('C:\Users\csrc-lab03\Desktop\yakal5.bmp'); | |
Circle = rgb2gray(Circle) | |
//Use edge() function sobel | |
edge_sobel = edge(Circle,'canny'); | |
imshow(edge_sobel); | |
imwrite(edge_sobel,'Circle_sobel.bmp'); | |
//Edge pixel coordinates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select SQLDATE, MonthYear, EventRootCode, GoldsteinScale, NumMentions, AvgTone, ActionGeo_CountryCode, ActionGeo_Lat, ActionGeo_Long | |
from `gdelt-bq.full.events` | |
where | |
SQLDATE > 20000101 and | |
ActionGeo_CountryCode = 'RP'; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.cm import ScalarMappable | |
from mpl_toolkits.basemap import Basemap | |
from matplotlib.animation import FuncAnimation | |
### Create a figure and draw a basemap | |
fig, ax = plt.subplots(figsize=(10,8), dpi=500) | |
m = Basemap(resolution='h', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
### Read in county data and drought info data | |
dr = pd.read_csv('rallies.csv') | |
dr1 = dr[['event_date', 'event_type', 'latitude', 'longitude', 'location']] | |
### Data cleansing | |
dr1.event_date = pd.to_datetime(dr1.event_date) | |
num_m = len(dr.event_date.unique()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Set county location values, drough level values, marker sizes (according to county size), colormap and title | |
x, y = m(dr_m.nth(0).longitude.tolist(), dr_m.nth(0).latitude.tolist()) | |
colors = (dr_m.nth(0).code).tolist() | |
sizes = (dr_m.nth(0).count1*80).tolist() | |
cmap = plt.cm.plasma#autumn_r | |
#cmap = plt.cm.hot_r | |
sm = ScalarMappable(cmap=cmap) | |
plt.title('Social Movement (Year-Month): '+dr_m.nth(0).event_date.iloc[0].strftime('%Y-%m')) | |
### Display the scatter plot and its colorbar (0-5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#assuming that x is a list of values and is not empty | |
#because we are not allowed to divide by 0 | |
def mean(x): | |
return sum(x) / len(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def median(x): | |
sorted_ = sorted(x) | |
N = len(x) | |
middle_value = N // 2 | |
if n % 2 != 0: #CASE 1: if N is odd | |
M = sorted_[middle_value] | |
else: #CASE 2: if N is odd | |
M = (sorted_[(middle_value) - 1] + sorted_[middle_value]) / 2 | |
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
random.seed( 30 ) #for replicability | |
n = 100 | |
y = [] | |
for i in range(n): | |
y += [random.randint(25, 50)] |
OlderNewer