Closed zacharycope0 closed 2 years ago
I added this raise FileNotFound
if the file_path
is None
in load_shapefile()
. This allows us to do a try except anytime we call this function and if the filepath is saved as None
it will allow us to handle it in any way we deem fit. I was initially running into an issue trying to do it in clip_to_bbox
since mod_wetlands()
called this function and then the file was opened in there.
This is because I assumed that everytime we used clip_to_bbox
this is the way it was handled. I finally realized that as in the code below, sometimes the file was opened beforehand.
In the end, adding this raise to load_shapefile
and changing the behavior of mod_wetlands
was easier and may allow for the removal of the loads within clip_to_bbox
. The only issue may be with the bbox filepaths in that function but if so a try catch should be able to handle that there for all instances of the bbox.
I believe for now this issue can be resolved but some fine tuning or cleanup may be needed in the future.
I think that should be good. I'll run a few test and merge it to main.
Cameron. This is working great! Before you merge I'd like to have functionality to warn the user that they are not building the simulation as expected:
def load_shapefile(file_path):
if file_path == None:
#Idk the best way to let the user know what function isn't working properly
print('statement to warning the user of the file they are missing/function that is messing up?')
answer = input("Continue (y/n)")
if answer[0].lower = 'y':
raise FileNotFoundError
else: sys.exit()
Otherwise the code keeps running and you don't see that the functions didn't run.
Since when burn_plot.shp doesn't exist nothing can be built, it is better to handle the continuation on a case by case basis. This means that I added a condition to the try except in mod_wetlands like so:
This is how any additional try except for shapefile loads should be handled unless it is required, in which case only sys.exit()
should be called.
Feature Description The functions that modify the QF arrays typically reference a shape file that it assumes to exist. Instead of having, for example, qf_arrs.mod_wetlands() crash the script if the wetlands shapefile isn't read in; I would rather there be a try statement with the except warning the user that the function didn't run because the script didn't read in the correct shapefile.
Getting Started Look at implementation of qf_arrs.build_fuelbreak() and qf.arrs.mod_wetlands(). Warn user if there script is not tracking the appropriated shapefiles to implement the function. Feel free to implement additional error handling where you see fit.
Screenshots