This file contains hidden or 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
from pdf2image import convert_from_path | |
from PyPDF2 import PdfFileReader | |
def pdf_to_image(file: str, page_num=0, output_file=None) -> Image: | |
""" Convert a PDF to a PIL Image. """ | |
pdf_page = PdfFileReader(open(file, 'rb')).getPage(page_num) | |
pdf_shape = pdf_page.mediaBox | |
pdf_height = pdf_shape[3] - pdf_shape[1] | |
pdf_width = pdf_shape[2] - pdf_shape[0] |
This file contains hidden or 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 os | |
def listdirs(path='./', filetype='.*'): | |
""" List all files in directory. """ | |
output = [] | |
for root, dirs, files in os.walk(path): | |
for file in files: | |
if filetype in ['.*', '*']: |
This file contains hidden or 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 pretty_size(size): | |
"""Pretty prints a torch.Size object""" | |
assert(isinstance(size, torch.Size)) | |
return " × ".join(map(str, size)) | |
def bytes2human(n, format='%(value).1f %(symbol)s', symbols='customary'): | |
""" | |
Convert n bytes into a human readable string based on format. | |
symbols can be either "customary", "customary_ext", "iec" or "iec_ext", |
This file contains hidden or 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
""" | |
@author: dcbark01 | |
@date: Nov 2019 | |
@license: MIT | |
""" | |
import os | |
import json | |
import shlex | |
import subprocess |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import matplotlib.dates as mdates | |
# if your dates are strings you need this step | |
df.Date = pd.to_datetime(df.Date) | |
fig,ax = plt.subplots() | |
ax.plot_date(df.Date,df.A) | |
ax.plot_date(df.Date,df.B) |
This file contains hidden or 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
#!/usr/bin/env bash | |
# ---------------------------- INSTALL NOTES ---------------------------- | |
# To properly setup the AWS CLI, make sure that this shell script is run with the two required positional args: | |
# $1 :: (string) AWS Access Key ID | |
# $2 :: (string) AWS Secret Key | |
# | |
# Also make sure to give the script permission to run!: | |
# chmod 755 /home/ec2-user/install.sh | |
# |
This file contains hidden or 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 matplotlib.pyplot as plt | |
from FloodScraper import FloodScraper | |
# User Inputs | |
gage_number = 475 | |
reported_from = '09/02/2017 07:31:00 AM' | |
last = '7 Days' | |
# Create scraper interest and run a query |
This file contains hidden or 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 the FloodScraper Module | |
from FloodScraper import FloodScraper | |
# User inputs | |
gage_number = 520 | |
reported_from = '09/02/2017 07:31:00 AM' | |
last = '7 Days' | |
filename = 'gage_data.json' | |
# Create scraper interest and run a query |
This file contains hidden or 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 the FloodScraper Module | |
from FloodScraper import FloodScraper | |
# User inputs | |
gage_number = 520 | |
reported_from = '09/02/2017 07:31:00 AM' | |
last = '6 Hours' | |
# Create scraper interest and run a query | |
scraper = FloodScraper() |
This file contains hidden or 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
value | ||
---|---|---|
2018-08-20 12:05:10.000000 | 0 | |
2018-08-20 12:05:19.888677 | 1 | |
2018-08-20 12:05:24.758246 | 1 | |
2018-08-20 12:05:25.584516 | 0 | |
2018-08-20 12:05:32.897718 | 1 | |
2018-08-20 12:05:36.799978 | 1 | |
2018-08-20 12:05:44.782406 | 1 | |
2018-08-20 12:05:45.493593 | 0 | |
2018-08-20 12:05:52.628990 | 1 |