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

Carb ratio of 26 reported as 0.26 in profile.json #432

Closed
ryanchen26 opened this issue Mar 27, 2017 · 24 comments
Closed

Carb ratio of 26 reported as 0.26 in profile.json #432

ryanchen26 opened this issue Mar 27, 2017 · 24 comments

Comments

@ryanchen26
Copy link

After changing a carb ratio setting in the pump (723) from 25 to 26 and running autotune manually autotune failed to run because of the error: carb ratio 0.26 out of range. The ratio change to 26 had been interpreted as 0.26 in profile.json.

@scottleibrand
Copy link
Contributor

This is caused by openaps/openaps#111 - we'll need some folks to help figure out the underlying issue with decocare.

@scottleibrand
Copy link
Contributor

As a workaround, you could maybe set the carb ratio to 25 at midnight, and then let autotune adjust it upward from there. To make sure you're actually bolusing off the correct carb ratio in the pump, you can then set a 1am carb ratio to the correct value for the rest of the day. @Mackwe

@Mackwe
Copy link

Mackwe commented Jul 3, 2017

Thank you @scottleibrand . I believe I don't have enough data yet for autotune to work and letting autosens free to change it about x2(!).. I think I would need to wait for openaps/openaps#111 to get fixed (or fix it myself, but I lack time at the moment).

@YYGIRL
Copy link

YYGIRL commented Jul 9, 2017

