Skip to content

Commit

Permalink
Copy PredictedBirds.zip to everglades-forecast-web repo
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykironde committed May 8, 2024
1 parent a663f3f commit 5906d0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
.vscode/launch.json
App/Zooniverse/*
lightning_logs
logs/**
logs/**
17 changes: 15 additions & 2 deletions combine_bird_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,30 @@ def combine(paths):
if __name__ == "__main__":
working_dir = tools.get_working_dir()
predictions_path = f"{working_dir}/predictions/"
output_path = f"{working_dir}/everwatch-workflow/App/Zooniverse/data"
output_path = f"{working_dir}/EvergladesTools/App/Zooniverse/data"
output_zip = os.path.join(output_path, "PredictedBirds.zip")

predictions = sys.argv[1:]
# write output to zooniverse app
df = combine(predictions)
df.to_file(os.path.join(output_path, "PredictedBirds.shp"))

# Zip the shapefile for storage efficiency
with ZipFile(os.path.join(output_path, "PredictedBirds.zip"), 'w', ZIP_DEFLATED) as zip:
with ZipFile(output_zip, 'w', ZIP_DEFLATED) as zip:
for ext in ['cpg', 'dbf', 'prj', 'shp', 'shx']:
focal_file = os.path.join(output_path, f"PredictedBirds.{ext}")
file_name = os.path.basename(focal_file)
zip.write(focal_file, arcname=file_name)
os.remove(focal_file)

# Copy PredictedBirds.zip to everglades-forecast-web repo
dest_path = "/blue/ewhite/everglades/everglades-forecast-web/data"
if not os.path.exists(dest_path):
os.makedirs(dest_path)
dest_file = os.path.join(dest_path, "PredictedBirds.zip")

if os.path.exists(output_zip):
shutil.copy(output_zip, dest_file)
print(f"{output_zip} copied to {dest_file}.")
else:
print("{output_zip} file does not exist.")

0 comments on commit 5906d0d

Please sign in to comment.