Skip to content

Instantly share code, notes, and snippets.

View lgloege's full-sized avatar
🐶

Luke Gloege lgloege

🐶
View GitHub Profile
Region Baseline year Baseline emissions [MtCO2e] Target year Reduction percent Target emissions [MtCO2e] Source
Canada 2005 741.2 2030 40-45% 444.7 - 407.7 (Government of Canada, 2021)
British Columbia 2007 62.7 2030 40% 37.6 (British Columbia Climate Change Accountability Act, 2007)
Manitoba 2005 20.5 2030 33% 13.8 (Government of Manitoba, 2015)
New Brunswick 2005 19.8 2030 46% 10.7 (Government of New Brunswick. 2022)
Newfoundland and Labrador 2001 9.9 2030 30% 6.9 (Government of Newfoundland and Labrador. 2019)
Northwest Territories 2005 1.7 2030 30% 1.2 (Government of Northwest Territories, 2019)
Nova Scotia 2005 23.0 2030 53% 10.8 (Government of Nova Scotia. 2019)
Ontario 2005 204.4 2030 30% 143.1 (Government of Ontario, 2018)
Prince Edward Island 2005 2030 1.2 (Prince Edward Island, 2020)
@lgloege
lgloege / global_average_temperature.ipynb
Last active March 17, 2021 03:28
This notebook calculated the global average temperature anomaly from the Berkley Earth gridded product
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgloege
lgloege / area_grid.py
Last active March 20, 2023 13:01
All the files necessary to calculate the area-weighted mean of geospatial data are here.
def area_grid(lat, lon):
"""
Calculate the area of each grid cell
Area is in square meters
Input
-----------
lat: vector of latitude in degrees
lon: vector of longitude in degrees
@lgloege
lgloege / remote_login.md
Last active October 20, 2018 00:46
Steps to setup remote login and rsync backup

Setting up remote login

  1. Let's first see if you have a remote key. Open a terminal and type more ~/.ssh/id_rsa.pub If a random string of letters and numbers appears, then you already have a public key and you can skip to step 3.
  2. Don't have a public key? Let's make one! Open a terminal and type ssh-keygen to generate a public key. Just keep hitting enter. It's going to ask if you want to save the key to /Users/USER/.ssh/id_rsa and to make a passphrase. You want to save it to the default location and don't worry about the passphrase, just hit enter.
  3. Copy the public key to the remove computer with the command ssh-copy-id USER@artemis.ldeo.columbia.edu What this is doing is copying your key to .ssh/authorized_keys on artemis.
  4. Now you can log into artemis without a password. Try this ssh USER@artemi.ldeo.columbia.edu

Backup script

Now that we have remote login working, we can write a simple backup script that can use with crontab.

@lgloege
lgloege / calculate_statistics.py
Last active October 19, 2018 15:37
python scripts to analysis LE model output
import xarray as xr
import numpy as np
from processing import processing as pr
from skill_metrics import skill_metrics as sk
def calculate_statistics(model='CESM', member='002'):
###======================================
### Load data
###======================================
ds_somffn = read_peter(model=model, member=member)
@lgloege
lgloege / get_cbpm.m
Created April 16, 2018 18:31
reads CbPM from web
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Get CbPM carbon mg / m**3:
% This script reads CbPM data from web and saves to file.
%
% Source: http://www.science.oregonstate.edu/ocean.productivity/custom.php
%
% L. Gloege 2016 (Augmented a script from A.Fay)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear; clc
from mpl_toolkits.basemap import Basemap # for plotting 2D data on maps
from mpl_toolkits import basemap
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
import seaborn as sns
import cmocean
import os
from matplotlib.patches import Polygon
@lgloege
lgloege / startup.m
Last active April 11, 2018 14:23
startup script for MATALB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% STARTUP SCRIPT:
%
% This sets up the workspace.
% by adding path to scripts, and plot settings
%
% L. Gloege
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function startup()
@lgloege
lgloege / rsync_from_server.md
Last active November 2, 2023 17:04
Use rsync to copy from a server with bastion server between them. Does not require scp or ssh tunneling.

Setup keyless login

  1. On local make an RSA key if you haven't already (ssh-keygen)
  2. Copy that key into .ssh/authorized_keys on the first (i.e. bastion) server (ssh-copy-id user@first.server) 2b. Test that you can ssh user@first.server and connect without password
  3. ssh to first.server and create an RSA key on first.server if you haven't already (ssh-keygen)
  4. ssh-copy-id to the server you want to access (what I am calling second.server) 4b. test that you can ssh from first.server to second.server without entering a password

To copy from server to local

rsync -e "ssh user@first.server ssh" user@second.server:/path/to/file /path/to/local/dest