Repository: Akkudoktor-EOS/EOS

Issue:
[BUG]: Exception in visualize
### Describe the issue:

optimize results in exception. 

### Reproduceable code example:

```python
#    report.create_line_chart_date(                                                                                                                                                                                                                             
#       next_full_hour_date,                                                                                                                                                                                                                                    
#        [                                                                                                                                                                                                                                                      
#            np.full(                                                                                                                                                                                                                                           
#                len(parameters.ems.gesamtlast) - start_hour,                                                                                                                                                                                                   
#                parameters.ems.einspeiseverguetung_euro_pro_wh,                                                                                                                                                                                                
#            )                                                                                                                                                                                                                                                  
#        ],                                                                                                                                                                                                                                                     
#        title="Remuneration",                                                                                                                                                                                                                                  
#        # xlabel="Hours", # not enough space                                                                                                                                                                                                                   
#        ylabel="€/Wh",                                                                                                                                                                                                                                         
#        x2label=None,  # not enough space                                                                                                                                                                                                                      
#    )
```

### Error message:

```shell
<details>
Feb 10 08:36:38 openhab fastapi[203759]: Time evaluate inner: 84.2737 sec.
Feb 10 08:36:38 openhab fastapi[203759]:       INFO   192.168.71.12:34946 - "POST /optimize HTTP/1.1" 500
Feb 10 08:36:38 openhab fastapi[203759]:      ERROR   Exception in ASGI application
Feb 10 08:36:38 openhab fastapi[203759]: Traceback (most recent call last):
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
Feb 10 08:36:38 openhab fastapi[203759]:     result = await app(  # type: ignore[func-returns-value]
Feb 10 08:36:38 openhab fastapi[203759]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     return await self.app(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     await super().__call__(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     await self.middleware_stack(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     raise exc
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     await self.app(scope, receive, _send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
Feb 10 08:36:38 openhab fastapi[203759]:     raise exc
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
Feb 10 08:36:38 openhab Node-RED[205792]: 10 Feb 08:36:38 - [warn] [http request:31d21009fe6e6f10] JSON-Parse-Fehler
Feb 10 08:36:38 openhab Node-RED[205792]: 10 Feb 08:36:38 - [error] [function:Store Solution] TypeError: Cannot read properties of undefined (reading 'Last_Wh_pro_Stunde')
Feb 10 08:36:38 openhab fastapi[203759]:     await app(scope, receive, sender)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
Feb 10 08:36:38 openhab fastapi[203759]:     await self.middleware_stack(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
Feb 10 08:36:38 openhab fastapi[203759]:     await route.handle(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
Feb 10 08:36:38 openhab fastapi[203759]:     await self.app(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
Feb 10 08:36:38 openhab fastapi[203759]:     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
Feb 10 08:36:38 openhab fastapi[203759]:     raise exc
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
Feb 10 08:36:38 openhab fastapi[203759]:     await app(scope, receive, sender)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
Feb 10 08:36:38 openhab fastapi[203759]:     response = await f(request)
Feb 10 08:36:38 openhab fastapi[203759]:                ^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
Feb 10 08:36:38 openhab fastapi[203759]:     raw_response = await run_endpoint_function(
Feb 10 08:36:38 openhab fastapi[203759]:                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
Feb 10 08:36:38 openhab fastapi[203759]:     return await run_in_threadpool(dependant.call, **values)
Feb 10 08:36:38 openhab fastapi[203759]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool
Feb 10 08:36:38 openhab fastapi[203759]:     return await anyio.to_thread.run_sync(func)
Feb 10 08:36:38 openhab fastapi[203759]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
Feb 10 08:36:38 openhab fastapi[203759]:     return await get_async_backend().run_sync_in_worker_thread(
Feb 10 08:36:38 openhab fastapi[203759]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
Feb 10 08:36:38 openhab fastapi[203759]:     return await future
Feb 10 08:36:38 openhab fastapi[203759]:            ^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 962, in run
Feb 10 08:36:38 openhab fastapi[203759]:     result = context.run(func, *args)
Feb 10 08:36:38 openhab fastapi[203759]:              ^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/src/akkudoktoreos/server/eos.py", line 838, in fastapi_optimize
Feb 10 08:36:38 openhab fastapi[203759]:     result = opt_class.optimierung_ems(parameters=parameters, start_hour=start_hour)
Feb 10 08:36:38 openhab fastapi[203759]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/src/akkudoktoreos/optimization/genetic.py", line 670, in optimierung_ems
Feb 10 08:36:38 openhab fastapi[203759]:     prepare_visualize(parameters, visualize, start_hour=start_hour)
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/src/akkudoktoreos/utils/visualize.py", line 455, in prepare_visualize
Feb 10 08:36:38 openhab fastapi[203759]:     #            np.full(
Feb 10 08:36:38 openhab fastapi[203759]:                 ^^^^^^^^^
Feb 10 08:36:38 openhab fastapi[203759]:   File "/opt/EOS/.venv/lib/python3.11/site-packages/numpy/_core/numeric.py", line 353, in full
Feb 10 08:36:38 openhab fastapi[203759]:     multiarray.copyto(a, fill_value, casting='unsafe')
Feb 10 08:36:38 openhab fastapi[203759]: ValueError: could not broadcast input array from shape (48,) into shape (40,)
</details>
```

### Version information:

master

Discussion:

Patch:
diff --git a/src/akkudoktoreos/utils/visualize.py b/src/akkudoktoreos/utils/visualize.py
index fc684c9..51ccc63 100644
--- a/src/akkudoktoreos/utils/visualize.py
+++ b/src/akkudoktoreos/utils/visualize.py
@@ -454,7 +454,9 @@ def prepare_visualize(
         [
             np.full(
                 len(parameters.ems.gesamtlast) - start_hour,
-                parameters.ems.einspeiseverguetung_euro_pro_wh,
+                parameters.ems.einspeiseverguetung_euro_pro_wh[start_hour:]
+                if isinstance(parameters.ems.einspeiseverguetung_euro_pro_wh, list)
+                else parameters.ems.einspeiseverguetung_euro_pro_wh,
             )
         ],
         title="Remuneration",


Test patch:
diff --git a/tests/testdata/optimize_input_1.json b/tests/testdata/optimize_input_1.json
index 88000e6..f5cde44 100644
--- a/tests/testdata/optimize_input_1.json
+++ b/tests/testdata/optimize_input_1.json
@@ -1,7 +1,14 @@
 {
     "ems": {
         "preis_euro_pro_wh_akku": 0.0001,
-        "einspeiseverguetung_euro_pro_wh": 0.00007,
+        "einspeiseverguetung_euro_pro_wh": [
+          0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007,
+          0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007,
+          0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007,
+          0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007,
+          0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007, 0.00007,
+          0.00007, 0.00007, 0.00007
+        ],
         "gesamtlast": [
           676.71, 876.19, 527.13, 468.88, 531.38, 517.95, 483.15, 472.28, 1011.68, 995.00,
           1053.07, 1063.91, 1320.56, 1132.03, 1163.67, 1176.82, 1216.22, 1103.78, 1129.12,