diff --git a/eos/graph/fitCapAmountVsTime.py b/eos/graph/fitCapAmountVsTime.py deleted file mode 100644 index e0a9069a0..000000000 --- a/eos/graph/fitCapAmountVsTime.py +++ /dev/null @@ -1,15 +0,0 @@ -import math - -from .base import SmoothGraph - - -class FitCapAmountVsTimeGraph(SmoothGraph): - - def getYForX(self, fit, extraData, time): - if time < 0: - return 0 - maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity') - regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 - # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate - cap = maxCap * (1 + math.exp(5 * -time / regenTime) * -1) ** 2 - return cap diff --git a/gui/builtinGraphs/__init__.py b/gui/builtinGraphs/__init__.py index 5e3cf7838..b61b12335 100644 --- a/gui/builtinGraphs/__init__.py +++ b/gui/builtinGraphs/__init__.py @@ -4,7 +4,7 @@ from gui.builtinGraphs import ( # noqa: E402,F401 # fitDmgVsTime, # fitShieldRegenVsShieldPerc, # fitShieldAmountVsTime, - # fitCapRegenVsCapPerc, + fitCap, # fitCapAmountVsTime, fitMobility, fitWarpTime diff --git a/gui/builtinGraphs/fitCap.py b/gui/builtinGraphs/fitCap.py new file mode 100644 index 000000000..33ef59aa9 --- /dev/null +++ b/gui/builtinGraphs/fitCap.py @@ -0,0 +1,60 @@ +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + + +import math + +from .base import FitGraph, XDef, YDef, Input + + +class FitCapAmountVsTimeGraph(FitGraph): + + name = 'Capacitor' + + # UI stuff + @property + def xDefs(self): + return [XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))] + + @property + def yDefs(self): + return [YDef(handle='capAmount', unit='GJ', label='Cap amount')] + + @property + def inputs(self): + return [Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=False)] + + # Calculation stuff + def _time2capAmount(self, mainInput, miscInputs, fit, tgt): + xs = [] + ys = [] + maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity') + regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 + for time in self._iterLinear(mainInput[1]): + # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate + cap = maxCap * (1 + math.exp(5 * -time / regenTime) * -1) ** 2 + xs.append(time) + ys.append(cap) + return xs, ys + + _getters = { + ('time', 'capAmount'): _time2capAmount} + + +FitCapAmountVsTimeGraph.register() diff --git a/gui/builtinGraphs/fitCapAmountVsTime.py b/gui/builtinGraphs/fitCapAmountVsTime.py deleted file mode 100644 index 3958687a7..000000000 --- a/gui/builtinGraphs/fitCapAmountVsTime.py +++ /dev/null @@ -1,44 +0,0 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - - -from collections import OrderedDict - -from eos.graph.fitCapAmountVsTime import FitCapAmountVsTimeGraph as EosGraph -from .base import FitGraph, XDef, YDef - - -class FitCapAmountVsTimeGraph(FitGraph): - - name = 'Cap Amount vs Time' - - def __init__(self): - super().__init__() - self.eosGraph = EosGraph() - - @property - def xDef(self): - return XDef(inputDefault='0-300', inputLabel='Time (seconds)', inputIconID=1392, axisLabel='Time, s') - - @property - def yDefs(self): - return OrderedDict([('capAmount', YDef(switchLabel='Cap amount', axisLabel='Cap amount, GJ', eosGraph='eosGraph'))]) - - -FitCapAmountVsTimeGraph.register()