Skip to content

Instantly share code, notes, and snippets.

View chrisb13's full-sized avatar

Christopher Bull chrisb13

View GitHub Profile
@chrisb13
chrisb13 / TasmanSeaBoxPlot.py
Last active January 25, 2019 16:54
NOW code for Tasman Sea boxplot
if paper_case=='20170113_EACnowClimateChange01':
section_description_dict=collections.OrderedDict()
section_description_dict['AB']=[ 60, 61,217,226,0,54,'zonal' ]
section_description_dict['BC']=[ 60, 61,226,303,0,54,'zonal' ]
section_description_dict['GD']=[ 85,128,311,312,0,54,'meridional' ]
section_description_dict['FE']=[127,128,239,247,0,54,'zonal' ]
section_description_dict['ED']=[127,128,247,311,0,54,'zonal' ]
section_description_dict['IH']=[ 46,58 ,212,213,0,54,'meridional' ]
section_description_dict['JK']=[ 85,86 ,224,231,0,54,'zonal' ]
section_description_dict['PQ']=[ 68,80 ,212,213,0,54,'meridional' ]
lg.info("")
lg.info("Running check to see if changes found in "+cfgf+" are now in: "+ofile)
#run quick check to make sure all diff'd parameters were inserted
#(still uses f90nml, so not exactly independent)
with open(ofile) as nml_file:
new_nml = f90nml.read(nml_file)
for top_key in diff[cfgf].keys():
for bot_key in diff[cfgf][top_key].keys():
# assert(new_nml[top_key][bot_key]==diff[cfgf][top_key][bot_key]),ofile + " did not get created correctly"
# print(top_key,bot_key,new_nml[top_key][bot_key],diff[cfgf][top_key][bot_key])
@chrisb13
chrisb13 / etopo_quick_plot.py
Last active July 6, 2017 01:08
Quick hack of plotting ETOPO1 ocean bedrock with a nice colormap
# hacked up from: http://www.trondkristiansen.com/?page_id=846
import os
from netCDF4 import Dataset
import matplotlib.pyplot as plt
import matplotlib.cm
import numpy as np
def LevelColormap(levels, cmap=None):
"""
@chrisb13
chrisb13 / nci_scp_bfunc.sh
Created March 31, 2017 08:02
Bash function to use scp on NCI
function vimnci()
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: vimnci PATH_TO."
echo "Purpose: Allows remote editing of files on nci servers..."
echo " "
echo "Mandatory arguments: "
echo "path or file: vim will either edit or open file passed"
echo " "
echo "Example."
@chrisb13
chrisb13 / ncocdo_snippets.sh
Created January 28, 2017 03:13
List of handy one-liners for NCO and CDO
snippet cdo
###########################################################################
# CDO #
###########################################################################
#extract a time
cdo seltimestep,1,2,5 cordex24_CURLFX-FLUXFCE_3h_20040101_20041231_grid_U_2D.nc test.nc
#do simple arithmatic
cdo expr,'sum=qsr+qns-qt' cordex24_CURLFX-FLUXFCE_3h_19980101_19981231_grid_T_2D.nc ofile.nc
@chrisb13
chrisb13 / mpl_latex_toy.py
Created January 24, 2017 01:24
Matplotlib toy example using LaTeX labels
import matplotlib
import matplotlib.pyplot as plt
#nb requires latex installed on the machine, see http://matplotlib.org/users/usetex.html
from matplotlib import rc
import numpy as np
rc('text', usetex=True)
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.rm'] = 'Bitstream Vera Sans'
matplotlib.rcParams['mathtext.it'] = 'Bitstream Vera Sans:italic'
@chrisb13
chrisb13 / combine.py
Created July 26, 2016 04:10 — forked from glombard/combine.py
Merging 4 images into one with Python and PIL/Pillow
# Combine multiple images into one.
#
# To install the Pillow module on Mac OS X:
#
# $ xcode-select --install
# $ brew install libtiff libjpeg webp little-cms2
# $ pip install Pillow
#
from __future__ import print_function
function loadnc() #load netcdf file in python
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: loadnc FILENAME_PATHNAME"
echo "Purpose: loads path of file into ipython (creates loadvar.py in your current dir). Prints file info and available variables. 'ifile' is name of netCDF4 object."
echo " "
echo "Requires: python netCDF4"
echo " "
echo "Mandatory arguments: "
echo "FILENAME_PATHNAME: path to netCDF file"
function servername_push()
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: servername_push PATH_FROM PATH TO."
echo "Purpose: rsync function to push files to servername."
echo " "
echo "Mandatory arguments: "
echo "PATH_FROM: Path on local to Rsync from"
echo "PATH_TO: Path on server to Rsync to"
echo " "
@chrisb13
chrisb13 / rsync-bash-function_pull.sh
Last active October 7, 2015 23:32
Bash function for painless rsync.
function servername_pull()
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: servername_pull PATH_FROM PATH_TO."
echo "Purpose: rsync function to pull files from servername."
echo " "
echo "Mandatory arguments: "
echo "PATH_FROM: Path on server to Rsync from"
echo "PATH_TO: Path on local to Rsync to"
echo " "