fimeval 0.1.48__tar.gz → 0.1.50__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fimeval-0.1.48 → fimeval-0.1.50}/PKG-INFO +1 -1
- {fimeval-0.1.48 → fimeval-0.1.50}/pyproject.toml +1 -1
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/evaluationFIM.py +34 -0
- fimeval-0.1.50/src/fimeval/ContingencyMap/fix_permissions.sh +20 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/LICENSE.txt +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/README.md +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/BuildingFootprint/__init__.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/BuildingFootprint/evaluationwithBF.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/PWBs3.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/__init__.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/methods.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/metrics.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/plotevaluationmetrics.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/ContingencyMap/printcontingency.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/__init__.py +0 -0
- {fimeval-0.1.48 → fimeval-0.1.50}/src/fimeval/utilis.py +0 -0
|
@@ -4,6 +4,8 @@ from pathlib import Path
|
|
|
4
4
|
import geopandas as gpd
|
|
5
5
|
import rasterio
|
|
6
6
|
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import platform
|
|
7
9
|
import pandas as pd
|
|
8
10
|
from rasterio.warp import reproject, Resampling
|
|
9
11
|
from rasterio.io import MemoryFile
|
|
@@ -19,6 +21,30 @@ from .metrics import evaluationmetrics
|
|
|
19
21
|
from .PWBs3 import get_PWB
|
|
20
22
|
from ..utilis import MakeFIMsUniform
|
|
21
23
|
|
|
24
|
+
#giving the permission to the folder
|
|
25
|
+
def is_writable(path):
|
|
26
|
+
"""Check if the directory and its contents are writable."""
|
|
27
|
+
path = Path(path)
|
|
28
|
+
return os.access(path, os.W_OK)
|
|
29
|
+
|
|
30
|
+
def fix_permissions(path):
|
|
31
|
+
path = Path(path).resolve()
|
|
32
|
+
script_path = Path(__file__).parent / "fix_permissions.sh"
|
|
33
|
+
|
|
34
|
+
if not script_path.exists():
|
|
35
|
+
raise FileNotFoundError(f"Shell script not found: {script_path}")
|
|
36
|
+
|
|
37
|
+
if is_writable(path):
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
result = subprocess.run(["bash", str(script_path), str(path)],
|
|
42
|
+
check=True, capture_output=True, text=True)
|
|
43
|
+
print(result.stdout)
|
|
44
|
+
except subprocess.CalledProcessError as e:
|
|
45
|
+
print(f"Shell script failed:\n{e.stderr}")
|
|
46
|
+
|
|
47
|
+
|
|
22
48
|
# Function for the evalution of the model
|
|
23
49
|
def evaluateFIM(
|
|
24
50
|
benchmark_path, candidate_paths, gdf, folder, method, output_dir, shapefile=None
|
|
@@ -49,6 +75,9 @@ def evaluateFIM(
|
|
|
49
75
|
# Save the smallest extent boundary and cliped FIMS
|
|
50
76
|
save_dir = os.path.join(output_dir, os.path.basename(folder), f"{method.__name__}")
|
|
51
77
|
os.makedirs(save_dir, exist_ok=True)
|
|
78
|
+
|
|
79
|
+
#Give the permission to the output directory
|
|
80
|
+
fix_permissions(save_dir)
|
|
52
81
|
|
|
53
82
|
# Get the smallest matched raster extent and make a boundary shapefile
|
|
54
83
|
smallest_raster_path = get_smallest_raster_path(benchmark_path, *candidate_paths)
|
|
@@ -351,7 +380,12 @@ def EvaluateFIM(main_dir, method_name, output_dir, PWB_dir=None, shapefile_dir=N
|
|
|
351
380
|
gdf = get_PWB()
|
|
352
381
|
else:
|
|
353
382
|
gdf = gpd.read_file(PWB_dir)
|
|
383
|
+
|
|
384
|
+
#Grant the permission to the main directory
|
|
385
|
+
print(f"Fixing permissions for {main_dir}...")
|
|
386
|
+
fix_permissions(main_dir)
|
|
354
387
|
|
|
388
|
+
#runt the process
|
|
355
389
|
def process_TIFF(tif_files, folder_dir):
|
|
356
390
|
benchmark_path = None
|
|
357
391
|
candidate_path = []
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
DIR="$1"
|
|
4
|
+
|
|
5
|
+
if [ -z "$DIR" ]; then
|
|
6
|
+
echo "No directory provided."
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
UNAME=$(uname)
|
|
11
|
+
if [[ "$UNAME" == "Darwin" || "$UNAME" == "Linux" ]]; then
|
|
12
|
+
chmod -R u+rwX "$DIR"
|
|
13
|
+
|
|
14
|
+
elif [[ "$UNAME" == *"MINGW"* || "$UNAME" == *"MSYS"* || "$UNAME" == *"CYGWIN"* ]]; then
|
|
15
|
+
icacls "$DIR" /grant Everyone:F /T > /dev/null
|
|
16
|
+
|
|
17
|
+
else
|
|
18
|
+
echo "Unsupported OS: $UNAME"
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|