Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ ci:
autoupdate_schedule: 'quarterly'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 8.0.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.20.0
hooks:
- id: mypy
args: [--no-strict-optional]
Expand Down
24 changes: 8 additions & 16 deletions src/area_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ def load_ne(country_code: str, regions_of_interest: List[str]) -> gpd.GeoDataFra
if len(regions_not_found) > 0:
condition = ne_gdf["adm1_code"].str.startswith(country_code)
boundary = None
print(
f"WARNING: {regions_not_found} was not found. Please select \
regions only seen in below plot."
)
print(f"WARNING: {regions_not_found} was not found. Please select \
regions only seen in below plot.")
ne_gdf[condition].plot(
column="name",
legend=True,
Expand Down Expand Up @@ -170,12 +168,10 @@ def load_raster(

with rio.open(in_raster) as src:
if src.meta["crs"] == "EPSG:4326":
print(
"""WARNING: The map CRS is EPSG:4326. This means the map unit is degrees \
print("""WARNING: The map CRS is EPSG:4326. This means the map unit is degrees \
and the pixel-wise areas will not be in meters.
\n You need to project the map to the local UTM Zone \
(EPSG:XXXXX)."""
)
(EPSG:XXXXX).""")

t_srs = input("Input EPSG Code; EPSG:XXXX:")
options = gdal.WarpOptions(dstSRS=f"EPSG:{t_srs}", dstNodata=255)
Expand Down Expand Up @@ -216,20 +212,16 @@ def cal_map_area_class(
if unit == "ha":
crop_area = crop_px[0].shape[0] * (px_size * px_size) / 10000
noncrop_area = noncrop_px[0].shape[0] * (px_size * px_size) / 10000
print(
f"[Pixel counting] Crop area: {crop_area:.2f} ha, \
print(f"[Pixel counting] Crop area: {crop_area:.2f} ha, \
Non-crop area: {noncrop_area:.2f} ha \n \
Total area: {crop_area + noncrop_area:.2f} ha"
)
Total area: {crop_area + noncrop_area:.2f} ha")

elif unit == "pixels":
crop_area = int(crop_px[0].shape[0])
noncrop_area = int(noncrop_px[0].shape[0])
print(
f"Crop pixels count: {crop_area}, \
print(f"Crop pixels count: {crop_area}, \
Non-crop pixels count: {noncrop_area} pixels \n \
Total counts: {crop_area + noncrop_area} pixels"
)
Total counts: {crop_area + noncrop_area} pixels")

elif unit == "fraction":
crop_area = int(crop_px[0].shape[0]) / total
Expand Down
6 changes: 2 additions & 4 deletions src/inference_profiling/concurrent_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def inference_service(img_file):
results = pool.map(inference_service, img_list)
end_time = time.time()

print(
f"""For {len(img_list)} parallel requests,the program finished in {end_time - start_time}
seconds"""
)
print(f"""For {len(img_list)} parallel requests,the program finished in {end_time - start_time}
seconds""")
print(list(results))
Loading