Skip to content

Instantly share code, notes, and snippets.

View dneuman's full-sized avatar

Dan Neuman dneuman

  • Ottawa, Canada
  • 00:31 (UTC -04:00)
  • Hometown @dan613@ottawa.place
View GitHub Profile
@dneuman
dneuman / Impulse_Response.py
Created February 25, 2022 21:25
Estimate Earth impulse response to changes in energy forcing.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Derive Earth system response from atmospheric composition and
temperature record using Fourier Ttansform to perform a deconvolution.
Created on Thu Feb 24 18:42:31 2022
@author: dan
"""
@dneuman
dneuman / 1_plate.py
Created June 22, 2021 01:25
Solving 1 plate problem assuming finite conduction between hot and cold side.
from sympy import *
init_session(quiet=True)
from sympy.abc import epsilon, sigma, c, w
var('P1 P2 P12 Pin T1 T2')
const = dict(sigma=5.67e-8, # Stefan-Boltzmann constant
epsilon=1.0, # emissivity of flat black paint
c = 401.) # W/mK, conductivity of copper plate
# In[111]:
@dneuman
dneuman / tmp_compare.txt
Created June 28, 2019 01:45
Download and process NOAA 5-min data
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 25 18:45:37 2019
@author: dan
https://www.ncdc.noaa.gov/crn/qcdatasets.html
Change `filebase` for your local storage location
@dneuman
dneuman / WrappedText.py
Last active February 7, 2024 06:10
Text Wrapping in Matplotlib
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Wrapping arbitrary text to a defined box is not supported at least up to
Matplotlib 3.1. This is because the wrap width is hardwired to the Figure box.
A way around this is to override the _get_wrap_line_width method, either with
a new function, or by subclassing the matplotlib.text.Text class. Both
methods are shown below.
@dneuman
dneuman / Dialogue.txt
Created May 25, 2019 02:39
French Phrases
Pronoms relatifs
Est-ce que les enfants veulent des biscuits?
Oui, Ils en veulent.
Est-ce que Annie va terminer le rapport dans une demi-heure?
Oui, elle va le terminer dans une demi-heure.
Est-ce que tu es allé au restaurant La Belle marquise vendredi?
Oui, J'y suis allé vendredi.
@dneuman
dneuman / clock.html
Last active September 30, 2018 17:21
Simple HTML page to run on your phone to turn it into a simple clock.
<!DOCTYPE html>
<!--
Simple html page that creates a clock for old phones with old browsers.
Save this file in a folder (eg. as clock.html) on your computer, then
start a web server in a terminal window from that folder.
A simple way to do this is open a terminal window and move to the folder
holding the script (don't type '$', that's your prompt):
$ cd path/to/folder
@dneuman
dneuman / mirror.py
Created October 16, 2017 10:17
Utility function to use with matplotlib.pyplot to put a mirrored y-axis on the right of the plot. Uses state of pyplot to determine appropriate axes.
import matplotlib.pyplot as plt
import matplotlib.ticker as tk
def Mirror(prec=1):
"""Adds y-axis that's a mirror of the y-axis on left.
Parameters
----------
prec : int (opt) Default=1
Number of significant digits (precision) to use on scale
@dneuman
dneuman / WeightedMovingAverage.py
Last active October 16, 2017 10:35
Weighted Moving Average Smoother in Python using Pandas and Numpy
import numpy as np
import pandas as pd
def Hanning(size):
w = np.hanning(size+2)
w = np.array(w[1:-1]) # remove zeros at endpoints
return (w / max(w))
def WeightedMovingAverage(fs, size, pad=True, winType=Hanning, wts=None):
"""Apply a weighted moving average on the supplied series.
@dneuman
dneuman / lowess.py
Last active May 30, 2021 19:26
Lowess Smoothing Function for Python using Pandas and Numpy
import numpy as np
import pandas as pd
def Lowess(data, f=2./3., pts=None, itn=3, order=1):
"""Fits a nonparametric regression curve to a scatterplot.
Parameters
----------
data : pandas.Series
Data points in the scatterplot. The