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

RAINRATE hack #47

Open
JordanLaserGit opened this issue Apr 2, 2024 · 2 comments
Open

RAINRATE hack #47

JordanLaserGit opened this issue Apr 2, 2024 · 2 comments
Assignees

Comments

@JordanLaserGit
Copy link
Collaborator

Currently forcingprocessor contains a poor hack to calculate precip_rate for NextGen. RAINRATE should be converted in a physically consistent way.

nwm_variables = [
    "U2D",
    "V2D",
    "LWDOWN",
    "RAINRATE",
    "RAINRATE",
    "T2D",
    "Q2D",
    "PSFC",
    "SWDOWN",
]

global ngen_variables
ngen_variables = [
    "UGRD_10maboveground",
    "VGRD_10maboveground",
    "DLWRF_surface",
    "APCP_surface",
    "precip_rate",  # HACK RAINRATE * 3600
    "TMP_2maboveground",        
    "SPFH_2maboveground",
    "PRES_surface",
    "DSWRF_surface",
] 
@JordanLaserGit
Copy link
Collaborator Author

JordanLaserGit commented Apr 2, 2024

It looks like we need to implement the code recommended here:
NOAA-OWP/ngen#302
and here:
NOAA-OWP/ngen#509

def rho(temp): 
    """
        Calculate water density at temperature
    """
    return 999.99399 + 0.04216485*temp - 0.007097451*(temp**2) + 0.00003509571*(temp**3) - 9.9037785E-8*(temp**4) 

And

def aorc_as_rate(dataFrame):
    """
        Convert kg/m^2 -> m/s
    """
    if isinstance(dataFrame.index, pd.MultiIndex):
        interval = pd.Series(dataFrame.index.get_level_values(0))
    else:
        interval = pd.Series(dataFrame.index)
    interval = ( interval.shift(-1) - interval ) / np.timedelta64(1, 's')
    interval.index = dataFrame.index
    precip_rate = ( dataFrame['APCP_surface'].shift(-1) / dataFrame['TMP_2maboveground'].apply(rho) ) / interval
    precip_rate.name = 'precip_rate'
    return precip_rate

@jameshalgren
Copy link
Member

jameshalgren commented Apr 4, 2024

@chp2001 -- something you could do?
@JoshCu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants