Skip to content

Commit

Permalink
feat: update for new IFT.pairfloes features
Browse files Browse the repository at this point in the history
Includes latlon data in output data structure which requires a path to a reference geotiff image with these data.
  • Loading branch information
cpaniaguam committed Nov 28, 2023
1 parent 21f5458 commit 5154344
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
ArgParse = "1.1.4"
Folds = "0.2.8"
HDF5 = "0.16.15"
IceFloeTracker = "0.3.0"
IceFloeTracker = "0.4"
LoggingExtras = "1.0.1"
PyCall = "1.96.1"
Pkg = "1.9.0"
Expand Down
4 changes: 2 additions & 2 deletions src/cli-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ function mkclitrack!(settings)
help = "Path to object with satellite pass times"
required = true

"--deltat"
help = "Path to object with time deltas between consecutive images"
"--latlon"
help = "Path to geotiff image with latitude/longitude data"
required = true

"--output", "-o"
Expand Down
2 changes: 1 addition & 1 deletion src/track-docstring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pair floes in the floe library using an equivalent implementation as in the MATLAB script `final_2020.m` from https://github.com/WilhelmusLab/ice-floe-tracker/blob/main/existing_code/final_2020.m.
# Arguments
- `indir`: path to directory containing the floe library (cropped floe masks for registration and correlation), extracted features from segmented images, and overpass elapsed times `delta_t`.
- `indir`: path to directory containing the floe library (cropped floe masks for registration and correlation), extracted features from segmented images, and satellite overpass times.
- `condition_thresholds`: 3-tuple of thresholds (each a named tuple) for deciding whether to match floe `i` from day `k` to floe j from day `k+1`.
- `mc_thresholds`: thresholds for area mismatch and psi-s shape correlation and goodness of a match.
Expand Down
10 changes: 5 additions & 5 deletions src/tracker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
track(
imgsdir::String,
propsdir::String,
timedeltasdir::String,
passtimesdir::String,
paramsdir::String,
outdir::String,
)
Expand All @@ -11,13 +11,13 @@ $(include("track-docstring.jl"))
"""
function track(; args...)
condition_thresholds, mc_thresholds = get_thresholds(; args...)
vals = values(args)
vals = NamedTuple{Tuple(keys(args))}(values(args)) # convert to NamedTuple
imgs = deserialize(joinpath(vals.imgs, "segmented_floes.jls"))
props = deserialize(joinpath(vals.props, "floe_props.jls"))
passtimes = deserialize(joinpath(vals.passtimes, "passtimes.jls"))
deltat = deserialize(joinpath(vals.deltat, "timedeltas.jls"))
labeledfloes, tracked = pairfloes(imgs, props, passtimes, deltat, condition_thresholds, mc_thresholds)
[serialize(joinpath(vals.output, name), obj) for (name, obj) in zip(["labeled_floes.jls", "track_data.jls"], [labeledfloes, tracked])]
latlon = vals.latlon
labeledfloes = IceFloeTracker.pairfloes(imgs, props, passtimes, latlon, condition_thresholds, mc_thresholds)
serialize(joinpath(vals.output, "labeled_floes.jls"), labeledfloes)
return nothing
end

Expand Down
13 changes: 6 additions & 7 deletions test/_test-track.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ end
IFTPipeline.mkclitrack!(settings)

params_path = "../config/sample-tracker-params.toml"

latlonrefimage = "test_inputs/NE_Greenland_truecolor.2020162.aqua.250m.tiff"
data_path = "test_inputs/tracker/"
temp = mkpath(joinpath(@__DIR__, "__temp__"))
cliparams = [
"track",
"track", # command
"--imgs",
temp,
"--props",
temp,
"--passtimes",
temp,
"--deltat",
temp,
"--latlon",
latlonrefimage,
"--output",
temp,
"--params",
Expand All @@ -36,14 +36,13 @@ end

serialize(joinpath(temp, "segmented_floes.jls"), obj.imgs)
serialize(joinpath(temp, "floe_props.jls"), obj.props)
serialize(joinpath(temp, "timedeltas.jls"), [15.0, 20.0])
serialize(joinpath(temp, "passtimes.jls"), passtimes)

argsparam = parse_args(cliparams, settings; as_symbols=true)
cmd = argsparam[:_COMMAND_]
IFTPipeline.track(; argsparam[cmd]...)
tracked = deserialize(joinpath(temp, "labeled_floes.jls"))
@test isfile(joinpath(temp, "labeled_floes.jls"))
@test nrow(tracked) == 22
@test maximum(tracked.ID) == 10
@test nrow(tracked) == 18
@test maximum(tracked.ID) == 6
@test "passtime" in names(tracked)

0 comments on commit 5154344

Please sign in to comment.