From d1eccef73881cdc84f03b925d123a7313bbbee2e Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Tue, 21 Feb 2023 16:16:03 +0100
Subject: [PATCH] Do not write valid attribute to shapefile extremum

The attribute written was always true.
---
 Common/derived_types.f90         | 2 +-
 Common/read_field_indices.f90    | 1 -
 Convert_Matlab/inst_eddies_v6.py | 6 ++----
 Inst_eddies/shpc_create.f90      | 2 --
 Inst_eddies/write_eddy.f90       | 2 --
 test_write_null.f90              | 2 --
 6 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/Common/derived_types.f90 b/Common/derived_types.f90
index ff2edafd..33a22831 100644
--- a/Common/derived_types.f90
+++ b/Common/derived_types.f90
@@ -84,7 +84,7 @@ module derived_types
      logical cyclone
 
      ! Field identifiers in the DBF files:
-     integer extr_ssh, extr_date, extr_eddy_index, extr_valid, extr_speed
+     integer extr_ssh, extr_date, extr_eddy_index, extr_speed
      integer extr_proj_date, extr_proj_eddy_index
      integer out_r_eq_area, out_ssh, out_date, out_eddy_index, out_radius4
      integer max_speed_r_eq_area, max_speed_ssh, max_speed_date, &
diff --git a/Common/read_field_indices.f90 b/Common/read_field_indices.f90
index ff0edbe7..5ed90cdd 100644
--- a/Common/read_field_indices.f90
+++ b/Common/read_field_indices.f90
@@ -20,7 +20,6 @@ contains
     call dbf_get_field_index_03(hshp%extremum, "date", hshp%extr_date)
     call dbf_get_field_index_03(hshp%extremum, "eddy_index", &
          hshp%extr_eddy_index)
-    call dbf_get_field_index_03(hshp%extremum, "valid", hshp%extr_valid)
     call dbf_get_field_index_03(hshp%extremum, "speed", hshp%extr_speed)
 
     if (.not. dbffileisnull(hshp%extr_proj)) then
diff --git a/Convert_Matlab/inst_eddies_v6.py b/Convert_Matlab/inst_eddies_v6.py
index 51437a00..411c0dd4 100755
--- a/Convert_Matlab/inst_eddies_v6.py
+++ b/Convert_Matlab/inst_eddies_v6.py
@@ -32,7 +32,6 @@ def define_fields(writers):
     writers["extr"].field("ssh", "N", 13, 6)
     writers["extr"].field("date", "N", 5)
     writers["extr"].field("eddy_index", "N", 5)
-    writers["extr"].field("valid", "N", 1)
     writers["extr"].field("speed", "N", 13, 6)
 
     writers["centroid"].field("date", "N", 5)
@@ -79,9 +78,8 @@ def write_to_shp(writers, cyclone, d, cell = None, X = None, Y = None,
                 i = np.argwhere(X == eddy[0]).item()
                 j = np.argwhere(Y == eddy[1]).item()
                 speed = 1e4 if np.isnan(eddy[12]) else eddy[12] # Azimuthal Vit
-                writers["extr"].record(ssh = ADT[i, j], valid = 1,
-                                       date = d, eddy_index = eddy_index,
-                                       speed = speed)
+                writers["extr"].record(ssh = ADT[i, j], date = d,
+                                       eddy_index = eddy_index, speed = speed)
 
                 # Amplitude Out:
                 if cyclone:
diff --git a/Inst_eddies/shpc_create.f90 b/Inst_eddies/shpc_create.f90
index 1c6283d0..1f17a973 100644
--- a/Inst_eddies/shpc_create.f90
+++ b/Inst_eddies/shpc_create.f90
@@ -33,8 +33,6 @@ contains
          ftinteger, nwidth = 5, ndecimals = 0)
     call dbf_add_field_03(hshp%extr_eddy_index, hshp%extremum, 'eddy_index', &
          ftinteger, nwidth = 5, ndecimals = 0)
-    call dbf_add_field_03(hshp%extr_valid, hshp%extremum, 'valid', &
-         ftinteger, nwidth = 1, ndecimals = 0)
     call dbf_add_field_03(hshp%extr_speed, hshp%extremum, 'speed', ftdouble, &
          nwidth = 13, ndecimals = 6)
 
diff --git a/Inst_eddies/write_eddy.f90 b/Inst_eddies/write_eddy.f90
index bcadfbef..168660be 100644
--- a/Inst_eddies/write_eddy.f90
+++ b/Inst_eddies/write_eddy.f90
@@ -36,8 +36,6 @@ contains
     call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_date, date)
     call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_eddy_index, &
          i)
-    call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_valid, &
-         merge(1, 0, e%out_cont%closed))
 
     if (ieee_is_nan(e%max_speed)) then
        call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_speed, &
diff --git a/test_write_null.f90 b/test_write_null.f90
index 8ce866df..cc31e482 100644
--- a/test_write_null.f90
+++ b/test_write_null.f90
@@ -37,7 +37,6 @@ program test_write_null
         call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_date, 0)
         call dbf_write_attribute_03(hshpc%extremum, ishape, &
              hshpc%extr_eddy_index, i)
-        call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_valid, 1)
         call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_speed, &
              0.)
         call shp_append_null_03(ishape, hshpc%outermost)
@@ -68,7 +67,6 @@ program test_write_null
         call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_date, 0)
         call dbf_write_attribute_03(hshpc%extremum, ishape, &
              hshpc%extr_eddy_index, i)
-        call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_valid, 1)
         call dbf_write_attribute_03(hshpc%extremum, ishape, hshpc%extr_speed, &
              0.)
      end do
-- 
GitLab