Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception at live re-start #2

Open
bijwaard opened this issue Aug 9, 2023 · 2 comments
Open

Exception at live re-start #2

bijwaard opened this issue Aug 9, 2023 · 2 comments

Comments

@bijwaard
Copy link

bijwaard commented Aug 9, 2023

Hi Gerwin,

I get the following exception at start related to sunData, and sometimes also later. I merged the old ORTEP scripts using the sst sensor and model workspace with the most recent Demkit. In the ORTEP model the sunData is used to predict PV on both 3-phase and single-line inverters:

  • pvc = LivePvCtrl("PVCTRL_3P_L"+str(i+1), pv, ctrl, sun, sim)
  • pvc = LivePvCtrl("PVCTRL_SP_L3", pv, ctrl, sun, sim)
09:24:43 | MESSAGE: Starting
09:24:50 | MESSAGE: Simulating at time: 09-08-2023 09:24:50 CEST+0200
Exception in thread Thread-3 (zCallSingle):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dennis/work/ortep/demkit-github/components/core/core.py", line 682, in zCallSingle
    return getattr(recv, func)(*args)
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/groupCtrl.py", line 225, in initiatePlanning
    self.doInitialPlanning(s)
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/groupCtrl.py", line 261, in doInitialPlanning
    results = self.zCall(self.children, 'doInitialPlanning', s, list(parents))
  File "/home/dennis/work/ortep/demkit-github/components/core/entity.py", line 143, in zCall
    return self.host.zCall(receivers, func, *args)
  File "/home/dennis/work/ortep/demkit-github/components/core/core.py", line 654, in zCall
    return self.zCallList(receivers, func, *args)
  File "/home/dennis/work/ortep/demkit-github/components/core/core.py", line 671, in zCallList
    result[recv] = getattr(recv, func)(*args)
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/devCtrl.py", line 158, in doInitialPlanning
    result = copy.deepcopy(self.doPlanning(signal,  False))
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/loadCtrl.py", line 133, in doPlanning
    p[c] = self.doPrediction(time-(time%timeBase),  time-(time%timeBase)+timeBase*len(signal.desired[c]))
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/live/livePvCtrl.py", line 82, in doPrediction
    result = self.predictProduction(sunPrediction, startTime,  endTime)
  File "/home/dennis/work/ortep/demkit-github/components/ctrl/live/livePvCtrl.py", line 171, in predictProduction
    result.append(min(0, max(sunData[idx]['GHI']*self.model[b][0] + sunData[idx]['DNI']*self.model[b][1], self.maxProduction[b]) ) )
IndexError: list index out of range

Kind regards,
Dennis

@bijwaard
Copy link
Author

bijwaard commented Aug 9, 2023

I did some debugging, on the arguments of result.append and found the following, apparently self.maxProduction is empty, while it worked fine until 01:00 this morning after I started yesterday.

12:17:41 | WARNING: [PVCTRL_3P_L1] livePvCtrl model b=20 idx=0, len(model)=48, len(maxProduction)=0

Because of this, I now initialize self.maxProduction in livePvCtrl::startup() after self.bins is initialized.

	def startup(self):
		self.bins = int(86400/self.binSize) # 1 day = 86400 seconds
		self.maxProduction = [0] * self.bins

@bijwaard
Copy link
Author

bijwaard commented Aug 9, 2023

Apparently not all realized values are available after restarting demkit with live data, also had to change the following in loadCtrl::updatePrediction(self):

-						self.realized[c][time] = prediction[idx]
+						try:
+							self.realized[c][time] = prediction[idx]
+						except:
+							self.realized[c]={ time : prediction[idx] }

The mix-up may have appeared because I wrestled a bit with the ortep model while changing the measurements and prediction of the single-line inverter from L2 to L3.

@bijwaard bijwaard changed the title Exception at start Exception at live re-start Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant