Skip to content

Instantly share code, notes, and snippets.

View barronh's full-sized avatar

Barron H. Henderson barronh

View GitHub Profile
@barronh
barronh / tempo_geoxo_meeting.ipynb
Last active May 3, 2024 14:46
TEMPO_GeoXO_Meeting.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@barronh
barronh / backup.py
Last active April 12, 2024 17:02
Backup Project Scripts
#!/usr/bin/env python
__doc__ = """
Overview
========
Module designed to make backups of scripts (.sh, .csh, .py), makefiles,
configuration files, and README files.
Contents
--------
@barronh
barronh / cmaq_dust.py
Last active April 23, 2024 16:07
Offline CMAQ Dust Emulator
__doc__ = """
Offline CMAQ Python WBD approximator
====================================
github.com/USEPA/CMAQ/emis/emis/DUST_EMIS.F routines and functions converted
from Fortran to Python. All modules are replaced by inline code and direct
access to MCIP files. The original DUST_EMIS.F was developed by Foroutan et
al. (https://dx.doi.org/10.1002/2016MS0008230.
To-Do:
@barronh
barronh / pair_rsigcmaq.py
Last active March 7, 2024 21:44
Pair RSIG data with CMAQ
__all__ = ['pair_rsigcmaq']
__doc__ = """
pair_rsigcmaq is designed to pair RSIG data with CMAQ files.
Example:
from pair_rsigcmaq import pair_rsigcmaq
import pandas a pd
outpath = pair_rsigcmaq('CMAQ_ACONC_20160101', 'O3', 'airnow.ozone')
@barronh
barronh / rundayenv.sh
Created March 6, 2024 16:17
Run Scripts with strftime to make day-specific environments from a template file.
#!/bin/bash
POSITIONAL_ARGS=()
PREFIX="ENV"
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
echo "Usage"
echo "-----"
echo " $0 [--prefix=PREFIX] TEMPLATE_ENV STARTDAY [ENDDAY [SCRIPT]]"
@barronh
barronh / cmaq_taylor_example.py
Last active February 7, 2024 14:32
Python Taylor Diagram
"""
This example calculates statistics for a single day from the EPA EQUATES CMAQ simulation for 2018-06-14
and creates a taylor diagram.
"""
import pyrsig
import pandas as pd
import pyproj
import taylordiagram as td
@barronh
barronh / hrrr.py
Created November 29, 2023 15:35
Retrieve HRRR via Open Data on AWS and Zarr
__doc__ = """
# Overview
This example shows how to open High Resolution Rapid Refresh (HRRR) meteorology
"surfaces." These surfaces are slices in vertical space to create single level
maps of variables like temperature, wind speed components, pressure, etc. Each
surface is opened using the Zarr archive described in Amazon's opendata registry
described at https://registry.opendata.aws/noaa-hrrr-pds/.
# Examples
@barronh
barronh / lonlatarea.py
Created October 5, 2023 14:05
Area on a regular lat/lon grid
__all__ = ['getarea']
def getarea(nlat, nlon, late=None, R=6371000.):
"""
Arguments
---------
nlat : int
Number of latitude bands
nlon : int
@barronh
barronh / purpleair_epa.py
Last active September 30, 2023 11:40
EPA PurpleAir Corrections
def purpleair_epa(pa, rh, method='extended'):
"""
Corrects PM2.5 using the US-wide original or extended correction.
The "original" correction was developed by Barkjohn et al. 2021[1]
The "extended" correction is used in teh Fire and Smoke Map as described in
the QA[2] document in Eq. 4 (implemented Oct 2021). This equation is cited
and evaluated in Jaffe et al.(2023)[3]
Use at your own risk and submit updates if you find issues.
@barronh
barronh / mpestats.py
Last active September 26, 2023 13:31
Air Quality Model Performance Metrics
def getstats(df, refkey='obs'):
"""
Calculate typical model statistics
[1] https://epa.gov/sites/production/files/2015-11/modelperformancestatisticsdefinitions.docx
Example assuming you have a csv with 'obs' and 'mod' columns:
```
import pandas as pd