ustroetz / cost_model Goto Github PK
View Code? Open in Web Editor NEWA model that estimates timber harvest costs.
A model that estimates timber harvest costs.
Styling guide: http://www.python.org/dev/peps/pep-0008/
B28 in FRCS
OSRM request to find nearest road fails. It is a bug on the OSRM side. landing.py
will no longer be necessary once the road model is integrated.
Cost model issues as they pertain to the Ecotrust Forest Planner will be here:
https://github.com/Ecotrust/land_owner_tools/issues?labels=Cost+Model&state=open
arguments to the main cost function:
(12.3297506053987, 570.791667, 18.125, u'POLYGON((-13633466.268387 5547319.3920823,-13633549.871386 5547343.2786536,-13633613.1708 5547333.7240251,-13633668.109914 5547380.3028392,-13633736.186643 5547350.444625,-13633842.481885 5547406.5780677,-13633877.117414 5547382.6914963,-13633871.145771 5547294.3111824,-13633812.623671 5547182.0442971,-13633826.955615 5547159.352054,-13634013.270871 5547398.217768,-13633936.833843 5547417.327025,-13633932.056529 5547445.99091,-13634033.491654 5547520.427044,-13633546.4885642 5547537.64432512,-13633445.964801 5547475.8491245,-13633459.102415 5547382.6914963,-13633477.017344 5547346.8616393,-13633466.268387 5547319.3920823))', 0.0, 0.0, 228.75, 29.91, 9.01, 728.71, 0.0, 0.0, 0.0, 0, (-122.47573, 44.5236), 25.146262999, 74.32, (-122.47, 44.4))
gives us this geometry error:
Traceback (most recent call last):
File "test_errors2.py", line 38, in main
cost = m.cost_func(*cost_args)
File "/usr/local/apps/cost_model/forestcost/main_model.py", line 16, in cost_func
SkidDist, HaulDistExtension, coord_landing_stand = skidding.skidding(stand_wkt, landing_coords, Slope)
File "/usr/local/apps/cost_model/forestcost/skidding.py", line 50, in skidding
for line in skidLineStand:
File "/usr/lib/python2.7/dist-packages/osgeo/ogr.py", line 4015, in next
if self.iter_subgeom < self.GetGeometryCount():
File "/usr/lib/python2.7/dist-packages/osgeo/ogr.py", line 3125, in GetGeometryCount
return _ogr.Geometry_GetGeometryCount(self, *args)
RuntimeError: Incompatible geometry for operation
It would be good to have small sample datasets in the repository so that users can quickly start experimenting with the code or running tests.
It might be a good idea to start up a proper unit test suite to help with validating the model and ensuring that future changes don't introduce bugs. It's effectively very similar to what I've already started doing with test_routing.py. You write small isolated test cases that can check if each piece of the model is returning reasonable data.
I'd suggest http://pythontesting.net/framework/pytest/pytest-introduction/ .. its very easy to get started with.
http://router.project-osrm.org/nearest?loc=44.530765,-122.510725
and
http://router.project-osrm.org/nearest?loc=44.530451,-122.517537
both return something like:
'{"version":0.3,"status":0,"mapped_coordinate":[44.530607,],"name":"","transactionId":"OSRM Routing Engine JSON Nearest (v0.3)"}'
Note the incomplete coordinate (no longitude returned). This results in:
line 59, landing.py: json.loads(binary)
*** ValueError: No JSON object could be decoded
We will need to guard against this case and/or work with OSRM to fix it.
remove transporting variables from code and read from excel instead(xlrd)
in skidding.py
ground based max: no dist limit, slope max 40 %
cabel: 1300 ft, no slope limit
helicopter: 10000 ft, no slope limit
main_model.cost_func(8.523, 1300.0, 25.438,
'POLYGON((-13841693.141460 5280341.295039,-13841682.985371 5280332.035772,-13841676.856164 5280326.447790,-13841664.216071 5280282.544117,-13841665.277370 5280239.549378,-13841662.503676 5280212.076117,-13841659.702472 5280183.061277,-13841638.719502 5280160.974175,-13841631.162639 5280155.237933,-13841654.149620 5280154.173908,-13841671.685455 5280148.904800,-13841691.523512 5280145.757774,-13841718.108792 5280144.527032,-13841730.993870 5280134.930053,-13841734.140478 5280121.069420,-13841738.883612 5280125.564340,-13841746.035990 5280140.148223,-13841747.774207 5280146.668081,-13841746.491967 5280154.870723,-13841743.540775 5280166.493677,-13841743.965332 5280179.589016,-13841747.502060 5280189.282962,-13841760.829468 5280198.780776,-13841850.211164 5280176.298174,-13841864.682528 5280178.285311,-13841899.467655 5280182.931862,-13841945.113514 5280178.246200,-13842027.417160 5280183.338442,-13842086.139860 5280186.971301,-13842104.435714 5280195.638459,-13842132.401149 5280208.915003,-13842157.675934 5280220.858942,-13842163.469135 5280230.764808,-13842178.419515 5280256.328602,-13842181.998999 5280266.020527,-13842185.518344 5280279.058333,-13842195.035329 5280304.590555,-13841693.577202 5280303.215005,-13841693.141460 5280341.295039))',
11.95, 0.12, 233.96, 25.42, 0.0, 167.0, 0.0, 0.0, 0.0, 1, (-124.36079, 42.7944), 59.899543029, 106.52, (-124.14, 43.31)
)
Gives the following error
Traceback (most recent call last):
File "test_errors2.py", line 33, in main
cost = m.cost_func(*cost_args)
File "/usr/local/apps/cost_model/forestcost/main_model.py", line 22, in cost_func
harvest_result = harvesting.harvestcost(PartialCut, Slope, SkidDist, Elevation, RemovalsCT, TreeVolCT, RemovalsSLT, TreeVolSLT, RemovalsLLT, TreeVolLLT, HdwdFractionCT, HdwdFractionSLT, HdwdFractionLLT)
File "/usr/local/apps/cost_model/forestcost/harvesting.py", line 1509, in harvestcost
CostManFLBLLT = CostManFLBLLTfunc()
File "/usr/local/apps/cost_model/forestcost/harvesting.py", line 412, in CostManFLBLLTfunc
CostManFLBLLT = round (felllimbbuckfunc(RemovalsLLT, TreeVolLLT, DBHLLT, LogsPerTreeLLT, CHardwoodLLT), 2)
File "/usr/local/apps/cost_model/forestcost/harvesting.py", line 350, in felllimbbuckfunc
walkdistance = (max((43560/removals),1))**0.5
ZeroDivisionError: float division by zero
It looks like RemovalsLLT is set to 0.0
but we also have a TreeVolLLT of 167.0
. The CostManFLBLLTfunc()
function should return an appropriate value (zero?) instead of raising an exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.