Skip to content

Instantly share code, notes, and snippets.

View evu's full-sized avatar
🌎
>>> ▌

evu

🌎
>>> ▌
View GitHub Profile
@evu
evu / compress_json.py
Created April 18, 2023 15:13
In-mem compression / decompression and json serialization
import base64
import io
import json
import urllib.request
import zipfile
from pathlib import Path
from urllib.parse import urlparse
@evu
evu / py_build_env.sh
Created March 3, 2023 14:40
Python build env for Amazon Linux 2
sudo yum install gcc make zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel tk-devel libffi-devel xz-devel
sudo yum remove openssl-devel.x86_64
sudo yum autoremove
sudo yum install openssl11-devel
@evu
evu / _jaccard.py
Created January 20, 2023 00:00 — forked from JDWarner/_jaccard.py
Jaccard coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity metric, and it is a true metric. The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the modified BSD license, otherwise known as the 3-clause BSD.
"""
_jaccard.py : Jaccard metric for comparing set similarity.
"""
import numpy as np
def jaccard(im1, im2):
"""
@evu
evu / ssh-retry.sh
Created July 26, 2022 22:20 — forked from 9point6/ssh-retry.sh
Keep retrying SSH connection until success (Useful for waiting for VMs to boot)
#!/usr/bin/env bash
# Check we've got command line arguments
if [ -z "$*" ] ; then
echo "Need to specify ssh options"
exit 1
fi
# Start trying and retrying
((count = 100))
@evu
evu / peg_cpu.sh
Created June 23, 2022 16:59
Max out CPU utilization for 1 minute
#!/bin/bash
for i in $(seq $(getconf _NPROCESSORS_ONLN)); do yes > /dev/null & done
echo "To stop, run:"
echo "killall yes"
echo
sleep 60
killall yes
@evu
evu / latlon_to_xy.py
Created June 23, 2022 15:51
Get image x, y coordinates of point on geotiff using lat, lon
import rasterio as rio
ds = rio.open(img_file)
for lon, lat in points:
y, x = ds.index(lon, lat)
print(x, y)
@evu
evu / scatterplot_reg.py
Created August 20, 2021 17:33
Scatterplot with regression lines
palette = iter(sns.color_palette("tab10"))
# Plot points
g = sns.scatterplot(x=x, y=y, color=next(palette))
g.grid(False)
# Plot regression line
m, b = np.polyfit(x, y, 1)
linecolor = next(palette)
xr = range(x.min(), x.max(), 1)
@evu
evu / poisson.py
Created August 20, 2021 17:28
Poisson regression in python
import statsmodels.api as sm
from patsy import dmatrices
import numpy as np
y, X = dmatrices("time_s ~ cloud + model + sensor", data=df)
# Note that offset is in 100s of square miles
offset = np.asarray(df["sq_mi"]) / 100
m = sm.Poisson(y, X, offset=offset)

Pansharpening notes, mid-2021

Preface

This is a collection of notes on how I’ve been approaching CNNs for pansharpening. It’s an edited version of an e-mail to a friend, who had asked about this tweet, and so it’s informal and somewhat silly; it is not as polished as, say, a blog post would be. Basically, what I’ve written up here is the advice I would give to an enthusiastic image processing hobbyist before they started working on pansharpening.

If you want a more serious brief review of the problem, try the first two pages of Learning deep multiresolution representations for pansharpening – most of the work I would recommend is mentioned there.

If you spot an error in the physics or math here, please mention it, but if you see a simplification or minor abuse of terminology, it’s on purpose; for textbook rigor, please refer to a textbook. The focus here is

@evu
evu / enable_path
Created October 11, 2020 13:49
Permanently enable nautilus path (Ubuntu)
sudo apt install dconf-editor
dconf-editor
# Go to org > gnome > nautilus > preferences and check always-use-location-entry