Skip to content

Commit

Permalink
add bones to the fire blending in the prep_emissions job
Browse files Browse the repository at this point in the history
  • Loading branch information
bbakernoaa committed Sep 13, 2024
1 parent 108db4d commit c8e6344
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 31 deletions.
9 changes: 9 additions & 0 deletions jobs/JGLOBAL_PREP_EMISSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ 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
COM_CHEM_HISTORY_TMPL
YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
COMOUT_CHEM_HISTORY:COM_CHEM_HISTORY_TMPL

###############################################################
# Run relevant script
Expand All @@ -32,4 +35,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

echo "BEGIN: config.prep_emissions"

# Get task specific resources
export STARTHOUR=${STARTHOUR:-00}
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 @@ -78,7 +78,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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -1193,7 +1193,7 @@ case ${step} in
walltime="02:00:00"
export ntasks=141
threads_per_task=6
export tasks_per_node=21
export tasks_per_node=21
export ntasks_postsndcfp=9
export tasks_per_node_postsndcfp=1
postsnd_req_cores=$(( tasks_per_node * threads_per_task ))
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
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:
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 }}/"]
- ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_so2.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 | strftime('%Y%m%d') }}.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"]
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
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']
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'])
Loading

0 comments on commit c8e6344

Please sign in to comment.