Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 11, 2024
1 parent 20a0463 commit 71eceae
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/ncas_amof_netcdf_template/create_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ def add_variables(ncfile, instrument_dict, product, verbose=0):
# if we encounter one, we're going to print out an error
# and forget about that variable
if "dimension" not in tmp_value.keys():
print(
f"WARN: No dimensions for variable {key} in product {obj}"
)
print(f"WARN: No dimensions for variable {key} in product {obj}")

Check warning on line 147 in src/ncas_amof_netcdf_template/create_netcdf.py

View check run for this annotation

Codecov / codecov/patch

src/ncas_amof_netcdf_template/create_netcdf.py#L147

Added line #L147 was not covered by tests
print("Variable not added file")
var_dims = ()

Check warning on line 149 in src/ncas_amof_netcdf_template/create_netcdf.py

View check run for this annotation

Codecov / codecov/patch

src/ncas_amof_netcdf_template/create_netcdf.py#L149

Added line #L149 was not covered by tests
else:
Expand Down Expand Up @@ -198,21 +196,13 @@ def add_variables(ncfile, instrument_dict, product, verbose=0):
# flag meanings in the tsv files are separated by '|',
# should be space separated
if "|" in mdatvalue and "flag_meaning" in mdatkey:
mdatvalue = " ".join(
[i.strip() for i in mdatvalue.split("|")]
)
mdatvalue = " ".join([i.strip() for i in mdatvalue.split("|")])
# flag values are bytes, can't add byte array
# into NETCDF4_CLASSIC so have to muddle a bit
if (
"flag_value" in mdatkey
and "qc" in key
and var.dtype == np.int8
):
if "flag_value" in mdatkey and "qc" in key and var.dtype == np.int8:
# turn string "0b,1b..." into list of ints [0,1...]
mdatvalue = mdatvalue.strip(",")
newmdatvalue = [
int(i.strip("b")) for i in mdatvalue.split(",")
]
newmdatvalue = [int(i.strip("b")) for i in mdatvalue.split(",")]
# turn list into array with int8 type
mdatvalue = np.array(newmdatvalue, dtype=np.int8)
# print warning for example values,
Expand Down

0 comments on commit 71eceae

Please sign in to comment.