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
from datetime import datetime, timedelta | |
base = datetime.today() | |
numdays = 5 | |
date_list = [base - timedelta(days=x) for x in range(0,numdays)] |
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
from datetime import datetime | |
dates = ['01/01/2016 04:50','01/01/2016 05:50','01/01/2016 06:50','01/01/2016 07:50'] | |
DATE = [datetime.strptime(x,'%m/%d/%Y %H:%M') for x in dates] |
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
DATES = np.array([]) | |
for i in dates: | |
DATES = np.append(DATES,datetime.strptime(i,'%m/%d/%Y %H%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
# where dates is a list or numpy array of epoch dates... | |
DATE = [datetime.utcfromtimestamp(x) for x in dates] |
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 numpy as np | |
import datetime | |
def datestr_to_datetime(x): | |
return datetime.datetime.strptime(x,'%Y-%m-%dT%H:%M:%SZ') | |
# where dates is some list of dates as a string... | |
# vectorize the function | |
converttime = np.vectorize(datestr_to_datetime) | |
DATES = converttime(dates) |
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
# To untar just about everything | |
tar -xzvf models.tar.gz 20160101/models/hrrr/ | |
# To untar just the HRRR pressure fields for analysis hours | |
tar -zxvf models.tar.gz --wildcards --no-anchored 'hrrr.t*z.wrfprsf00.grib2' | |
$ to untar just the HRRR surface fields for analysis hours | |
tar -zxvf models.tar.gz --wildcards --no-anchored 'hrrr.t*z.wrfsfcf00.grib2' |
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
# Brian Blaylock | |
# ATMOS 6910 Homework | |
# 10 November 2016 | |
# Look at the figures here: | |
# http://kbkb-wx-python.blogspot.com/2016/11/verifying-gfs-dewpoint-data-with.html | |
""" | |
[X] Reads a GRiB forecast file from the GFS (15%) | |
[X] Extracts Temperature and Relative Humidity from ingest (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
ffmpeg -f image2 -pattern_type glob -framerate 6 -i '*.png' foo.avi | |
# Retain high resolution | |
ffmpeg -f image2 -pattern_type glob -framerate 6 -i '*.png' -vb 20M foo.avi | |
# Convert .mov to .avi | |
ffmpeg -i file.mov file.avi |
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 os | |
OUTDIR = '/this/path/will/be/created/' | |
if not os.path.exists(OUTDIR): | |
os.makedirs(OUTDIR) |
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 multiprocessing | |
from multiprocessing.dummy import Pool as ThreadPool | |
import numpy as np | |
def my_multipro(items, func, max_cpus=12): | |
"""Do an embarrassingly parallel task using multiprocessing. | |
Use this for CPU bound tasks. |
OlderNewer