Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
//"args": ["-v", "1", "--last_n_days", "30", "--start_year", "2022", "--end_year", "2022", "--resample", "--noinput"]
//"args": ["-v", "1", "--last_n_days", "30", "--start_year", "2022", "--end_year", "2022", "--archive", "--noinput"]
//"args": ["-v", "1", "--start_year", "2021", "--end_year", "2022", "--noinput"]
//"args": ["-v", "1", "--mission", "2022.201.00", "--clobber", "--noinput", "--no_cleanup"]
"args": ["-v", "1", "--mission", "2022.201.00", "--clobber", "--noinput", "--no_cleanup"]
//"args": ["-v", "1", "--mission", "2009.084.00", "--clobber", "--noinput"]
//"args": ["-v", "1", "--mission", "2022.243.00", "--calibrate", "--clobber", "--noinput"]
//"args": ["-v", "1", "--start_year", "2004", "--end_year", "2004", "--start_yd", "168", "--use_portal", "--clobber", "--noinput"]
Expand Down Expand Up @@ -265,7 +265,7 @@
//"args": ["-v", "1", "--noinput", "--num_cores", "8"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2011.256.02", "--clobber"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2010.341.00", "--download_process", "--local"]
"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2020.337.00", "--local"]
//"args": ["-v", "1", "--noinput", "--no_cleanup", "--mission", "2020.337.00", "--local"]
},
]
}
36 changes: 27 additions & 9 deletions src/data/hs2_proc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# noqa: INP001

from collections import defaultdict
from math import exp
from math import exp, pi
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -164,15 +164,30 @@ def hs2_calc_bb(orig_nc, cals):
(_int_signer(orig_nc[f"Snorm{chan}"]) * float(cals[f"Ch{chan}"]["Mu"])),
denom,
)
# Replaces "RawTempValue" as the name, helpful when looking at things in the debugger
beta_uncorr.name = f"beta_uncorr_Ch{chan}"
wavelength = int(cals[f"Ch{chan}"]["Name"][2:])
beta_w, b_bw = purewater_scatter(wavelength)

# Use compute_backscatter - same as used for ecopucks - to calculate bbp
_, bbp = compute_backscatter(wavelength, 35.2, beta_uncorr)
setattr(hs2, f"bbp{wavelength}", bbp)
chi = 1.08
b_b_uncorr = ((2 * pi * chi) * (beta_uncorr - beta_w)) + b_bw

globals()[f"bb{wavelength}_uncorr"] = b_b_uncorr
globals()[f"bbp{wavelength}_uncorr"] = b_b_uncorr - b_bw

# ESTIMATION OF KBB AND SIGMA FUNCTION
a = typ_absorption(wavelength)
b_b_tilde = 0.015
b = (b_b_uncorr - b_bw) / b_b_tilde

K_bb = a + 0.4 * b
k_1 = 1.0
k_exp = float(cals[f"Ch{chan}"]["SigmaExp"])
sigma = k_1 * np.exp(k_exp * K_bb)

b_b_corr = sigma * b_b_uncorr

setattr(hs2, f"bb{wavelength}", b_b_corr)
setattr(hs2, f"bbp{wavelength}", b_b_corr - b_bw)

# Fluorescence
# -% 'hs2.fl700_uncorr = (hs2.Snorm3.*50)./((1 + str2num(CAL.Ch(3).TempCoeff).*(hs2.Temp-str2num(CAL.General.CalTemp))).*hs2.Gain3.*str2num(CAL.Ch(3).RNominal));' # noqa: E501
denom = (
(
Expand All @@ -186,8 +201,11 @@ def hs2_calc_bb(orig_nc, cals):
snorm3 = _int_signer(orig_nc["Snorm3"])
setattr(hs2, f"fl{wavelength}", np.divide(snorm3 * 50, denom))

hs2.caldepth = float(cals["General"]["DepthCal"]) * orig_nc["RawDepthValue"] - float(
cals["General"]["DepthOff"]
setattr( # noqa: B010
hs2,
"caldepth",
float(cals["General"]["DepthCal"]) * orig_nc["RawDepthValue"]
- float(cals["General"]["DepthOff"]),
)

return hs2
Expand Down