Skip to content

Commit

Permalink
switch to ref/sec for insar_isce_burst_job
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestfwilliams committed Aug 21, 2024
1 parent d880064 commit d68ed11
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.0.0]

### Changed
* The `insar_isce_burst_job` so that it takes a `reference` and `secondary` scene as input, not `granule1` and `granule2`.

## [7.0.1]

### Removed
Expand Down
28 changes: 17 additions & 11 deletions src/hyp3_sdk/hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime, timezone
from functools import singledispatchmethod
from getpass import getpass
from typing import List, Literal, Optional, Union
from typing import Iterable, List, Literal, Optional, Union
from urllib.parse import urljoin
from warnings import warn

Expand Down Expand Up @@ -424,16 +424,16 @@ def prepare_insar_job(cls,
return job_dict

def submit_insar_isce_burst_job(self,
granule1: str,
granule2: str,
reference: Union[str, Iterable[str]],
secondary: Union[str, Iterable[str]],
name: Optional[str] = None,
apply_water_mask: bool = False,
looks: Literal['20x4', '10x2', '5x1'] = '20x4') -> Batch:
"""Submit an InSAR ISCE burst job.
Args:
granule1: The first granule (scene) to use
granule2: The second granule (scene) to use
reference: The reference granule (older scene) to use
secondary: The secondary granule (younger scene) to use
name: A name for the job
apply_water_mask: Sets pixels over coastal waters and large inland waterbodies
as invalid for phase unwrapping
Expand All @@ -449,16 +449,16 @@ def submit_insar_isce_burst_job(self,

@classmethod
def prepare_insar_isce_burst_job(cls,
granule1: str,
granule2: str,
reference: Union[str, Iterable[str]],
secondary: Union[str, Iterable[str]],
name: Optional[str] = None,
apply_water_mask: bool = False,
looks: Literal['20x4', '10x2', '5x1'] = '20x4') -> dict:
"""Prepare an InSAR ISCE burst job.
Args:
granule1: The first granule (scene) to use
granule2: The second granule (scene) to use
reference: The reference granule (older scene) to use
secondary: The secondary granule (younger scene) to use
name: A name for the job
apply_water_mask: Sets pixels over coastal waters and large inland waterbodies
as invalid for phase unwrapping
Expand All @@ -468,11 +468,17 @@ def prepare_insar_isce_burst_job(cls,
A dictionary containing the prepared InSAR ISCE burst job
"""
job_parameters = locals().copy()
for key in ['cls', 'granule1', 'granule2', 'name']:
for key in ['cls', 'reference', 'secondary', 'name']:
job_parameters.pop(key)

if isinstance(reference, str):
reference = [reference]

if isinstance(secondary, str):
secondary = [secondary]

job_dict = {
'job_parameters': {'granules': [granule1, granule2], **job_parameters},
'job_parameters': {'reference': reference, 'secondary': secondary, **job_parameters},
'job_type': 'INSAR_ISCE_BURST',
}
if name is not None:
Expand Down
21 changes: 14 additions & 7 deletions tests/test_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,30 @@ def test_prepare_insar_job():


def test_prepare_insar_isce_burst_job():
assert HyP3.prepare_insar_isce_burst_job(granule1='my_granule1', granule2='my_granule2') == {
assert HyP3.prepare_insar_isce_burst_job(reference='ref_granule1', secondary='sec_granule2') == {
'job_type': 'INSAR_ISCE_BURST',
'job_parameters': {
'granules': ['my_granule1', 'my_granule2'],
'reference': ['ref_granule1'],
'secondary': ['sec_granule2'],
'apply_water_mask': False,
'looks': '20x4',
}
},
}
assert HyP3.prepare_insar_isce_burst_job(granule1='my_granule1', granule2='my_granule2', name='my_name',
apply_water_mask=True, looks='10x2') == {
assert HyP3.prepare_insar_isce_burst_job(
reference=['ref_granule1', 'ref_granule2'],
secondary=['sec_granule1', 'sec_granule2'],
name='my_name',
apply_water_mask=True,
looks='10x2',
) == {
'job_type': 'INSAR_ISCE_BURST',
'name': 'my_name',
'job_parameters': {
'granules': ['my_granule1', 'my_granule2'],
'reference': ['ref_granule1', 'ref_granule2'],
'secondary': ['sec_granule1', 'sec_granule2'],
'apply_water_mask': True,
'looks': '10x2',
}
},
}


Expand Down

0 comments on commit d68ed11

Please sign in to comment.