Skip to content

Commit

Permalink
refactor: update notebook
Browse files Browse the repository at this point in the history
to use long tracker
  • Loading branch information
cpaniaguam committed Dec 7, 2024
1 parent 13dc002 commit 50ecf06
Showing 1 changed file with 136 additions and 15 deletions.
151 changes: 136 additions & 15 deletions notebooks/track-floes/track-floes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"metadata": {},
"outputs": [],
"source": [
"using IceFloeTracker: pairfloes, deserialize, PaddedView, float64, mosaicview, Gray\n",
"using DataFrames\n",
"imshow(x) = Gray.(x);\n"
"using IceFloeTracker: deserialize, addfloemasks!, adduuid!, add_passtimes!, addψs!, long_tracker, imshow"
]
},
{
Expand Down Expand Up @@ -80,26 +78,133 @@
"metadata": {},
"outputs": [],
"source": [
"# Load data\n",
"pth = joinpath(HOME, \"test\", \"test_inputs\", \"tracker\")\n",
"floedata = deserialize(joinpath(pth,\"tracker_test_data.dat\"))\n",
"passtimes = deserialize(joinpath(pth,\"passtimes.dat\"))\n",
"begin # Load data\n",
" pth = joinpath(HOME, \"test\", \"test_inputs\", \"tracker\")\n",
" floedata = deserialize(joinpath(pth, \"tracker_test_data.dat\"))\n",
" # test/test_inputs/tracker/tracker_test_data.dat\n",
" passtimes = deserialize(joinpath(pth, \"passtimes.dat\"))\n",
" props, imgs = deepcopy.([floedata.props, floedata.imgs])\n",
"\n",
"latlonimgpth = joinpath(HOME, \"test\", \"test_inputs\", \"NE_Greenland_truecolor.2020162.aqua.250m.tiff\")\n",
" # This order is important: masks, uuids, passtimes, ψs\n",
" addfloemasks!(props, imgs)\n",
" adduuid!(props)\n",
" add_passtimes!(props, passtimes)\n",
" addψs!(props)\n",
"end\n",
"\n",
"props, imgs = deepcopy(floedata.props), deepcopy(floedata.imgs);\n",
"begin # Filter out floes with area less than `floe_area_threshold` pixels\n",
" floe_area_threshold = 400\n",
" for (i, prop) in enumerate(props)\n",
" props[i] = prop[prop[:, :area].>=floe_area_threshold, :];\n",
" sort!(props[i], :area, rev=true);\n",
" end\n",
"end\n",
"\n",
"# Filter out floes with area less than 350 pixels\n",
"for (i, prop) in enumerate(props)\n",
" props[i] = prop[prop[:, :area].>=350, :]\n",
"end"
"# Delete some floes\n",
"deleteat!(props[1], 1); # delete the first floe in day 1 so it doesn't have a match in day 2\n",
"deleteat!(props[2], 5); # delete the fifth floe in day 2 so it doesn't have a match in day 1\n",
"\n",
"# All floes in days 1 and 2 have a match in day 3\n",
"# Expected: 5 trajectories, 3 of length 3 and 2 of length 2\n",
"nothing # suppress output -- not particularly informative. See the next block."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 4. Pair and label floes"
"### 4. View floe data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Day 1\n",
"props[1][!, [:uuid, :passtime, :area]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(imgs[1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(props[1][1, :mask])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Day 2\n",
"props[2][!, [:uuid, :passtime, :area]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(imgs[2]) # slightly rotated version of the image in day 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(props[2][1, :mask])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Day 3\n",
"props[3][!, [:uuid, :passtime, :area]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(props[3][1, :mask]) # missing in day 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"imshow(props[3][5, :mask]) # missing in day 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5. Pair and label floes"
]
},
{
Expand All @@ -109,7 +214,23 @@
"outputs": [],
"source": [
"# Get paired floes with labels\n",
"pairs = pairfloes(imgs, props, passtimes, latlonimgpth, condition_thresholds, mc_thresholds)"
"trajectories = long_tracker(props, condition_thresholds, mc_thresholds);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 6. View trajectories and _goodness_ of pairings"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"trajectories[!, [:uuid, :passtime, :area_mismatch, :corr]]"
]
}
],
Expand Down

0 comments on commit 50ecf06

Please sign in to comment.