Skip to content

Instantly share code, notes, and snippets.

View Zeitsperre's full-sized avatar
🗺️
Keeping on keepin' on.

Trevor James Smith Zeitsperre

🗺️
Keeping on keepin' on.
View GitHub Profile
@Zeitsperre
Zeitsperre / scp_usage.py
Last active September 8, 2022 17:20
Using SCP in Python
import logging
from datetime import datetime as dt
from getpass import getpass
from pathlib import Path
from paramiko import SSHClient
from scp import SCPClient
logging.basicConfig(
filename=f"{ dt.strftime(dt.now(), '%Y-%m-%d')}_{Path(__file__).stem}.log",
@Zeitsperre
Zeitsperre / read_shapefile.py
Created August 9, 2021 13:32 — forked from aerispaha/read_shapefile.py
Read a shapefile into a Pandas dataframe
def read_shapefile(shp_path):
"""
Read a shapefile into a Pandas dataframe with a 'coords' column holding
the geometry information. This uses the pyshp package
"""
import shapefile
#read file, parse out the records and shapes
sf = shapefile.Reader(shp_path)
fields = [x[0] for x in sf.fields][1:]
@Zeitsperre
Zeitsperre / subset_clisops_xarray.py
Last active July 27, 2021 19:37
Subsetting NetCDF4 with xarray and clisops
"""
Install Anaconda3 https://www.anaconda.com/products/individual (Beginner-level, larger install)
or Miniconda3: https://docs.conda.io/en/latest/miniconda.html (Experienced, minimal install)
In a terminal / command prompt with `conda` installed:
$ conda create --name data_processing -c conda-forge python=3.7 xarray clisops
$ conda activate data_processing
<Modify paths to folders (source files, target_folder)>
$ python subset_clisops_xarray.py
@Zeitsperre
Zeitsperre / xclim_convert_calendars.py
Last active July 27, 2021 15:46
Calendar conversion using xclim/xarray
from pathlib import Path
from typing import List
import xarray as xr
from xclim.core import calendar as xcal
root_dir = Path(Path().cwd().root)
source_dir = root_dir.joinpath("my/source/files/folder/")
processed_files = [x for x in source_dir.glob("*.nc")]
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis readOnly="0" simplifyLocal="1" simplifyMaxScale="1" version="3.6.0-Noosa" styleCategories="AllStyleCategories" simplifyAlgorithm="0" minScale="1e+08" hasScaleBasedVisibilityFlag="0" labelsEnabled="0" simplifyDrawingTol="1" maxScale="0" simplifyDrawingHints="1">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<renderer-v2 forceraster="0" type="graduatedSymbol" enableorderby="0" attr="hist_1981-2010_p50" graduatedMethod="GraduatedColor" symbollevels="0">
<ranges>
<range label=" 980.0 - 990.0 " upper="990.000000000000000" symbol="0" lower="980.000000000000000" render="true"/>
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@Zeitsperre
Zeitsperre / subset_examples.py
Created July 18, 2018 14:03 — forked from danwild/subset_examples.py
Crop a NetCDF file by XY, Z, and Time with CDO + python bindings
# setup
from cdo import *
cdo = Cdo()
cdo.debug = True
in_file = '/path/to/in_file.nc'
out_file = '/path/to/out_file.nc'
date1 = '2018-03-01T00:00:00'
date2 = '2018-03-01T02:00:00'
# my target is in meters
#" .. "
#" .PLTJ. "
#" <><><><> "
#" KKSSV' 4KKK LJ KKKL.'VSSKK "
#" KKV' 4KKKKK LJ KKKKAL 'VKK "
#" V' ' 'VKKKK LJ KKKKV' ' 'V "
#" .4MA.' 'VKK LJ KKV' '.4Mb. "
#" . KKKKKA.' 'V LJ V' '.4KKKKK . "
#" .4D KKKKKKKA.'' LJ ''.4KKKKKKK FA. "
#" +QDD ++++++++++++XX++++++++++++ GFD+ "
@Zeitsperre
Zeitsperre / TicTacToe.py
Created December 20, 2017 23:31
A hokey but functional TicTacToe game
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 14 17:34:07 2017
"""
import sys
import random
import time
def boardOut(board):

Keybase proof

I hereby claim:

  • I am zeitsperre on github.
  • I am zeitsperre (https://keybase.io/zeitsperre) on keybase.
  • I have a public key ASAYbNVyoi4t4gD94LiYrYO6-b3YuMNwLY3pTddnlo6ImAo

To claim this, I am signing this object: