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

Add fire blending to GOCART #2883

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/scripts/utils/publish_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def upload_logs_to_repo(args, emcbot_gh, emcbot_ci_url):
file_path_in_repo = f"{repo_path}/{path_header}/" + str(os.path.basename(file.name))
emcbot_gh.repo.create_file(file_path_in_repo, "Adding error log file", file_content, branch="error_logs")

file_url = f"{emcbot_ci_url.rsplit('.',1)[0]}/tree/{repo_branch}/{repo_path}/{path_header}"
file_url = f"{emcbot_ci_url.rsplit('.', 1)[0]}/tree/{repo_branch}/{repo_path}/{path_header}"
print(file_url)


Expand Down
8 changes: 8 additions & 0 deletions jobs/JGLOBAL_PREP_EMISSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ source "${HOMEgfs}/ush/jjob_header.sh" -e "prep_emissions" -c "base prep_emissio
##############################################
# Generate COM variables from templates
# TODO: Add necessary COMIN, COMOUT variables for this job
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMOUT_CHEM_HISTORY:COM_CHEM_HISTORY_TMPL

###############################################################
# Run relevant script
Expand All @@ -32,4 +34,10 @@ if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi

##########################################
# Remove the Temporary working directory
##########################################
cd "${DATAROOT}" || exit 1
[[ ${KEEPDATA} = "NO" ]] && rm -rf "${DATA}"

exit 0
28 changes: 28 additions & 0 deletions parm/config/gefs/config.prep_emissions
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@

########## config.prep_emissions ##########
# aerosol emissions preprocessing specific
# TODO: this is duplicated in the config.aero file. Should use a common function
case ${machine} in
"HERA")
AERO_INPUTS_DIR="/scratch1/NCEPDEV/global/glopara/data/gocart_emissions"
;;
"ORION" | "HERCULES")
AERO_INPUTS_DIR="/work2/noaa/global/wkolczyn/noscrub/global-workflow/gocart_emissions"
;;
"S4")
AERO_INPUTS_DIR="/data/prod/glopara/gocart_emissions"
;;
"WCOSS2")
AERO_INPUTS_DIR="/lfs/h2/emc/global/noscrub/emc.global/data/gocart_emissions"
;;
"GAEA")
AERO_INPUTS_DIR="/gpfs/f5/epic/proj-shared/global/glopara/data/gocart_emissions"
;;
"JET")
AERO_INPUTS_DIR="/lfs4/HFIP/hfv3gfs/glopara/data/gocart_emissions"
;;
*)
echo "FATAL ERROR: Machine ${machine} unsupported for aerosols"
exit 2
;;
esac
export AERO_INPUTS_DIR
Comment on lines +5 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can/shouldplace AERO_INPUTS_DIR in workflow/hosts/<machine>.yaml and then here, replace this section with:

export AERO_INPUTS_DIR="@AERO_INPUTS_DIR@"

Repeat the same in config.aero.
What do you think @WalterKolczynski-NOAA ?

ps. this can be done in a follow-up PR.


echo "BEGIN: config.prep_emissions"

# Get task specific resources
export STARTHOUR=${STARTHOUR:-00}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put STARTHOUR in the yaml? Does it change or have a upstream configuration that provides this value?

export PREP_EMISSION_CONFIG="${PARMgfs}/prep/aero_emissions.yaml"
source "${EXPDIR}/config.resources" prep_emissions

echo "END: config.prep_emissions"
2 changes: 1 addition & 1 deletion parm/config/gefs/config.resources
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ case ${step} in
export ntasks=1
export threads_per_task=1
export tasks_per_node=$(( max_tasks_per_node / threads_per_task ))
export memory="1GB"
export memory="20GB"
;;

"fcst" | "efcs")
Expand Down
2 changes: 1 addition & 1 deletion parm/config/gfs/config.aero
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export AERO_INPUTS_DIR

