From b7cd46038c69d16b4309ef36d13ddd7af16d0729 Mon Sep 17 00:00:00 2001
From: "M. Kanamaru" <kanamaru-masanori@hotmail.co.jp>
Date: Wed, 22 Nov 2023 13:41:27 +0900
Subject: [PATCH] Cleanup 7 (#102)

* Just corrected a message

* Remove `ENABLE_JLD`

* Update shape.jl

Remove `load_shape_jld` and `save_shape_jld`

* Update Project.toml

* Update .gitignore

* Remove JLD-related code
---
 .gitignore                          |  2 --
 Project.toml                        |  2 --
 src/AsteroidThermoPhysicalModels.jl |  1 -
 src/shape.jl                        |  9 ---------
 test/TPM_Didymos.jl                 | 18 +++---------------
 test/TPM_Ryugu.jl                   | 12 +++---------
 test/find_visiblefacets.jl          |  2 +-
 test/non-uniform_thermoparams.jl    | 12 +++---------
 test/runtests.jl                    |  2 --
 9 files changed, 10 insertions(+), 50 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4cb82068..ee460538 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,6 @@
 
 /test/kernel
 /test/shape/*.obj
-/test/shape/*.jld2
-/test/*.jld2
 
 /test/TPM_Ryugu
 /test/non-uniform_thermoparams
diff --git a/Project.toml b/Project.toml
index 7ae1afaa..0ea129c6 100644
--- a/Project.toml
+++ b/Project.toml
@@ -7,7 +7,6 @@ version = "0.0.6-DEV"
 CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
 DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
 FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
-JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
 ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
 SPICE = "5bab7191-041a-5c2e-a744-024b9c3a5062"
@@ -21,7 +20,6 @@ DataFrames = "1"
 Downloads = "1"
 FileIO = "1"
 Git = "1"
-JLD2 = "0.4"
 LinearAlgebra = "1"
 ProgressMeter = "1"
 Rotations = "1"
diff --git a/src/AsteroidThermoPhysicalModels.jl b/src/AsteroidThermoPhysicalModels.jl
index 87e87121..008bf963 100644
--- a/src/AsteroidThermoPhysicalModels.jl
+++ b/src/AsteroidThermoPhysicalModels.jl
@@ -10,7 +10,6 @@ using DataFrames
 using ProgressMeter
 
 using FileIO
-using JLD2
 using CSV
 
 
diff --git a/src/shape.jl b/src/shape.jl
index 1af1cee0..82e086b1 100644
--- a/src/shape.jl
+++ b/src/shape.jl
@@ -71,15 +71,6 @@ function load_shape_obj(shapepath; scale=1.0, find_visible_facets=false)
     return shape
 end
 
-function load_shape_jld(shapepath)
-    shape = load(shapepath, "shape")
-    return shape
-end
-
-function save_shape_jld(shapepath, shape)
-    save(splitext(shapepath)[1] * ".jld2", Dict("shape" => shape))
-end
-
 
 ################################################################
 #               Create a shape model from grid
diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl
index 1ca4d814..1e55ff7f 100644
--- a/test/TPM_Didymos.jl
+++ b/test/TPM_Didymos.jl
@@ -76,21 +76,9 @@
     ##= Load the shape models =##
     path_shape1_obj = joinpath("shape", "g_50677mm_rad_obj_didy_0000n00000_v001.obj")
     path_shape2_obj = joinpath("shape", "g_08438mm_lgt_obj_dimo_0000n00000_v002.obj")
-    path_shape1_jld = joinpath("shape", "g_50677mm_rad_obj_didy_0000n00000_v001.jld2")
-    path_shape2_jld = joinpath("shape", "g_08438mm_lgt_obj_dimo_0000n00000_v002.jld2")
-
-    if isfile(path_shape1_jld) && ENABLE_JLD
-        shape1 = AsteroidThermoPhysicalModels.load_shape_jld(path_shape1_jld)
-    else
-        shape1 = AsteroidThermoPhysicalModels.load_shape_obj(path_shape1_obj; scale=1000, find_visible_facets=true)
-        AsteroidThermoPhysicalModels.save_shape_jld(path_shape1_jld, shape1)
-    end
-    if isfile(path_shape2_jld) && ENABLE_JLD
-        shape2 = AsteroidThermoPhysicalModels.load_shape_jld(path_shape2_jld)
-    else
-        shape2 = AsteroidThermoPhysicalModels.load_shape_obj(path_shape2_obj; scale=1000, find_visible_facets=true)
-        AsteroidThermoPhysicalModels.save_shape_jld(path_shape2_jld, shape2)
-    end
+    
+    shape1 = AsteroidThermoPhysicalModels.load_shape_obj(path_shape1_obj; scale=1000, find_visible_facets=true)
+    shape2 = AsteroidThermoPhysicalModels.load_shape_obj(path_shape2_obj; scale=1000, find_visible_facets=true)
     
     ##= Thermal properties =##
     k  = 0.125
diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl
index e7d9fdea..d1a5f4c1 100644
--- a/test/TPM_Ryugu.jl
+++ b/test/TPM_Ryugu.jl
@@ -57,16 +57,10 @@
     SPICE.kclear()
 
     ##= Load obj file =##
-    path_obj = joinpath("shape", "ryugu_test.obj")   # Small model for test
-    path_jld = joinpath("shape", "ryugu_test.jld2")  # Small model for test
+    path_obj = joinpath("shape", "ryugu_test.obj")  # Small model for test
     # path_obj = joinpath("shape", "SHAPE_SFM_49k_v20180804.obj")
-    # path_jld = joinpath("shape", "SHAPE_SFM_49k_v20180804.jld2")
-    if isfile(path_jld) && ENABLE_JLD
-        shape = AsteroidThermoPhysicalModels.load_shape_jld(path_jld)
-    else
-        shape = AsteroidThermoPhysicalModels.load_shape_obj(path_obj; scale=1000, find_visible_facets=true)
-        AsteroidThermoPhysicalModels.save_shape_jld(path_jld, shape)
-    end
+    
+    shape = AsteroidThermoPhysicalModels.load_shape_obj(path_obj; scale=1000, find_visible_facets=true)
 
     ##= Thermal properties =##
     k  = 0.1
diff --git a/test/find_visiblefacets.jl b/test/find_visiblefacets.jl
index 025a2082..0ea5da44 100644
--- a/test/find_visiblefacets.jl
+++ b/test/find_visiblefacets.jl
@@ -27,6 +27,6 @@
     xs, ys, zs = AsteroidThermoPhysicalModels.concave_spherical_segment(0.4, 0.2; Nx=2^5, Ny=2^5, xc=0.5, yc=0.5)
     shape = AsteroidThermoPhysicalModels.load_shape_grid(xs, ys, zs; scale=1.0, find_visible_facets=true)
     
-    println(length(shape.visiblefacets[992]), " faces are visible from the crater center:")
+    println("Number of faces visible from the crater center: ", length(shape.visiblefacets[992]))
     println()
 end
diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl
index e5ff30d0..b8ab96d5 100644
--- a/test/non-uniform_thermoparams.jl
+++ b/test/non-uniform_thermoparams.jl
@@ -59,16 +59,10 @@
     SPICE.kclear()
 
     ##= Load obj file =##
-    path_obj = joinpath("shape", "ryugu_test.obj")   # Small model for test
-    path_jld = joinpath("shape", "ryugu_test.jld2")  # Small model for test
+    path_obj = joinpath("shape", "ryugu_test.obj")  # Small model for test
     # path_obj = joinpath("shape", "SHAPE_SFM_49k_v20180804.obj")
-    # path_jld = joinpath("shape", "SHAPE_SFM_49k_v20180804.jld2")
-    if isfile(path_jld) && ENABLE_JLD
-        shape = AsteroidThermoPhysicalModels.load_shape_jld(path_jld)
-    else
-        shape = AsteroidThermoPhysicalModels.load_shape_obj(path_obj; scale=1000, find_visible_facets=true)
-        AsteroidThermoPhysicalModels.save_shape_jld(path_jld, shape)
-    end
+    
+    shape = AsteroidThermoPhysicalModels.load_shape_obj(path_obj; scale=1000, find_visible_facets=true)
 
     ##= Thermal properties =##
     """
diff --git a/test/runtests.jl b/test/runtests.jl
index daa44b7b..b1df0ad0 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,7 +1,6 @@
 using AsteroidThermoPhysicalModels
 using Test
 using Aqua
-using JLD2
 using SPICE
 using Git
 using Downloads
@@ -11,7 +10,6 @@ using StaticArrays
 using Rotations
 using DataFrames
 
-ENABLE_JLD = false
 Aqua.test_all(AsteroidThermoPhysicalModels, ambiguities=false)
 
 include("find_visiblefacets.jl")