Skip to content

Instantly share code, notes, and snippets.

View carderne's full-sized avatar

Chris Arderne carderne

View GitHub Profile
@carderne
carderne / grd_to_tif.py
Created October 10, 2022 12:02 — forked from jesserobertson/grd_to_tif.py
Convert all Geosoft *.grd files to geotiff in a directory (recursively)
import pathlib
from itertools import product
from tqdm import tqdm
import rasterio
import geosoft
import geosoft.gxpy.gx as gx
import geosoft.gxpy.coordinate_system as gxcs
import geosoft.gxpy.grid as gxgrid
We couldn’t find that file to show.
@carderne
carderne / clip_to_same.py
Created February 14, 2022 15:52
Run as follows: `python clip_to_same.py source.tif raster_with_desired_shape.tif outputfile.tif`
import sys
import numpy as np
import rasterio as rio
from rasterio.warp import reproject, Resampling
def make_same(src_path: str, like_path: str, out_path: str) -> None:
with rio.open(like_path) as ds:
like_arr = ds.read(1)
from prefect import Flow, task
from loguru import logger
def fn1():
print("Hello from fn1")
def fn2():
logger.info("Hello from fn2")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carderne
carderne / syslog-i3
Created October 10, 2019 09:40
Regolith issue with 19.10
whoopsie-upload-all[1195]: /var/crash/_usr_bin_i3.1000.crash already marked for upload, skipping
systemd[1463]: Starting GNOME Session Manager (session: i3-gnome-flashback)...
systemd[1463]: Started GNOME Session Manager (session: i3-gnome-flashback).
systemd[1463]: Reached target GNOME Session (session: i3-gnome-flashback).
i3-gnome-flashback.desktop[2246]: method return time=1570699567.739931 sender=:1.31 -> destination=:1.50 serial=125 reply_serial=2
i3-gnome-flashback.desktop[2246]: object path "/org/gnome/SessionManager/Client10"
i3-gnome-flashback.desktop[2246]: Usage:
i3-gnome-flashback.desktop[2246]: gsettings [--schemadir SCHEMADIR] get SCHEMA[:PATH] KEY
i3-gnome-flashback.desktop[2246]: Get the value of KEY
i3-gnome-flashback.desktop[2246]: Arguments:
@carderne
carderne / service_transf.py
Created April 2, 2019 14:48
Service transformer calculation
from math import pi, ceil
def get_num_service_transf(pop, peak_kw_pp=1):
grid_cell_area = 0.45 * 0.45 # km2
num_people_per_hh = 4
power_factor = 0.9
lv_line_max_length = 0.5 # km
service_transf_type = 50 # kVa
max_nodes_per_serv_trans = 300 # maximum number of nodes served by each service transformer
@carderne
carderne / GRIDFINDER_INSTRUCTIONS.md
Last active January 30, 2019 13:29
Instructions to run gridfinder on cloud through SSH

Instructions to run gridfinder on cloud through SSH

  1. Open your terminal and type the following and enter the password.
$ ssh <user>@<IP>
  1. There are several different processes running in different tmux sessions. I prepared two sessions called g1 and g2 that we can use to run the algorithm in parallel. To connect to one of the sessions, type the below. There should now be an extra bar on the bottom of the terminal with the session name in it.
$ tmux attach -t 
@carderne
carderne / run_ntl_filter.py
Created January 17, 2019 09:15
Code snippet to apply convolutional filter to a raster
from math import sqrt
import numpy as np
from scipy import signal
import rasterio
# Code from https://github.com/carderne/gridfinder/blob/master/gridfinder/prepare.py
# And https://github.com/carderne/gridfinder/blob/master/gridfinder/_util.py
def filter_func(i, j):