Add warp time graph
This commit is contained in:
61
eos/graph/fitWarpTimeDistance.py
Normal file
61
eos/graph/fitWarpTimeDistance.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import math
|
||||
from logbook import Logger
|
||||
|
||||
from eos.graph import Graph
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
AU_METERS = 149597870700
|
||||
|
||||
|
||||
class FitWarpTimeDistanceGraph(Graph):
|
||||
|
||||
defaults = {"distance": 0}
|
||||
|
||||
def __init__(self, fit, data=None):
|
||||
Graph.__init__(self, fit, self.calcTime, data if data is not None else self.defaults)
|
||||
self.fit = fit
|
||||
|
||||
def calcTime(self, data):
|
||||
distance = data["distance"]
|
||||
if distance == 0:
|
||||
return 0
|
||||
maxWarpDistance = self.fit.maxWarpDistance
|
||||
if distance > maxWarpDistance:
|
||||
return None
|
||||
maxSubwarpSpeed = self.fit.ship.getModifiedItemAttr('maxVelocity')
|
||||
maxWarpSpeed = self.fit.warpSpeed
|
||||
time = calculate_time_in_warp(maxWarpSpeed, maxSubwarpSpeed, distance * AU_METERS)
|
||||
return time
|
||||
|
||||
|
||||
# Taken from https://wiki.eveuniversity.org/Warp_time_calculation#Implementation
|
||||
# with minor modifications
|
||||
# Warp speed in AU/s, subwarp speed in m/s, distance in m
|
||||
def calculate_time_in_warp(max_warp_speed, max_subwarp_speed, warp_dist):
|
||||
|
||||
k_accel = max_warp_speed
|
||||
k_decel = min(max_warp_speed / 3, 2)
|
||||
|
||||
warp_dropout_speed = max_subwarp_speed / 2
|
||||
max_ms_warp_speed = max_warp_speed * AU_METERS
|
||||
|
||||
accel_dist = AU_METERS
|
||||
decel_dist = max_ms_warp_speed / k_decel
|
||||
|
||||
minimum_dist = accel_dist + decel_dist
|
||||
|
||||
cruise_time = 0
|
||||
|
||||
if minimum_dist > warp_dist:
|
||||
max_ms_warp_speed = warp_dist * k_accel * k_decel / (k_accel + k_decel)
|
||||
else:
|
||||
cruise_time = (warp_dist - minimum_dist) / max_ms_warp_speed
|
||||
|
||||
accel_time = math.log(max_ms_warp_speed / k_accel) / k_accel
|
||||
decel_time = math.log(max_ms_warp_speed / warp_dropout_speed) / k_decel
|
||||
|
||||
total_time = cruise_time + accel_time + decel_time
|
||||
return total_time
|
||||
@@ -2,10 +2,11 @@ __all__ = [
|
||||
'fitDpsRange',
|
||||
'fitDpsTime',
|
||||
'fitDmgTime',
|
||||
'fitSpeedTime',
|
||||
'fitDistanceTime',
|
||||
'fitShieldRegenAmount',
|
||||
'fitShieldAmountTime',
|
||||
'fitCapRegenAmount',
|
||||
'fitCapAmountTime'
|
||||
'fitCapAmountTime',
|
||||
'fitSpeedTime',
|
||||
'fitDistanceTime',
|
||||
'fitWarpTimeDistance'
|
||||
]
|
||||
|
||||
82
gui/builtinGraphs/fitWarpTimeDistance.py
Normal file
82
gui/builtinGraphs/fitWarpTimeDistance.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# =============================================================================
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
import gui.mainFrame
|
||||
from eos.graph import Data
|
||||
from eos.graph.fitWarpTimeDistance import FitWarpTimeDistanceGraph as EosFitWarpTimeDistanceGraph
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.graph import Graph
|
||||
from service.attribute import Attribute
|
||||
|
||||
|
||||
class FitWarpTimeDistanceGraph(Graph):
|
||||
|
||||
propertyLabelMap = {"distance": "Distance (AU)"}
|
||||
|
||||
defaults = EosFitWarpTimeDistanceGraph.defaults.copy()
|
||||
|
||||
def __init__(self):
|
||||
Graph.__init__(self)
|
||||
self.defaults["distance"] = "0-50"
|
||||
self.name = "Warp Time vs. Distance"
|
||||
self.eosGraph = None
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def getFields(self):
|
||||
return self.defaults
|
||||
|
||||
def getLabels(self):
|
||||
return self.propertyLabelMap
|
||||
|
||||
def getIcons(self):
|
||||
iconFile = Attribute.getInstance().getAttributeInfo('maxRange').iconID
|
||||
bitmap = BitmapLoader.getBitmap(iconFile, "icons")
|
||||
return {"distance": bitmap}
|
||||
|
||||
def getPoints(self, fit, fields):
|
||||
eosGraph = getattr(self, "eosGraph", None)
|
||||
if eosGraph is None or eosGraph.fit != fit:
|
||||
eosGraph = self.eosGraph = EosFitWarpTimeDistanceGraph(fit)
|
||||
|
||||
eosGraph.clearData()
|
||||
variable = None
|
||||
for fieldName, value in fields.items():
|
||||
d = Data(fieldName, value)
|
||||
if not d.isConstant():
|
||||
if variable is None:
|
||||
variable = fieldName
|
||||
else:
|
||||
# We can't handle more then one variable atm, OOPS FUCK OUT
|
||||
return False, "Can only handle 1 variable"
|
||||
|
||||
eosGraph.setData(d)
|
||||
|
||||
if variable is None:
|
||||
return False, "No variable"
|
||||
|
||||
x = []
|
||||
y = []
|
||||
for point, val in eosGraph.getIterator():
|
||||
if val is not None:
|
||||
x.append(point[variable])
|
||||
y.append(val)
|
||||
return x, y
|
||||
|
||||
|
||||
FitWarpTimeDistanceGraph.register()
|
||||
Reference in New Issue
Block a user