This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chmod a+x ~ | |
apt update | |
apt install build-essential autoconf automake libtool postgresql-server-dev-all libxml2-dev libgeos-dev libproj-dev libxml2-utils xsltproc bison postgresql-10 | |
service postgresql start | |
su postgres -c 'createuser root' | |
su postgres -c 'psql -d postgres -c "alter user root superuser;"' | |
git clone git@github.com:postgis/postgis.git | |
cd postgis | |
./autogen.sh | |
./configure --without-raster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import xarray as xr | |
import itertools | |
import numpy as np | |
def auto_merge(datasets): | |
""" | |
Automatically merge a split xarray Dataset. This is designed to behave like | |
`xarray.open_mfdataset`, except it supports concatenation along multiple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dataset name="NECOFS GOM3 Forecast" ID="gom3_nocache" | |
urlPath="FVCOM/NECOFS/Forecasts/NECOFS_GOM3_FORECAST.nc" dataType="Grid"> | |
<serviceName>allServices</serviceName> | |
<access serviceName="wms" urlPath="" /> | |
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" | |
location="/http/www/CODFISH/Data/FVCOM/NECOFS/Forecasts/NECOFS_GOM3_FORECAST.nc"> | |
name="cdm_data_type" value="any"/> | |
<attribute name="Conventions" value="CF-1.0, UGRID-1.0"/> | |
<attribute name="title" value="NECOFS GOM3 (FVCOM) - Northeast US - Latest Forecast"/> | |
<attribute name="summary" value="Latest forecast from the FVCOM Northeast Coastal Ocean Forecast System using an newer, higher-resolution GOM3 mesh (GOM2 was the preceding mesh)"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires the requests library (install with 'pip install requests') | |
import requests | |
class APIClient(object): | |
BASE_URL = "https://api.octopus.energy/v1" | |
class DataUnavailable(Exception): | |
""" | |
Catch-all exception indicating we can't get data back from the API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" invdisttree.py: inverse-distance-weighted interpolation using KDTree | |
fast, solid, local | |
https://stackoverflow.com/a/3119544 | |
""" | |
from __future__ import division | |
import numpy as np | |
from scipy.spatial import cKDTree as KDTree | |
# http://docs.scipy.org/doc/scipy/reference/spatial.html | |
__date__ = "2010-11-09 Nov" # weights, doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
import numpy as np | |
import operator | |
airtemps = xr.tutorial.load_dataset('air_temperature') | |
airtemps = airtemps.sel(time=slice('2013-01-01', '2013-12-31')) | |
airtemps['air'] = airtemps.air - 273.15 | |
air_day = airtemps.resample('1D', 'time', how='mean') | |
meets_condition = (air_day.air > 22) & (air_day.air < 30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geopands as gpd | |
from shapely.geometry.polygon import Polygon | |
from shapely.geometry.multipolygon import MultiPolygon | |
def explode(indata): | |
indf = gpd.GeoDataFrame.from_file(indata) | |
outdf = gpd.GeoDataFrame(columns=indf.columns) | |
for idx, row in indf.iterrows(): | |
if type(row.geometry) == Polygon: | |
outdf = outdf.append(row,ignore_index=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Converts eastings and northings (British national grid coordinates) to Lat/Long | |
# | |
# Original code author: Hannah Fry; see code/comments here: | |
# http://www.hannahfry.co.uk/blog/2012/02/01/converting-british-national-grid-to-latitude-and-longitude-ii | |
# | |
from math import sqrt, pi, sin, cos, tan, atan2 as arctan2 | |
import csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
def datetime2matlabdn(dt): | |
ord = dt.toordinal() | |
mdn = dt + timedelta(days = 366) | |
frac = (dt-datetime(dt.year,dt.month,dt.day,0,0,0)).seconds / (24.0 * 60.0 * 60.0) | |
return mdn.toordinal() + frac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
# Copyright (C) 2016 Sixten Bergman | |
# License WTFPL | |
# | |
# This program is free software. It comes without any warranty, to the extent | |
# permitted by applicable law. | |
# You can redistribute it and/or modify it under the terms of the Do What The | |
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See |
NewerOlder