Skip to content

Instantly share code, notes, and snippets.

View MiriamMakhyoun's full-sized avatar

Miriam Makhyoun MiriamMakhyoun

View GitHub Profile
@MiriamMakhyoun
MiriamMakhyoun / munging.py
Last active January 28, 2019 21:32
Step 1: Munging Data from California Independent System Operator's OASIS Platform
#gets data from API
import requests
from io import BytesIO
from zipfile import ZipFile
def QueryAPI(query_name):
api_url=f'http://oasis.caiso.com/oasisapi/SingleZip?queryname={query_name}&startdatetime=20180919T07:00-0000&enddatetime=20180920T07:00-0000&market_run_id=DAM&version=1'
response = requests.get(api_url)
zipfile = ZipFile(BytesIO(response.content))
output_url="/Users/miriammakhyoun/Desktop/Python Class 2018/Energy Storage/Data/Raw/"
@MiriamMakhyoun
MiriamMakhyoun / parse.py
Last active November 13, 2018 00:09
Step 2: Parsing data from XML into CSV using Element Tree (data from California Independent System Operator's OASIS Platform)
#!/usr/bin/env python3
#Make sure the file is executable if you plan to run it as a module
#>>>./parse2.py Data/Raw/
import os
import sys
from xml.etree import ElementTree
import csv
directory = sys.argv[1]
@MiriamMakhyoun
MiriamMakhyoun / crunch.py
Last active December 6, 2018 19:19
Crunch the Energy Storage Capacity and Market Price Data from a CSV format to Optimize Market Revenue
#Emulates the logic in this Google Sheet: https://docs.google.com/spreadsheets/d/1iFbXhb_Jv_ZGh9Yzt8CtokU-LeLRoNxMPwN8e-iLlyU/edit?usp=sharing
#populate_charge_discharge_values("/Users/miriammakhyoun/Desktop/Python Class 2018/Energy Storage/data_analysis.csv",200,20,4,.8,30,.2)
import numpy as np
import pandas as pd
def populate_charge_discharge_values(
file_path,
max_budget,
max_capacity,