diff --git a/Inst_eddies/Tests/long_tests.json b/Inst_eddies/Tests/long_tests.json index 2fd259b50d52c998e54a8b58f5b8112b5ffffac4..481ef6cbb222c1565b461576b3c183fe2e5346cc 100644 --- a/Inst_eddies/Tests/long_tests.json +++ b/Inst_eddies/Tests/long_tests.json @@ -2,7 +2,7 @@ { "commands": [ - ["mkdir", "SHP_triplet"], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], [ "$build_dir/Inst_eddies/test_set_all_outerm", "$src_dir/Inst_eddies/Tests/Input/h_region_3.nc" @@ -13,7 +13,10 @@ }, { "commands": - [["mkdir", "SHP_triplet"], "$build_dir/Inst_eddies/inst_eddies"], + [ + ["mkdir", "SHPC_cyclo", "SHPC_anti"], + "$build_dir/Inst_eddies/inst_eddies" + ], "title": "Extraction_eddies_region_3", "required": [ @@ -25,7 +28,10 @@ }, { "commands": - [["mkdir", "SHP_triplet"], "$build_dir/Inst_eddies/inst_eddies"], + [ + ["mkdir", "SHPC_cyclo", "SHPC_anti"], + "$build_dir/Inst_eddies/inst_eddies" + ], "title": "Extraction_eddies_region_3_min", "required": [ @@ -38,7 +44,10 @@ }, { "commands": - [["mkdir", "SHP_triplet"], "$build_dir/Inst_eddies/inst_eddies"], + [ + ["mkdir", "SHPC_cyclo", "SHPC_anti"], + "$build_dir/Inst_eddies/inst_eddies" + ], "title": "Extraction_eddies_region_5", "required": [ diff --git a/Inst_eddies/Tests/short_tests.json b/Inst_eddies/Tests/short_tests.json index a089aebca34de4a3fd082c4e469aa31d5e3eaa05..2d5e8a9a44ccdd7efb4ec75b5979562c2d4288c0 100644 --- a/Inst_eddies/Tests/short_tests.json +++ b/Inst_eddies/Tests/short_tests.json @@ -237,10 +237,7 @@ ], "title": "Extraction_eddies_region_1", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, @@ -254,10 +251,7 @@ ], "title": "Extraction_eddies_region_1_noise", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, @@ -269,10 +263,7 @@ ], "title": "Extraction_eddies_region_2", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, @@ -284,10 +275,7 @@ ], "title": "Extraction_eddies_region_2_noise", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, @@ -300,10 +288,7 @@ ], "title": "Extraction_eddies_region_4", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, @@ -322,7 +307,7 @@ "title": "Set_all_outerm_periodic", "commands": [ - ["mkdir", "SHP_triplet"], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], [ "$build_dir/Inst_eddies/test_set_all_outerm", "$src_dir/Inst_eddies/Tests/Input/h_2006_01_01_coarse.nc" @@ -344,10 +329,7 @@ ], "title": "Extraction_eddies_periodic", "commands": [ - [ - "mkdir", - "SHP_triplet" - ], + ["mkdir", "SHPC_cyclo", "SHPC_anti"], "$build_dir/Inst_eddies/inst_eddies" ] }, diff --git a/Inst_eddies/Tests/test_set_all_outerm.f90 b/Inst_eddies/Tests/test_set_all_outerm.f90 index d5d1a612fbfc4a53585b007451483c69faf44e8d..8876289aadcafd462b075d7b3397090366190a61 100644 --- a/Inst_eddies/Tests/test_set_all_outerm.f90 +++ b/Inst_eddies/Tests/test_set_all_outerm.f90 @@ -28,14 +28,14 @@ program test_set_all_outerm ! maximum radius of an eddy in longitude and latitude, in number of ! grid points - integer ncid, varid, dimid, i + integer ncid, varid, dimid, i, n_cyclo, n_anti real, allocatable:: ssh(:, :) ! (1 - max_radius(1):nlon + max_radius(1), nlat) if the grid is periodic ! in longitude, else (nlon, nlat). Sea-surface height, in m. real step_deg(2), step(2) ! longitude and latitude steps, in degrees and rad logical periodic ! grid is periodic in longitude - TYPE(shp_tr) hshp + TYPE(shp_tr) hshp_cyclo, hshp_anti !-------------------------------------------------------------- @@ -88,16 +88,26 @@ program test_set_all_outerm s%list_vis(i)%radius4 = 0 end do - call shp_tr_create(hshp, shp_tr_dir = "SHP_triplet") + call shp_tr_create(hshp_cyclo, shp_tr_dir = "SHPC_cyclo") + call shp_tr_create(hshp_anti, shp_tr_dir = "SHPC_anti") + n_cyclo = 0 + n_anti = 0 do i = 1, s%number_vis_extr - call write_eddy(s%list_vis(i), hshp, k = 1, i = i) + if (s%list_vis(i)%cyclone) then + n_cyclo = n_cyclo + 1 + call write_eddy(s%list_vis(i), hshp_cyclo, k = 1, i = n_cyclo) + else + n_anti = n_anti + 1 + call write_eddy(s%list_vis(i), hshp_anti, k = 1, i = n_anti) + end if end do print *, "s%number_vis_extr = ", s%number_vis_extr - CALL shp_tr_close(hshp) - print *, 'Created shapefiles in SHP_triplet.' + CALL shp_tr_close(hshp_cyclo) + CALL shp_tr_close(hshp_anti) + print *, 'Created shapefile collections in SHPC_cyclo and SHPC_anti.' print *, "Average number of points per outermost contour: ", & sum(s%list_vis%out_cont%n_points) / real(s%number_vis_extr) diff --git a/Inst_eddies/config.f90 b/Inst_eddies/config.f90 index 887ef13e9ee3c30d4322725bcc2c71910b32d96a..7a2e63b3312fd1acecebee29145ac0c145106fe3 100644 --- a/Inst_eddies/config.f90 +++ b/Inst_eddies/config.f90 @@ -26,7 +26,8 @@ contains write(unit = error_unit, nml = main_nml) write(unit = error_unit, fmt = *) "Enter namelist main_nml." read(unit = *, nml = main_nml) - call write_nml(shp_tr_dir = "SHP_triplet") + call write_nml(shp_tr_dir = "SHPC_cyclo") + call write_nml(shp_tr_dir = "SHPC_anti") end subroutine config diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index 7e8e195ffe3ad2369ea9784e525e91866d1019f8..c4416e49d2f27d0a9648c19230d2d825bf9682d4 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -24,8 +24,8 @@ program inst_eddies implicit none type(snapshot) s - TYPE(shp_tr) hshp - integer i, k + TYPE(shp_tr) hshp_cyclo, hshp_anti + integer i, k, n_cyclo, n_anti integer ncid, dimid, varid, copy @@ -175,16 +175,29 @@ program inst_eddies end if end do - call shp_tr_create(hshp, shp_tr_dir = "SHP_triplet") - ! Write snapshot: + + call shp_tr_create(hshp_cyclo, shp_tr_dir = "SHPC_cyclo") + call shp_tr_create(hshp_anti, shp_tr_dir = "SHPC_anti") + n_cyclo = 0 + n_anti = 0 + do i = 1, s%number_vis_extr - call write_eddy(s%list_vis(i), hshp, k, i) + if (s%list_vis(i)%cyclone) then + n_cyclo = n_cyclo + 1 + call write_eddy(s%list_vis(i), hshp_cyclo, k, n_cyclo) + else + n_anti = n_anti + 1 + call write_eddy(s%list_vis(i), hshp_anti, k, n_anti) + end if end do - CALL shp_tr_close(hshp) - print *, 'Created shapefiles in SHP_triplet.' - call write_aux(corner_deg, step_deg, nlon, nlat, s%number_vis_extr, & - shp_tr_dir = "SHP_triplet") + CALL shp_tr_close(hshp_cyclo) + CALL shp_tr_close(hshp_anti) + print *, 'Created shapefile collections in SHPC_cyclo and SHPC_anti.' + call write_aux(corner_deg, step_deg, nlon, nlat, n_cyclo, & + shp_tr_dir = "SHPC_cyclo") + call write_aux(corner_deg, step_deg, nlon, nlat, n_anti, & + shp_tr_dir = "SHPC_anti") end program inst_eddies diff --git a/Inst_eddies/inst_eddies_in.py b/Inst_eddies/inst_eddies_in.py index c7c77a2ae6c97146e604dba03d5f17c642bb1c6c..262a256a3a9b00bcbcae6e57b9318d6bece2cdc9 100755 --- a/Inst_eddies/inst_eddies_in.py +++ b/Inst_eddies/inst_eddies_in.py @@ -30,7 +30,10 @@ inst_eddies_exe = "@CMAKE_CURRENT_BINARY_DIR@/inst_eddies" if not os.access(inst_eddies_exe, os.X_OK): sys.exit(inst_eddies_exe + " not found or not executable") -if os.access("SHPC_all_dates", os.F_OK): shutil.rmtree("SHPC_all_dates") +for orient in ["cyclo", "anti"]: + if os.access(f"SHPC_{orient}_all_dates", os.F_OK): + shutil.rmtree("SHPC_all_dates") + dirname, basename = path.split(args.first_file) my_date = datetime.datetime.strptime(basename, args.date_format).date() nc_file = args.first_file @@ -57,7 +60,8 @@ while True: nc_file = "unpacked.nc" os.symlink(nc_file, "h.nc") os.symlink(nc_file, "uv.nc") - os.mkdir("SHP_triplet") + os.mkdir("SHPC_cyclo") + os.mkdir("SHPC_anti") with open("main_nml.txt") as nml_file: subprocess.run(inst_eddies_exe, stdin = nml_file, check = True) @@ -67,26 +71,28 @@ while True: else: print("Missing file:", nc_file) - if os.access("SHPC_all_dates", os.F_OK): - if os.access("SHP_triplet", os.F_OK): - for filename in ["extremum", "max_speed_contour", - "outermost_contour"]: - from_file = path.join("SHP_triplet", filename) - to_file = path.join("SHPC_all_dates", filename) + for orient in ["cyclo", "anti"]: + if os.access(f"SHPC_{orient}_all_dates", os.F_OK): + if os.access(f"SHPC_{orient}", os.F_OK): + for filename in ["extremum", "max_speed_contour", + "outermost_contour"]: + from_file = path.join(f"SHPC_{orient}", filename) + to_file = path.join(f"SHPC_{orient}_all_dates", filename) - for command in ["dbfcat", "shpcat"]: - subprocess.run([command, from_file, to_file], check = True) - - shutil.rmtree("SHP_triplet") - - with open("SHPC_all_dates/ishape_last.txt", "a") as \ - ishape_last, shapefile.Reader("SHPC_all_dates/extremum") \ - as shpr: - n_shapes = len(shpr) - ishape_last.write(str(n_shapes - 1) + "\n") - else: - if os.access("SHP_triplet", os.F_OK): - os.rename("SHP_triplet", "SHPC_all_dates") + for command in ["dbfcat", "shpcat"]: + subprocess.run([command, from_file, to_file], + check = True) + + shutil.rmtree(f"SHPC_{orient}") + + with open(f"SHPC_{orient}_all_dates/ishape_last.txt", "a") as \ + ishape_last, \ + shapefile.Reader(f"SHPC_{orient}_all_dates/extremum") as shpr: + n_shapes = len(shpr) + ishape_last.write(str(n_shapes - 1) + "\n") + else: + if os.access(f"SHPC_{orient}", os.F_OK): + os.rename(f"SHPC_{orient}", f"SHPC_{orient}_all_dates") my_date += datetime.timedelta(1) if my_date > last_date: break diff --git a/Overlap/Tests/short_tests.json b/Overlap/Tests/short_tests.json index c2ce5cf7a8bac6277821de62e4dc792cb6f7c315..91a380e5328db7c137737e978f5cf758afcc2245 100644 --- a/Overlap/Tests/short_tests.json +++ b/Overlap/Tests/short_tests.json @@ -111,7 +111,7 @@ "-n", "1", "$build_dir/Overlap/test_overlap", - "$tests_old_dir/Extraction_eddies_periodic/SHP_triplet" + "$tests_old_dir/Extraction_eddies_periodic/SHPC_cyclo" ] ] },