I have this issue @scottleibrand @Mackwe @ryanchen26. I troubleshooted with @Kdisimone. I am not running autotune, only autosens. It is causing me to get NaN errors and causes lots of other random errors including OpenAPS will set my temp basal to zero. OpenAPS will also not create a pumpprofile.json file. My son has been running very high in the afternoon and at night. I have a 723. This will affect a lot of little kids with an x23, and I know of at least another one (Leigh Fickling's daughter). My son's carb ratios are almost all above 25 (most are from 30-50) except for one - the one time of day he runs OK. Many thanks.

@YYGIRL
Copy link

YYGIRL commented Jul 9, 2017

I am switching to my 722 for now, but any other workaround ideas would be great - for the community, and like I said especially for the little kids and for people who might not have another pump. Thanks again.

@scottleibrand
Copy link
Contributor

As a workaround, I could have oref0 multiply any < 1 carb ratios by 100 until someone fixes this properly in openaps/decocare. Our 723 supports 1.0 to 200, and the 522 supports 3.0 to 150, so we know that any reading < 1 is incorrect, and must really represent something in the 25-99 range. I don't know how CRs >= 100 show up, and whether any further adjustments would be needed there.

@YYGIRL
Copy link

YYGIRL commented Jul 9, 2017

Yes! That would work. However, the r value is wrong as well? What is that? Is it used in calculations?

@scottleibrand
Copy link
Contributor

Does the r value match the ratio value?

We don't use r for anything in oref0, so I could probably just ignore that. Since I'd be putting this workaround into oref0, the actual contents of carb_ratios.json would be unchanged: we would just apply the correction when creating the profile.json.

@scottleibrand
Copy link
Contributor

Ok, just pushed an as-yet-untested commit that implements the workaround. If anyone currently running oref0 dev wants to test it, you can cd ~/src/oref0 and git checkout cr-decoding-workaround.

@Kdisimone
Copy link
Contributor

I can setup a test rig for this later today

@YYGIRL
Copy link

YYGIRL commented Jul 9, 2017

Here's a correct entry:
r: 230; ratio: 23.0
r: 80; ratio: 8.0
Incorrect entries (seems random, depending on time of day):
r: 32; ratio: 0.8
r: 34; ratio: 0.29
r: 244; ratio 0.5
r: 94; ratio 0.35
r: 144; ratio 0.4

So I think you could multiply the CR number coming in by 100 and get the ratio number; and you could multiply the CR number coming by 1000 and get the r number.

@Kdisimone
Copy link
Contributor

@scottleibrand do I also need to do an npm-global-install after the branch change? thus far the fix isn't implementing the *100

@Kdisimone
Copy link
Contributor

glucose.json newer than pumphistory: Refreshed pumphistory
{"carbs":0,"mealCOB":0,"reason":"carb_ratio 0.57 out of bounds"}

@PieterGit
Copy link
Contributor

I'm -1 on implementing a workaround of changing carb ratio in oref0 instead of fixing the real problem in decocare or wherever. Please stick to https://en.wikipedia.org/wiki/Separation_of_concerns and make sure oref0 can trust the the carb ratio it gets. If it's not a oref0 bug, it should not be fixed in oref0.

@PieterGit
Copy link
Contributor

Just had a quick peek and search. Isn't this the logic where it goes wrong?
https://github.com/openaps/decocare/blob/6c87c83c8280850411a78b21005d217aaf06caa9/decocare/commands.py#L1000

@scottleibrand
Copy link
Contributor

@YYGIRL (or anyone else who's seeing this): could you paste in your full carb_ratios.json, as well as a list of what the carb ratio schedule actually is, so we can figure out how to adjust the https://github.com/openaps/decocare/blob/master/decocare/commands.py#L1000-L1002 logic to fix this properly?

@moomoobloo
Copy link
Contributor

I submitted openaps/decocare#28, so probably the workaround isn't needed.

@Kdisimone
Copy link
Contributor

root@jubilinux:~/src/oref0# cat ~/myopenaps/settings/carb_ratios.json
{
  "units": "grams", 
  "first": 1, 
  "schedule": [
    {
      "q": 1, 
      "start": "00:00:00", 
      "r": 24, 
      "ratio": 0.28, 
      "offset": 0, 
      "i": 0, 
      "x": 0
    }, 
    {
      "q": 2, 
      "start": "16:00:00", 
      "r": 138, 
      "ratio": 0.65, 
      "offset": 960, 
      "i": 32, 
      "x": 1
    }, 
    {
      "q": 1, 
      "start": "17:30:00", 
      "r": 24, 
      "ratio": 0.28, 
      "offset": 1050, 
      "i": 35, 
      "x": 2
    }, 
    {
      "q": 2, 
      "start": "18:00:00", 
      "r": 58, 
      "ratio": 0.57, 
      "offset": 1080, 
      "i": 36, 
      "x": 3
    }
  ]

actual are (test pump)
midnight 28
4pm 65
5:30 28
6:00 57

@scottleibrand
Copy link
Contributor

@Kdisimone Did you check out and install openaps/decocare#28? If so, which commands did you use?

@Kdisimone
Copy link
Contributor

Kdisimone commented Jul 10, 2017

@scottleibrand I am testing it out. I'm not so git saavy still so I manually edited file with
nano /home/.rootfs/usr/local/lib/python2.7/dist-packages/decocare/commands.py
and then followed the changes in #28

screen shot 2017-07-09 at 9 04 02 pm

@scottleibrand
Copy link
Contributor

I have no idea whether that file is the one actually being used by your system. I would instead clone the decocare repo, get the fixed source code from @moomoobloo's branch using the command-line instructions (the part about how to check out a new branch and test the changes) in the merge section at the bottom of openaps/decocare#28 .

Then, once you've verified you have the right source code, you can install that using these directions:
https://github.com/openaps/decocare#from-source

Hit me up on Slack or Gitter if you run into any trouble with that...

@Kdisimone
Copy link
Contributor

OK...I'll try that because it doesn't look like my attempt worked. :)

@scottleibrand
Copy link
Contributor

Since openaps/decocare#28 was merged to dev, It looks like the only thing remaining to do to resolve this is to release decocare dev to master, and update oref0 to install it. Leaving this open for now until we get closer to that. In the mean time, anyone affected by this issue can simply clone and install decocare dev.

@Kdisimone
Copy link
Contributor

Kdisimone commented Jul 24, 2017

Leaving the specific commands here for info:

For x23 and x54 pumps for carb ratios over 25 and/or ISF over 255:

cd && git clone https://github.com/openaps/decocare.git

cd decocare

git checkout dev

sudo python setup.py develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants