From 988688939b6e87f5de3b296e803cc34f084e3c89 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 28 Jun 2019 20:17:23 +0300 Subject: [PATCH] Merge cap regen graph into already existing cap graph --- eos/graph/fitCapRegenVsCapPerc.py | 14 ---- gui/builtinGraphs/fitCap.py | 78 ++++++++++++++++++++--- gui/builtinGraphs/fitCapRegenVsCapPerc.py | 44 ------------- gui/builtinGraphs/fitDamageStats.py | 10 +-- gui/builtinGraphs/fitWarpTime.py | 2 +- 5 files changed, 75 insertions(+), 73 deletions(-) delete mode 100644 eos/graph/fitCapRegenVsCapPerc.py delete mode 100644 gui/builtinGraphs/fitCapRegenVsCapPerc.py diff --git a/eos/graph/fitCapRegenVsCapPerc.py b/eos/graph/fitCapRegenVsCapPerc.py deleted file mode 100644 index d4a01f7c7..000000000 --- a/eos/graph/fitCapRegenVsCapPerc.py +++ /dev/null @@ -1,14 +0,0 @@ -import math - -from .base import SmoothGraph - - -class FitCapRegenVsCapPercGraph(SmoothGraph): - - def getYForX(self, fit, extraData, perc): - maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity') - regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 - currentCap = maxCap * perc / 100 - # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate - regen = 10 * maxCap / regenTime * (math.sqrt(currentCap / maxCap) - currentCap / maxCap) - return regen diff --git a/gui/builtinGraphs/fitCap.py b/gui/builtinGraphs/fitCap.py index 33ef59aa9..7e9dc8c58 100644 --- a/gui/builtinGraphs/fitCap.py +++ b/gui/builtinGraphs/fitCap.py @@ -30,31 +30,91 @@ class FitCapAmountVsTimeGraph(FitGraph): # UI stuff @property def xDefs(self): - return [XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))] + return [ + XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')), + XDef(handle='capAmount', unit='GJ', label='Cap amount', mainInput=('capAmount', '%')), + XDef(handle='capAmount', unit='%', label='Cap amount', mainInput=('capAmount', '%'))] @property def yDefs(self): - return [YDef(handle='capAmount', unit='GJ', label='Cap amount')] + return [ + YDef(handle='capAmount', unit='GJ', label='Cap amount'), + YDef(handle='capRegen', unit='GJ/s', label='Cap regen')] @property def inputs(self): - return [Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=False)] + return [ + Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=False), + Input(handle='capAmount', unit='%', label='Cap amount', iconID=1668, defaultValue=25, defaultRange=(0, 100), mainOnly=True)] # Calculation stuff + _normalizers = { + ('capAmount', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('capacitorCapacity')} + + _limiters = { + 'capAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('capacitorCapacity'))} + + _denormalizers = { + ('capAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('capacitorCapacity')} + def _time2capAmount(self, mainInput, miscInputs, fit, tgt): xs = [] ys = [] - maxCap = fit.ship.getModifiedItemAttr('capacitorCapacity') - regenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 + maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity') + capRegenTime = 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 + currentCapAmount = calculateCapAmount(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, time=time) xs.append(time) - ys.append(cap) + ys.append(currentCapAmount) + return xs, ys + + def _time2capRegen(self, mainInput, miscInputs, fit, tgt): + xs = [] + ys = [] + maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity') + capRegenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 + for time in self._iterLinear(mainInput[1]): + currentCapAmount = calculateCapAmount(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, time=time) + currentRegen = calculateCapRegen(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, currentCapAmount=currentCapAmount) + xs.append(time) + ys.append(currentRegen) + return xs, ys + + def _capAmount2capAmount(self, mainInput, miscInputs, fit, tgt): + # Useless, but valid combination of x and y + xs = [] + ys = [] + for currentCapAmount in self._iterLinear(mainInput[1]): + xs.append(currentCapAmount) + ys.append(currentCapAmount) + return xs, ys + + def _capAmount2capRegen(self, mainInput, miscInputs, fit, tgt): + xs = [] + ys = [] + maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity') + capRegenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000 + for currentCapAmount in self._iterLinear(mainInput[1]): + currentRegen = calculateCapRegen(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, currentCapAmount=currentCapAmount) + xs.append(currentCapAmount) + ys.append(currentRegen) return xs, ys _getters = { - ('time', 'capAmount'): _time2capAmount} + ('time', 'capAmount'): _time2capAmount, + ('time', 'capRegen'): _time2capRegen, + ('capAmount', 'capAmount'): _capAmount2capAmount, + ('capAmount', 'capRegen'): _capAmount2capRegen} + + +def calculateCapAmount(maxCapAmount, capRegenTime, time): + # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate + return maxCapAmount * (1 + math.exp(5 * -time / capRegenTime) * -1) ** 2 + + +def calculateCapRegen(maxCapAmount, capRegenTime, currentCapAmount): + # https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate + return 10 * maxCapAmount / capRegenTime * (math.sqrt(currentCapAmount / maxCapAmount) - currentCapAmount / maxCapAmount) FitCapAmountVsTimeGraph.register() diff --git a/gui/builtinGraphs/fitCapRegenVsCapPerc.py b/gui/builtinGraphs/fitCapRegenVsCapPerc.py deleted file mode 100644 index a2607837c..000000000 --- a/gui/builtinGraphs/fitCapRegenVsCapPerc.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.fitCapRegenVsCapPerc import FitCapRegenVsCapPercGraph as EosGraph -from .base import FitGraph, XDef, YDef - - -class FitCapRegenVsCapPercGraph(FitGraph): - - name = 'Cap Regen vs Cap Amount' - - def __init__(self): - super().__init__() - self.eosGraph = EosGraph() - - @property - def xDef(self): - return XDef(inputDefault='0-100', inputLabel='Cap amount (percent)', inputIconID=1668, axisLabel='Cap amount, %') - - @property - def yDefs(self): - return OrderedDict([('capRegen', YDef(switchLabel='Cap regen', axisLabel='Cap regen, GJ/s', eosGraph='eosGraph'))]) - - -FitCapRegenVsCapPercGraph.register() diff --git a/gui/builtinGraphs/fitDamageStats.py b/gui/builtinGraphs/fitDamageStats.py index d92684703..60e1f17d5 100644 --- a/gui/builtinGraphs/fitDamageStats.py +++ b/gui/builtinGraphs/fitDamageStats.py @@ -66,17 +66,17 @@ class FitDamageStatsGraph(FitGraph): # Calculation stuff _normalizers = { ('distance', 'km'): lambda v, fit, tgt: v * 1000, - ('atkSpeed', '%'): lambda v, fit, tgt: v * fit.ship.getModifiedItemAttr('maxVelocity', 0), - ('tgtSpeed', '%'): lambda v, fit, tgt: v * tgt.ship.getModifiedItemAttr('maxVelocity', 0), - ('tgtSigRad', '%'): lambda v, fit, tgt: v * fit.ship.getModifiedItemAttr('signatureRadius', 0)} + ('atkSpeed', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('maxVelocity'), + ('tgtSpeed', '%'): lambda v, fit, tgt: v / 100 * tgt.ship.getModifiedItemAttr('maxVelocity'), + ('tgtSigRad', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('signatureRadius')} _limiters = { 'time': lambda fit, tgt: (0, 2500)} _denormalizers = { ('distance', 'km'): lambda v, fit, tgt: v / 1000, - ('tgtSpeed', '%'): lambda v, fit, tgt: v / tgt.ship.getModifiedItemAttr('maxVelocity', 0), - ('tgtSigRad', '%'): lambda v, fit, tgt: v / fit.ship.getModifiedItemAttr('signatureRadius', 0)} + ('tgtSpeed', '%'): lambda v, fit, tgt: v * 100 / tgt.ship.getModifiedItemAttr('maxVelocity'), + ('tgtSigRad', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('signatureRadius')} def _distance2dps(self, mainInput, miscInputs, fit, tgt): return [], [] diff --git a/gui/builtinGraphs/fitWarpTime.py b/gui/builtinGraphs/fitWarpTime.py index 6d2eafcce..d2c322dec 100644 --- a/gui/builtinGraphs/fitWarpTime.py +++ b/gui/builtinGraphs/fitWarpTime.py @@ -66,7 +66,7 @@ class FitWarpTimeGraph(FitGraph): subwarpSpeed = self.__getSubwarpSpeed(fit) warpSpeed = fit.warpSpeed for distance in self._iterLinear(mainInput[1]): - time = calculate_time_in_warp(subwarpSpeed, warpSpeed, distance) + time = calculate_time_in_warp(max_subwarp_speed=subwarpSpeed, max_warp_speed=warpSpeed, warp_dist=distance) xs.append(distance) ys.append(time) return xs, ys