Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Oct 9, 2024
1 parent bcdcf3c commit 2ac6b61
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
5 changes: 3 additions & 2 deletions ush/enspost_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HRRR-E PYTHON GRIB GENERATION
# CONFIGURATION FILE
"""
HRRR-E python GRIB generation configuration file
"""
## CREATE DICTIONARIES ##
grib_discipline = {}
grib_category = {}
Expand Down
74 changes: 65 additions & 9 deletions ush/fire_emiss_tools.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
"""
Fire emisivity tools?
"""
import os
import numpy as np
import xarray as xr
from datetime import datetime
from netCDF4 import Dataset
import interp_tools as i_tools

#Compute average FRP from raw RAVE for the previous 24 hours
def averaging_FRP(fcst_dates, cols, rows, intp_dir, rave_to_intp, veg_map, tgt_area, beta, fg_to_ug):
# There are two situations here.
# 1) there is only on fire detection whithin 24 hours so FRP is divided by 2
# 2) There are more than one fire detection so the average FRP is stimated
# ebb_smoke is always divided by the number of times a fire is detected within 24 hours window
"""
Compute average FRP from raw RAVE for the previous 24 hours.
There are two situations here.
1) there is only on fire detection whithin 24 hours so FRP is divided by 2
2) There are more than one fire detection so the average FRP is stimated
ebb_smoke is always divided by the number of times a fire is detected within 24 hours window
fcst_dates: ???
cols: ???
rows: ???
intp_dir: ???
rave_to_intp: ???
veg_map: ???
tgt_area: ???
beta: ???
fg_to_ug: ???
"""
base_array = np.zeros((cols*rows))
frp_daily = base_array
ebb_smoke_total = []
Expand Down Expand Up @@ -67,9 +83,25 @@ def averaging_FRP(fcst_dates, cols, rows, intp_dir, rave_to_intp, veg_map, tgt_a
return(frp_avg_reshaped, ebb_total_reshaped)

def estimate_fire_duration(intp_avail_hours, intp_dir, fcst_dates, current_day, cols, rows, rave_to_intp):
# There are two steps here.
# 1) First day simulation no RAVE from previous 24 hours available (fire age is set to zero)
# 2) previus files are present (estimate fire age as the difference between the date of the current cycle and the date whe the fire was last observed whiting 24 hours)
"""
There are two steps here.
1. First day simulation no RAVE from previous 24 hours available
(fire age is set to zero)
2. previus files are present (estimate fire age as the difference
between the date of the current cycle and the date whe the fire
was last observed whiting 24 hours)
intp_avail_hours: ???
intp_dir: ???
fcst_dates: ???
current_day: ???
cols: ???
rows: ???
rave_to_intp: ???
"""
t_fire = np.zeros((cols, rows))

for date_str in fcst_dates:
Expand Down Expand Up @@ -103,10 +135,34 @@ def estimate_fire_duration(intp_avail_hours, intp_dir, fcst_dates, current_day,
return(te)

def save_fire_dur(cols, rows, te):
"""
???
cols: ???
rows: ???
te: ???
"""
fire_dur = np.array(te).reshape(cols, rows)
return(fire_dur)

def produce_emiss_file(xarr_hwp, frp_avg_reshaped, totprcp_ave_arr, xarr_totprcp, intp_dir, current_day, tgt_latt, tgt_lont, ebb_tot_reshaped, fire_age, cols, rows):
"""
???
xarr_hwp: ???
frp_avg_reshaped: ???
totprcp_ave_arr: ???
xarr_totprcp: ???
intp_dir: ???
current_day: ???
tgt_latt: ???
tgt_lont: ???
ebb_tot_reshaped: ???
fire_age: ???
cols: ???
rows: ???
"""
# Ensure arrays are not negative or NaN
frp_avg_reshaped = np.clip(frp_avg_reshaped, 0, None)
frp_avg_reshaped = np.nan_to_num(frp_avg_reshaped)
Expand Down Expand Up @@ -159,4 +215,4 @@ def produce_emiss_file(xarr_hwp, frp_avg_reshaped, totprcp_ave_arr, xarr_totprcp
print(f"Error creating or writing to NetCDF file {file_path}: {e}")
return f"Error creating or writing to NetCDF file {file_path}: {e}"

return "Emissions file created successfully"
return "Emissions file created successfully"

0 comments on commit 2ac6b61

Please sign in to comment.