Skip to content

Commit

Permalink
Merge pull request #97 from fredliporace/dev
Browse files Browse the repository at this point in the history
Work with two alternatives for PAN10M xmls
  • Loading branch information
fredliporace committed Aug 13, 2023
2 parents f214e74 + a1251fe commit d9c2454
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
tests:
# if: github.event_name == 'push' || github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7.9]
Expand All @@ -23,7 +23,7 @@ jobs:
# Hack to get setup-python to work on act
# https://github.com/nektos/act/issues/251#issuecomment-706412948
if [ ! -f "/etc/lsb-release" ] ; then
echo "DISTRIB_RELEASE=18.04" > /etc/lsb-release
echo "DISTRIB_RELEASE=20.04" > /etc/lsb-release
fi
# Hack needed for ES to start
if [ ! -d "/tmp/localstack/es_backup" ] ; then
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ repos:
- "click==7.1.2"

- repo: https://github.com/PyCQA/isort
rev: 5.4.2
# See https://stackoverflow.com/a/75295105/1259982 for
# rev value
rev: 5.11.5
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
6 changes: 4 additions & 2 deletions cbers2stac/elasticsearch/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Any, Dict, List, Tuple, Union

from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
from elasticsearch_dsl import Q, Search
from elasticsearch_dsl import Q, Search # pylint: disable=wrong-import-order

from cbers2stac.layers.common.utils import (
STAC_API_VERSION,
Expand All @@ -22,7 +22,9 @@
static_to_api_collection,
)
from elasticsearch import Elasticsearch, RequestsHttpConnection
from elasticsearch.helpers import bulk

from elasticsearch.helpers import bulk # isort: skip


# Get rid of "Found credentials in environment variables" messages
logging.getLogger("botocore.credentials").disabled = True
Expand Down
6 changes: 6 additions & 0 deletions cbers2stac/layers/common/cbers_2_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def build_asset(
return asset


@typing.no_type_check
def build_stac_item_keys(cbers_am, buckets):
"""
Builds a STAC item dict based on CBERS_AM metadata
Expand Down Expand Up @@ -529,6 +530,11 @@ def candidate_xml_files(xml_file: str) -> List[str]:
):
for optics in ["", "_LEFT", "_RIGHT"]:
xml_options.append(re.sub(r"_L(\d+)_", f"_L\\g<1>{optics}_", xml_file))
elif group["satellite"] == "CBERS" and group["camera"] == "PAN10M":
# CB4 PAN10M uses band4 for old INPE catalog and BAND3 for new
# catalog
xml_options.append(xml_file)
xml_options.append(re.sub(r"_BAND4", r"_BAND3", xml_file))
else:
xml_options.append(xml_file)
return xml_options
Expand Down
8 changes: 8 additions & 0 deletions test/cbers_am_2_stac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def test_candidate_xml_files():
"CBERS_4_AWFI_20220614_170_099_L4_RIGHT_BAND14.xml",
]

# CBERS4 PAN10M special case
options = candidate_xml_files("CBERS_4_PAN10M_20230301_092_100_L2_BAND4.xml")
assert len(options) == 2
assert options == [
"CBERS_4_PAN10M_20230301_092_100_L2_BAND4.xml",
"CBERS_4_PAN10M_20230301_092_100_L2_BAND3.xml",
]


def test_get_keys_from_cbers4():
"""test_get_keys_from_cbers"""
Expand Down

0 comments on commit d9c2454

Please sign in to comment.