From e8a607effc67e16ce9b8a77741a35f547e2190d5 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 3 Oct 2019 18:38:07 +0200 Subject: [PATCH] Bug fixes in `test_overlap` In procedure `write_eddy`, no need of special treatment for interpolated eddy: the outermost contours and max-speed contours are defined as null. Read name of input file on the command line in script `read_overlap.py`. Add tests with program `test_overlap` in `short_tests.json`. Bug fix in main unit `test_overlap`: we have to call `init_interpolated_eddy`. In main unit `test_overlap`, change the initial value of `flow(2:max_delta)%number_eddies` for more clarity in the results. Bug fix in main unit `test_overlap`: valid isolated eddies of snasphot 2 are in `flow(max_delta + 1)`, not `flow(2)`. --- Analysis/read_overlap.py | 4 ++- Analysis/triplet_dump.sh | 1 + Tests/Input/NSO_region_5_nml.txt | 5 ++++ Tests/Input/non_successive_overlap_nml.txt | 5 ++++ Tests/short_tests.json | 24 ++++++++++++++++++ Tests/test_overlap.f90 | 11 +++++--- write_eddy.f90 | 29 +++++++++------------- 7 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 Tests/Input/NSO_region_5_nml.txt create mode 100644 Tests/Input/non_successive_overlap_nml.txt diff --git a/Analysis/read_overlap.py b/Analysis/read_overlap.py index 0fd0ab9e..9d48c76d 100755 --- a/Analysis/read_overlap.py +++ b/Analysis/read_overlap.py @@ -3,10 +3,12 @@ import networkx as nx import csv import matplotlib.pyplot as plt +import sys +if len(sys.argv) != 2: sys.exit("Required argument: edgelist-CSV-file") G = nx.DiGraph() -with open("edgelist.csv") as f: +with open(sys.argv[1]) as f: reader = csv.reader(f, delimiter = " ", skipinitialspace = True) # Skip title lines: diff --git a/Analysis/triplet_dump.sh b/Analysis/triplet_dump.sh index 8f0adb3b..178373b0 100755 --- a/Analysis/triplet_dump.sh +++ b/Analysis/triplet_dump.sh @@ -8,6 +8,7 @@ set -e for shapefile in extremum outermost_contour max_speed_contour do + echo "------------------------------------------------" echo echo "dbfdump $1/$shapefile:" dbfdump $1/$shapefile diff --git a/Tests/Input/NSO_region_5_nml.txt b/Tests/Input/NSO_region_5_nml.txt new file mode 100644 index 00000000..3619a965 --- /dev/null +++ b/Tests/Input/NSO_region_5_nml.txt @@ -0,0 +1,5 @@ + &MAIN_NML + CORNER_deg = 0.12500 , -59.875, + NLON = 120, + NLAT = 180, max_delta = 3 + / diff --git a/Tests/Input/non_successive_overlap_nml.txt b/Tests/Input/non_successive_overlap_nml.txt new file mode 100644 index 00000000..2420c73c --- /dev/null +++ b/Tests/Input/non_successive_overlap_nml.txt @@ -0,0 +1,5 @@ +&MAIN_NML + CORNER_deg = 16.12500 , -38.87500 , + NLON = 20, + NLAT = 20, max_delta = 3 + / diff --git a/Tests/short_tests.json b/Tests/short_tests.json index 089bd4cf..ce46d06b 100644 --- a/Tests/short_tests.json +++ b/Tests/short_tests.json @@ -346,5 +346,29 @@ "title": "Write_overlap_delta_3", "stdin_filename" : "$src_dir/Tests/Input/write_overlap_delta_3_nml.txt", "description" : "Different coordinates and ssh, shifting in longitude, delta = 3." + }, + { + "args" : ["$src_dir/mkdir_run.sh", "$build_dir/test_overlap", + "$src_dir/Tests/Input/Region_4_2006_01_01/SHP_triplet", + "$src_dir/Tests/Input/Region_4_2006_01_01/SHP_triplet"], + "title" : "Non_successive_overlap", + "description": "Same as Successive_overlap, except for max_delta.", + "stdin_filename": "$src_dir/Tests/Input/non_successive_overlap_nml.txt" + }, + { + "args" : ["$src_dir/mkdir_run.sh", "$build_dir/test_overlap", + "$src_dir/Tests/Input/Region_4_2006_01_01/SHP_triplet", + "$src_dir/Tests/Input/Region_4_2006_01_02/SHP_triplet"], + "title" : "NSO_different_snapshots", + "description": "Same as Successive_overlap_different_snapshots, except for max_delta.", + "stdin_filename": "$src_dir/Tests/Input/non_successive_overlap_nml.txt" + }, + { + "args" : ["$src_dir/mkdir_run.sh", "$build_dir/test_overlap", + "$src_dir/Tests/Input/Extraction_eddies_region_5/SHP_triplet", + "$src_dir/Tests/Input/SHP_triplet_region_5_2006_01_02"], + "title" : "NSO_region_5", + "description": "Same as Successive_overlap_region_5, except for max_delta.", + "stdin_filename": "$src_dir/Tests/Input/NSO_region_5_nml.txt" } ] diff --git a/Tests/test_overlap.f90 b/Tests/test_overlap.f90 index a20a6863..ef2f0a68 100644 --- a/Tests/test_overlap.f90 +++ b/Tests/test_overlap.f90 @@ -13,6 +13,7 @@ program test_overlap use read_field_indices_m, only: read_field_indices use read_snapshot_m, only: read_snapshot use overlap_m, only: overlap + use write_overlap_m, only: init_interpolated_eddy implicit none @@ -90,7 +91,7 @@ program test_overlap CALL shpclose(hshp_max_speed) print *, snapshot_2, ", k = ", k - flow(2:max_delta)%number_eddies = 0 + flow(2:max_delta)%number_eddies = 20000 call new_unit(unit_edgelist) open(unit_edgelist, file = "edgelist.csv", status = "replace", & @@ -103,6 +104,7 @@ program test_overlap write(unit_edgelist, fmt = *) "k1 i1 k2 i2 weight" call init_shapefiles(hshp_extremum, hshp_outermost, hshp_max_speed) + call init_interpolated_eddy call overlap(flow, unit_edgelist, nlon, nlat, periodic, dist_lim, & hshp_extremum, hshp_outermost, hshp_max_speed, j = max_delta + 1, & k = k, delta = max_delta) @@ -127,9 +129,10 @@ program test_overlap print *, Snapshot_2, ":" print *, "Valid isolated eddies:" - do i = 1, flow(2)%number_vis_extr - if (flow(2)%list_vis(i)%valid .and. flow(2)%list_vis(i)%delta_in & - == huge(0)) write(unit = *, fmt = "(i0, 1x)", advance = "no") i + do i = 1, flow(max_delta + 1)%number_vis_extr + if (flow(max_delta + 1)%list_vis(i)%valid & + .and. flow(max_delta + 1)%list_vis(i)%delta_in == huge(0)) & + write(unit = *, fmt = "(i0, 1x)", advance = "no") i end do print * diff --git a/write_eddy.f90 b/write_eddy.f90 index 8ea0dd4e..116282ed 100644 --- a/write_eddy.f90 +++ b/write_eddy.f90 @@ -39,7 +39,7 @@ contains !------------------------------------------------------------- call shp_append_point_03(ishape, hshp_extremum, e%coord_extr * rad_to_deg) - + call dbf_write_attribute_03(hshp_extremum, ishape, ifield_extr_ssh, & e%ssh_extr) call dbf_write_attribute_03(hshp_extremum, ishape, ifield_extr_date, k) @@ -61,23 +61,18 @@ contains e%max_speed) end if - if (e%interpolated) then + if (e%out_cont%n_points == 0) then call shp_append_null_03(ishape, hshp_outermost) + else + call shp_append_object_03(ishape, hshp_outermost, shpt_polygon, & + e%out_cont%points * rad_to_deg) + end if + + if (e%speed_cont%n_points == 0) then call shp_append_null_03(ishape, hshp_max_speed) else - if (e%out_cont%n_points == 0) then - call shp_append_null_03(ishape, hshp_outermost) - else - call shp_append_object_03(ishape, hshp_outermost, shpt_polygon, & - e%out_cont%points * rad_to_deg) - end if - - if (e%speed_cont%n_points == 0) then - call shp_append_null_03(ishape, hshp_max_speed) - else - call shp_append_object_03(ishape, hshp_max_speed, shpt_polygon, & - e%speed_cont%points * rad_to_deg) - end if + call shp_append_object_03(ishape, hshp_max_speed, shpt_polygon, & + e%speed_cont%points * rad_to_deg) end if if (e%out_cont%area >= 0) then @@ -87,7 +82,7 @@ contains call dbf_write_attribute_03(hshp_outermost, ishape, & ifield_out_r_eq_area, - 100.) end if - + call dbf_write_attribute_03(hshp_outermost, ishape, ifield_out_ssh, & e%out_cont%ssh) call dbf_write_attribute_03(hshp_outermost, ishape, ifield_out_date, k) @@ -103,7 +98,7 @@ contains call dbf_write_attribute_03(hshp_max_speed, ishape, & ifield_max_speed_r_eq_area, - 100.) end if - + call dbf_write_attribute_03(hshp_max_speed, ishape, ifield_max_speed_ssh, & e%speed_cont%ssh) call dbf_write_attribute_03(hshp_max_speed, ishape, ifield_max_speed_date, & -- GitLab