picadae calibration programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

velTableToDataStruct.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ##| Copyright: (C) 2019-2020 Kevin Larke <contact AT larke DOT org>
  2. ##| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. import json
  4. from common import parse_yaml_cfg
  5. ymlFn = 'p_ac.yml'
  6. ifn = 'velMapD.json'
  7. ofn = 'velMapD.h'
  8. with open(ofn,"wt") as f1:
  9. with open(ifn,"r") as f:
  10. d = json.load(f)
  11. f1.write("{\n");
  12. for key,velL in d.items():
  13. f1.write("{ ")
  14. f1.write( str(key) + ", { " )
  15. for us,x in velL:
  16. f1.write("%5i, " % (us))
  17. f1.write("} },\n")
  18. f1.write("}\n\n");
  19. cfg = parse_yaml_cfg(ymlFn)
  20. d = cfg.calibrateArgs['holdDutyPctD']
  21. n = 0
  22. for key,dutyL in d.items():
  23. n = max(n, len(dutyL))
  24. f1.write("{\n")
  25. for key,dutyL in d.items():
  26. f1.write( str(key)+", {")
  27. for i,(us,duty) in enumerate(dutyL):
  28. f1.write("{ %i, %i }, " % (us,duty))
  29. for j in range(i,n):
  30. f1.write("{ -1, -1 }, ")
  31. f1.write("},\n");
  32. f1.write("}\n");