Skip to content

Instantly share code, notes, and snippets.

View bradyrx's full-sized avatar

Riley Brady bradyrx

View GitHub Profile
"""
Test script for parallelization with groupby() objects in xarray.
"""
import numpy as np
import xarray as xr
from scipy import stats
def linear_regression(x):
t = range(len(x))
@bradyrx
bradyrx / subset_particle_init.py
Last active July 9, 2018 18:42
Create subset of LIGHT particle initialization file to only seed specific region of ocean
"""
Subset Particle Init
--------------------
Author: Riley X. Brady
Date: July 9th, 2018
Given a LIGHT particle initialization file and latitude/longitude bounds,
this script will subset the global seeding and only seed a specific
subregion of the ocean.
"""
@bradyrx
bradyrx / pearsonr.py
Created August 23, 2018 17:09
Compute pearson r accounting for autocorrelation (generates an n_effective)
import numpy as np
import scipy.stats as ss
from scipy.stats.stats import pearsonr as pr
def pearsonr(x, y, two_sided=True):
"""
Computes the Pearson product-moment coefficient of linear correlation. This
version calculates the effective degrees of freedom, accounting for autocorrelation
within each time series that could fluff the significance of the correlation.
@bradyrx
bradyrx / run_python_script.sh
Created August 27, 2018 16:25
Run python script through batch submission on Cheyenne.
#!/bin/bash
#PBS -A PROJECT_CODE
#PBS -N JOBNAME
#PBS -l walltime=01:00:00
#PBS -M EMAIL
#PBS -q regular
#PBS -l select=1:ncpus=1
#PBS -m abe
script=global_seasonal_internal_magnitudes.py
@bradyrx
bradyrx / generate_E3SM_case.sh
Created November 4, 2018 19:42
automated way to build an MPAS case with particles
#!/bin/bash
# Author : Riley X. Brady
# Date : 11/04/2018
#
# This script sets up a g-case experiment with lagrangian particles, following
# all steps until submit.
# setup
res=T62_oEC60to30v3
nproc_ocean=512
@bradyrx
bradyrx / manual_coarsen.py
Last active January 9, 2019 15:21
Manually coarsen horizontal seeding pattern in LIGHT
# Manual Coarsen
# --------------
# Author : Riley X. Brady
# Date : 11/14/2018
# --------------
# The pyAMG method of coarsening our particles traverses in 3D, rather than
# just removing full 2D columns. This method simply strides through the
# lat and lon list, removing full columns.
#
# NOTE: Run make_particle_file.py first without any coarsening turned on.
@bradyrx
bradyrx / argparse_template.py
Created February 5, 2019 16:47
template for code using argparse
import argparse
def main(f_in):
pass
if __name__ == '__main__':
ap = argparse.ArgumentParser(description=None)
ap.add_argument('-i', '--input', required=True, type=str)
@bradyrx
bradyrx / regrid_standard_to_POP.ncl
Created February 5, 2019 21:41
regrid a rectilinear grid to a POP ocean grid.
;----------------------------------------------------------------------
; ESMF_regrid_28.ncl
;
; Author: Riley X. Brady
; Date: February 5th, 2019
; *This script was adapted from the following example:
; http://www.ncl.ucar.edu/Applications/Scripts/ESMF_regrid_28.ncl
;
; - takes rectilinear global grid (e.g. 180x360) and regrids to POP 1 degree.
; - plots a single time slice of both to make sure the comparison looks good.
@bradyrx
bradyrx / .gitconfig
Created March 11, 2019 20:09
sample git config file
[user]
name = Riley X. Brady
email = riley.brady@colorado.edu
[core]
editor = /usr/local/bin/vim
autocrlf = input
whitespace = trailing-space
excludesfile = ~/.git_core_excludes
edits = /usr/bin/vim
[alias]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.