Skip to content

Commit

Permalink
Merge pull request #2396 from gerritholl/did-attributeerror
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud authored Mar 6, 2023
2 parents 16d3184 + 1a785e5 commit b045d84
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 37 deletions.
14 changes: 1 addition & 13 deletions satpy/dataset/dataid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2021 Satpy developers
# Copyright (c) 2015-2023 Satpy developers
#
# This file is part of satpy.
#
Expand All @@ -19,7 +17,6 @@

import logging
import numbers
import warnings
from collections import namedtuple
from contextlib import suppress
from copy import copy, deepcopy
Expand Down Expand Up @@ -400,15 +397,6 @@ def to_dict(self):
res_dict[key] = value
return res_dict

def __getattr__(self, key):
"""Support old syntax for getting items."""
if key in self._id_keys:
warnings.warn('Attribute access to DataIDs is deprecated, use key access instead.',
stacklevel=2)
return self[key]
else:
return super().__getattr__(key)

def __deepcopy__(self, memo=None):
"""Copy this object.
Expand Down
7 changes: 2 additions & 5 deletions satpy/readers/abi_l2_nc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019 Satpy developers
# Copyright (c) 2019-2023 Satpy developers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,7 +35,7 @@ def get_dataset(self, key, info):
"""Load a dataset."""
var = info['file_key']
if self.filetype_info['file_type'] == 'abi_l2_mcmip':
var += "_" + key.name
var += "_" + key["name"]
LOG.debug('Reading in get_dataset %s.', var)
variable = self[var]
variable.attrs.update(key.to_dict())
Expand Down
9 changes: 3 additions & 6 deletions satpy/readers/fci_l2_nc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019 Satpy developers
# Copyright (c) 2019-2023 Satpy developers
#
# satpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -252,7 +249,7 @@ def _get_proj_area(self, dataset_id):
# as fallback until all L2PF test files are correctly formatted.
rf = float(self._projection.attrs.get('inverse_flattening', 298.257223563))

res = dataset_id.resolution
res = dataset_id["resolution"]

area_naming_input_dict = {'platform_name': 'mtg',
'instrument_name': 'fci',
Expand Down Expand Up @@ -360,7 +357,7 @@ def _construct_area_def(self, dataset_id):
AreaDefinition: A pyresample AreaDefinition object containing the area definition.
"""
res = dataset_id.resolution
res = dataset_id["resolution"]

area_naming_input_dict = {'platform_name': 'mtg',
'instrument_name': 'fci',
Expand Down
7 changes: 2 additions & 5 deletions satpy/readers/seviri_l2_grib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019-2020 Satpy developers
# Copyright (c) 2019-2023 Satpy developers
#
# satpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -111,7 +108,7 @@ def get_dataset(self, dataset_id, dataset_info):

if parameter_number == dataset_info['parameter_number']:

self._res = dataset_id.resolution
self._res = dataset_id["resolution"]
self._read_attributes(gid)

# Read the missing value
Expand Down
6 changes: 2 additions & 4 deletions satpy/tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2022 Satpy developers
# Copyright (c) 2015-2023 Satpy developers
#
# This file is part of satpy.
#
Expand Down Expand Up @@ -686,7 +684,7 @@ def test_seviri_hrv_has_priority_over_vis008(self):
resolution=3000.403165817, calibration="counts", modifiers=())]
dq = DataQuery(wavelength=0.8)
res, distances = dq.sort_dataids(dids)
assert res[0].name == "HRV"
assert res[0]["name"] == "HRV"


def test_frequency_quadruple_side_band_class_method_convert():
Expand Down
6 changes: 2 additions & 4 deletions satpy/tests/test_dependency_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Satpy developers
# Copyright (c) 2020-2023 Satpy developers
#
# This file is part of satpy.
#
Expand Down Expand Up @@ -219,7 +217,7 @@ def test_compositor_loaded_sensor_order(self):
self.dependency_tree.populate_with_keys({'comp1'})
comp_nodes = self.dependency_tree.trunk()
self.assertEqual(len(comp_nodes), 1)
self.assertEqual(comp_nodes[0].name.resolution, 500)
self.assertEqual(comp_nodes[0].name["resolution"], 500)

def test_modifier_loaded_sensor_order(self):
"""Test that a modifier is loaded from the first alphabetical sensor."""
Expand Down

0 comments on commit b045d84

Please sign in to comment.