Skip to content

Instantly share code, notes, and snippets.

View deeplycloudy's full-sized avatar

Eric Bruning deeplycloudy

  • Lubbock, TX
View GitHub Profile
@deeplycloudy
deeplycloudy / gist:a13b198d2660f0b30bf7c3994a07b3e6
Created September 7, 2023 16:08
Windows doesn't like this conda environment
name: atmo5331
channels:
- conda-forge
dependencies:
- python
- jupyterlab
- numpy
- scipy
- pandas
- xarray
@deeplycloudy
deeplycloudy / 20220809-1000Z-GLM-Wisconsin-non-lightning-events.ipynb
Last active August 9, 2022 18:26
20220809-1000Z-GLM-Wisconsin-non-lightning-events
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@deeplycloudy
deeplycloudy / cartopy_feature_distance.py
Created November 19, 2021 23:22
Distance from Cartopy feature polygon
import cartopy.feature as cfeature
import pyproj
from shapely.geometry import Point
from shapely.ops import transform as shapely_transform
# Some location of interest. Also used as center of projection.
wgs84_pt = Point(-72.2495, 43.886)
# Set up projections
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@deeplycloudy
deeplycloudy / get_dois.sh
Created June 1, 2021 22:26
DOI URLs scraped from webpages
# Here’s the URL to a journal’s search results page for papers from the Geostationary Lightning Mapper that
# were published from 2018-2021. There are several pages of results; below is an example of the third and final URL
# Download the webpage. Do this for each page of the search results, changing the URL and output filename:
curl "https://journals.ametsoc.org/search?access_0=all&fromDate=2018&page=3&pageSize=50&q1=geostationary+lightning+mapper&sort=relevance&toDate=2021" > page3dois.txt
# Then concatenate all three files, and save out just the DOIs linked on each page.
cat page[1-3]dois.txt | grep -Eoi '<a [^>]+>' |
@deeplycloudy
deeplycloudy / lidar3dep.py
Created May 28, 2020 02:19
USGS 3DEP Lidar elevation data with xarray, rasterio, and matplotlib
import matplotlib.pyplot as plt
import xarray as xr
import glob
# The code below is for 4 DEMs that cover the Montford Dam that forms Lake Alan Henry.
# Download geotiffs here.
: https://viewer.nationalmap.gov/basic/?basemap=b1&category=ned,nedsrc&q=&zoom=4&bbox=-139.74609375,10.14193169,-54.22851563,61.14323525&preview=&avail=&refpoly=
fns = glob.glob('/Users/ebruning/Downloads/*.tif')
# ds=xr.open_rasterio('/Users/ebruning/Downloads/USGS_one_meter_x31y366_TX_West_Central_B12_2018.tif')
@deeplycloudy
deeplycloudy / getbib.sh
Created March 24, 2020 16:47
Use dx.doi.org service to get a BibTeX-formatted reference from a DOI.
#!/bin/bash
# | pbcopy; pbpaste are mac-only commands; delete to simply print to the shell.
# Use: getbib $DOI where $DOI is something like 10.xxx/xxxxxx
getbib(){
curl -LH "Accept:text/bibliography; style=bibtex" http://dx.doi.org/$1 2>/dev/null | cut -c 2- | pbcopy ; pbpaste
}
@deeplycloudy
deeplycloudy / iem_nexrad_wms_cartopy.py
Last active March 7, 2019 18:57
Overlay IEM NEXRAD composite on Cartopy
""" Overlay IEM NEXRAD composite on Cartopy for any date or time in the
long-running IEM archive. This works for any target projection, with the
reprojection handled by the Cartopy WMS functionality.
If you don't enter a time on an even 5 min boundary, you will get a blank map.
"""
iem_wms_nexrad = 'https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi?'
layers = ["nexrad-n0r-wmst"]
wms_kw = {"time":"2017-10-22T05:15:00Z", "transparent":'true'}
@deeplycloudy
deeplycloudy / extract_unique_el_sweep.py
Created December 7, 2018 21:59
Eliminate duplicate elevation angles in a pyart radar object (e.g., 88D SAILS)
def get_vcp(radar):
""" Return a list of elevation angles representative of each sweep.
These are the median of the elevation angles in each sweep, which are
more likely to be identical than the mean due to change of elevation angle
at the beginning and end of each sweep.
"""
vcp = [np.median(el_this_sweep) for el_this_sweep in radar.iter_elevation()]
return np.asarray(vcp, dtype=radar.elevation['data'].dtype)
def unique_sweeps_by_elevation_angle(radar, tol=0.05):
@deeplycloudy
deeplycloudy / derivatives.py
Created July 1, 2016 17:30
Gradient (4th order accuracy) and laplacian (3rd order accuracy) functions for numpy arrays.
import numpy as np
#4th order accurate gradient function based on 2nd order version from http://projects.scipy.org/scipy/numpy/browser/trunk/numpy/lib/function_base.py
def gradientO4(f, *varargs):
"""Calculate the fourth-order-accurate gradient of an N-dimensional scalar function.
Uses central differences on the interior and first differences on boundaries
to give the same shape.
Inputs: