-
Notifications
You must be signed in to change notification settings - Fork 322
Change area names to new naming scheme and remove some areas. #3299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,10 @@ | |||||
| # You should have received a copy of the GNU General Public License along with | ||||||
| # satpy. If not, see <http://www.gnu.org/licenses/>. | ||||||
| """Utility functions for area definitions.""" | ||||||
| import warnings | ||||||
|
|
||||||
| from pyresample.area_config import AreaNotFound, _create_area_def_from_dict, _read_yaml_area_file_content | ||||||
|
|
||||||
| from ._config import config_search_paths, get_config_path | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -29,7 +33,37 @@ def get_area_file(): | |||||
| else: | ||||||
| return get_config_path("areas.def") | ||||||
|
|
||||||
| def deprecate_area_name(fun): | ||||||
| """Decorator to deprecate area names. | ||||||
|
|
||||||
| This function is used to retire area names or warn about changed area names. | ||||||
| """ | ||||||
| def area_with_new_name(area_name): | ||||||
| try: | ||||||
| return fun(area_name) | ||||||
| except AreaNotFound: | ||||||
| area_file_name = get_area_file() | ||||||
| areas_dict = _read_yaml_area_file_content(area_file_name) | ||||||
| area_dict = None | ||||||
| for new_area_name, v in areas_dict.items(): | ||||||
|
|
||||||
| if "old_name" in v.keys() and area_name in v["old_name"]:# == area_name: | ||||||
| area_dict = areas_dict.get(new_area_name) | ||||||
| del area_dict["old_name"] | ||||||
| break | ||||||
|
|
||||||
| if area_dict is not None: | ||||||
| warnings.simplefilter("always", DeprecationWarning) | ||||||
| warnings.warn(f"This area name is being deprecated in Satpy v1.0. Pleas use the new area name:" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| f" {new_area_name}", DeprecationWarning, stacklevel=2) | ||||||
| warnings.simplefilter("default", DeprecationWarning) | ||||||
|
Comment on lines
+56
to
+59
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the |
||||||
| return _create_area_def_from_dict(new_area_name, area_dict) | ||||||
| else: | ||||||
| raise AreaNotFound('Area "{0}" not found in file "{1}"'.format(area_name, area_file_name)) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be easier to read with an f-strring. |
||||||
|
|
||||||
| return area_with_new_name | ||||||
|
|
||||||
| @deprecate_area_name | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it confusing to define a decorator that is used exactly once and unlikely to be reused elsewhere. Wouldn't it be clearer to simply integrate this into |
||||||
| def get_area_def(area_name): | ||||||
| """Get the definition of *area_name* from file. | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment should be removed.