diff --git a/Project.toml b/Project.toml index e41b66b3..684478f2 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ version = "0.1.0" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" +Folds = "41a02a25-b8f0-4f67-bc48-60067656b558" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" IceFloeTracker = "04643c7a-9ac6-48c5-822f-2704f9e70bd3" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" diff --git a/src/IFTPipeline.jl b/src/IFTPipeline.jl index 3a40eff4..aeb21d2d 100644 --- a/src/IFTPipeline.jl +++ b/src/IFTPipeline.jl @@ -8,10 +8,10 @@ using ArgParse using LoggingExtras using IceFloeTracker using IceFloeTracker: DataFrames, Dates, @dateformat_str, DataFrame, nrow, rename!, Not, select!, Date, Time, DateTime -using IceFloeTracker: Folds, RGB, Gray, load, float64, imsharpen +using IceFloeTracker: RGB, Gray, load, float64, imsharpen, getlatlon +using Folds using HDF5 using TOML: parsefile -using PyCall using Pkg include("cli-config.jl") include("soit-parser.jl") @@ -39,7 +39,8 @@ export cache_vector, sharpen, mkcliextract!, mkclitrack!, mkfilenames, - makeh5files + makeh5files, + getlatlon export IceFloeTracker end diff --git a/src/h5.jl b/src/h5.jl index 3e0fa355..cf841af7 100644 --- a/src/h5.jl +++ b/src/h5.jl @@ -123,8 +123,6 @@ The `floe_properties` group contains a floe properties matrix `properties` for ` The `index` group contains the spatial coordinates in the source image coordinate reference system (default NSIDC polar stereographic, meters) and geographic coordinates (latitude and longitude, decimal degrees). Estimated satellite overpass time `time` is provided in Unix timestamp format (seconds since 1970-01-01 00:00 UTC). """ function makeh5files(; pathtosampleimg::String, resdir::String) - @pyinclude(joinpath(@__DIR__, "latlon.py")) - getlatlon = py"getlatlon" latlondata = getlatlon(pathtosampleimg) iftversion = getiftversion() diff --git a/src/latlon.py b/src/latlon.py deleted file mode 100644 index 2a8fda4c..00000000 --- a/src/latlon.py +++ /dev/null @@ -1,25 +0,0 @@ -import numpy as np -from pyproj import Transformer -import rasterio - - -def getlatlon(imgpath): - """ - Get the longitude and latitude of the pixels in the image with path `imgpath`. - :param imgpath: the path of the image - """ - - im = rasterio.open(imgpath) - crs = im.crs.__str__() # Coordinate reference system code - nrows, ncols = im.shape - rows, cols = np.meshgrid(np.arange(nrows), np.arange(ncols)) - xs, ys = rasterio.transform.xy(im.transform, rows, cols) - # X and Y are the 1D index vectors - X = np.array(xs)[:, 0] - Y = np.array(ys)[0, :] - ps_to_ll = Transformer.from_crs(im.crs, "WGS84", always_xy=True) - lons, lats = ps_to_ll.transform(np.ravel(xs), np.ravel(ys)) - # longitude and latitude are 2D index arrays - longitude = np.reshape(lons, (nrows, ncols)) - latitude = np.reshape(lats, (nrows, ncols)) - return {"crs": crs, "longitude": longitude, "latitude": latitude, "X": X, "Y": Y} diff --git a/test/runtests.jl b/test/runtests.jl index 1a761fd7..4d051f3b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,15 +1,13 @@ using IFTPipeline using IFTPipeline: load_imgs, sharpen, sharpen_gray, loadimg using IFTPipeline: HDF5, h5open, attrs -using .IceFloeTracker: DataFrames, save, Gray, create_cloudmask, deserialize, serialize, float64, load, imrotate, loadimg, RGB, DataFrame, nrow, rename!, Dates, Not, select! +using .IceFloeTracker: DataFrames, save, Gray, create_cloudmask, deserialize, serialize, float64, load, imrotate, loadimg, RGB, DataFrame, nrow, rename!, Dates, Not, select!, getlatlon using ArgParse: @add_arg_table!, ArgParseSettings, add_arg_group!, parse_args using DelimitedFiles -using PyCall: @pyinclude, @py_str using Pkg using Random using Serialization using Test -using Conda include(joinpath(@__DIR__, "config.jl")) function test_similarity(imgA::BitMatrix, imgB::BitMatrix, error_rate=0.005) diff --git a/test/test-h5.jl b/test/test-h5.jl index 0558a9b2..f59de688 100644 --- a/test/test-h5.jl +++ b/test/test-h5.jl @@ -4,8 +4,6 @@ resdir = joinpath(dirname(pathtosampleimg), "h5") originalbbox = (latitude=[81, 79], longitude=[-22, -12]) -@pyinclude(joinpath(@__DIR__, "../src/latlon.py")) -getlatlon = py"getlatlon" latlondata = getlatlon(pathtosampleimg) getcorners(m) = [m[1, 1], m[end, end]]