diff --git a/NEWS.md b/NEWS.md index a60add81..a0e5b87d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ ClimaAnalysis.jl Release Notes =============================== +v0.5.4 +------ +- Reorganized internal modules so that each file is a module. + v0.5.3 ------ - Add `Visualize.contour2D_on_globe!` for discrete contours. diff --git a/Project.toml b/Project.toml index 413e955f..6030c90d 100644 --- a/Project.toml +++ b/Project.toml @@ -6,6 +6,7 @@ version = "0.5.3" [deps] NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [weakdeps] @@ -26,6 +27,7 @@ NCDatasets = "0.13.1, 0.14" OrderedCollections = "1.3" SafeTestsets = "0.1" Statistics = "1" +Reexport = "1" Test = "1" julia = "1.9" diff --git a/ext/CairoMakieExt.jl b/ext/CairoMakieExt.jl index 00b54676..ccd614b8 100644 --- a/ext/CairoMakieExt.jl +++ b/ext/CairoMakieExt.jl @@ -107,7 +107,7 @@ function _sliced_plot_generic( var_sliced = var for (dim_name, val) in cut - var_sliced = ClimaAnalysis._slice_general(var_sliced, val, dim_name) + var_sliced = ClimaAnalysis.Var._slice_general(var_sliced, val, dim_name) end func(fig, var_sliced; p_loc, more_kwargs) diff --git a/src/ClimaAnalysis.jl b/src/ClimaAnalysis.jl index 0f185c64..3f850fad 100644 --- a/src/ClimaAnalysis.jl +++ b/src/ClimaAnalysis.jl @@ -1,13 +1,15 @@ module ClimaAnalysis +using Reexport include("Utils.jl") import .Utils -include("OutputVar.jl") -include("SimDir.jl") -import .SimDir +include("Var.jl") +@reexport using .Var +include("Sim.jl") +@reexport using .Sim include("Visualize.jl") -import .Visualize +@reexport using .Visualize end # module ClimaAnalysis diff --git a/src/SimDir.jl b/src/Sim.jl similarity index 99% rename from src/SimDir.jl rename to src/Sim.jl index 953fee22..d3bd51aa 100644 --- a/src/SimDir.jl +++ b/src/Sim.jl @@ -1,7 +1,12 @@ +module Sim + import Base: get export SimDir, available_vars, available_reductions, available_periods +import ..Utils +import ..Var: read_var + """ SimDir(simulation_path::String) @@ -191,3 +196,5 @@ end Check if the given SimDir contains OutputVars. """ Base.isempty(simdir::SimDir) = isempty(simdir.vars) + +end diff --git a/src/OutputVar.jl b/src/Var.jl similarity index 98% rename from src/OutputVar.jl rename to src/Var.jl index 05fbd0b6..de0bbe98 100644 --- a/src/OutputVar.jl +++ b/src/Var.jl @@ -1,9 +1,11 @@ +module Var + import NCDatasets import OrderedCollections: OrderedDict import Statistics: mean -import .Utils: nearest_index, seconds_to_prettystr +import ..Utils: nearest_index, seconds_to_prettystr, squeeze export OutputVar, read_var, @@ -17,7 +19,10 @@ export OutputVar, slice, window, arecompatible, - center_longitude! + center_longitude!, + short_name, + long_name, + units """ Representing an output variable @@ -184,10 +189,7 @@ function _reduce_over( dim_index = var.dim2index[dim] # squeeze removes the unnecessary singleton dimension - data = Utils.squeeze( - reduction(var.data, dims = dim_index), - dims = (dim_index,), - ) + data = squeeze(reduction(var.data, dims = dim_index), dims = (dim_index,)) # If we reduce over a dimension, we have to remove it dims = copy(var.dims) @@ -518,3 +520,5 @@ end @overload_binary_op (-) @overload_binary_op (*) @overload_binary_op (/) + +end diff --git a/src/Visualize.jl b/src/Visualize.jl index 6dc6ec24..307c814c 100644 --- a/src/Visualize.jl +++ b/src/Visualize.jl @@ -1,5 +1,7 @@ module Visualize +export plot! + function heatmap2D! end function sliced_heatmap! end diff --git a/test/runtests.jl b/test/runtests.jl index 2f1af838..9dc9e25a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,11 +6,11 @@ using Test @safetestset "Docstrings" begin @time include("doctest.jl") end @safetestset "Format" begin @time include("format.jl") end -@safetestset "Utils" begin @time include("Utils.jl") end -@safetestset "SimDir" begin @time include("SimDir.jl") end -@safetestset "OutputVar" begin @time include("OutputVar.jl") end -@safetestset "CairoMakieExt" begin @time include("CairoMakieExt.jl") end -@safetestset "GeoMakieExt" begin @time include("GeoMakieExt.jl") end +@safetestset "Utils" begin @time include("test_Utils.jl") end +@safetestset "SimDir" begin @time include("test_Sim.jl") end +@safetestset "OutputVar" begin @time include("test_Var.jl") end +@safetestset "CairoMakieExt" begin @time include("test_CairoMakieExt.jl") end +@safetestset "GeoMakieExt" begin @time include("test_GeoMakieExt.jl") end #! format: on nothing diff --git a/test/CairoMakieExt.jl b/test/test_CairoMakieExt.jl similarity index 100% rename from test/CairoMakieExt.jl rename to test/test_CairoMakieExt.jl diff --git a/test/GeoMakieExt.jl b/test/test_GeoMakieExt.jl similarity index 100% rename from test/GeoMakieExt.jl rename to test/test_GeoMakieExt.jl diff --git a/test/SimDir.jl b/test/test_Sim.jl similarity index 100% rename from test/SimDir.jl rename to test/test_Sim.jl diff --git a/test/Utils.jl b/test/test_Utils.jl similarity index 100% rename from test/Utils.jl rename to test/test_Utils.jl diff --git a/test/OutputVar.jl b/test/test_Var.jl similarity index 100% rename from test/OutputVar.jl rename to test/test_Var.jl