Skip to content

Instantly share code, notes, and snippets.

View mikofski's full-sized avatar
😎
Solving solar

Mark Mikofski mikofski

😎
Solving solar
View GitHub Profile
@mikofski
mikofski / models.py
Created July 19, 2016 07:54
django derived database field
from __future__ import unicode_literals
from django.db import models
class HeaderField(models.CharField):
"""
Custom field class based on :class:`~django.db.models.CharField` that
creates a unique header from the header, data source and site coordinates.
"""
def pre_save(self, model_instance, add):
@mikofski
mikofski / README.md
Last active July 26, 2016 17:05
Using org.json in MATLAB
@mikofski
mikofski / Analysis of NREL mPERT Data for Validating Models.ipynb
Last active November 10, 2016 00:55
comparison of NREL mPERT data with SAPM model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from tzwhere import tzwhere
from datetime import datetime
import pytz
# timezone lookup, force nearest tz for coords outside of polygons
WHERETZ = tzwhere.tzwhere(shapely=True, forceTZ=True)
# daylight savings time (DST) in northern hemisphere starts in March and ends
# in November and the opposite in southern hemisphere
JAN1 = datetime(2016, 1, 1) # date with standard time in northern hemisphere
JUN1 = datetime(2016, 6, 1) # date with standard time in southern hemisphere
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikofski
mikofski / release_robot.py
Last active April 5, 2017 22:39
gets sorted list of latest git tags - part of dulwich.contrib see PR #462 and #489
"""Determine last version string from tags.
Alternate to `Versioneer <https://pypi.python.org/pypi/versioneer/>`_ using
`Dulwich <https://pypi.python.org/pypi/dulwich>`_ to sort tags by time from
newest to oldest.
Copy the following into the package ``__init__.py`` module::
from dulwich.contrib.release_robot import get_current_version
__version__ = get_current_version('..')
@mikofski
mikofski / vcvarsall.bat.patch
Last active April 9, 2017 20:40
Fix for vcvarsall.bat to build Python-2.7 extensions using v90 instead of sdk7
--- C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.txt
+++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
@@ -16,23 +16,23 @@
goto :eof
:amd64
-if not exist "%~dp0bin\amd64\vcvarsamd64.bat" goto missing
-call "%~dp0bin\amd64\vcvarsamd64.bat"
+if not exist "%~dp0bin\vcvars64.bat" goto missing
+call "%~dp0bin\vcvars64.bat"
@mikofski
mikofski / hdf5dotnet_iso8601_ipy64_example.py
Last active May 19, 2017 17:51
IronPython Example of Writing ISO 8601 Strings to HDF5 from .NET
# Writing Fixed Length Strings to HDF5 file using HDF5DotNet
# http://hdf5.net/
# * download HDF5 library and install first
# * add shared objects to PATH
# set PATH=%PATH%;C:\Program Files\HDF Group\HDF5\1.8.9\bin
# * download and extract HDF5DotNet assemblies
# * start IronPython (ipy64.exe), must be 64-bit version!
# help links:
@mikofski
mikofski / bench_scalar_array_newton.py
Created March 1, 2018 23:42
Comparison of scalar scipy.optimze.zeros.newton from v1.0.0 with proposed vectorized version from pr #8357
from __future__ import division, print_function, absolute_import
from math import sqrt, exp, sin, cos
import warnings
import numpy as np
# Newton-Raphson method
def scalar_newton(func, x0, fprime=None, args=(), tol=1.48e-8, maxiter=50,
fprime2=None):
"""
@mikofski
mikofski / profile_active_mask.py
Created March 23, 2018 21:53
profiling script of scipy PR8357 to vectorize newton using a mask for active array items
from __future__ import division, print_function, absolute_import
import warnings
import numpy as np
# Newton-Raphson method
def newton(func, x0, fprime=None, args=(), tol=1.48e-8, maxiter=50,
fprime2=None, **kwargs):
if tol <= 0: