parameters: (epwfile,scale=1,sectors=24)
return_statement: return masternode
docstring: makeWindRose(site,sectors):
      returns a wind rose diagram as a pivy node
docstring_summary: makeWindRose(site,sectors):
      returns a wind rose diagram as a pivy node
docstring_tokens: makeWindRose ( site sectors ) : returns a wind rose diagram as a pivy node
function: def makeWindRose(epwfile,scale=1,sectors=24):
  
      """makeWindRose(site,sectors):
      returns a wind rose diagram as a pivy node"""
  
      try:
          import ladybug
          from ladybug import epw
      except Exception:
          FreeCAD.Console.PrintError("The ladybug module was not found. Unable to generate solar diagrams\n")
          return None
      if not epwfile:
          FreeCAD.Console.PrintWarning("No EPW file, unable to generate wind rose.\n")
          return None
      epw_data = ladybug.epw.EPW(epwfile)
      baseangle = 360/sectors
      sectorangles = [i * baseangle for i in range(sectors)] # the divider angles between each sector
      basebissect = baseangle/2
      angles = [basebissect] # build a list of central direction for each sector
      for i in range(1,sectors):
          angles.append(angles[-1]+baseangle)
      windsbysector = [0 for i in range(sectors)] # prepare a holder for values for each sector
      for hour in epw_data.wind_direction:
          sector = min(angles, key=lambda x:abs(x-hour)) # find the closest sector angle
          sectorindex = angles.index(sector)
          windsbysector[sectorindex] = windsbysector[sectorindex] + 1
      maxwind = max(windsbysector)
      windsbysector = [wind/maxwind for wind in windsbysector] # normalize
      vectors = [] # create 3D vectors
      dividers = []
      for i in range(sectors):
          angle = math.radians(90 + angles[i])
          x = math.cos(angle) * windsbysector[i] * scale
          y = math.sin(angle) * windsbysector[i] * scale
          vectors.append(FreeCAD.Vector(x,y,0))
          secangle = math.radians(90 + sectorangles[i])
          x = math.cos(secangle) * scale
          y = math.sin(secangle) * scale
          dividers.append(FreeCAD.Vector(x,y,0))
      vectors.append(vectors[0])
  
      # build coin node
      import Part
      from pivy import coin
      masternode = coin.SoSeparator()
      for r in (0.25,0.5,0.75,1.0):
          c = Part.makeCircle(r * scale)
          masternode.addChild(toNode(c))
      for divider in dividers:
          l = Part.makeLine(FreeCAD.Vector(),divider)
          masternode.addChild(toNode(l))
      ds = coin.SoDrawStyle()
      ds.lineWidth = 2.0
      masternode.addChild(ds)
      d = Part.makePolygon(vectors)
      masternode.addChild(toNode(d))
      return masternode
function_tokens: def makeWindRose ( epwfile , scale = 1 , sectors = 24 ) : try : import ladybug from ladybug import epw except Exception : FreeCAD . Console . PrintError ( "The ladybug module was not found. Unable to generate solar diagrams\n" ) return None if not epwfile : FreeCAD . Console . PrintWarning ( "No EPW file, unable to generate wind rose.\n" ) return None epw_data = ladybug . epw . EPW ( epwfile ) baseangle = 360 / sectors sectorangles = [ i * baseangle for i in range ( sectors ) ] # the divider angles between each sector basebissect = baseangle / 2 angles = [ basebissect ] # build a list of central direction for each sector for i in range ( 1 , sectors ) : angles . append ( angles [ - 1 ] + baseangle ) windsbysector = [ 0 for i in range ( sectors ) ] # prepare a holder for values for each sector for hour in epw_data . wind_direction : sector = min ( angles , key = lambda x : abs ( x - hour ) ) # find the closest sector angle sectorindex = angles . index ( sector ) windsbysector [ sectorindex ] = windsbysector [ sectorindex ] + 1 maxwind = max ( windsbysector ) windsbysector = [ wind / maxwind for wind in windsbysector ] # normalize vectors = [ ] # create 3D vectors dividers = [ ] for i in range ( sectors ) : angle = math . radians ( 90 + angles [ i ] ) x = math . cos ( angle ) * windsbysector [ i ] * scale y = math . sin ( angle ) * windsbysector [ i ] * scale vectors . append ( FreeCAD . Vector ( x , y , 0 ) ) secangle = math . radians ( 90 + sectorangles [ i ] ) x = math . cos ( secangle ) * scale y = math . sin ( secangle ) * scale dividers . append ( FreeCAD . Vector ( x , y , 0 ) ) vectors . append ( vectors [ 0 ] ) # build coin node import Part from pivy import coin masternode = coin . SoSeparator ( ) for r in ( 0.25 , 0.5 , 0.75 , 1.0 ) : c = Part . makeCircle ( r * scale ) masternode . addChild ( toNode ( c ) ) for divider in dividers : l = Part . makeLine ( FreeCAD . Vector ( ) , divider ) masternode . addChild ( toNode ( l ) ) ds = coin . SoDrawStyle ( ) ds . lineWidth = 2.0 masternode . addChild ( ds ) d = Part . makePolygon ( vectors ) masternode . addChild ( toNode ( d ) ) return masternode