Skip to content

Commit

Permalink
add spa_c_files to pvlib path
Browse files Browse the repository at this point in the history
* move logging to core
* in tests import unc_wrapper and logging from core
* set logging in basic config, don't set per LOGGER
* some logging for core for carousel
* save spa source files in pvlib/spa_c_files
  • Loading branch information
mikofski committed May 4, 2016
1 parent 6e37b41 commit ecc8d16
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions get_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@
}
SPAH_URL = r'http://midcdmz.nrel.gov/spa/spa.h' # spa.h source url
PVLIB_PATH = os.environ['PVLIB_PATH'] # path to PVLIB on travis
SPA_C_FILES = os.path.join(PVLIB_PATH, 'spa_c_files')

if __name__ == "__main__":
# get spa.c source
LOGGER.debug('post payload to url: %s\n\tpayload:\n%s', SPAC_URL, PAYLOAD)
r = requests.post(SPAC_URL, data=PAYLOAD)
LOGGER.debug('post response: %r', r)
# save spa.c source to PVLIB spa_c_files folder
with open(os.path.join(PVLIB_PATH, 'spa.c'), 'wb') as f:
# save spa.c source to PVLIB/SPA_C_FILES folder
with open(os.path.join(SPA_C_FILES, 'spa.c'), 'wb') as f:
f.write(r.content)
LOGGER.debug('saved file: %r to PVLIB PATH: %s', f.name, PVLIB_PATH)
LOGGER.debug('saved file: %r', f.name)
# get spa.c source
LOGGER.debug('get url: %s', SPAH_URL)
r = requests.get(SPAH_URL)
LOGGER.debug('get response: %r', r)
# save spa.c source to PVLIB spa_c_files folder
with open(os.path.join(PVLIB_PATH, 'spa.h'), 'wb') as f:
# save spa.c source to PVLIB/SPA_C_FILES folder
with open(os.path.join(SPA_C_FILES, 'spa.h'), 'wb') as f:
f.write(r.content)
LOGGER.debug('saved file: %r to PVLIB PATH: %s', f.name, PVLIB_PATH)
LOGGER.debug('saved file: %r', f.name)
LOGGER.debug('exiting %s', __file__) # exit
4 changes: 0 additions & 4 deletions uncertainty_wrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"""UncertaintyWrapper"""

import logging
from uncertainty_wrapper.core import unc_wrapper, unc_wrapper_args

logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
__VERSION__ = '0.3.2'
__RELEASE__ = u"Mesoproterozoic Era"
__URL__ = u'https://github.com/SunPower/UncertaintyWrapper'
Expand Down
6 changes: 6 additions & 0 deletions uncertainty_wrapper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

from functools import wraps
import numpy as np
import logging

logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
DELTA = np.finfo(float).eps ** (1.0 / 3.0) / 2.0


Expand Down Expand Up @@ -124,6 +127,7 @@ def wrapper(f):
@wraps(f)
def wrapped_function(*args, **kwargs):
cov = kwargs.pop('__covariance__', None) # pop covariance
LOGGER.debug('covariance:\n%r', cov)
# covariance keys cannot be defaults, they must be in args or kwargs
cov_keys = covariance_keys
# convert args to kwargs by index
Expand All @@ -141,6 +145,8 @@ def wrapped_function(*args, **kwargs):
else:
# arguments already grouped
x = kwargs.pop(0) # use first argument
LOGGER.debug('covariance keys:\n%r', cov_keys)
LOGGER.debug('independent variables:\n%r', x)
# remaining args
args_dict = {}

Expand Down
3 changes: 1 addition & 2 deletions uncertainty_wrapper/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from nose.tools import ok_
import numpy as np
from uncertainty_wrapper import unc_wrapper, unc_wrapper_args, logging
from uncertainty_wrapper.core import unc_wrapper, unc_wrapper_args, logging
from scipy.constants import Boltzmann as KB, elementary_charge as QE
import pytz
import pint
Expand All @@ -19,6 +19,5 @@
PST = pytz.timezone('US/Pacific')
UTC = pytz.UTC
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
__all__ = ['ok_', 'np', 'pd', 'unc_wrapper', 'unc_wrapper_args', 'KB', 'QE',
'pvlib', 'plt', 'UREG', 'PST', 'UTC', 'LOGGER']

0 comments on commit ecc8d16

Please sign in to comment.