-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a271ac
commit 1292331
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using JSON | ||
using CSV | ||
using DataFrames | ||
using SpeciesDistributionToolkit | ||
|
||
function read_inputs_dict(runtime_dir) | ||
filepath = joinpath(runtime_dir, "input.json") | ||
output_dir = joinpath(runtime_dir, "data/") | ||
isdir(output_dir) || mkdir(output_dir) | ||
return JSON.parsefile(filepath) | ||
end | ||
|
||
function write_outputs(runtime_dir, priority) | ||
outpath = joinpath(runtime_dir, "priority.tif") | ||
SpeciesDistributionToolkit._write_geotiff(outpath, priority; compress="COG") | ||
|
||
output_json_path = joinpath(runtime_dir, "output.json") | ||
open(output_json_path, "w") do f | ||
write(f, JSON.json(Dict(:priority_map=>outpath))) | ||
end | ||
end | ||
|
||
function main() | ||
runtime_dir = ARGS[1] | ||
inputs = read_inputs_dict(runtime_dir) | ||
|
||
β = inputs["weights"] | ||
|
||
uncert_path = inputs["uncertainty"] | ||
uniqueness_path = inputs["climate_uniqueness"] | ||
velocity_path = inputs["climate_velocity"] | ||
access_path = inputs["accessability"] | ||
|
||
layer_paths = [uncert_path, uniqueness_path, velocity_path, access_path] | ||
|
||
layers = [rescale(SimpleSDMPredictor(joinpath(runtime_dir, layer_path)), (0,1)) for layer_path in layer_paths] | ||
|
||
priority = sum([β[i] .* layers[i].grid for i in eachindex(β)]) | ||
|
||
write_outputs(runtime_dir, priority) | ||
end | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
script: weightLayers.jl | ||
name: Weight Layers | ||
description: "This script takes in multiple layers and computes a priority map based on a weighted average of those layers" | ||
author: | ||
- name: Michael D. Catchen | ||
identifier: https://orcid.org/0000-0002-6506-6487 | ||
inputs: | ||
uncertainty: | ||
label: uncertainty | ||
description: uncertainty in the inference of some value across space | ||
example: null | ||
climate_uniqueness: | ||
label: climate uniqueness | ||
description: foobar | ||
example: null | ||
climate_velocity: | ||
label: climate uniqueness | ||
description: foobar | ||
example: null | ||
accessibility: | ||
label: accessibility | ||
descrpition: foobar | ||
example: null | ||
weights: | ||
label: weights | ||
description: weight vector that sums to one. Weights correnspond to layers in this order, [uncertainty, uniqueness, velocity, accessability] | ||
example: [0.3, 0.2, 0.4, 0.1] | ||
outputs: | ||
priority_map: | ||
label: priority_map | ||
description: Sampling priority map. | ||
type: image/tiff;application=geotiff | ||
|