Skip to content

Instantly share code, notes, and snippets.

View cgobat's full-sized avatar
🛰️

Caden Gobat cgobat

🛰️
View GitHub Profile
@cgobat
cgobat / NASA_images.py
Created March 26, 2020 17:36
Search NASA media library and display image results
import requests, matplotlib.pyplot as plt, json
from PIL import Image
from bs4 import BeautifulSoup as bs
def NASA_img(query,num):
endpoint = "https://images-api.nasa.gov/search?q="+str(query).replace(" ","+")
response = requests.get(endpoint)
results = json.loads(response.content)
@cgobat
cgobat / GW_GPACs.py
Created April 1, 2020 02:58
Reads and filters George Washington University courses that satisfy multiple GPAC (general education) requirements
import requests, json
from bs4 import BeautifulSoup as bs
from pprint import pprint
# Retrieve info from web
page = requests.get('https://advising.columbian.gwu.edu/general-education-courses')
soup = bs(page.content, 'html.parser')
main_content = soup.find('div',{"id":"main_content"})
# Generate a dictionary of GPAC categories and the courses that fall under them. Basically just converting
@cgobat
cgobat / pulsar_diagram.md
Last active April 28, 2020 05:15
ATNF pulsar catalog plotter: retrieves and parses data and generates a categorized, presentable plot of pulsar periods vs period time derivatives.
@cgobat
cgobat / sph_harm_viz.py
Last active May 27, 2020 01:25
3D spherical harmonic visualization capable superposing multiple user-defined Ylm functions.
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm, pyplot as plt
from scipy.special import sph_harm # (very convenient)
theta = np.linspace(0, 2*np.pi, 361) # define independent vars
phi = np.linspace(0, np.pi, 181)
THETA, PHI = np.meshgrid(theta, phi) # 2D versions of the independent variables
XYZ = np.array([np.sin(PHI) * np.sin(THETA), np.sin(PHI) * np.cos(THETA), np.cos(PHI)])
@cgobat
cgobat / montecarlo_pi.py
Created April 13, 2020 21:14
Simplistic implementation of a Monte-Carlo-type method to estimate pi
with open("randomstate.pkl","rb") as picklefile:
np.random.set_state(pickle.load(picklefile))
N = 100
trials = 50000
theta = np.linspace(0,2*np.pi,360)
fractions = np.array([])
for i in range(trials):
points = np.array([[2*x-1,2*y-1] for [x,y] in np.random.rand(N,2)])
C = np.array([point for point in points if point[0]**2+point[1]**2 <= 1])
fractions = np.append(fractions, len(C)/len(points))
@cgobat
cgobat / electric_vehicle.ino
Created April 14, 2020 02:52
Science Olympiad Electric Vehicle code. Target distance is set using 3 rotary dials and progress is counted using a hall effect sensor.
long cm; //goal distance
long target; //target # of pulses
volatile long pulses; //current # of pulses
long timer; //time elapsed since start
float conv = 10.208; //cm per 100 pulses
long gatecm = 900; //distance to run before slowing down
long gateTarget; //number of pulses the previous translates to
long dir; //current direction of motion
void setup()
@cgobat
cgobat / 00_ohmicity_analysis.ipynb
Last active April 23, 2020 03:02
Analysis of various electrical components and their effective resistances as a function of voltage
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgobat
cgobat / pulsars.md
Last active April 28, 2020 05:17
Collect and analyze pulsar information from a number of databases, with a focus on nulling. Mostly dynamic. WIP.
@cgobat
cgobat / LED_RC_circuit.ipynb
Last active April 23, 2023 16:58
Concurrent time-series analysis of light intensity and current decay in an RC+LED circuit
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.