Skip to content

Instantly share code, notes, and snippets.

View ScottWales's full-sized avatar

Scott Wales ScottWales

  • Bureau of Meteorology
  • Melbourne
View GitHub Profile
@ScottWales
ScottWales / EarthSciencesUnixIntro.md
Last active August 29, 2015 13:56
Links & Info for the Unix course
/**
* \file src/celllist.c
* \author Scott Wales <scott.wales@unimelb.edu.au>
* \brief
*
* Copyright 2014 ARC Centre of Excellence for Climate System Science
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
module netcdf
private
public type netcdf_file
contains
procedure open
procedure close
! ...
end type
module quart
type quaternion
! q(4) = (w, x, y, z) where w is the scalar part
real :: q(4)
! Flags to tell us if we want to keep the quaternion unitised, and
! also if the quaternion represents an improper rotation (rotation + inversion)
logical :: unit
logical :: improper
end type quaternion
contains
import xarray
import numpy
from scipy.interpolate import RectBivariateSpline
data = xarray.open_mfdataset('/g/data1/v45/APE-MOM/gfdl_nyf_1080_cp/output539/ocean__539_00*.nc', decode_cf=False)
# Bouy locations
bouy = {
'lat': [-58.239, -57.916, -57.612, -57.513, -57.321, -56.897, -56.484, -56.058],
'lon': [82.001, 82.228, 82.381, 82.523, 82.779, 83.305, 83.770, 84.261],
#!/usr/bin/env python
from __future__ import division
import os
import math
def write_model_ranks(rankfile, nranks, start_rank, start_host, slots_per_host, hostnames, omp=1):
"""
Write out the rankfile for a single model
Output looks like
set -eu
# Get input files from the command line
INPUTS=$*
add_time() {
INPUT=$1
OUTPUT=${INPUT}.nc
import sys
import mule
import numpy.ma as ma
class RemoveMissing(mule.DataOperator):
"""
Remove missing data from a field, setting to average value
"""
def __init__(self):
import xarray
import scipy
import numpy as np
def interpolate_points(
grid_lons, grid_lats,
lons, lats, values,
method='cubic'):
"""
Interpolate point data onto the DataArray
if ( -f ~/.gpg-agent-info ) then
setenv GPG_AGENT_INFO `sed -n 's/GPG_AGENT_INFO=\(.*\)/\1/p' ~/.gpg-agent-info`
endif
if ( ! -S `echo $GPG_AGENT_INFO | sed 's/:.*\+$//'` ) then
eval `gpg-agent --daemon --allow-preset-passphrase --batch --max-cache-ttl 43200 --write-env-file ~/.gpg-agent-info`
endif