How to use the pysolar.solar.get_azimuth function in pysolar

To help you get started, we’ve selected a few pysolar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github soravux / skylibs / hdrtools / sunutils.py View on Github external
def sunPosFromCoord(latitude, longitude, time_):
    """
    Find azimuth annd elevation of the sun using the pysolar library.
    Takes latitude(deg), longitude(deg) and a datetime object.
    Return tuple conaining (elevation, azimuth)
    
    TODO verify if timezone influences the results.
    """

    azim = solar.get_azimuth(latitude, longitude, time_)
    alti = solar.get_altitude(latitude, longitude, time_)

    # Convert to radians
    azim = (azim + 360)*np.pi/180
    elev = (90 - alti)*np.pi/180

    return elev, azim
github FreeCAD / FreeCAD / src / Mod / Arch / ArchSite.py View on Github external
hpts = [ [] for i in range(24) ]
    m = [(6,21),(7,21),(8,21),(9,21),(10,21),(11,21),(12,21)]
    if complete:
        m.extend([(1,21),(2,21),(3,21),(4,21),(5,21)])
    for i,d in enumerate(m):
        pts = []
        for h in range(24):
            if oldversion:
                dt = datetime.datetime(year, d[0], d[1], h)
                alt = math.radians(pysolar.solar.GetAltitudeFast(latitude, longitude, dt))
                az = pysolar.solar.GetAzimuth(latitude, longitude, dt)
                az = -90 + az # pysolar's zero is south, ours is X direction
            else:
                dt = datetime.datetime(year, d[0], d[1], h, tzinfo=tz)
                alt = math.radians(pysolar.solar.get_altitude_fast(latitude, longitude, dt))
                az = pysolar.solar.get_azimuth(latitude, longitude, dt)
                az = 90 + az # pysolar's zero is north, ours is X direction
            if az < 0:
                az = 360 + az
            az = math.radians(az)
            zc = math.sin(alt)*scale
            ic = math.cos(alt)*scale
            xc = math.cos(az)*ic
            yc = math.sin(az)*ic
            p = FreeCAD.Vector(xc,yc,zc)
            pts.append(p)
            hpts[h].append(p)
            if i in [0,6]:
                ep = FreeCAD.Vector(p)
                ep.multiply(1.08)
                if ep.z >= 0:
                    if not oldversion:
github FreeCAD / FreeCAD / src / Mod / Arch / ArchSite.py View on Github external
year = datetime.datetime.now().year
    hpts = [ [] for i in range(24) ]
    m = [(6,21),(9,21),(12,21)]
    pts = []
    for i,d in enumerate(m):
        for h in [9,12,15]:
            if oldversion:
                dt = datetime.datetime(year, d[0], d[1], h)
                alt = math.radians(pysolar.solar.GetAltitudeFast(latitude, longitude, dt))
                az = pysolar.solar.GetAzimuth(latitude, longitude, dt)
                az = -90 + az # pysolar's zero is south, ours is X direction
            else:
                dt = datetime.datetime(year, d[0], d[1], h, tzinfo=tz)
                alt = math.radians(pysolar.solar.get_altitude_fast(latitude, longitude, dt))
                az = pysolar.solar.get_azimuth(latitude, longitude, dt)
                az = 90 + az # pysolar's zero is north, ours is X direction
            if az < 0:
                az = 360 + az
            az = math.radians(az)
            zc = math.sin(alt)
            ic = math.cos(alt)
            xc = math.cos(az)*ic
            yc = math.sin(az)*ic
            p = FreeCAD.Vector(xc,yc,zc).negative()
            p.normalize()
            if not oldversion:
                p.x = -p.x # No idea why that is, empirical find
            pts.append(p)
    return pts
github enesbcs / rpieasy / commands.py View on Github external
res = "0"
     return res

   elif svname==SysVars[26]: #sun azimuth
    try:
      from pytz import reference
      from pysolar.solar import get_azimuth
      pysolarsupported = 1
    except:
      pysolarsupported = 0
    res = "0"
    if pysolarsupported==1:
     try:
      localtime = reference.LocalTimezone()
      today = datetime.now(localtime)
      res = get_azimuth(Settings.AdvSettings["Latitude"],Settings.AdvSettings["Longitude"], today)
     except Exception as e:
      print(e)
      res = "0"
     return res

   elif svname==SysVars[27]: #sun radiation
    try:
      from pytz import reference
      from pysolar.solar import get_altitude
      from pysolar.radiation import get_radiation_direct
      pysolarsupported = 1
    except:
      pysolarsupported = 0
    res = "-1"
    if pysolarsupported==1:
     try:

pysolar

Collection of Python libraries for simulating the irradiation of any point on earth by the sun

GPL-3.0
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis