Hello,
I try to read IES file using Hops and module called luxpy
The file output work but i got error
The code
import ghhops_server as hs
import rhino3dm
import luxpy as lx
hops = hs.Hops()
@hops.component(
"/read",
name="Read IES",
nickname="ReadIES",
description="Add numbers with CPython",
inputs=[
hs.HopsString("file", "F", "IES file"),
],
outputs=[hs.HopsString("Data", "D", "IES data")]
)
def read(iesfile):
return read_ies(iesfile)
def read_ies(iesfile):
return lx.iolidfiles.read_lamp_data(iesfile,1.0,0,'I0',True)
if __name__ == "__main__":
hops.start(debug=True)
Th error
C:\Python39\python.exe "C:/Users/archi/Dropbox/Maxwell tool/player/read_ies.py"
[DEBUG] (private) matplotlib data path: C:\Python39\lib\site-packages\matplotlib\mpl-data
[DEBUG] matplotlib data path: C:\Python39\lib\site-packages\matplotlib\mpl-data
[DEBUG] CONFIGDIR=C:\Users\archi\.matplotlib
[DEBUG] matplotlib version 3.3.4
[DEBUG] interactive is False
[DEBUG] platform is win32
[DEBUG] loaded modules: ['sys', 'builtins', '_frozen_importlib', '_imp', '_thread', '_warnings', '_weakref', '_frozen_importlib_external', 'nt', '_io', 'marshal', 'winreg', 'time', 'zipimport', '_codecs', 'codecs', 'encodings.aliases', 'encodings', 'encodings.utf_8', '_signal', 'encodings.latin_1', '_abc', 'abc', 'io', '__main__', '_stat', 'stat', '_collections_abc', 'genericpath', 'ntpath', 'os.path', 'os', '_sitebuiltins', '_locale', '_bootlocale', 'encodings.cp1256', 'types', 'importlib._bootstrap', 'importlib._bootstrap_external', 'warnings', 'importlib', 'importlib.machinery', '_heapq', 'heapq', 'itertools', 'keyword', '_operator', 'operator', 'reprlib', '_collections', 'collections', 'collections.abc', '_functools', 'functools', 'contextlib', 'enum', '_sre', 'sre_constants', 'sre_parse', 'sre_compile', 'copyreg', 're', 'typing.io', 'typing.re', 'typing', 'importlib.abc', 'importlib.util', 'mpl_toolkits', 'site', 'token', 'tokenize', 'linecache', 'traceback', '_ast', 'ast', '_opcode', 'opcode', 'dis', 'inspect', '_json', 'json.scanner', 'json.decoder', 'json.encoder', 'json', '_struct', 'struct', 'binascii', 'base64', '_weakrefset', 'weakref', '_string', 'string', 'threading', 'atexit', 'logging', 'ghhops_server.logger', 'ghhops_server.component', 'ghhops_server.base', 'http', 'copy', 'math', '_datetime', 'datetime', 'email', '_bisect', 'bisect', '_random', '_sha512', 'random', '_socket', 'select', 'selectors', 'errno', 'socket', 'urllib', 'urllib.parse', 'locale', 'calendar', 'email._parseaddr', 'email.base64mime', 'email.quoprimime', 'email.errors', 'quopri', 'email.encoders', 'email.charset', 'email.utils', 'html.entities', 'html', 'email.header', 'email._policybase', 'email.feedparser', 'email.parser', 'uu', 'email._encoded_words', 'email.iterators', 'email.message', '_ssl', 'ssl', 'http.client', 'posixpath', 'mimetypes', 'fnmatch', 'zlib', '_compression', '_bz2', 'bz2', '_lzma', 'lzma', 'shutil', 'socketserver', 'http.server', 'ghhops_server.middlewares.hopsdefault', 'signal', 'werkzeug._compat', 'werkzeug._internal', 'pkgutil', 'werkzeug.utils', 'werkzeug.exceptions', 'werkzeug.urls', '_ctypes', 'ctypes._endian', 'ctypes', 'ctypes.wintypes', 'msvcrt', 'click._winconsole', 'click._compat', 'click._unicodefun', 'click.globals', 'click.utils', 'click.exceptions', 'click.parser', 'click.types', 'click.termui', 'click.formatting', 'click.core', 'click.decorators', 'click', 'werkzeug.serving', 'tempfile', 'werkzeug.filesystem', '_hashlib', '_blake2', 'hashlib', 'urllib.response', 'urllib.error', 'nturl2path', 'urllib.request', 'werkzeug.http', 'werkzeug.datastructures', 'werkzeug.wrappers.accept', 'werkzeug.wrappers.auth', 'werkzeug.wsgi', 'werkzeug.formparser', 'werkzeug.wrappers.base_request', 'werkzeug.wrappers.base_response', 'werkzeug.wrappers.common_descriptors', 'werkzeug.wrappers.etag', 'werkzeug.wrappers.cors', 'werkzeug.useragents', 'werkzeug.wrappers.user_agent', 'werkzeug.wrappers.request', 'werkzeug.wrappers.response', 'werkzeug.wrappers', 'http.cookiejar', 'werkzeug.test', 'werkzeug', 'ghhops_server.middlewares.hopsflask', 'ghhops_server.middlewares', 'ghhops_server.params', 'ghhops_server', 'rhino3dm._rhino3dm', 'rhino3dm', 'luxpy', 'numpy._globals', 'numpy.__config__', 'numpy.version', 'glob', 'numpy._distributor_init', 'textwrap', 'numpy.core._multiarray_umath', 'numpy.compat._inspect', 'pathlib', '_compat_pickle', '_pickle', 'pickle', 'numpy.compat.py3k', 'numpy.compat', 'numpy.core.overrides', 'numpy.core.multiarray', 'numpy.core.umath', 'numbers', 'numpy.core._string_helpers', 'numpy.core._dtype', 'numpy.core._type_aliases', 'numpy.core.numerictypes', 'numpy.core._asarray', 'numpy.core._exceptions', 'numpy.core._methods', 'numpy.core.fromnumeric', 'numpy.core.shape_base', 'numpy.core._ufunc_config', 'numpy.core.arrayprint', 'numpy.core.numeric', 'numpy.core.defchararray', 'numpy.core.records', 'numpy.core.memmap', 'numpy.core.function_base', 'numpy.core.machar', 'numpy.core.getlimits', 'numpy.core.einsumfunc', 'numpy.core._multiarray_tests', 'numpy.core._add_newdocs', 'numpy.core._add_newdocs_scalars', 'numpy.core._dtype_ctypes', '_winapi', 'subprocess', 'platform', 'numpy.core._internal', 'numpy._pytesttester', 'numpy.core', 'numpy.lib.mixins', 'numpy.lib.ufunclike', 'numpy.lib.type_check', 'numpy.lib.scimath', 'numpy.lib.twodim_base', 'numpy.linalg.lapack_lite', 'numpy.linalg._umath_linalg', 'numpy.linalg.linalg', 'numpy.linalg', 'numpy.matrixlib.defmatrix', 'numpy.matrixlib', 'numpy.lib.histograms', 'numpy.lib.function_base', 'numpy.lib.stride_tricks', 'numpy.lib.index_tricks', 'numpy.lib.nanfunctions', 'numpy.lib.shape_base', 'numpy.lib.polynomial', 'numpy.lib.utils', 'numpy.lib.arraysetops', 'numpy.lib.format', 'numpy.lib._datasource', 'numpy.lib._iotools', 'numpy.lib.npyio', 'numpy.lib.arrayterator', 'numpy.lib.arraypad', 'numpy.lib._version', 'numpy.lib', 'numpy.fft._pocketfft_internal', 'numpy.fft._pocketfft', 'numpy.fft.helper', 'numpy.fft', 'numpy.polynomial.polyutils', 'numpy.polynomial._polybase', 'numpy.polynomial.polynomial', 'numpy.polynomial.chebyshev', 'numpy.polynomial.legendre', 'numpy.polynomial.hermite', 'numpy.polynomial.hermite_e', 'numpy.polynomial.laguerre', 'numpy.polynomial', 'cython_runtime', '_cython_0_29_21', 'numpy.random._common', 'hmac', 'secrets', 'numpy.random.bit_generator', 'numpy.random._bounded_integers', 'numpy.random._mt19937', 'numpy.random.mtrand', 'numpy.random._philox', 'numpy.random._pcg64', 'numpy.random._sfc64', 'numpy.random._generator', 'numpy.random._pickle', 'numpy.random', 'numpy.ctypeslib', 'numpy.ma.core', 'numpy.ma.extras', 'numpy.ma', 'numpy', 'luxpy.utils', 'luxpy.utils.utilities', '_lsprof', 'profile', 'cProfile', 'dataclasses', 'pstats', 'mpl_toolkits.mplot3d', 'mpl_toolkits.mplot3d.axes3d', 'matplotlib', 'distutils', 'distutils.version', 'pprint', 'gzip', 'shlex', 'matplotlib.cbook.deprecation', 'matplotlib.cbook', '_uuid', 'uuid', 'matplotlib._animation_data', 'matplotlib.animation', 'pyparsing', 'matplotlib.fontconfig_pattern', 'matplotlib.docstring', 'matplotlib._color_data', 'matplotlib.colors', '__future__', 'six', 'six.moves', 'cycler', 'matplotlib.rcsetup', 'matplotlib._version', 'matplotlib.ft2font', 'dateutil._version', 'dateutil', 'kiwisolver']
[DEBUG] CACHEDIR=C:\Users\archi\.matplotlib
[DEBUG] Using fontManager instance from C:\Users\archi\.matplotlib\fontlist-v330.json
[DEBUG] Loaded backend tkagg version unknown.
[DEBUG] Loaded backend TkAgg version unknown.
[INFO] Starting hops python server on localhost:5000
[DEBUG] Getting component metadata: <HopsComponent /read [file -> Read IES -> Data] >
[DEBUG] True : {"Description": "Add numbers with CPython", "Inputs": [{"Name": "file", "Nickname": "F", "Description": "IES file", "ParamType": "Text", "ResultType": "System.String", "AtLeast": 1, "AtMost": 1}], "Outputs": [{"Name": "Data", "Nickname": "D", "Description": "IES data", "ParamType": "Text", "ResultType": "System.String", "AtLeast": 1, "AtMost": 1}]}
[INFO] 127.0.0.1 - - [23/Mar/2021 22:36:38] "GET /read HTTP/1.1" 200 -
[DEBUG] Getting component metadata: <HopsComponent /read [file -> Read IES -> Data] >
[DEBUG] True : {"Description": "Add numbers with CPython", "Inputs": [{"Name": "file", "Nickname": "F", "Description": "IES file", "ParamType": "Text", "ResultType": "System.String", "AtLeast": 1, "AtMost": 1}], "Outputs": [{"Name": "Data", "Nickname": "D", "Description": "IES data", "ParamType": "Text", "ResultType": "System.String", "AtLeast": 1, "AtMost": 1}]}
[INFO] 127.0.0.1 - - [23/Mar/2021 22:36:38] "GET /read HTTP/1.1" 200 -
[INFO] Solving using legacy API: <HopsComponent /read [file -> Read IES -> Data] >
[DEBUG] Return data: {'filename': 'C:\\Users\\archi\\Desktop\\maxwell scene test\\Real_IES_wide_cone_floor_lamp.ies', 'version': None, 'candela_values': array([5.2109e+03, 4.3867e+03, 3.5626e+03, 2.5648e+03, 1.5671e+03,
1.3367e+03, 1.1062e+03, 1.5428e+03, 1.9793e+03, 1.2085e+03,
4.3762e+02, 2.1881e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]), 'candela_2d': array([[1.0000e+00, 8.4184e-01, 6.8368e-01, 4.9221e-01, 3.0073e-01,
2.5651e-01, 2.1229e-01, 2.9607e-01, 3.7984e-01, 2.3191e-01,
8.3981e-02, 4.1990e-02, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), 'intensity': 1.0, 'map': {'thetas': array([0.0000e+00, 5.0000e+00, 1.0000e+01, 1.5000e+01, 2.0000e+01,
2.5000e+01, 3.0000e+01, 3.5000e+01, 4.0000e+01, 4.5000e+01,
5.0000e+01, 5.5000e+01, 6.0000e+01, 6.5000e+01, 7.0000e+01,
7.5000e+01, 8.0000e+01, 8.5000e+01, 9.0000e+01]), 'phis': array([0.0000e+00]), 'values': array([[1.0000e+00, 8.4184e-01, 6.8368e-01, 4.9221e-01, 3.0073e-01,
2.5651e-01, 2.1229e-01, 2.9607e-01, 3.7984e-01, 2.3191e-01,
8.3981e-02, 4.1990e-02, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]])}, 'theta': array([0.0000e+00, 5.0000e+00, 1.0000e+01, 1.5000e+01, 2.0000e+01,
2.5000e+01, 3.0000e+01, 3.5000e+01, 4.0000e+01, 4.5000e+01,
5.0000e+01, 5.5000e+01, 6.0000e+01, 6.5000e+01, 7.0000e+01,
7.5000e+01, 8.0000e+01, 8.5000e+01, 9.0000e+01]), 'values': array([[1.0000e+00, 8.4184e-01, 6.8368e-01, 4.9221e-01, 3.0073e-01,
2.5651e-01, 2.1229e-01, 2.9607e-01, 3.7984e-01, 2.3191e-01,
8.3981e-02, 4.1990e-02, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), 'phi': array([0.0000e+00]), 'Iv0': 1.5}
[DEBUG] Exception occured in handler: Object of type ndarray is not JSON serializable
File "C:\Python39\lib\site-packages\ghhops_server\params.py", line 175, in from_result
json_data = RHINO_TOJSON(value)
File "C:\Python39\lib\site-packages\ghhops_server\params.py", line 98, in to_json
return json.dumps(value, cls=_HopsEncoder)
File "C:\Python39\lib\json\__init__.py", line 234, in dumps
return cls(
File "C:\Python39\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Python39\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Python39\lib\site-packages\ghhops_server\base.py", line 224, in default
return json.JSONEncoder.default(self, o)
File "C:\Python39\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
[DEBUG] False : {"values": [], "errors": ["Exception occured in handler:\nObject of type ndarray is not JSON serializable\n File \"C:\\Python39\\lib\\site-packages\\ghhops_server\\params.py\", line 175, in from_result\n json_data = RHINO_TOJSON(value)\n\n File \"C:\\Python39\\lib\\site-packages\\ghhops_server\\params.py\", line 98, in to_json\n return json.dumps(value, cls=_HopsEncoder)\n\n File \"C:\\Python39\\lib\\json\\__init__.py\", line 234, in dumps\n return cls(\n\n File \"C:\\Python39\\lib\\json\\encoder.py\", line 199, in encode\n chunks = self.iterencode(o, _one_shot=True)\n\n File \"C:\\Python39\\lib\\json\\encoder.py\", line 257, in iterencode\n return _iterencode(o, 0)\n\n File \"C:\\Python39\\lib\\site-packages\\ghhops_server\\base.py\", line 224, in default\n return json.JSONEncoder.default(self, o)\n\n File \"C:\\Python39\\lib\\json\\encoder.py\", line 179, in default\n raise TypeError(f'Object of type {o.__class__.__name__} '\n"]}
[INFO] 127.0.0.1 - - [23/Mar/2021 22:36:40] "POST /solve HTTP/1.1" 500 -
Process finished with exit code -1