Ejemplo n.º 1
0
def plotPath(lat,days):
    ts = np.arange(0,24,0.25)
    for day in days:
        (mon,md) = solar.findDay(day)
        az= solar.azimuth(lat,day,ts)
        alt = solar.altitude(lat,day,ts)
        plt.plot(az,alt,label= mon + " " + str(md) + " " + str(lat) + "deg")
    plt.xlabel('azimuth')
    plt.ylabel('altitude')
    plt.title('Solar Path over Day at '+str(lat)+' degs lat')
    axes = plt.axes()
    handles, labels = axes.get_legend_handles_labels()
    axes.legend(handles, labels, loc=2)
    return axes
Ejemplo n.º 2
0
def plotAltitudeDays(lats,days):
    ts = np.arange(0,24,0.25)
    for lat in lats:
        for day in days:
            (mon,md) = solar.findDay(day)
            plt.plot(ts,solar.altitude(lat,day,ts),label= mon + " " + str(md) + " " + str(lat) + "deg")
    plt.plot(ts,0*np.ones(len(ts)),label="horizon")
    plt.axis([0,24,-90,90])
    plt.xlabel('Hour')
    plt.ylabel('deg')
    plt.title('Solar Altitude Angle over Day at '+str(lat) + ' degs lat')
    axes = plt.axes()
    handles, labels = axes.get_legend_handles_labels()
    axes.legend(handles, labels, loc=3)
    return axes
Ejemplo n.º 3
0
def sol_table(sols, models, varnames, filename, ttype, latns=[],
              title="Design Variables", label="vals"):

    with open(filename, "w") as f:
        f.write("\\begin{longtable}{lccccccccccccc}\n")
        f.write("\\caption{%s}\\\\\n" % title)
        f.write("\\toprule\n")
        f.write("\\toprule\n")
        f.write("\\label{t:%s}\n" % label)
        if ttype == "solar":
            f.write("\\multirow{2}{*}{Variable} & 25$^{\circ}$ Latitude & "
                    "30$^{\circ}$ Latitude & 25$^{\circ}$ Latitude & "
                    "30$^{\circ}$ Latitude \\\\\n")
            f.write("& $p_{\\mathrm{wind}}=0.85$& $p_{\\mathrm{wind}}=0.85$ & "
                    "$p_{\\mathrm{wind}}=0.90$ & "
                    "$p_{\\mathrm{wind}}=0.90$ \\\\\n")
        elif ttype == "tbflex":
            f.write("\\multirow{2}{*}{Variable} & "
                    "\\multicolumn{2}{c}{Without Tail Boom Flex} & "
                    "\\multicolumn{2}{c}{With Tail Boom Flex} \\\\\n")
            f.write("& 25$^{\circ}$ Latitude & 30$^{\circ}$ Latitude & "
                    "25$^{\circ}$ Latitude & 30$^{\circ}$ Latitude \\\\\n")
        elif ttype == "tbflexg":
            f.write("\\multirow{2}{*}{Variable} & Without Tail Boom Flex & "
                    "With Tail Boom Flex \\\\\n")
            f.write("& 9 Day Endurance & 9 Day Endurance \\\\\n")
        elif ttype == "gas":
            f.write("Variable & 5 Day Endurance & 7 Day Endurance & 9 Day "
                    "Endurance\\\\\n")
        else:
            raise ValueError("Invalid ttype. Valid inputs are "
                             "[solar, tbflex, gas]")
        f.write("\\midrule\n")

        for vnm, ltnm in zip(varnames, latns):
            vals = []
            for s, m in zip(sols, models):
                if isinstance(s(vnm), float):
                    val = s(vnm)
                    units = ""
                elif not hasattr(s(vnm), "magnitude"):
                    if ttype == "solar":
                        mn = [max(m[sv].descr["modelnums"]) for sv in
                              s("(E/S)_{irr}") if abs(
                                  s["sensitivities"]["constants"][sv])
                              > 0.01][0]
                        val = [s(vk) for vk in m.varkeys[vnm] if
                               max(vk.modelnums) == mn][0]
                    elif ttype == "gas":
                        val = [s(sv) for sv in s(vnm) if "Loiter"
                               in sv.models][0][1]
                    if hasattr(val, "magnitude"):
                        units = " [" + unitstr(val) + "]"
                        val = val.magnitude
                    else:
                        units = ""
                    if vnm == "\\rho":
                        val = altitude(val)*0.3048
                        units = " [m]"
                else:
                    val = s(vnm).magnitude
                    units = " [" + unitstr(s(vnm)) + "]"
                if "**" in units:
                    sp = units.split("**")
                    units = sp[0] + "$^{" + sp[-1].replace("]", "") + "}$]"
                vals.append(val)
            row = ltnm + units + "&" + " & ".join(["%.3g" % x for x in vals])
            f.write(row + "\\\\\n")
        f.write("\\bottomrule\n")
        f.write("\\end{longtable}")