Skip to content

Instantly share code, notes, and snippets.

View dgketchum's full-sized avatar

David Ketchum dgketchum

  • State of Montana, University of Montana
  • Missoula, MT
View GitHub Profile
@dgketchum
dgketchum / mrsid.py
Created January 28, 2022 19:11
Write MrSID to GeoTIFF with open-source software in Python
import json
import os
from glob import glob
import subprocess
from subprocess import Popen, PIPE, check_call, call
from pathlib import Path
from pyproj import datadir
proj_dir = datadir.get_data_dir()
@dgketchum
dgketchum / state_county_names_codes.py
Created November 24, 2021 19:09
United States state abbreviations, state FIPS code, county names, county FIPS codes (Federal Information Processing Standard)
# NOTE: to invert dicts (e.g., to look up state FIPS and get state abbreviation:
# fips_codes = {v: k for k, v in state_fips_code().items()}
def state_name_abbreviation():
return {'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkansas',
'AS': 'American Samoa',
'AZ': 'Arizona',
@dgketchum
dgketchum / snotel_list.csv
Last active May 2, 2022 21:10
SNOTEL locations shapefile, mean April 1st SWE calculated in Python and written to shapefile
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 11 columns, instead of 8. in line 8.
Name,ID,State,Network,County,Elevation_ft,Latitude,Longitude,HUC,Date_of_Data,Date_Report_Created
Abbey,ABY ,California,Snow Course/Aerial Marker,Plumas,5650,39.955,-120.538,180201220103 ,,"10-11-2021, 04:26 PM MDT"
Aberdeen Lake,1F01A ,British Columbia,Snow Course/Aerial Marker, ,4298,50.14733,-119.0534, ,,"10-11-2021, 04:26 PM MDT"
Above Gilmore,13E19 ,Idaho,Snow Course/Aerial Marker,Lemhi,8289,44.45615,-113.30097,170602040101 ,,"10-11-2021, 04:26 PM MDT"
Above Roland,15B07 ,Idaho,Snow Course/Aerial Marker,Shoshone,4347,47.38507,-115.66405,170103040201 ,,"10-11-2021, 04:26 PM MDT"
Adin Mountains,20H08 ,California,Snow Course/Aerial Marker,Modoc,6190,41.23483,-120.79467,180200021403 ,,"10-11-2021, 04:26 PM MDT"
Adin Mtn,301 ,California,SNOTEL,Modoc,6190,41.23583,-120.79192,180200021403 ,,"10-11-2021, 04:26 PM MDT"
Agnew Pass,AGP ,California,Cooperator Snow Sensors,Madera,9450,37.724,-119.143,180400060401 ,,"10-11-2021, 04:26 PM MDT"
Agnew Pass,AGP ,California,Snow Course/Aerial Marker,Madera,9450,37.724,-119
@dgketchum
dgketchum / running_jupyter_with_miniconda.md
Last active February 6, 2018 21:46
installing and running jupyter notebooks on miniconda

I had some trouble running jupyter notebooks with miniconda from a new env. The key is miniconda doesn't install a fresh python install for each new env. This leads to unable to create process /blah/Miniconda3/python.exe from /blah/Miniconda/envs/myenv/Scripts/jupyter-notebook.py

So install another version of python (can be same release) into your env, install jupyter, and run jupyter notebook. Copy the token and paste it into the url bar.

Then follow directions http://jupyter-notebook.readthedocs.io/en/latest/public_server.html and setup your password using jupyter_notebook_config.json

Then you can run, and log into your notebook session securely from there on out.