Skip to content

Commit

Permalink
Pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
isatotun committed Nov 12, 2024
1 parent a0d6461 commit 1416abd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 4 additions & 2 deletions run_raster_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def process_chunk(start, end, dataset, mode, df_iso3s, engine_url, chunksize):
max_adm = row["max_adm_level"]

# Coverage check for specific datasets
if dataset in df_iso3s.keys() :
if dataset in df_iso3s.keys():
if not row[dataset]:
logger.info(f"Skipping {iso3}...")
continue
Expand Down Expand Up @@ -160,6 +160,8 @@ def process_chunk(start, end, dataset, mode, df_iso3s, engine_url, chunksize):

else:
logger.info("Processing entire date range in a single chunk")
process_chunk(start, end, dataset, args.mode, df_iso3s, engine_url, args.chunksize)
process_chunk(
start, end, dataset, args.mode, df_iso3s, engine_url, args.chunksize
)

logger.info("Done calculating and saving stats.")
8 changes: 4 additions & 4 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import yaml
from dotenv import load_dotenv
from sqlalchemy import Integer, VARCHAR
from sqlalchemy import VARCHAR, Integer

from src.utils.general_utils import get_most_recent_date

Expand All @@ -26,13 +26,13 @@ def load_pipeline_config(pipeline_name):
config = yaml.safe_load(config_file)
return config

# TODO shift this to some utils?
def parse_extra_dims(extra_dims):

# TODO shift this to some utils?
def parse_extra_dims(extra_dims):
parsed_extra_dims = {}
for extra_dim in extra_dims:
dim = next(iter(extra_dim))
if extra_dim[dim] == 'str':
if extra_dim[dim] == "str":
parsed_extra_dims[dim] = VARCHAR
else:
parsed_extra_dims[dim] = Integer
Expand Down
2 changes: 1 addition & 1 deletion src/utils/iso3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def create_iso3_df(engine):
]

# TODO add info on how to retrieve this file
floodscan_iso3_coverage = pd.read_csv("data/floodscan_iso3s.csv")['iso3'].tolist()
floodscan_iso3_coverage = pd.read_csv("data/floodscan_iso3s.csv")["iso3"].tolist()

iso3_codes = set()
for locations in df_active_hrp["locations"]:
Expand Down
9 changes: 4 additions & 5 deletions src/utils/raster_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,10 @@ def upsample_raster(ds, resampled_resolution=UPSAMPLED_RESOLUTION, logger=None):
# Expand along the fourth dimension
if fourth_dim == "band":
# Falls under different bands, use the long_name instead of integer value
#ds_ = ds_.expand_dims({'band': [ds_.long_name[val-1]]})
if int(ds_['band']) ==1 :
ds_ = ds_.expand_dims({'band': ['SFED']})
if int(ds_["band"]) == 1:
ds_ = ds_.expand_dims({"band": ["SFED"]})
else:
ds_ = ds_.expand_dims({'band': ['MFED']})
ds_ = ds_.expand_dims({"band": ["MFED"]})
else:
ds_ = ds_.expand_dims([fourth_dim])
resampled_arrays.append(ds_)
Expand Down Expand Up @@ -377,4 +376,4 @@ def rasterize_admin(
fill=rast_fill,
all_touched=all_touched,
)
return admin_raster
return admin_raster

0 comments on commit 1416abd

Please sign in to comment.