Skip to content

Instantly share code, notes, and snippets.

@gidden
gidden / pyomo_differentiate_example_incorrect.ipynb
Created January 22, 2020 08:00
Pyomo Differentiate Example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gidden
gidden / ex.csv
Created June 2, 2017 13:12
read from db
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 10.
"REGION","MODEL","SCENARIO","WHAT","TSYEAR","TSVALUE"
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1990,0.060111363426
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1990,0.060111363426
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1991,0.066719862828
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1991,0.066719862828
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1992,0.06319255648
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1992,0.06319255648
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1993,0.064592366254
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural Waste Burning|Harmonized",1993,0.064592366254
"AFR","History","CEDS","CEDS+|9+ Sectors|Emissions|BC|Agricultural W
@gidden
gidden / count_nans.py
Created May 10, 2017 15:19
rasterio fill value of 0, but fillna with nans?
x = xr.open_dataset('wind5min100m.nc').Band1
x.isnull().count()
<xarray.DataArray 'Band1' ()>
array(9331200) # should be 0, right?
@gidden
gidden / numcols.py
Created January 12, 2017 14:39
columns in dataframe with numeric types
def numcols(df):
"""Returns columns in dataframe with numeric types"""
dtypes = df.dtypes
return [i for i in dtypes.index if dtypes.loc[i].name.startswith(('float', 'int'))]
@gidden
gidden / latex-diff.py
Last active February 1, 2022 19:23
Generate diff PDF from one or more latex files
#!/usr/bin/env python
import argparse
import glob
import os
import shutil
import subprocess
def main():
@gidden
gidden / layout.html
Created October 3, 2016 07:28
Update relbar
{% extends "!layout.html" %}
{%- block linktags %}
{%- if hasdoc('about') %}
<link rel="author" title="{{ _('About these documents') }}"
href="{{ pathto('about') }}"/>
{%- endif %}
<!-- {%- if hasdoc('genindex') %}
!-- <link rel="index" title="{{ _('Index') }}"
!-- href="{{ pathto('genindex') }}"/>
!-- {%- endif %} -->
@gidden
gidden / download.sh
Created April 5, 2016 18:13
Reading in custom-written raster bands causes seg fault
wget https://www.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc
@gidden
gidden / output
Created March 29, 2016 10:14
R jupyter to pdf failure
$ jupyter nbconvert --to pdf --template r.tplx hh_data.ipynb
[NbConvertApp] WARNING | Collisions detected in jupyter_nbconvert_config.py and jupyter_nbconvert_config.json config files. jupyter_nbconvert_config.json has higher priority: {
"Exporter": {
"template_path": "['.', '/home/gidden/.local/share/jupyter/templates'] ignored, using [u'/home/gidden/.local/share/jupyter/templates']"
}
}
[NbConvertApp] Converting notebook kevin_hh_data.ipynb to pdf
[NbConvertApp] Writing 20356 bytes to notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running pdflatex 3 times: [u'pdflatex', u'notebook.tex']
@gidden
gidden / boostrap.out
Last active March 2, 2016 08:10
cmake build from source failure on solaris
---------------------------------------------
CMake 3.5.20160301, Copyright 2000-2016 Kitware, Inc.
C compiler on this system is: cc
C++ compiler on this system is: CC
Makefile processor on this system is: gmake
CC is not GNU compiler
CC is SolarisStudio compiler
CC has setenv
CC has unsetenv
CC does not have environ in stdlib.h
@gidden
gidden / run.sh
Created March 1, 2016 11:31
pyomo wrong guess_format()
~/work/pyomo/pyomo$ svn up
Updating '.':
At revision 11187.
~/work/pyomo/pyomo$ cd ~/tmp
~/tmp$ python write.py
~/tmp$ diff modelb.mps model.lp # no difference, same file