Skip to content

Commit

Permalink
Adding n_persist to the yaml file and populating that through
Browse files Browse the repository at this point in the history
  • Loading branch information
bbakernoaa committed Oct 31, 2024
1 parent 4e660a5 commit f4a31bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions parm/prep/aero_emissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ aero_emissions:
coarsen_scale: 150 # scale for coarsen function to generate weights
output_vars: ["BC", "CH4", "CO", "CO2", "NH3", "NOx", "OC", "PM2.5", "SO2"] # OUTPUT VARIABLE NAMES
input_vars: ['oc', 'so2', 'bc'] # Emission file species: for GBBEPx ["bc", "ch4", "co", "co2", "nh3", "no", "oc", "pm25", "so2"]
n_persist: 5
data_in:
mkdir:
- "{{ DATA }}"
Expand Down
18 changes: 11 additions & 7 deletions ush/python/pygfs/task/aero_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, config: Dict[str, Any]) -> None:
hfedfiles = [os.path.basename(fname[0]) for fname in config['data_in']['hfed']['copy']]
gbbepxfiles = [os.path.basename(fname[0]) for fname in config['data_in']['gbbepx']['copy']]
climofiles = [os.path.basename(fname[0]) for fname in config['data_in']['climo']['copy']]
print(climofiles)
n_persist = config['n_persist']

localdict = AttrDict(
{
Expand All @@ -78,7 +78,8 @@ def __init__(self, config: Dict[str, Any]) -> None:
'climofiles': climofiles,
'qfedfiles': qfedfiles,
'hfedfiles': hfedfiles,
'gbbepxfiles': gbbepxfiles
'gbbepxfiles': gbbepxfiles,
'n_persist': n_persist
}
)

Expand Down Expand Up @@ -135,8 +136,6 @@ def run(self) -> None:
--------
None
"""

print(self.task_config)
Config_dict = self.task_config['config']
emistype = self.task_config['emistype']
ratio = Config_dict['ratio']
Expand All @@ -145,6 +144,7 @@ def run(self) -> None:
output_vars = Config_dict['output_vars']
input_vars = Config_dict['input_vars']
current_date = self.task_config['current_date']
n_persist = Config_dict['n_persist']

emission_map = {'qfed': self.task_config['qfedfiles'],
'gbbepx': self.task_config['gbbepxfiles'],
Expand All @@ -167,7 +167,8 @@ def run(self) -> None:
coarsen_scale=coarsen_scale,
obsfile=basefile,
output_vars=output_vars,
input_vars=input_vars)
input_vars=input_vars,
n_persist=n_persist)

AerosolEmissions.write_ncf(dset, Config_dict.data_out['copy'][0][0])

Expand Down Expand Up @@ -388,6 +389,7 @@ def make_fire_emission(
obsfile: str,
output_vars: Union[str, list],
input_vars: list,
n_persist: int,
) -> xr.Dataset:
"""
Generate fire emissions data for a given date and forecast period.
Expand All @@ -408,6 +410,8 @@ def make_fire_emission(
Path to the file containing observed fire emissions data.
climo_directory: str
Directory containing climatology files.
n_persist: int
Assumed number of days that are able to be persistant fire emissions
Returns:
--------
Expand Down Expand Up @@ -442,7 +446,7 @@ def make_fire_emission(

for v in ObsEmis.data_vars:
if not scale_climo:
if tslice > 5:
if tslice > n_persist:
# kk = ratio * dset[v] + (1 - ratio) * climo[v].data[tslice, :, :]
dset[v].data = (
ratio * dset[v] + (1 - ratio) * climo[v].data[tslice, :, :]
Expand All @@ -454,7 +458,7 @@ def make_fire_emission(
ObsEmisC[v], climo[v], lon_coarse=150, lat_coarse=150
)
else:
if tslice > 5:
if tslice > n_persist:
dset[v].data = (
ratio * dset[v] + (1 - ratio) * climo_scaled[v].data[tslice, :, :]
)
Expand Down

0 comments on commit f4a31bd

Please sign in to comment.