Skip to content
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

loose the limit of only processing the NADIR scenes #42

Merged
merged 33 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea6b157
loose the limit of only processing the NADIR scenes
cirrusasf Apr 4, 2024
bf194be
update the CHANGELOG.md
cirrusasf Apr 4, 2024
e4e54aa
add test_get_stac_item function to test_main.py
cirrusasf Apr 4, 2024
2bbf4f2
add test function and test_get_landsat_pairs_for_reference_scene and…
cirrusasf Apr 5, 2024
6d9a8e4
updata CHANGELOG.md
cirrusasf Apr 5, 2024
cd637bd
Update CHANGELOG.md
cirrusasf Apr 6, 2024
5cfe39d
Update tests/landsat/test_main.py
cirrusasf Apr 6, 2024
1c9b874
modify test function code to adopt unittest mock class
cirrusasf Apr 9, 2024
3882759
remove unused data files
cirrusasf Apr 9, 2024
9d4831c
modified test to use hyp3-sdk rather than json
AndrewPlayer3 Apr 9, 2024
15ffb4f
remove unnecessary json files
AndrewPlayer3 Apr 9, 2024
173a2a4
add test_submit_pairs_for_processing function to test_main.py
cirrusasf Apr 9, 2024
db9a3dd
remove code for debug
cirrusasf Apr 9, 2024
697b880
modify main.py code
cirrusasf Apr 9, 2024
2fc4010
ruff format test_main.py
cirrusasf Apr 9, 2024
423743a
make variable name more sense
cirrusasf Apr 9, 2024
c10628d
Merge branch 'handle_off_nadir_scenes' of https://github.com/ASFHyP3/…
AndrewPlayer3 Apr 10, 2024
673457c
formatting
AndrewPlayer3 Apr 10, 2024
c49a67f
formatting
AndrewPlayer3 Apr 10, 2024
55497ef
Merge pull request #54 from ASFHyP3/off_nadir_andrew
AndrewPlayer3 Apr 10, 2024
35051b8
modify the main.py code
cirrusasf Apr 11, 2024
ae4db40
merge the test_main.py
cirrusasf Apr 11, 2024
e88799e
code style
cirrusasf Apr 11, 2024
88dca4e
modify test_main.py
cirrusasf Apr 11, 2024
a34baa2
modify the duplicate_hyp3_pairs function in the main.py
cirrusasf Apr 11, 2024
51405ba
modify duplicates function
cirrusasf Apr 11, 2024
2f3abcf
modify to satisfy ruff check
cirrusasf Apr 11, 2024
fe4c1ea
modify code to satisfy ruff format
cirrusasf Apr 11, 2024
cb91ae4
Merge branch 'develop' into handle_off_nadir_scenes
AndrewPlayer3 Apr 11, 2024
34e74cc
add sample jobs with job_status=SUCCESS to test the test_deduplicate_…
cirrusasf Apr 11, 2024
9bc3bfd
Merge branch 'handle_off_nadir_scenes' of github.com:ASFHyP3/its-live…
cirrusasf Apr 11, 2024
d0dafb2
fix ruff format
cirrusasf Apr 11, 2024
4903c60
fix job_status value to be SUCCEEDED
cirrusasf Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0]

### Fixed
- Off-naider scenes will now be processed and will only be paired with other off-nadir scenes.

## [0.3.0]

Expand Down
17 changes: 11 additions & 6 deletions landsat/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def _qualifies_for_processing(
log.log(log_level, f'{item.id} disqualifies for processing because it has too much cloud cover')
return False

if item.properties['view:off_nadir'] != 0:
log.log(log_level, f'{item.id} disqualifies for processing because it is off-nadir')
return False

log.log(log_level, f'{item.id} qualifies for processing')
return True

Expand Down Expand Up @@ -99,11 +95,16 @@ def get_landsat_pairs_for_reference_scene(
query=[
f'landsat:wrs_path={reference.properties["landsat:wrs_path"]}',
f'landsat:wrs_row={reference.properties["landsat:wrs_row"]}',
f'view:off_nadir={reference.properties["view:off_nadir"]}',
],
datetime=[reference.datetime - max_pair_separation, reference.datetime - timedelta(seconds=1)],
)

items = [item for page in results.pages() for item in page if _qualifies_for_processing(item, max_cloud_cover)]

if len(items) == 0:
return gpd.GeoDataFrame()

features = []
for item in items:
feature = item.to_dict()
Expand Down Expand Up @@ -137,8 +138,11 @@ def deduplicate_hyp3_pairs(pairs: gpd.GeoDataFrame) -> gpd.GeoDataFrame:
user_id=EARTHDATA_USERNAME,
)

df = pd.DataFrame([job.job_parameters['granules'] for job in jobs], columns=['reference', 'secondary'])

df = pd.DataFrame(
[[*job.job_parameters['granules'], *[job.job_id, job.status_code]] for job in jobs],
columns=['reference', 'secondary', 'job_id', 'status_code'],
)
df = df[df.status_code == 'SUCCEEDED']
df = df.set_index(['reference', 'secondary'])
pairs = pairs.set_index(['reference', 'secondary'])

Expand Down Expand Up @@ -192,6 +196,7 @@ def process_scene(
return sdk.Batch()

pairs = get_landsat_pairs_for_reference_scene(reference, max_pair_separation, max_cloud_cover)

log.info(f'Found {len(pairs)} pairs for {scene}')
with pd.option_context('display.max_rows', None, 'display.max_columns', None, 'display.width', None):
log.debug(pairs.loc[:, ['reference', 'secondary']])
Expand Down
Binary file added tests/data/scene1_pair.parquet
Binary file not shown.
Loading
Loading