Skip to content

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkehoe committed Jul 22, 2024
1 parent 768248f commit 572ebcf
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions act/qc/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def clean_arm_qc(
SERI_QC = False

if SERI_QC and global_qc is None and qc_attributes is None:
self._ds.clean.clean_seri_qc()
self._ds.clean.clean_seri_qc()

def normalize_assessment(
self,
Expand Down Expand Up @@ -930,15 +930,23 @@ def fix_incorrect_variable_bit_description_attributes(self):

def clean_seri_qc(self):
for var_name in self._ds.data_vars:
if not self._ds[var_name].attrs['long_name'].startswith("Quality check results on field:"):
if (
not self._ds[var_name]
.attrs['long_name']
.startswith("Quality check results on field:")
):
continue

qc_var_name = var_name
var_name = var_name.replace('qc_', '')
qc_data = self._ds[qc_var_name].values.copy()
self._ds[qc_var_name] = xr.zeros_like(self._ds[qc_var_name], dtype=np.int32)

if qc_var_name in ["qc_down_short_diffuse", "qc_short_direct_normal", "qc_down_short_hemisp"]:
if qc_var_name in [
"qc_down_short_diffuse",
"qc_short_direct_normal",
"qc_down_short_hemisp",
]:
value_number = [1, 2, 3, 6, 7, 8, 9, 94, 95, 96, 97]
test_number = list(range(2, len(value_number) + 2))
test_description = [
Expand All @@ -953,7 +961,6 @@ def clean_seri_qc(self):
'Data fall into a physically impossible region where Kn>Kt by K-space distances of 0.10 to 0.15.',
'Data fall into a physically impossible region where Kn>Kt by K-space distances of 0.15 to 0.20.',
'Data fall into a physically impossible region where Kn>Kt by K-space distances of >= 0.20.',

]
test_assessment = [
'Not failing',
Expand Down Expand Up @@ -1018,10 +1025,15 @@ def clean_seri_qc(self):
index=index,
test_number=test_number[ii],
test_meaning=test_description[ii],
test_assessment=test_assessment[ii])
test_assessment=test_assessment[ii],
)

if qc_var_name in ["qc_down_short_diffuse", "qc_short_direct_normal", "qc_down_short_hemisp"]:
calculation = ((qc_data + 2) / 4.) % 4
if qc_var_name in [
"qc_down_short_diffuse",
"qc_short_direct_normal",
"qc_down_short_hemisp",
]:
calculation = ((qc_data + 2) / 4.0) % 4
calculation = calculation.astype(np.int16)
value_number = [0, 1, 2, 3]
test_description = [
Expand All @@ -1032,9 +1044,7 @@ def clean_seri_qc(self):
]
test_assessment = ['Bad', 'Bad', 'Bad', 'Bad']
for ii, _ in enumerate(value_number):
index = ((qc_data >= 10) &
(qc_data <= 93) &
(calculation == value_number[ii]))
index = (qc_data >= 10) & (qc_data <= 93) & (calculation == value_number[ii])
self._ds.qcfilter.add_test(
var_name,
index=index,
Expand Down

0 comments on commit 572ebcf

Please sign in to comment.