Skip to content

Commit

Permalink
fix bug, add env
Browse files Browse the repository at this point in the history
  • Loading branch information
matamadio committed Sep 19, 2023
1 parent 276a57b commit e579718
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Top-down/parallelization/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Environment variables for the CCDR Hazard analysis notebooks

# Specify working directory, location of data files
# Use absolute paths, and keep the trailing slash
DATA_DIR = C:/Work/data

# Location to store downloaded rasters and other data
# for the analysis notebooks
CACHE_DIR = ${DATA_DIR}/cache
OUTPUT_DIR = ${DATA_DIR}/output
9 changes: 9 additions & 0 deletions Top-down/parallelization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,12 @@ Example of `main.py` running flood analysis (`haz_cat`) over Cambodia (`country`
class_edges = [0.05, 0.25, 0.50, 1.00, 2.00]
save_check_raster = False
```

## Running the analysis

```bash
$ python main.py
```

The analysis runs on all selected exposed categories, in sequence. Depending on the number of cores, the size and resolution of the data, and power of CPU, the analysis can take from less than a minute to few minutes.
E.g. for Bangladesh on a i9-12900KF (16 cores), 64 Gb RAM: below 100 seconds.
2 changes: 1 addition & 1 deletion Top-down/parallelization/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main():
haz_cat = 'FL' #'FL' for floods; 'HS' for heat stress; 'DR' for drought; 'LS' for landslide
return_periods = [5, 10, 20, 50, 75, 100, 200, 250, 500, 1000] # FL [5, 10, 20, 50, 75, 100, 200, 250, 500, 1000] # TC [10, 20, 50, 100, 200, 500] # add here as will
min_haz_slider = 0.05 # FL 0.05 # TC 25.0 # ASI 0.01
exp_cat_list = ['pop', 'BU', 'AGR'] # ['pop', 'builtup', 'agri']
exp_cat_list = ['POP', 'BU', 'AGR'] # ['POP', 'BU', 'AGR']
exp_nam_list = ['POP', 'BU', 'AGR'] # if None, the default applies: 'Population':'POP', 'Built-up':'BU', 'Agricultural land':'AGR' - If not None, expect a list of same length of exp_cat_list
adm = 'ADM3' #['ADM1', 'ADM2', 'ADM3']
analysis_app = 'Function' #['Classes', 'Function']
Expand Down
3 changes: 0 additions & 3 deletions Top-down/parallelization/runAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ def run_analysis(country: str, haz_cat: str, valid_RPs: list[int],
bin_seq = class_edges + [np.inf]
num_bins = len(bin_seq)

# Testing data file locations
# TODO: Temp data store, to be replaced with a config spec (.env file?) before deployment

# Checking which kind of exposed category is being considered...
# If the exposed category is population...
if exp_cat == 'POP':
Expand Down

0 comments on commit e579718

Please sign in to comment.