Coverage for docs/source/examples/breakdowns.py: 10%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

29 statements  

1"An example to show off Breakdowns" 

2import pickle 

3from gpkit.breakdowns import Breakdowns 

4 

5# the code to create solar.p is in ./breakdowns/solartest.py 

6sol = pickle.load(open("solar.p", "rb")) 

7bds = Breakdowns(sol) 

8 

9print("Cost breakdown (you may be familiar with this from solution tables)") 

10print("==============") 

11bds.plot("cost") 

12 

13print("Variable breakdowns (note the two methods of access)") 

14print("===================") 

15varkey, = sol["variables"].keymap[("Mission.FlightSegment.AircraftPerf" 

16 ".AircraftDrag.Poper")] 

17bds.plot(varkey) 

18bds.plot("AircraftPerf.AircraftDrag.MotorPerf.Q") 

19 

20print("Combining the two above by increasing maxwidth") 

21print("----------------------------------------------") 

22bds.plot("AircraftPerf.AircraftDrag.Poper", maxwidth=105) 

23 

24print("Model sensitivity breakdowns (note the two methods of access)") 

25print("============================") 

26bds.plot("model sensitivities") 

27bds.plot("Aircraft") 

28 

29print("Exhaustive variable breakdown traces (and configuration arguments)") 

30print("====================================") 

31# often useful as a reference point when reading traces 

32bds.plot("AircraftPerf.AircraftDrag.Poper", height=12) 

33# includes factors, can be useful for reading traces as well 

34bds.plot("AircraftPerf.AircraftDrag.Poper", showlegend=True) 

35print("\nPermissivity = 2 (the default)") 

36print("----------------") 

37bds.trace("AircraftPerf.AircraftDrag.Poper") 

38print("\nPermissivity = 1 (stops at Pelec = v·i)") 

39print("----------------") 

40bds.trace("AircraftPerf.AircraftDrag.Poper", permissivity=1)