Skip to content

Instantly share code, notes, and snippets.

Ryan J. Dillon ryanjdillon

  • Norway
View GitHub Profile
@ryanjdillon
ryanjdillon / s3-rsync.sh
Last active Feb 20, 2019
Sync data to S3 with `aws s3 sync`, an AWS `rsync` emulator
View s3-rsync.sh
# Install the aws cli
source your-venv/bin/activate
pip install awscli
# Setup your credentials
aws configure
# Check out what is going to get transfered first
aws s3 sync ./path/to/data s3://bucket-name --exclude "*" --include "*.nc" --dryrun
@ryanjdillon
ryanjdillon / perc_bc_from_lipid.py
Created Sep 8, 2017
Percent body compositions from percent lipids
View perc_bc_from_lipid.py
def perc_bc_from_lipid(perc_lipid, perc_water=None):
'''Calculate body composition component percentages based on % lipid
Calculation of percent protein and percent ash are based on those presented
in Reilly and Fedak (1990).
Args
----
perc_lipid: ndarray
1D array of percent lipid values from which to calculate body composition
@ryanjdillon
ryanjdillon / kartverket_wms.py
Created Aug 23, 2017
Working on getting retrieving Kartverket map data
View kartverket_wms.py
'''
A Package for retrieving Kartverket image data for specified areas.
Exampl URLs
-----------
GetCapabilities:
http://opencache.statkart.no/gatekeeper/gk/gk.open?Version=1.0.0&service=wms&request=getcapabilities
NOAA (not active/testable):
http://porter.pmel.noaa.gov:8922/wms/wms_servlet?VERSION=1.1.1&REQUEST=GetMap&LAYERS=coads_climatology_cdf:airt&STYLES=ferret_default&WIDTH=640&HEIGHT=320&FORMAT=image/png&SRS=EPSG:4326&BBOX=-180.0,-90.0,180.0,90.0&EXCEPTION=application/vnd.ogc.se_xml&DIM_COADS_CLIMATOLOGY_CDF_TIME=15-Jan
@ryanjdillon
ryanjdillon / calc_mod_density.py
Last active Jul 3, 2017
Example routine for calculating modified body density of seals
View calc_mod_density.py
def calc_mod_density(mass_kg, dens_kgm3, n_blocks, block_type):
'''Calculate the modified density with attached blocks
Args
----
mass_kg: float
mass of the seal (kg)
dens_kgm3: float
mass of the seal (kg/m^3)
block_type: str
@ryanjdillon
ryanjdillon / lip2dens.py
Last active Jun 22, 2017
Seal lipid to body density calculation
View lip2dens.py
def lip2dens(p_lipid, lipid_dens=0.9007, prot_dens=1.34, water_dens=0.994, a_dens=2.3):
'''Derive tissue density from lipids
Translated to python from R code written by Martin Biuw
'''
p_comps = perc_bc_from_lipid(p_lipid)
p_comps['density'] = (lipid_dens * (0.01 * p_comps['perc_lipid'])) + \
@ryanjdillon
ryanjdillon / algae_light_response.py
Created Mar 13, 2017
Algae light response - Calculate the level of oxygen at a give light level
View algae_light_response.py
import seaborn
def light_response(light, EC50, hillslop=2.5):
'''Typical response function for EC50 tests'''
import numpy
# http://www.sigmaplot.co.uk/splot/products/sigmaplot/productuses/prod-uses43.php
# Response to concentration
dose_min = light.min()
dose_max = light.max()
You can’t perform that action at this time.