Skip to content

Commit

Permalink
Make attribute encoding public
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinkens committed Dec 11, 2023
1 parent ac5301e commit a59fdd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions satpy/cf/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def _encode_to_cf(obj):
return _encode_python_objects(obj)


def _encode_nc_attrs(attrs):
"""Encode dataset attributes in a netcdf compatible datatype.
def encode_attrs_to_cf(attrs):
"""Encode dataset attributes as a netcdf compatible datatype.
Args:
attrs (dict):
Expand Down Expand Up @@ -161,7 +161,7 @@ def preprocess_attrs(
if flatten_attrs:
data_arr.attrs = flatten_dict(data_arr.attrs)

data_arr.attrs = _encode_nc_attrs(data_arr.attrs)
data_arr.attrs = encode_attrs_to_cf(data_arr.attrs)

return data_arr

Expand Down Expand Up @@ -224,7 +224,7 @@ def preprocess_header_attrs(header_attrs, flatten_attrs=False):
if header_attrs is not None:
if flatten_attrs:
header_attrs = flatten_dict(header_attrs)
header_attrs = _encode_nc_attrs(header_attrs) # OrderedDict
header_attrs = encode_attrs_to_cf(header_attrs) # OrderedDict
else:
header_attrs = {}
header_attrs = _add_history(header_attrs)
Expand Down
4 changes: 2 additions & 2 deletions satpy/tests/cf_tests/test_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class TestCFAttributeEncoding:

def test__encode_nc_attrs(self):
"""Test attributes encoding."""
from satpy.cf.attrs import _encode_nc_attrs
from satpy.cf.attrs import encode_attrs_to_cf
from satpy.tests.cf_tests._test_data import get_test_attrs
from satpy.tests.utils import assert_dict_array_equality

attrs, expected, _ = get_test_attrs()

# Test encoding
encoded = _encode_nc_attrs(attrs)
encoded = encode_attrs_to_cf(attrs)
assert_dict_array_equality(expected, encoded)

# Test decoding of json-encoded attributes
Expand Down

0 comments on commit a59fdd5

Please sign in to comment.