GEUS-Glaciology-and-Climate / pypromice

Process AWS data from L0 (raw logger) through Lx (end user)
https://pypromice.readthedocs.io
GNU General Public License v2.0
14 stars 4 forks source link

rainfall data and wind-based undercatch correction #52

Closed jasonebox closed 1 year ago

jasonebox commented 2 years ago

does present code handle rain, i.e. for QAS_U new station (there are two stations at QAS_U since 2020 or 2019), NUK_U, and the new GCN sites: SDM, NSE, SDL, NAU, CEN as of 2021 field work

here's Python that applies correction after Yang, D., Ishida, S., Goodison, B. E., and Gunther, T.: Bias correction of daily precipitation measurements for Greenland, https://doi.org/10.1029/1998jd200110, 1999.

suggest outputting corrected and uncorrected instantaneous values from which users can compute accumulated precipitation

sensor_levels=['L','U']
if ((site=='SWC')or(site=='NUK_U')):
    sensor_levels=['L']

for sensor_level in sensor_levels:
    df["Rain_amount_uncor"+sensor_level]=df["Rain_amount_"+sensor_level]
    if do_plot: plt.plot(df["Rain_amount_uncor"+sensor_level][t0:t1],label='uncor '+sensor_level)

    # rain correction after Yang, D., Ishida, S., Goodison, B. E., and Gunther, T.: Bias correction of daily precipitation measurements for Greenland, https://doi.org/10.1029/1998jd200110, 1999.

    df['k_shield_hellman']=100/(100.00-4.37*df["WindSpeed_"+sensor_level]+0.35*df["WindSpeed_"+sensor_level]*df["WindSpeed_"+sensor_level])
    df['k_shield_hellman'][df['k_shield_hellman']<1.02]=1.02

    # rain_rate=np.zeros(N)
    # rain_acc=np.zeros(N)
    df['rain_rate'+sensor_level]=np.nan
    df['rain_acc'+sensor_level]=np.nan
    temp=0.

    for k in range(N-1):
        df['rain_rate'+sensor_level][k]=df["Rain_amount_"+sensor_level][k+1]-df["Rain_amount_"+sensor_level][k]
        df['rain_rate'+sensor_level][k]=df['rain_rate'+sensor_level][k]*df['k_shield_hellman'][k]
        if np.isfinite(df['rain_rate'+sensor_level][k]):
            temp+=df['rain_rate'+sensor_level][k]
        df["Rain_amount_"+sensor_level][k]=temp
        df['rain_acc'+sensor_level][k]=temp
mankoff commented 2 years ago

Rain gauge is not supported in current code. Thank you for sharing the implementation. As for corrected vs uncorrected, see related issue #46

mankoff commented 2 years ago

Big-picture implementation and architecture question (@PennyHow ). The code above has,

sensor_levels=['L','U']
if ((site=='SWC')or(site=='NUK_U')):
    sensor_levels=['L']

Is this the type of thing we want in the code, or want in the config file?

PennyHow commented 1 year ago

This is the current implementation of the undercatch correction in pypromice.

https://github.com/GEUS-Glaciology-and-Climate/pypromice/blob/2331c02e1e121648c06dd054d370f0b99a6a8f6d/src/pypromice/L1toL2.py#L296-L335

Which is executed depending on the boom - the upper boom, for example: https://github.com/GEUS-Glaciology-and-Climate/pypromice/blob/2331c02e1e121648c06dd054d370f0b99a6a8f6d/src/pypromice/L1toL2.py#L117-L119

So @jasonebox's sensor level flag is not needed in pypromice - precipitation will be processed from a boom specified by the variable name i.e. precip_u or precip_l. And this is defined the station config file (.toml), under the column names. In cases where a station has two booms, precipitation observations are therefore corrected with the appropriate boom variables. As SWC is a one-boom station, precipitation observations are automatically defined as variable precip_u, and therefore corrected with the necessary "upper" boom (i.e. the only boom) variables.