diff --git a/ush/generate_fire_emissions.py b/ush/generate_fire_emissions.py index c675ece96..c9101b12a 100755 --- a/ush/generate_fire_emissions.py +++ b/ush/generate_fire_emissions.py @@ -19,7 +19,7 @@ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Workflow #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def generate_emiss_workflow(staticdir, ravedir, intp_dir, predef_grid, ebb_dcycle, restart_interval, persistence): +def generate_emiss_workflow(staticdir, ravedir, intp_dir, predef_grid, ebb_dcycle, restart_interval, persistence_flag): # staticdir: path to FIX files # ravedir: path to RAVE fire data files (hourly), typically workding directory (DATA) @@ -40,7 +40,8 @@ def generate_emiss_workflow(staticdir, ravedir, intp_dir, predef_grid, ebb_dcycl vars_emis = ["FRP_MEAN","FRE"] cols, rows = (2700, 3950) if predef_grid == 'RRFS_NA_3km' else (1092, 1820) print('PREDEF GRID',predef_grid,'cols,rows',cols,rows) - print('WARNING, EBB_DCYCLE set to', ebb_dcycle, 'and persistence=', persistence, 'if persistence is false, emissions comes from same day satellite obs') + persistence = convert_string_flag_to_boolean(persistence_flag) + print('WARNING, EBB_DCYCLE set to', ebb_dcycle, 'and persistence=', persistence, 'if persistence is False, emissions comes from same day satellite obs') #used later when working with ebb_dcyle 1 or 2 ebb_dcycle = float(ebb_dcycle) @@ -102,6 +103,17 @@ def generate_emiss_workflow(staticdir, ravedir, intp_dir, predef_grid, ebb_dcycl print('First day true, no RAVE files available. Use dummy emissions file') i_tools.create_dummy(intp_dir, current_day, tgt_latt, tgt_lont, cols, rows) + +def convert_string_flag_to_boolean(flag: str) -> bool: + lowered = flag.lower() + if lowered == 'true': + return True + elif lowered == 'false': + return False + else: + raise ValueError('Boolean flag not recognized. Acceptable values are true, TRUE, false, or FALSE') + + if __name__ == '__main__': print('') diff --git a/ush/interp_tools.py b/ush/interp_tools.py index f685d6512..f1fd4740b 100755 --- a/ush/interp_tools.py +++ b/ush/interp_tools.py @@ -25,7 +25,7 @@ def date_range(current_day, ebb_dcycle, persistence): if ebb_dcycle == 1: print('Find RAVE for ebb_dcyc 1') - if persistence == True: + if persistence: # Start date range from one day prior if persistence is True print('Creating emissions for persistence method where satellite FRP persist from previous day') start_datetime = fcst_datetime - dt.timedelta(days=1)