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 / solpos_mex.c
Last active June 7, 2018 20:50
MATLAB mex gateway function for NREL SOLPOS
/*==========================================================
* solpos.c - NREL solar position calculator
*
* calculates solar position from location and time
*
* The calling syntax is:
*
* angles = solpos(location,datetime,weather)
*
* This is a MEX-file for MATLAB.
@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:
@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 / newton_example.pyx
Last active April 24, 2018 23:51
cythonized example of scipy.optimized.newton to solve solar-cell for 100,000 different cases
from __future__ import division, print_function, absolute_import
from math import exp, sin
from scipy.optimize.cython_optimize cimport zeros
NUM_OF_IRRAD = 10
IL = [sin(il) + 6.0 for il in range(NUM_OF_IRRAD)]
# governing equations
@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:
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
@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.
@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 / 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 / darwin.mk
Last active July 10, 2016 04:40
overloading ccompiler to build dylibs for mac osx with xcode
#define macros
SOLPOSAM = libsolposAM.dylib
SOLPOSAM_LIB = solposAM
SPECTRL2 = libspectrl2.dylib
SPECTEST = spectest
STEST00 = stest00
SRC_DIR = src
BUILD_DIR = build