Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main_aqm] fix: persistence flag always evaluates to false #1148

Draft
wants to merge 7 commits into
base: main_aqm
Choose a base branch
from
Draft
25 changes: 19 additions & 6 deletions ush/smoke_dust_generate_fire_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generate_emiss_workflow(
predef_grid: str,
ebb_dcycle_flag: str,
restart_interval: str,
persistence: str,
persistence_flag: str,
) -> None:
"""
Prepares fire-related ICs. This is the main function that handles data movement and interpolation.
Expand All @@ -37,7 +37,7 @@ def generate_emiss_workflow(
predef_grid: If ``RRFS_NA_3km``, use pre-defined grid dimensions
ebb_dcycle_flag: Select the EBB cycle to run. Valid values are ``"1"`` or ``"2"``
restart_interval: Indicates if restart files should be copied. The actual interval values are not used
persistence: If ``TRUE``, use satellite observations from the previous day. Otherwise, use observations from the same day.
persistence_flag: If ``TRUE``, use satellite observations from the previous day. Otherwise, use observations from the same day.
"""

# ----------------------------------------------------------------------
Expand All @@ -56,15 +56,16 @@ def generate_emiss_workflow(
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)
# used later when working with ebb_dcyle 1 or 2
ebb_dcycle = int(ebb_dcycle_flag)
persistence = convert_string_flag_to_boolean(persistence_flag)
print(
"WARNING, EBB_DCYCLE set to",
ebb_dcycle,
ebb_dcycle_flag,
"and persistence=",
persistence,
"if persistence is false, emissions comes from same day satellite obs",
"if persistence is False, emissions comes from same day satellite obs",
)
# used later when working with ebb_dcyle 1 or 2
ebb_dcycle = int(ebb_dcycle_flag)

print("CDATE:", current_day)
print("DATA:", nwges_dir)
Expand Down Expand Up @@ -208,6 +209,18 @@ def generate_emiss_workflow(
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("")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
Expand Down
4 changes: 2 additions & 2 deletions ush/smoke_dust_interp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import ESMF


def date_range(current_day: str, ebb_dcycle: int, persistence: str) -> Index:
def date_range(current_day: str, ebb_dcycle: int, persistence: bool) -> Index:
"""
Create date range, this is later used to search for RAVE and HWP from previous 24 hours.

Expand All @@ -41,7 +41,7 @@ def date_range(current_day: str, ebb_dcycle: int, persistence: str) -> Index:

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"
Expand Down