From 7c9a1e1bf8a51ec1b6eadf569985050df4c95edc Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ipsl.fr> Date: Tue, 2 Jul 2024 16:58:24 +0200 Subject: [PATCH] Write shapefile `cont_list_proj` with `cont_list` Note that, as each shapefile should have an associated DBF file with at least one field, we choose to put the SSH field in `cont_list_proj` and the speed field in `cont_list`. --- Inst_eddies/Analysis/plot_ssh_lev.py | 4 ++-- Inst_eddies/Tests/cont_list.f90 | 8 +++++--- Inst_eddies/Tests/test_get_1_outerm.f90 | 22 ++++++++++++++++++---- Inst_eddies/set_max_speed.f90 | 10 ++++++---- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Inst_eddies/Analysis/plot_ssh_lev.py b/Inst_eddies/Analysis/plot_ssh_lev.py index 647799f8..c53cfa2b 100755 --- a/Inst_eddies/Analysis/plot_ssh_lev.py +++ b/Inst_eddies/Analysis/plot_ssh_lev.py @@ -4,9 +4,9 @@ import shapefile import matplotlib.pyplot as plt import numpy as np -cont_list = shapefile.Reader("cont_list") +cont_list_proj = shapefile.Reader("cont_list_proj") ssh_lev = [] -for rec in cont_list.iterRecords(fields = ["ssh"]): ssh_lev.append(rec[0]) +for rec in cont_list_proj.iterRecords(fields = ["ssh"]): ssh_lev.append(rec[0]) ssh_lev = np.array(ssh_lev) left = 0.95 * ssh_lev.min() right = 1.05 * ssh_lev.max() diff --git a/Inst_eddies/Tests/cont_list.f90 b/Inst_eddies/Tests/cont_list.f90 index c6b5bd33..db15a49d 100644 --- a/Inst_eddies/Tests/cont_list.f90 +++ b/Inst_eddies/Tests/cont_list.f90 @@ -4,7 +4,7 @@ module cont_list_m implicit none - TYPE(shpfileobject), protected, save:: hshp_cont_list + TYPE(shpfileobject), protected, save:: hshp_cont_list, hshp_cont_list_proj logical, protected:: write_cont_list = .false. integer, save:: ifield_ssh, ifield_speed @@ -19,9 +19,10 @@ contains !--------------------------------------------------------------- - call shp_create_03("cont_list", shpt_polygon, hshp_cont_list) - call dbf_add_field_03(ifield_ssh, hshp_cont_list, 'ssh', ftdouble, & + call shp_create_03("cont_list_proj", shpt_polygon, hshp_cont_list_proj) + call dbf_add_field_03(ifield_ssh, hshp_cont_list_proj, 'ssh', ftdouble, & nwidth = 13, ndecimals = 6) + call shp_create_03("cont_list", shpt_polygon, hshp_cont_list) call dbf_add_field_03(ifield_speed, hshp_cont_list, 'speed', ftdouble, & nwidth = 13, ndecimals = 6) write_cont_list = .true. @@ -37,6 +38,7 @@ contains !--------------------------------------------------------------- CALL shpclose(hshp_cont_list) + CALL shpclose(hshp_cont_list_proj) end subroutine close_cont_list diff --git a/Inst_eddies/Tests/test_get_1_outerm.f90 b/Inst_eddies/Tests/test_get_1_outerm.f90 index 7d053c3c..be62f296 100644 --- a/Inst_eddies/Tests/test_get_1_outerm.f90 +++ b/Inst_eddies/Tests/test_get_1_outerm.f90 @@ -111,18 +111,32 @@ program test_get_1_outerm ! cont_list shapefile: call shp_create_03("cont_list", shpt_polygon, hshp) - call dbf_add_field_03(ifield, hshp, 'ssh', ftdouble, & - nwidth = 13, ndecimals = 6) + call dbf_add_field_03(ifield, hshp, 'speed', ftdouble, nwidth = 13, & + ndecimals = 6) do i = 1, n_cont call shp_append_object_03(ishape, hshp, shpt_polygon, & cont_list(i)%points * rad_to_deg) - call dbf_write_attribute_03(hshp, ishape, ifield, & - cont_list_proj(i)%ssh) + call dbf_write_attribute_03(hshp, ishape, ifield, missing_speed) end do CALL shpclose(hshp) print *, 'test_get_1_outerm: Created shapefile "cont_list".' + + ! cont_list_proj shapefile: + + call shp_create_03("cont_list_proj", shpt_polygon, hshp) + call dbf_add_field_03(ifield, hshp, 'ssh', ftdouble, nwidth = 13, & + ndecimals = 6) + + do i = 1, n_cont + call shp_append_object_03(ishape, hshp, shpt_polygon, & + cont_list_proj(i)%points) + call dbf_write_attribute_03(hshp, ishape, ifield, cont_list_proj(i)%ssh) + end do + + CALL shpclose(hshp) + print *, 'test_get_1_outerm: Created shapefile "cont_list_proj".' else print *, "test_get_1_outerm: Could not find an outermost contour." end if diff --git a/Inst_eddies/set_max_speed.f90 b/Inst_eddies/set_max_speed.f90 index 81b81275..cc82777c 100644 --- a/Inst_eddies/set_max_speed.f90 +++ b/Inst_eddies/set_max_speed.f90 @@ -31,8 +31,8 @@ contains use input_ssh_m, only: corner_whole => corner use mean_speed_m, only: mean_speed use spher_polyline_area_m, only: spher_polyline_area - use cont_list_m, only: write_cont_list, hshp_cont_list, ifield_ssh, & - ifield_speed + use cont_list_m, only: write_cont_list, hshp_cont_list, & + hshp_cont_list_proj, ifield_ssh, ifield_speed type(ssh_contour), intent(out):: speed_cont @@ -116,10 +116,12 @@ contains if (write_cont_list) then do i = 1, n_cont + call shp_append_object_03(ishape, hshp_cont_list_proj, & + shpt_polygon, cont_list_proj(i)%points) + call dbf_write_attribute_03(hshp_cont_list_proj, ishape, ifield_ssh, & + fieldvalue = cont_list_proj(i)%ssh) call shp_append_object_03(ishape, hshp_cont_list, shpt_polygon, & cont_list(i)%points * rad_to_deg) - call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_ssh, & - fieldvalue = cont_list_proj(i)%ssh) if (ieee_is_nan(speed(i))) then call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_speed, & -- GitLab