Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andybell
andybell / Pipfile
Last active June 12, 2020 21:42
SentinelSat 5P methane
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
sentinelsat = "*"
pandas = "*"
@andybell
andybell / makeColormap.py
Created December 3, 2019 18:55
Blindside make .clr
# make value to rgb colormap for blindside data packing
minValue = 905
maxValue = 552674
mod = 256
with open('fullrgb_values.clr', 'w') as fullclr:
for i in range(minValue, maxValue+1):
value = i
blue = i % mod
@andybell
andybell / arcgispro_exportGroup.py
Created November 1, 2019 18:26
Export ArcGIS Pro Layout Groups as PNGs
# export layer groups as pngs to create multiple views from a single layout
# run in arcgis pro python prompt, pngs will be created in the project folder using the name of the layer group
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0] # enter name of map if more than one
# get the list of the group layers in the current map
group_layer_list = [lyr for lyr in m.listLayers() if lyr.isGroupLayer]
# name of the layout to export
@andybell
andybell / arcgispro_stopexport.py
Last active October 30, 2019 15:23
ArcGIS Pro map stop export
# loop through map stops and export an inset map
# run in an arcgis pro session
aprx = arcpy.mp.ArcGISProject("CURRENT")
# get the info for the map and layer
map = aprx.listMaps()[0]
mapstops = map.listLayers()[0]
# name of the layout
lyt = aprx.listLayouts("Layout")[0]
@andybell
andybell / timeit.py
Created July 10, 2019 13:37
Timer decorator
import time
# timer decorator
# adapted from https://medium.com/pythonhive/python-decorator-to-measure-the-execution-time-of-methods-fa04cb6bb36d
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
@andybell
andybell / normalizeField.py
Last active July 1, 2019 20:30
Earth Genome GRAT Normalize Index Field
import arcpy
def normalizeField(in_table, in_field, out_field, index_min, index_max):
"""
Normalizes a field to a new range
:param in_table: input table
:param in_field: field with the original values
:param out_field: output field
:param index_min: the minimum value for the new range
:param index_max: the mazimum value for the new range
:return:
@andybell
andybell / mtb-example.py
Created January 25, 2019 15:36
MarinegeoTemplateBuilder Example Script
import MarinegeoTemplateBuilder # load the MarinegeoTemplateBuilder library
from MarinegeoTemplateBuilder.classes import Field, Vocab # load the objects to contstruct fields + vocab
# python dictionary of the metadata values to prefill
metadataValues = {"TemplateVersion": "v0.0.0",
"Title": "This is a demo workbook"}
# list of fields to construct
fields = [

Keybase proof

I hereby claim:

  • I am andybell on github.
  • I am andybell (https://keybase.io/andybell) on keybase.
  • I have a public key whose fingerprint is 0A0B 34A8 1594 3CE5 B786 0A6F E6E6 9A9E 21F4 FD66

To claim this, I am signing this object:

@andybell
andybell / BareET_sept2015.csv
Last active September 26, 2016 15:06
Creates bare ET vs measured graphs at five stations
Method D1 D2 D3 D4 D5
CalSIMETAW 0.4 0.4 0.4
DETAW 0.4 0.4 2.7
DisALEXI 2 1.8 1.6 1.7 1.3
ITRC 1.3 1.5 0.8 0.9 0.7
SIMS 1.3 1.3 1.6
UCD-METRIC 1.5 2.4 1.6 2.5 1.8
UCD-PT 3.3 3.3 4.4
MEASURED 0.17 0.35 0.051 0.41 0.39