ping
Creating a new workbench for photovoltaic
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Creating a new workbech for photovoltaic
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Posts: 31
- Joined: Thu Sep 06, 2018 5:43 pm
Re: Creating a new workbech for photovoltaic
Not really.
I am unsing this code:
https://gis.stackexchange.com/questions ... tude-and-e
This is my code:
Code: Select all
def npContours(obj, minor = 1000, mayor = 5000):
import numpy as np
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
# Prueba inicial
#points = np.array([])
#for vx in obj.Shape.Vertexes:
# points = np.append(points, vx.Point)
#print (len(points))
xArray = np.array([])
yArray = np.array([])
zArray = np.array([])
for vx in obj.Shape.Vertexes:
xArray = np.append(xArray, vx.Point[0])
yArray = np.append(yArray, vx.Point[0])
zArray = np.append(zArray, vx.Point[0])
numIndexes = 50
xi = np.linspace(np.min(xArray), np.max(xArray), numIndexes)
yi = np.linspace(np.min(yArray), np.max(yArray), numIndexes)
DEM = griddata(xArray, yArray, zArray, xi, yi, interp='linear')
levels = np.arange(np.min(DEM), np.max(DEM), 10)
cs = plt.contour(DEM, levels, linewidths=0.2, colors='k')
plt.imshow(DEM, cmap='RdYlGn_r', origin='lower')
plt.colorbar()
Code: Select all
Traceback (most recent call last):
File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 217, in accept
npContours(self.obj, minor, mayor)
File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 70, in npContours
DEM = griddata(xArray, yArray, zArray, xi, yi, interp='linear')
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\mlab.py", line 3498, in griddata
triang = Triangulation(x, y)
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\triangulation.py", line 55, in __init__
self.triangles, self._neighbors = _qhull.delaunay(x, y)
<type 'exceptions.RuntimeError'>: Error in qhull Delaunay triangulation calculation: singular input data (exitcode=2); use python verbose option (-v) to see original qhull error.
I managed to put rectangles inside a polygon with this code:
Code: Select all
while rack.Placement.Base.y < land.Shape.BoundBox.YMax:
common = land.Shape.common(rack.Shape)
if FirstPlace:
if common.Area >= area:
intersection_object = FreeCAD.activeDocument().addObject('Part::Feature')
intersection_object.Label = 'Common ({} - {})'.format(
land.Label, rack.Label)
intersection_object.Shape = common
intersection_object.ViewObject.ShapeColor = (1.0, 0.0, 0.0, 1.0)
# Desplazar segun la separacion de filas
rack.Placement.Base.x += DistColls
if rack.Placement.Base.x > land.Shape.BoundBox.XMax:
while rack.Placement.Base.x > land.Shape.BoundBox.XMin:
rack.Placement.Base.x -= DistColls
rack.Placement.Base.y += self.Pitch
else:
if common.Area >= area:
intersection_object = FreeCAD.activeDocument().addObject('Part::Feature')
intersection_object.Label = 'Common ({} - {})'.format(
land.Label, rack.Label)
intersection_object.Shape = common
intersection_object.ViewObject.ShapeColor = (1.0, 0.0, 0.0, 1.0)
IniPosX = rack.Placement.Base.x
IniPosY = rack.Placement.Base.y
# Desplazar segun la separacion de filas
rack.Placement.Base.x += DistColls
if rack.Placement.Base.x > land.Shape.BoundBox.XMax:
while rack.Placement.Base.x > land.Shape.BoundBox.XMin:
rack.Placement.Base.x -= DistColls
rack.Placement.Base.y += self.Pitch
FirstPlace = True
else:
# ajuste fino hasta encontrar el primer sitio:
rack.Placement.Base.x += 2000
if rack.Placement.Base.x > land.Shape.BoundBox.XMax:
rack.Placement.Base.x = land.Shape.BoundBox.XMin
rack.Placement.Base.y += 20000
Re: Creating a new workbech for photovoltaic
Did you figure out the error?JavierBrana wrote: ↑Thu Oct 11, 2018 9:22 amNot really.
I am unsing this code:
https://gis.stackexchange.com/questions ... tude-and-e
This is my code:but with "Z = ml.griddata(x, y, z, xi, yi)" it returns an error:Code: Select all
def npContours(obj, minor = 1000, mayor = 5000): import numpy as np from matplotlib.mlab import griddata import matplotlib.pyplot as plt # Prueba inicial #points = np.array([]) #for vx in obj.Shape.Vertexes: # points = np.append(points, vx.Point) #print (len(points)) xArray = np.array([]) yArray = np.array([]) zArray = np.array([]) for vx in obj.Shape.Vertexes: xArray = np.append(xArray, vx.Point[0]) yArray = np.append(yArray, vx.Point[0]) zArray = np.append(zArray, vx.Point[0]) numIndexes = 50 xi = np.linspace(np.min(xArray), np.max(xArray), numIndexes) yi = np.linspace(np.min(yArray), np.max(yArray), numIndexes) DEM = griddata(xArray, yArray, zArray, xi, yi, interp='linear') levels = np.arange(np.min(DEM), np.max(DEM), 10) cs = plt.contour(DEM, levels, linewidths=0.2, colors='k') plt.imshow(DEM, cmap='RdYlGn_r', origin='lower') plt.colorbar()
I like it because I could check that it returns polylines and labels.Code: Select all
Traceback (most recent call last): File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 217, in accept npContours(self.obj, minor, mayor) File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 70, in npContours DEM = griddata(xArray, yArray, zArray, xi, yi, interp='linear') File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\mlab.py", line 3498, in griddata triang = Triangulation(x, y) File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\triangulation.py", line 55, in __init__ self.triangles, self._neighbors = _qhull.delaunay(x, y) <type 'exceptions.RuntimeError'>: Error in qhull Delaunay triangulation calculation: singular input data (exitcode=2); use python verbose option (-v) to see original qhull error.
I managed to put rectangles inside a polygon with this code:Code: Select all
while rack.Placement.Base.y < land.Shape.BoundBox.YMax: common = land.Shape.common(rack.Shape) if FirstPlace: if common.Area >= area: intersection_object = FreeCAD.activeDocument().addObject('Part::Feature') intersection_object.Label = 'Common ({} - {})'.format( land.Label, rack.Label) intersection_object.Shape = common intersection_object.ViewObject.ShapeColor = (1.0, 0.0, 0.0, 1.0) # Desplazar segun la separacion de filas rack.Placement.Base.x += DistColls if rack.Placement.Base.x > land.Shape.BoundBox.XMax: while rack.Placement.Base.x > land.Shape.BoundBox.XMin: rack.Placement.Base.x -= DistColls rack.Placement.Base.y += self.Pitch else: if common.Area >= area: intersection_object = FreeCAD.activeDocument().addObject('Part::Feature') intersection_object.Label = 'Common ({} - {})'.format( land.Label, rack.Label) intersection_object.Shape = common intersection_object.ViewObject.ShapeColor = (1.0, 0.0, 0.0, 1.0) IniPosX = rack.Placement.Base.x IniPosY = rack.Placement.Base.y # Desplazar segun la separacion de filas rack.Placement.Base.x += DistColls if rack.Placement.Base.x > land.Shape.BoundBox.XMax: while rack.Placement.Base.x > land.Shape.BoundBox.XMin: rack.Placement.Base.x -= DistColls rack.Placement.Base.y += self.Pitch FirstPlace = True else: # ajuste fino hasta encontrar el primer sitio: rack.Placement.Base.x += 2000 if rack.Placement.Base.x > land.Shape.BoundBox.XMax: rack.Placement.Base.x = land.Shape.BoundBox.XMin rack.Placement.Base.y += 20000
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Posts: 31
- Joined: Thu Sep 06, 2018 5:43 pm
Re: Creating a new workbech for photovoltaic
Still not.
I have identified an error that it was I put the same points inside the X, Y, Z arrays but now I´m getting another error:
I don´t know but I am getting lot of problems, some of them are because python libraries are not update... others I don´t know the reason.
I am working in Windows 10 and python is complicated to work in it.
I have identified an error that it was I put the same points inside the X, Y, Z arrays but now I´m getting another error:
Code: Select all
Traceback (most recent call last):
File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 217, in accept
npContours(self.obj, minor, mayor)
File "C:\Users\javie\AppData\Roaming\FreeCAD\Mod\geodata\geodat\contours.py", line 70, in npContours
DEM = griddata(xArray, yArray, zArray, xi, yi, interp='linear')
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\mlab.py", line 3499, in griddata
interpolator = LinearTriInterpolator(triang, z)
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\triinterpolate.py", line 268, in __init__
TriInterpolator.__init__(self, triangulation, z, trifinder)
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\triinterpolate.py", line 50, in __init__
self._trifinder = trifinder or self._triangulation.get_trifinder()
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\triangulation.py", line 177, in get_trifinder
self._trifinder = TrapezoidMapTriFinder(self)
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\trifinder.py", line 44, in __init__
self._initialize()
File "C:\Program Files\FreeCAD 0.17\bin\lib\site-packages\matplotlib\tri\trifinder.py", line 81, in _initialize
self._cpp_trifinder.initialize()
<type 'exceptions.RuntimeError'>: Triangulation is invalid
I am working in Windows 10 and python is complicated to work in it.
Re: Creating a new workbech for photovoltaic
Do you have a git repository somewhere ? Can you post it here and in the first post of this thread?JavierBrana wrote: ↑Thu Oct 18, 2018 9:42 am I have identified an error that it was I put the same points inside the X, Y, Z arrays but now I´m getting another error:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Creating a new workbech for photovoltaic
bump
Can you show any screenshots of your progress also ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Posts: 31
- Joined: Thu Sep 06, 2018 5:43 pm
Re: Creating a new workbech for photovoltaic
Sorry for my late replies but these days I am very busy in my work. Very soon I will organize the code I have and upload it to github.Kunda1 wrote: ↑Thu Oct 18, 2018 12:35 pmDo you have a git repository somewhere ? Can you post it here and in the first post of this thread?JavierBrana wrote: ↑Thu Oct 18, 2018 9:42 am I have identified an error that it was I put the same points inside the X, Y, Z arrays but now I´m getting another error:
Normally when I start a project that I do not have much idea about, I do tests with several files and functions and then organize them.
Re: Creating a new workbech for photovoltaic
Now worries. Just wanted to let you know people are paying attention to your efforts. Thanks!JavierBrana wrote: ↑Thu Oct 25, 2018 5:22 pm Sorry for my late replies but these days I am very busy in my work. Very soon I will organize the code I have and upload it to github.
Normally when I start a project that I do not have much idea about, I do tests with several files and functions and then organize them.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Creating a new workbech for photovoltaic
We also like screenshots
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Posts: 31
- Joined: Thu Sep 06, 2018 5:43 pm