diff --git a/Analysis/plot_snapshot.py b/Analysis/plot_snapshot.py index 6dcf8ca3795f74970340f8116206873384f0d49b..e10d8a8f4a5f8a4ba5a8c44339f81d221ad56c90 100755 --- a/Analysis/plot_snapshot.py +++ b/Analysis/plot_snapshot.py @@ -2,7 +2,9 @@ """Plots outermost contours and max-speed contours. -Red for anti-cyclones, blue for cyclones. Empty circles for extrema +Red for anti-cyclones, blue for cyclones. + +Without the --light option. Empty circles for extrema with a valid outermost contour, empty squares for other extrema. Squares on outermost contour for a well-defined but invalid outermost contour. Crosses on outermost contour for a valid outermost @@ -10,6 +12,9 @@ contour but with no distinct max-speed contour. Filled circles on outermost contour and max-speed contour for a valid outermost contour with a distinct max-speed contour. +With the --light option. Crosses for extrema with a valid outermost +contour. + This scripts takes about 30 s of CPU for a 90° by 90° window, about 4 mn for a 180° by 180° window. @@ -118,7 +123,8 @@ for shape_rec_extr, shape_outer, shape_m_s \ src_crs), xytext = (3, 3), textcoords = "offset points") - if shape_outer.shapeType != shapefile.NULL: + if shape_outer.shapeType != shapefile.NULL and not args.light \ + or shape_rec_extr.record.valid: points = np.array(shape_outer.points) lines = ax.plot(points[:, 0], points[:, 1], color = color, transform = src_crs) diff --git a/Tests/Input/Region_4/extremum_1.dbf b/Tests/Input/Region_4/extremum.dbf similarity index 100% rename from Tests/Input/Region_4/extremum_1.dbf rename to Tests/Input/Region_4/extremum.dbf diff --git a/Tests/Input/Region_4/extremum_1.shp b/Tests/Input/Region_4/extremum.shp similarity index 100% rename from Tests/Input/Region_4/extremum_1.shp rename to Tests/Input/Region_4/extremum.shp diff --git a/Tests/Input/Region_4/extremum_1.shx b/Tests/Input/Region_4/extremum.shx similarity index 100% rename from Tests/Input/Region_4/extremum_1.shx rename to Tests/Input/Region_4/extremum.shx diff --git a/Tests/Input/Region_4/max_speed_contour_1.dbf b/Tests/Input/Region_4/max_speed_contour.dbf similarity index 100% rename from Tests/Input/Region_4/max_speed_contour_1.dbf rename to Tests/Input/Region_4/max_speed_contour.dbf diff --git a/Tests/Input/Region_4/max_speed_contour_1.shp b/Tests/Input/Region_4/max_speed_contour.shp similarity index 100% rename from Tests/Input/Region_4/max_speed_contour_1.shp rename to Tests/Input/Region_4/max_speed_contour.shp diff --git a/Tests/Input/Region_4/max_speed_contour_1.shx b/Tests/Input/Region_4/max_speed_contour.shx similarity index 100% rename from Tests/Input/Region_4/max_speed_contour_1.shx rename to Tests/Input/Region_4/max_speed_contour.shx diff --git a/Tests/Input/Region_4/outermost_contour_1.dbf b/Tests/Input/Region_4/outermost_contour.dbf similarity index 100% rename from Tests/Input/Region_4/outermost_contour_1.dbf rename to Tests/Input/Region_4/outermost_contour.dbf diff --git a/Tests/Input/Region_4/outermost_contour_1.shp b/Tests/Input/Region_4/outermost_contour.shp similarity index 100% rename from Tests/Input/Region_4/outermost_contour_1.shp rename to Tests/Input/Region_4/outermost_contour.shp diff --git a/Tests/Input/Region_4/outermost_contour_1.shx b/Tests/Input/Region_4/outermost_contour.shx similarity index 100% rename from Tests/Input/Region_4/outermost_contour_1.shx rename to Tests/Input/Region_4/outermost_contour.shx diff --git a/Tests/short_tests.json b/Tests/short_tests.json index caff0c19d35650439040ddc06d2658725f03f600..7c2cab5a07523733068b8047014afbe3c6048fba 100644 --- a/Tests/short_tests.json +++ b/Tests/short_tests.json @@ -204,32 +204,32 @@ "args": "$compil_prod_dir/test_read_eddy", "required": [ - ["$input_dir/Region_4/extremum_1.dbf", "extremum_1_old.dbf"], - ["$input_dir/Region_4/extremum_1.shp", "extremum_1_old.shp"], - ["$input_dir/Region_4/extremum_1.shx", "extremum_1_old.shx"], + ["$input_dir/Region_4/extremum.dbf", "extremum_old.dbf"], + ["$input_dir/Region_4/extremum.shp", "extremum_old.shp"], + ["$input_dir/Region_4/extremum.shx", "extremum_old.shx"], [ - "$input_dir/Region_4/max_speed_contour_1.dbf", - "max_speed_contour_1_old.dbf" + "$input_dir/Region_4/max_speed_contour.dbf", + "max_speed_contour_old.dbf" ], [ - "$input_dir/Region_4/max_speed_contour_1.shp", - "max_speed_contour_1_old.shp" + "$input_dir/Region_4/max_speed_contour.shp", + "max_speed_contour_old.shp" ], [ - "$input_dir/Region_4/max_speed_contour_1.shx", - "max_speed_contour_1_old.shx" + "$input_dir/Region_4/max_speed_contour.shx", + "max_speed_contour_old.shx" ], [ - "$input_dir/Region_4/outermost_contour_1.dbf", - "outermost_contour_1_old.dbf" + "$input_dir/Region_4/outermost_contour.dbf", + "outermost_contour_old.dbf" ], [ - "$input_dir/Region_4/outermost_contour_1.shp", - "outermost_contour_1_old.shp" + "$input_dir/Region_4/outermost_contour.shp", + "outermost_contour_old.shp" ], [ - "$input_dir/Region_4/outermost_contour_1.shx", - "outermost_contour_1_old.shx" + "$input_dir/Region_4/outermost_contour.shx", + "outermost_contour_old.shx" ] ], "title": "Read_eddy" @@ -238,32 +238,32 @@ "args": "$compil_prod_dir/test_read_snapshot", "required": [ - ["$input_dir/Region_4/extremum_1.dbf", "extremum_1_old.dbf"], - ["$input_dir/Region_4/extremum_1.shp", "extremum_1_old.shp"], - ["$input_dir/Region_4/extremum_1.shx", "extremum_1_old.shx"], + ["$input_dir/Region_4/extremum.dbf", "extremum_old.dbf"], + ["$input_dir/Region_4/extremum.shp", "extremum_old.shp"], + ["$input_dir/Region_4/extremum.shx", "extremum_old.shx"], [ - "$input_dir/Region_4/max_speed_contour_1.dbf", - "max_speed_contour_1_old.dbf" + "$input_dir/Region_4/max_speed_contour.dbf", + "max_speed_contour_old.dbf" ], [ - "$input_dir/Region_4/max_speed_contour_1.shp", - "max_speed_contour_1_old.shp" + "$input_dir/Region_4/max_speed_contour.shp", + "max_speed_contour_old.shp" ], [ - "$input_dir/Region_4/max_speed_contour_1.shx", - "max_speed_contour_1_old.shx" + "$input_dir/Region_4/max_speed_contour.shx", + "max_speed_contour_old.shx" ], [ - "$input_dir/Region_4/outermost_contour_1.dbf", - "outermost_contour_1_old.dbf" + "$input_dir/Region_4/outermost_contour.dbf", + "outermost_contour_old.dbf" ], [ - "$input_dir/Region_4/outermost_contour_1.shp", - "outermost_contour_1_old.shp" + "$input_dir/Region_4/outermost_contour.shp", + "outermost_contour_old.shp" ], [ - "$input_dir/Region_4/outermost_contour_1.shx", - "outermost_contour_1_old.shx" + "$input_dir/Region_4/outermost_contour.shx", + "outermost_contour_old.shx" ] ], "title": "Read_snapshot", @@ -294,15 +294,15 @@ "required": [ [ - "$tests_old_dir/Extraction_eddies_region_1_noise/extremum_1.shp", + "$tests_old_dir/Extraction_eddies_region_1_noise/extremum.shp", "extremum.shp" ], [ - "$tests_old_dir/Extraction_eddies_region_1_noise/extremum_1.shx", + "$tests_old_dir/Extraction_eddies_region_1_noise/extremum.shx", "extremum.shx" ], [ - "$tests_old_dir/Extraction_eddies_region_1_noise/extremum_1.dbf", + "$tests_old_dir/Extraction_eddies_region_1_noise/extremum.dbf", "extremum.dbf" ], [ @@ -317,9 +317,9 @@ "description": "Same as Successive_overlap, but with larger domain: region 5 instead of region 4.", "required": [ - "$tests_old_dir/Extraction_eddies_region_5/extremum_1.*", - "$tests_old_dir/Extraction_eddies_region_5/max_speed_contour_1.*", - "$tests_old_dir/Extraction_eddies_region_5/outermost_contour_1.*" + "$tests_old_dir/Extraction_eddies_region_5/extremum.*", + "$tests_old_dir/Extraction_eddies_region_5/max_speed_contour.*", + "$tests_old_dir/Extraction_eddies_region_5/outermost_contour.*" ], "stdin_filename": "$input_dir/successive_overlap_region_5_nml.txt" }, diff --git a/Tests/test_read_eddy.f b/Tests/test_read_eddy.f index 6ec119aa983678be7e69e30629d023ed6aec529d..343378f5ccd2bbdd50a6461a1d172d89cde668d6 100644 --- a/Tests/test_read_eddy.f +++ b/Tests/test_read_eddy.f @@ -14,16 +14,16 @@ program test_read_eddy type(eddy) e integer k, i - TYPE(shpfileobject) hshp_extremum ! shapefile extremum_1 - TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour_1 - TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour_1 + TYPE(shpfileobject) hshp_extremum ! shapefile extremum + TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour + TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour !------------------------------------------------------------------------- - call shp_open_03("extremum_1_old", pszaccess = "rb", hshp = hshp_extremum) - call shp_open_03("outermost_contour_1_old", pszaccess = "rb", & + call shp_open_03("extremum_old", pszaccess = "rb", hshp = hshp_extremum) + call shp_open_03("outermost_contour_old", pszaccess = "rb", & hshp = hshp_outermost) - call shp_open_03("max_speed_contour_1_old", pszaccess = "rb", & + call shp_open_03("max_speed_contour_old", pszaccess = "rb", & hshp = hshp_max_speed) call read_field_indices(hshp_extremum, hshp_outermost, hshp_max_speed) call read_eddy(e, k, i, hshp_extremum, hshp_outermost, hshp_max_speed, & @@ -35,10 +35,10 @@ program test_read_eddy call init_shapefiles(hshp_extremum, hshp_outermost, hshp_max_speed) call write_eddy(e, k, i, hshp_extremum, hshp_outermost, hshp_max_speed) CALL shpclose(hshp_extremum) - print *, 'Created shapefile "extremum_1".' + print *, 'Created shapefile "extremum".' CALL shpclose(hshp_outermost) - print *, 'Created shapefile "outermost_contour_1".' + print *, 'Created shapefile "outermost_contour".' CALL shpclose(hshp_max_speed) - print *, 'Created shapefile "max_speed_contour_1".' + print *, 'Created shapefile "max_speed_contour".' end program test_read_eddy diff --git a/Tests/test_read_snapshot.f b/Tests/test_read_snapshot.f index 857753c6db0f5fde97cdcb7cef2d10a53368ea3d..2c6232b87e7d971b2efd9d8ee70d05a3564bc09c 100644 --- a/Tests/test_read_snapshot.f +++ b/Tests/test_read_snapshot.f @@ -15,9 +15,9 @@ program test_read_snapshot implicit none type(snapshot) s - TYPE(shpfileobject) hshp_extremum ! shapefile extremum_1 - TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour_1 - TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour_1 + TYPE(shpfileobject) hshp_extremum ! shapefile extremum + TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour + TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour integer i real:: corner(2) = [0.125, - 59.875] @@ -33,10 +33,10 @@ program test_read_snapshot read(unit = *, nml = main_nml) write(unit = *, nml = main_nml) - call shp_open_03("extremum_1_old", pszaccess = "rb", hshp = hshp_extremum) - call shp_open_03("outermost_contour_1_old", pszaccess = "rb", & + call shp_open_03("extremum_old", pszaccess = "rb", hshp = hshp_extremum) + call shp_open_03("outermost_contour_old", pszaccess = "rb", & hshp = hshp_outermost) - call shp_open_03("max_speed_contour_1_old", pszaccess = "rb", & + call shp_open_03("max_speed_contour_old", pszaccess = "rb", & hshp = hshp_max_speed) call read_snapshot(s, hshp_extremum, hshp_outermost, hshp_max_speed, & corner * deg_to_rad, nlon, nlat) @@ -54,11 +54,11 @@ program test_read_snapshot print *, "Number of extrema:", s%number_vis_extr CALL shpclose(hshp_extremum) - print *, 'Created shapefile "extremum_1".' + print *, 'Created shapefile "extremum".' CALL shpclose(hshp_outermost) - print *, 'Created shapefile "outermost_contour_1".' + print *, 'Created shapefile "outermost_contour".' CALL shpclose(hshp_max_speed) - print *, 'Created shapefile "max_speed_contour_1".' + print *, 'Created shapefile "max_speed_contour".' print *, "s%ind_extr:" diff --git a/Tests/test_successive_overlap.f b/Tests/test_successive_overlap.f index add638bf04abe8b85b2f579ba0e5e6ffebda7124..0fefd7967ee6ba38549d0d95edc374caf9345093 100644 --- a/Tests/test_successive_overlap.f +++ b/Tests/test_successive_overlap.f @@ -16,9 +16,9 @@ program test_successive_overlap integer unit_edgelist, i type(snapshot) flow(2) - TYPE(shpfileobject) hshp_extremum ! shapefile extremum_1 - TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour_1 - TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour_1 + TYPE(shpfileobject) hshp_extremum ! shapefile extremum + TYPE(shpfileobject) hshp_outermost ! shapefile outermost_contour + TYPE(shpfileobject) hshp_max_speed ! shapefile max_speed_contour real:: corner(2) = [huge(0.), huge(0.)] ! longitude and latitude of the corner of the whole grid, in degrees @@ -33,10 +33,10 @@ program test_successive_overlap read(unit = *, nml = main_nml) write(unit = *, nml = main_nml) - call shp_open_03("extremum_1", pszaccess = "rb", hshp = hshp_extremum) - call shp_open_03("outermost_contour_1", pszaccess = "rb", & + call shp_open_03("extremum", pszaccess = "rb", hshp = hshp_extremum) + call shp_open_03("outermost_contour", pszaccess = "rb", & hshp = hshp_outermost) - call shp_open_03("max_speed_contour_1", pszaccess = "rb", & + call shp_open_03("max_speed_contour", pszaccess = "rb", & hshp = hshp_max_speed) call read_snapshot(flow(1), hshp_extremum, hshp_outermost, hshp_max_speed, & corner * deg_to_rad, nlon, nlat) diff --git a/extraction_eddies.f b/extraction_eddies.f index 28f5be4955b904cf30dba4412cd110ef60e03bf7..70e650c83b273b00fcec20a0cb71c710288dba44 100644 --- a/extraction_eddies.f +++ b/extraction_eddies.f @@ -91,8 +91,6 @@ program extraction_eddies call nf95_get_var(ncid, varid, lat_min) call nf95_get_var(ncid, varid, lat_max, start = [nlat]) - call nf95_close(ncid) - call assert(lon_max > lon_min .and. lat_max > lat_min, & "extraction_eddies coordinate order") step = [(lon_max - lon_min) / (nlon - 1), (lat_max - lat_min) / (nlat - 1)] & @@ -112,7 +110,6 @@ program extraction_eddies ! Read ssh, u and v at date k: - call nf95_open("h.nc", nf90_nowrite, ncid) call get_var(periodic, max_radius(1), ssh, ncid, nlon, k, name = "adt", & new_fill_value = huge(0.)) ! (We cannot keep the original fill value because Contour_531 diff --git a/init_shapefiles.f b/init_shapefiles.f index 30a0ef63daa022f66802d5d114fbc06eecfbec16..4aae6472d1966ee8ae9708e25bbd06c46c8b915f 100644 --- a/init_shapefiles.f +++ b/init_shapefiles.f @@ -28,7 +28,7 @@ contains !--------------------------------------------------------------------- - call shp_create_03("extremum_1", shpt_point, hshp_extremum) + call shp_create_03("extremum", shpt_point, hshp_extremum) call dbf_add_field_03(ifield_extr_ssh, hshp_extremum, 'ssh', ftdouble, & nwidth = 13, ndecimals = 6) call dbf_add_field_03(ifield_extr_date, hshp_extremum, 'date_index', & @@ -44,7 +44,7 @@ contains call dbf_add_field_03(ifield_extr_speed, hshp_extremum, 'speed', ftdouble, & nwidth = 13, ndecimals = 6) - call shp_create_03("outermost_contour_1", shpt_polygon, hshp_outermost) + call shp_create_03("outermost_contour", shpt_polygon, hshp_outermost) call dbf_add_field_03(ifield_out_r_eq_area, hshp_outermost, & 'r_eq_area', ftdouble, nwidth = 10, ndecimals = 4) call dbf_add_field_03(ifield_out_ssh, hshp_outermost, 'ssh', ftdouble, & @@ -56,7 +56,7 @@ contains call dbf_add_field_03(ifield_out_radius4, hshp_outermost, 'radius4', & ftinteger, nwidth = 2, ndecimals = 0) - call shp_create_03("max_speed_contour_1", shpt_polygon, hshp_max_speed) + call shp_create_03("max_speed_contour", shpt_polygon, hshp_max_speed) call dbf_add_field_03(ifield_max_speed_r_eq_area, hshp_max_speed, & 'r_eq_area', ftdouble, nwidth = 10, ndecimals = 4) call dbf_add_field_03(ifield_max_speed_ssh, hshp_max_speed, 'ssh', & diff --git a/set_all_outerm.f b/set_all_outerm.f index bd26e8e408247ab00f8824953260df0787214ac3..01a8d14e2c51c839e5fac95022c776b19f94cc9b 100644 --- a/set_all_outerm.f +++ b/set_all_outerm.f @@ -141,6 +141,7 @@ contains if (abs(s%list_vis(i)%ssh_extr - innermost_level(i)) < min_amp) & innermost_level(i) = s%list_vis(i)%ssh_extr & + merge(min_amp, - min_amp, s%list_vis(i)%cyclone) + outside_points = nearby_extr(s%extr_map(llc(1):urc(1), llc(2):urc(2)), & s%list_vis, i) if (periodic) outside_points(1, :) = outside_points(1, :) &