export AERO_DIAG_TABLE="${PARMgfs}/ufs/fv3/diag_table.aero"
export AERO_FIELD_TABLE="${PARMgfs}/ufs/fv3/field_table.aero"
# Biomass burning emission dataset. Choose from: gbbepx, qfed, none
# Biomass burning emission dataset. Choose from: gbbepx, qfed, hfed, none
export AERO_EMIS_FIRE="qfed"
# Directory containing GOCART configuration files
export AERO_CONFIG_DIR="${PARMgfs}/ufs/gocart"
Expand Down
2 changes: 1 addition & 1 deletion parm/config/gfs/config.resources
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (( $# != 1 )); then

echo "Must specify an input task argument to set resource variables!"
echo "argument can be any one of the following:"
echo "stage_ic aerosol_init"
echo "stage_ic aerosol_init prep_emissions"
echo "prep prepsnowobs prepatmiodaobs"
echo "atmanlinit atmanlvar atmanlfv3inc atmanlfinal"
echo "atmensanlinit atmensanlobs atmensanlsol atmensanlletkf atmensanlfv3inc atmensanlfinal"
Expand Down
24 changes: 24 additions & 0 deletions parm/prep/aero_emissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
aero_emissions:
config:
debug: False
ratio: 0.95 # weighting ratio
emistype: 'QFED' # EMission Type, Valid answers: 'QFED, GBBEPx, HFED'
climfile_str: 'GBBEPx-all01GRID_v4r0_climMean' # climate file base string used for glob later
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this climfile_str change when emistype changes?

GBBEPx_version: 'v4r0' # gbbepx version
qfed_version: '006' # qfed version
species: [ 'so2','oc','bc' ] # species to be used
historical: False # set to true to just use true data for the given day
data:
bbakernoaa marked this conversation as resolved.
Show resolved Hide resolved
mkdir:
- "{{ DATA }}"
- "{{ COMOUT_CHEM_HISTORY}}"
copy:
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_oc.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"]
bbakernoaa marked this conversation as resolved.
Show resolved Hide resolved
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_so2.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"]
bbakernoaa marked this conversation as resolved.
Show resolved Hide resolved
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_bc.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_bc.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"]
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_bc.006.{{ current_cycle | to_YMD }}.nc4", "{{ DATA }}/"]

{% for fdate in forecast_dates %}
- ["{{ AERO_INPUTS_DIR }}/nexus/GBBEPx/v4/climMean/GBBEPx-all01GRID_v4r0_climMean_{{ fdate | strftime('%m%d') }}.nc", "{{ DATA }}/"] # copy climo files
{% endfor %}
data_out:
copy:
- ["{{ DATA }}/gefs_blended_emissions.{{ current_cycle | strftime('%Y%m%d') }}.nc", "{{ COMOUT_CHEM_HISTORY }}/{{ RUN }}.{{ current_cycle | strftime('%Y%m%d') }}.gefs_blended_emissions.nc"]
bbakernoaa marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions parm/ufs/gocart/ExtData.hfed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#====== BIOMASS BURNING EMISSIONS =======================================

# HFED
#--------------------------------------------------------------------------------------------------------------------------------
SU_BIOMASS NA N Y %y4-%m2-%d2t12:00:00 none 0.7778 biomass ExtData/nexus/HFED/Y1994/M%m2/hfed.emis_so2.x576_y361.%y4%m2.nc4
OC_BIOMASS NA N Y %y4-%m2-%d2t12:00:00 none 0.7778 biomass ExtData/nexus/HFED/Y1994/M%m2/hfed.emis_oc.x576_y361.%y4%m2.nc4
BC_BIOMASS NA N Y %y4-%m2-%d2t12:00:00 none 0.7778 biomass ExtData/nexus/HFED/Y1994/M%m2/hfed.emis_bc.x576_y361.%y4%m2.nc4
# EMI_NH3_BB NA N Y %y4-%m2-%d2t12:00:00 none 0.7778 biomass ExtData/nexus/HFED/Y1994/M%m2/hfed.emis_nh3.x576_y361.%y4%m2.nc4
Comment on lines +1 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be linked from UFS and not added in the global-workflow.

36 changes: 28 additions & 8 deletions scripts/exglobal_prep_emissions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#!/usr/bin/env python3
# exglobal_prep_emissions.py
# This script creates a emissions object
# which perform the pre-processing for aerosol emissions
"""
This script initializes a logger, reads configuration from the environment, and performs emissions pre-processing tasks using the AerosolEmissions class.

The script does the following:
1. Initializes a root logger with the specified logging level and colored log output.
2. Reads configuration from the environment and converts it into a Python dictionary.
3. Instantiates an AerosolEmissions object with the configuration.
4. Retrieves specific keys from the emissions task configuration and stores them in a dictionary.
5. Sets the 'emistype' attribute in the configuration dictionary based on the 'emistype' value in the emissions configuration.
6. Initializes, configures, runs, and finalizes the emissions task using the provided parameters.

Note: Make sure to have the necessary dependencies (wxflow, pygfs) installed to run this script successfully.
"""
import os

from wxflow import Logger, cast_strdict_as_dtypedict
from wxflow import Logger, AttrDict, cast_strdict_as_dtypedict
from pygfs import AerosolEmissions


Expand All @@ -19,7 +29,17 @@

# Instantiate the emissions pre-processing task
emissions = AerosolEmissions(config)
emissions.initialize()
emissions.configure()
emissions.execute(emissions.task_config.DATA, emissions.task_config.APRUN)
emissions.finalize()

# get local keys for configuration
keys = ['DATA', 'forecast_dates', 'cdate', 'aero_emission_yaml']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have removed instances of cdate. Please use PDY and cyc in its place. I will try to find these instances as I go through the review and make suggestions.

edict = AttrDict()
for key in keys:
edict[key] = emissions.task_config[key]
edict['CONFIG'] = edict.aero_emission_yaml.aero_emissions['config']
edict.aero_emission_yaml['emistype'] = edict['CONFIG'].emistype

# print(aero_emission_yaml.aero_emissions['fix_data'])
emissions.initialize(edict.aero_emission_yaml)
emissions.configure(edict.aero_emission_yaml)
emissions.run(workdir=edict.DATA, current_date=edict.cdate, forecast_dates=edict.forecast_dates, Config_dict=edict.CONFIG)
emissions.finalize(edict['CONFIG'])
2 changes: 1 addition & 1 deletion scripts/exglobal_stage_ic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():
for key in keys:
# Make sure OCNRES is three digits
if key == "OCNRES":
stage.task_config.OCNRES = f"{stage.task_config.OCNRES :03d}"
stage.task_config.OCNRES = f"{stage.task_config.OCNRES:03d}"
stage_dict[key] = stage.task_config[key]

# Also import all COM* directory and template variables
Expand Down
2 changes: 1 addition & 1 deletion ush/compare_f90nml.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _print_diffs(diff_dict: Dict) -> None:
for kk in diff_dict[path].keys():
items = diff_dict[path][kk]
print(
f"{kk:>{max_len+2}} : {' | '.join(map(str, diff_dict[path][kk]))}")
f"{kk:>{max_len + 2}} : {' | '.join(map(str, diff_dict[path][kk]))}")
aerorahul marked this conversation as resolved.
Show resolved Hide resolved

_print_diffs(result)

Expand Down
Loading
Loading