Skip to content
Snippets Groups Projects
Commit 7c9a1e1b authored by GUEZ Lionel's avatar GUEZ Lionel
Browse files

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`.
parent c6f280e3
No related branches found
No related tags found
No related merge requests found
...@@ -4,9 +4,9 @@ import shapefile ...@@ -4,9 +4,9 @@ import shapefile
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
cont_list = shapefile.Reader("cont_list") cont_list_proj = shapefile.Reader("cont_list_proj")
ssh_lev = [] 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) ssh_lev = np.array(ssh_lev)
left = 0.95 * ssh_lev.min() left = 0.95 * ssh_lev.min()
right = 1.05 * ssh_lev.max() right = 1.05 * ssh_lev.max()
......
...@@ -4,7 +4,7 @@ module cont_list_m ...@@ -4,7 +4,7 @@ module cont_list_m
implicit none 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. logical, protected:: write_cont_list = .false.
integer, save:: ifield_ssh, ifield_speed integer, save:: ifield_ssh, ifield_speed
...@@ -19,9 +19,10 @@ contains ...@@ -19,9 +19,10 @@ contains
!--------------------------------------------------------------- !---------------------------------------------------------------
call shp_create_03("cont_list", shpt_polygon, hshp_cont_list) call shp_create_03("cont_list_proj", shpt_polygon, hshp_cont_list_proj)
call dbf_add_field_03(ifield_ssh, hshp_cont_list, 'ssh', ftdouble, & call dbf_add_field_03(ifield_ssh, hshp_cont_list_proj, 'ssh', ftdouble, &
nwidth = 13, ndecimals = 6) 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, & call dbf_add_field_03(ifield_speed, hshp_cont_list, 'speed', ftdouble, &
nwidth = 13, ndecimals = 6) nwidth = 13, ndecimals = 6)
write_cont_list = .true. write_cont_list = .true.
...@@ -37,6 +38,7 @@ contains ...@@ -37,6 +38,7 @@ contains
!--------------------------------------------------------------- !---------------------------------------------------------------
CALL shpclose(hshp_cont_list) CALL shpclose(hshp_cont_list)
CALL shpclose(hshp_cont_list_proj)
end subroutine close_cont_list end subroutine close_cont_list
......
...@@ -111,18 +111,32 @@ program test_get_1_outerm ...@@ -111,18 +111,32 @@ program test_get_1_outerm
! cont_list shapefile: ! cont_list shapefile:
call shp_create_03("cont_list", shpt_polygon, hshp) call shp_create_03("cont_list", shpt_polygon, hshp)
call dbf_add_field_03(ifield, hshp, 'ssh', ftdouble, & call dbf_add_field_03(ifield, hshp, 'speed', ftdouble, nwidth = 13, &
nwidth = 13, ndecimals = 6) ndecimals = 6)
do i = 1, n_cont do i = 1, n_cont
call shp_append_object_03(ishape, hshp, shpt_polygon, & call shp_append_object_03(ishape, hshp, shpt_polygon, &
cont_list(i)%points * rad_to_deg) cont_list(i)%points * rad_to_deg)
call dbf_write_attribute_03(hshp, ishape, ifield, & call dbf_write_attribute_03(hshp, ishape, ifield, missing_speed)
cont_list_proj(i)%ssh)
end do end do
CALL shpclose(hshp) CALL shpclose(hshp)
print *, 'test_get_1_outerm: Created shapefile "cont_list".' 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 else
print *, "test_get_1_outerm: Could not find an outermost contour." print *, "test_get_1_outerm: Could not find an outermost contour."
end if end if
......
...@@ -31,8 +31,8 @@ contains ...@@ -31,8 +31,8 @@ contains
use input_ssh_m, only: corner_whole => corner use input_ssh_m, only: corner_whole => corner
use mean_speed_m, only: mean_speed use mean_speed_m, only: mean_speed
use spher_polyline_area_m, only: spher_polyline_area use spher_polyline_area_m, only: spher_polyline_area
use cont_list_m, only: write_cont_list, hshp_cont_list, ifield_ssh, & use cont_list_m, only: write_cont_list, hshp_cont_list, &
ifield_speed hshp_cont_list_proj, ifield_ssh, ifield_speed
type(ssh_contour), intent(out):: speed_cont type(ssh_contour), intent(out):: speed_cont
...@@ -116,10 +116,12 @@ contains ...@@ -116,10 +116,12 @@ contains
if (write_cont_list) then if (write_cont_list) then
do i = 1, n_cont 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, & call shp_append_object_03(ishape, hshp_cont_list, shpt_polygon, &
cont_list(i)%points * rad_to_deg) 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 if (ieee_is_nan(speed(i))) then
call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_speed, & call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_speed, &
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment