-
Notifications
You must be signed in to change notification settings - Fork 300
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
Automatic list with overviews of inlcuded area definitions for the documentation #2167
Merged
mraspaud
merged 21 commits into
pytroll:main
from
BENR0:feat_automatic_area_def_overview
Jun 13, 2024
Merged
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e52fd96
feat: add first draft of area list
96ae5d8
fix: indentation of raw html block
bdf89b7
add: area_def_list.rst to gitignore
e310747
add: area definition list to resample chapter
7f41639
Merge branch 'main' into feat_automatic_area_def_overview
BENR0 d7893d5
refactor: move rst list generation function to pyresample
BENR0 d18023b
Merge branch 'main' into feat_automatic_area_def_overview
BENR0 d621089
fix: missing area file argument
BENR0 4b94939
fix: function name
BENR0 fd0879d
refactor: add class name argument to rst table header generation
BENR0 6edf540
refactor: add options for area table to datatable js init
BENR0 6a35d2f
Merge branch 'main' into feat_automatic_area_def_overview
BENR0 b1bacff
feat: add searchable reader table
BENR0 f766457
fix: areas yaml
BENR0 bd960ca
Merge branch 'main' into feat_automatic_area_def_overview
BENR0 23f6ae5
fix: error when projection is EPSG code
BENR0 ba46aca
fix: links for areas without html repr.
BENR0 fbb92b1
fix: relativ inlcude
BENR0 79d95b6
add cartopy to environment
BENR0 f9142b0
fix: columns widths
BENR0 269315c
remove testing code
BENR0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2022 Satpy developers | ||
# | ||
# This file is part of satpy. | ||
# | ||
# satpy is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# satpy is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with satpy. If not, see <http://www.gnu.org/licenses/>. | ||
"""Module for autogenerating a list and overview of available area definitions .""" | ||
|
||
from pyresample.area_config import _read_yaml_area_file_content | ||
from pyresample.formatting_html import area_repr | ||
|
||
from satpy.resample import get_area_def, get_area_file | ||
|
||
|
||
def generate_area_def_list(): | ||
"""Create list of available area definitions with overview plot. | ||
|
||
Returns: | ||
str | ||
""" | ||
area_list = [] | ||
|
||
template = ("{area_name}\n" | ||
"{n:->{header_title_length}}\n\n" | ||
".. raw:: html\n\n" | ||
"{content}\n\n" | ||
" <hr>\n\n") | ||
|
||
area_file = get_area_file()[0] | ||
for aname in list(_read_yaml_area_file_content(area_file).keys()): | ||
area = get_area_def(aname) | ||
if hasattr(area, "_repr_html_"): | ||
content = "\n".join([x.rjust(len(x) + 5) for x in area_repr(area, include_header=False).split("\n")]) | ||
area_list.append(template.format(area_name=aname, n="", header_title_length=len(aname), | ||
content=content)) | ||
else: | ||
pass | ||
|
||
return "".join(area_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Doesn't this function rather belong to pyresample?
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.
I think it doesn't really make sense to include in in pyresample because there is no area definition yaml included and this is only useful to generate a rst with a list of area definitions for the documentation.
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.
It is true that pyresample does not have a default yaml file, but it is pyresample that contains all the functions for reading such yaml files. And also, I would argue that for the sake of separation of concerns, it should be included there.
In practice, I wouldn't be against having a default yaml file with a few generic areas in pyresample by the way, that would probably help potential pyresample users in the future...
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.
Wouldn't
areas.yaml
fit better with pyresample entirely? But pyresample does not have a concept ofSATPY_CONFIG_PATH
or a config directory search, so it wouldn't know where to findareas.yaml
anyway?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.
Not that anyone asked for my opinion, but I agree with wanting this in pyresample. I'm not a big fan of a default set of areas in pyresample except only as a few examples (like global lon/lat, one LCC, one polar-stereographic, etc)...generic areas. Pyresample is the low-level functionality, but it doesn't know anything about satellite-specific areas or that it is used for "science" at all so to me it is a fine line.
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.
A while ago, I found a small list of generic areas, like europe, north and south america, etc. I'll try to find it again, so we can use that.
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.
would this work? https://cfconventions.org/Data/standardized-region-list/standardized-region-list.current.html
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.
As far as I see, those are just area names without defining anything
AreaDefinition
y that we could use.