Skip to content

Commit

Permalink
in preparation for convexengineering/gpkit#1463
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Mar 3, 2020
1 parent eac35af commit 9ff5568
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
1 change: 1 addition & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python -c "from gpkit.tests.from_paths import run; run(skipsolvers='look around')"
42 changes: 20 additions & 22 deletions solar/season.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

#pylint: disable=invalid-name

def season(lats):
def season(lats, days=[80, 52, 21, 355]):
" trade seasonal availibility with weight "
days = [80, 52, 21, 355]

V = Aircraft(sp=False)
data = {}
for l in lats:
failed = False
Expand All @@ -19,7 +18,6 @@ def season(lats):
if failed:
mtows = mtows + [np.nan]*(4-len(mtows))
break
V = Aircraft(sp=False)
M = Mission(V, latitude=range(1, l+1, 1), day=d)
M.cost = M[M.aircraft.Wtotal]
try:
Expand Down Expand Up @@ -59,23 +57,23 @@ def plot_season(df):

def test():
"setup for integrated testing"
_ = season([20])
_ = season(lats=[20], days=[355])

if __name__ == "__main__":

if len(sys.argv) > 1:
path = sys.argv[1]
else:
path = ""

GENERATE = False

if GENERATE:
DF = season(range(20, 30, 2))
DF.to_csv("season.generated.csv")
else:
DF = pd.read_csv("season.generated.csv")
del DF["Unnamed: 0"]

f, a = plot_season(DF)
f.savefig(path + "season.pdf", bbox_inches="tight")
test()
# if len(sys.argv) > 1:
# path = sys.argv[1]
# else:
# path = ""
#
# GENERATE = False
#
# if GENERATE:
# DF = season(range(20, 30, 2))
# DF.to_csv("season.generated.csv")
# else:
# DF = pd.read_csv("season.generated.csv")
# del DF["Unnamed: 0"]
#
# f, a = plot_season(DF)
# f.savefig(path + "season.pdf", bbox_inches="tight")
44 changes: 22 additions & 22 deletions solar/sens_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ def test():
_ = get_highestsens(model, result, vn)

if __name__ == "__main__":

if len(sys.argv) > 1:
path = sys.argv[1]
else:
path = ""

V = Aircraft(Npod=0, sp=False)
M = Mission(V, latitude=[20])
M.cost = M[M.aircraft.Wtotal]
sol = M.solve("mosek")

vns = {M.aircraft.Wpay: "$W_{\\mathrm{pay}}$",
M.aircraft.battery.etacharge: "$\\eta_{\\mathrm{charge}}$",
M.aircraft.battery.etadischarge: "$\\eta_{\\mathrm{discharge}}$",
M.aircraft.battery.hbatt: "$h_{\\mathrm{batt}}$",
M.aircraft.solarcells.etasolar: "$\\eta_{\\mathrm{solar}}$",
"Nmax": "$N_{\\mathrm{max}}$",
"e": "$e$", "etaprop": "$\\eta_{\\mathrm{prop}}$"}

sd = get_highestsens(M, sol, N=10)
f, a = plot_chart(sd)
f.savefig(path + "sensbar.pdf", bbox_inches="tight")
test()
# if len(sys.argv) > 1:
# path = sys.argv[1]
# else:
# path = ""
#
# V = Aircraft(Npod=0, sp=False)
# M = Mission(V, latitude=[20])
# M.cost = M[M.aircraft.Wtotal]
# sol = M.solve("mosek")
#
# vns = {M.aircraft.Wpay: "$W_{\\mathrm{pay}}$",
# M.aircraft.battery.etacharge: "$\\eta_{\\mathrm{charge}}$",
# M.aircraft.battery.etadischarge: "$\\eta_{\\mathrm{discharge}}$",
# M.aircraft.battery.hbatt: "$h_{\\mathrm{batt}}$",
# M.aircraft.solarcells.etasolar: "$\\eta_{\\mathrm{solar}}$",
# "Nmax": "$N_{\\mathrm{max}}$",
# "e": "$e$", "etaprop": "$\\eta_{\\mathrm{prop}}$"}
#
# sd = get_highestsens(M, sol, N=10)
# f, a = plot_chart(sd)
# f.savefig(path + "sensbar.pdf", bbox_inches="tight")

0 comments on commit 9ff5568

Please sign in to comment.