From e3cebe1b4b786d0349279d26971841490609eeed Mon Sep 17 00:00:00 2001 From: Dongdong Kong Date: Thu, 25 Apr 2024 10:27:14 +0800 Subject: [PATCH] rename rast to Raster --- Project.toml | 2 +- examples/example_apply.qmd | 8 ++++---- scripts/previous/hello.qmd | 2 +- scripts/previous/zarr-01.ipynb | 6 +++--- scripts/s4_upload_to_GEE.qmd | 6 +++--- src/Terra.jl | 6 +++--- src/apply.jl | 2 +- test/runtests.jl | 2 +- test/test-MFDataset.jl | 8 ++++---- test/test-apply.jl | 2 +- test/test-gdal_polygonize.jl | 4 ++-- test/test-rast.jl | 8 ++++---- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Project.toml b/Project.toml index eb647d4..f86a699 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Terra" uuid = "cfcdd479-6883-4e94-b5c8-0a25d121abce" authors = ["Dongdong Kong "] -version = "0.1.0" +version = "0.1.1" [deps] ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" diff --git a/examples/example_apply.qmd b/examples/example_apply.qmd index 156bf00..b801f7f 100644 --- a/examples/example_apply.qmd +++ b/examples/example_apply.qmd @@ -18,7 +18,7 @@ ntime = length(dates) data = rand(length(lon), length(lat), ntime) dims = X(lon), Y(lat), Ti(dates) -ra = rast(data, dims) +ra = Raster(data, dims) probs = [0.05, 0.95] dims_new = Dim{:prob}(probs) @@ -34,7 +34,7 @@ res = Ipaper.apply(data, 3; by=date_year(dates), fun=NanQuantile, combine=true, obj_size(res) ``` -## 0.2. 版本2: rast +## 0.2. 版本2: Raster > dimension信息终身携带 ```{julia} @@ -71,12 +71,12 @@ nc_info(f) ### 1.0.1. R语言 ```{julia} -r = rast("temp.nc", name=:pr) +r = Raster("temp.nc", name=:pr) ``` ```{r} library(terra) f = "temp.nc" -rast(f) +Raster(f) ``` diff --git a/scripts/previous/hello.qmd b/scripts/previous/hello.qmd index 714a234..984e6b3 100644 --- a/scripts/previous/hello.qmd +++ b/scripts/previous/hello.qmd @@ -1,7 +1,7 @@ ```{julia} using Terra f = "data/MOD13A2_Henan_2015_2020_10km.tif" -r = rast(f; missingval=0.0f0) +r = Raster(f; missingval=0.0f0) r[r .== 0.0f0] .= NaN32; ``` diff --git a/scripts/previous/zarr-01.ipynb b/scripts/previous/zarr-01.ipynb index d18a99e..1270e11 100644 --- a/scripts/previous/zarr-01.ipynb +++ b/scripts/previous/zarr-01.ipynb @@ -69,7 +69,7 @@ "source": [ "# 第一次读写\n", "fout = \"f_star.tif\"\n", - "ra = rast(A)\n", + "ra = Raster(A)\n", "@time st_write(ra, fout)" ] }, @@ -100,7 +100,7 @@ "source": [ "# 第二次读写\n", "# 可能是tiled的原因导致文件偏大\n", - "ra = rast(A)\n", + "ra = Raster(A)\n", "@time st_write(ra, fout)" ] }, @@ -208,7 +208,7 @@ "import Terra\n", "\n", "b = Terra.bbox(70, 15, 140, 55)\n", - "r2 = Terra.rast(A, b);" + "r2 = Terra.Raster(A, b);" ] }, { diff --git a/scripts/s4_upload_to_GEE.qmd b/scripts/s4_upload_to_GEE.qmd index 75b9159..b2e4cf5 100644 --- a/scripts/s4_upload_to_GEE.qmd +++ b/scripts/s4_upload_to_GEE.qmd @@ -61,11 +61,11 @@ library(terra) library(Ipaper) indir = "/mnt/z/GitHub/jl-spatial/Whittaker2.jl/scripts/Project_Global_LAI_smoothing/OUTPUT/global_param_lambda_vcurve" fs = dir(indir, "*.tif", full.names = TRUE) -# f = fs[1]; plot(rast(f), main = basename(f)) +# f = fs[1]; plot(Raster(f), main = basename(f)) write_fig({ par(mfrow = c(3, 2)) for(f in fs) { - plot(rast(f), main = basename(f)) + plot(Raster(f), main = basename(f)) } }, "Figure1_global_lambda_vcurve.pdf", 11, 7) ``` @@ -93,7 +93,7 @@ using Ipaper indir = realpath("/mnt/z/GitHub/jl-spatial/Whittaker2.jl/scripts/Project_Global_LAI_smoothing/OUTPUT/global_param_lambda_vcurve") fs = dir(indir, "tif") -ra = rast(fs[1], lazy=true) +ra = Raster(fs[1], lazy=true) x, y = st_dims(ra) l = (;xsize=length(x),ysize=length(y),num_bands=1) diff --git a/src/Terra.jl b/src/Terra.jl index 4276a87..082c923 100644 --- a/src/Terra.jl +++ b/src/Terra.jl @@ -14,7 +14,7 @@ const AG = ArchGDAL @reexport using Ipaper.sf @reexport using Rasters using Rasters: AbstractRaster -rast = Raster +Raster = Raster brick = RasterStack include("GDAL/GDAL.jl") @@ -32,14 +32,14 @@ include("IO.jl") include("MFDataset/MFDataset.jl") -# include("rast.jl") +# include("Raster.jl") include("apply.jl") include("tools.jl") include("tools_Ipaper.jl") include("main_cdo.jl") -export rast, brick, +export Raster, brick, rast_apply, set_names diff --git a/src/apply.jl b/src/apply.jl index 96c6a75..64a7a42 100644 --- a/src/apply.jl +++ b/src/apply.jl @@ -86,7 +86,7 @@ ntime = length(dates) data = rand(length(lon), length(lat), ntime) dims = X(lon), Y(lat), Ti(dates) -ra = rast(data, dims) +ra = Raster(data, dims) probs = [0.05, 0.95] dims_new = Dim{:prob}(probs) diff --git a/test/runtests.jl b/test/runtests.jl index c4fd4d0..56fcd01 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,6 +8,6 @@ using NetCDFTools include("test-MFDataset.jl") include("test-mapslices.jl") include("test-apply.jl") -include("test-rast.jl") +include("test-Raster.jl") include("test-gdal_polygonize.jl") include("test-st_mosaic.jl") diff --git a/test/test-MFDataset.jl b/test/test-MFDataset.jl index 2665d57..ed7e98e 100644 --- a/test/test-MFDataset.jl +++ b/test/test-MFDataset.jl @@ -9,8 +9,8 @@ dir_root = dirname(dirname(@__FILE__)) b = bbox(70, 15, 140, 55) A = rand(10, 10, 5) - ra1 = rast(A, b; name=:x) - ra2 = rast(A, b; name=:y) + ra1 = Raster(A, b; name=:x) + ra2 = Raster(A, b; name=:y) @test_nowarn ras = brick(ra1, ra2) end @@ -22,11 +22,11 @@ end @testset "tiff file" begin # b = bbox(70, 15, 140, 55) # A = rand(10, 10) - # ra = rast(A, b) + # ra = Raster(A, b) f = "$dir_root/data/test1.tif" # write(f, ra, force=true) - ra = rast(f) + ra = Raster(f) @test st_bbox(ra) == st_bbox(f) end ## 数据保存没有问题,可能是读取的时候出现了bug diff --git a/test/test-apply.jl b/test/test-apply.jl index 5912f1f..921083c 100644 --- a/test/test-apply.jl +++ b/test/test-apply.jl @@ -15,7 +15,7 @@ data = rand(length(lon), length(lat), ntime) dims = X(lon), Y(lat), Ti(dates) - ra = rast(data, dims) + ra = Raster(data, dims) probs = [0.05, 0.95] dims_new = Dim{:prob}(probs) diff --git a/test/test-gdal_polygonize.jl b/test/test-gdal_polygonize.jl index bed8d90..2198a57 100644 --- a/test/test-gdal_polygonize.jl +++ b/test/test-gdal_polygonize.jl @@ -13,7 +13,7 @@ using ArchGDAL b = bbox([70, 15, 140, 55]...) A[1] = 0 - ra = rast(A, b) + ra = Raster(A, b) # ra.A f = "test_nodata.tif" @@ -51,7 +51,7 @@ end # A = rand(Bool, 7 * n, 4 * n, 100) # b = bbox([70, 15, 140, 55]...) -# ra = rast(A, b) +# ra = Raster(A, b) # ra.A # ## 1. without nodata diff --git a/test/test-rast.jl b/test/test-rast.jl index c3d1e39..1c756ce 100644 --- a/test/test-rast.jl +++ b/test/test-rast.jl @@ -10,12 +10,12 @@ using Rasters.Extents: extent # 2d array data = rand(70, 40) - ra2 = rast(data, b) + ra2 = Raster(data, b) @test st_bbox(ra2) == b # 3d array data = rand(70, 40, 10) - ra3 = rast(data, b) + ra3 = Raster(data, b) @test st_bbox(ra3) == b @@ -26,7 +26,7 @@ using Rasters.Extents: extent b = bbox(70, 15, 140, 55) data = rand(70, 40, ntime) # obj_size(data) - ra = rast(data, b; date=dates) + ra = Raster(data, b; date=dates) @test collect(ra.dims[3]) == dates end @@ -35,7 +35,7 @@ end A = rand(360, 180) b = bbox(-180, -90, 180, 90) - ra = rast(A, b) + ra = Raster(A, b) # write("a.tif", ra, force=true) # run(`gdalinfo a.tif`) ext = extent(ra)