Skip to content

Commit

Permalink
Merge pull request #15 from ASFHyP3/release_review
Browse files Browse the repository at this point in the history
Release review feedback incorporation
  • Loading branch information
forrestfwilliams authored Oct 8, 2024
2 parents 9b179c5 + cf8a489 commit 4815b73
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 189 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ Where `-125 41 -124 42` is a desired bounding box in **integer** `minx, miny, ma

For TMS generation ASF will be using 1x1 degree tiles.

The resulting products have the name format:
`METADATA_{orbit direction}_{upper left corner in lon/lat}.tif`.
For example:
`METADATA_ASCENDING_W125N42.tif`

### Create a Short Wavelength Cumulative Displacement tile
The `generate_sw_disp_tile` CLI command can be used to generate a cumulative displacement geotiff:
```bash
generate_sw_disp_tile METADATA_ASCENDING_W125N42.tif --begin-date 20170901 --end-date 20171231
generate_sw_disp_tile METADATA_ASCENDING_W125N42.tif 20170901 20171231
```
Where `METADATA_ASCENDING_W125N42.tif` is the path to the frame metadata tile you want to generate a Short Wavelength Cumulative Displacement tile for, and `--begin-date` and `--end-date` specify the date range you want to generate the Short Wavelength Cumulative Displacement tile for.
Where `METADATA_ASCENDING_W125N42.tif` is the path to the frame metadata tile you want to generate a Short Wavelength Cumulative Displacement tile for, and `20170901`/`20171231` specify the start/end of the secondary date search range to generate a tile for in format `%Y%m%d`.

The resulting products have the name format:
`SW_CUMUL_DISP_{start date search range}_{stop data search range}_{orbit direction}_{upper left corner in lon/lat}.tif`
For example:
`SW_CUMUL_DISP_20170901_20171231_ASCENDING_W125N42.tif`

### Create a Tile Map
The `create_tile_map` CLI command generates a directory with small .png tiles from a list of rasters in a common projection, following the OSGeo Tile Map Service Specification, using gdal2tiles: https://gdal.org/en/latest/programs/gdal2tiles.html
Expand Down
180 changes: 0 additions & 180 deletions src/opera_disp_tms/generate_coh_tiles.py

This file was deleted.

16 changes: 11 additions & 5 deletions src/opera_disp_tms/generate_frame_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,17 @@ def create_granule_metadata_dict(granule: Granule) -> dict:
return frame_metadata


def add_frames_to_tile(frames: Iterable[Frame], tile_path: Path) -> None:
def create_metadata_tile(bbox: Iterable[int], frames: Iterable[Frame], tile_path: Path) -> None:
"""Add frame information to a frame metadata tile
Args:
bbox: The bounding box to create the frame for in the (minx, miny, maxx, maxy) in EPSG:4326, integers only.
frames: The frames to add to the tile
tile_path: The path to the frame metadata tile
"""
validate_bbox(bbox)
cal_data = find_california_dataset()
create_empty_frame_tile(bbox, tile_path)
frame_metadata = {}
for frame in frames:
relevant_granules = [x for x in cal_data if x.frame_id == frame.frame_id]
Expand All @@ -243,6 +246,11 @@ def add_frames_to_tile(frames: Iterable[Frame], tile_path: Path) -> None:
frame_metadata[str(frame.frame_id)] = create_granule_metadata_dict(first_granule)
burn_frame(frame, tile_path)

if frame_metadata == {}:
warnings.warn('No granules are available for this tile. The tile will not be created.')
tile_path.unlink()
return

tile_ds = gdal.Open(str(tile_path), gdal.GA_Update)
# Not all frames will be in the final array, so we need to find the included frames
band = tile_ds.GetRasterBand(1)
Expand All @@ -267,21 +275,19 @@ def create_tile_for_bbox(bbox: Iterable[int], direction: str) -> Path:
Returns:
The path to the frame metadata tile
"""
validate_bbox(bbox)
direction = direction.upper()
if direction not in ['ASCENDING', 'DESCENDING']:
raise ValueError('Direction must be either "ASCENDING" or "DESCENDING"')
out_path = Path(create_product_name(['metadata'], direction, bbox) + '.tif')
relevant_frames = intersect(bbox=bbox, orbit_pass=direction, is_north_america=True, is_land=True)
updated_frames = [buffer_frame_geometry(x) for x in relevant_frames]
ordered_frames = reorder_frames(updated_frames)
create_empty_frame_tile(bbox, out_path)
add_frames_to_tile(ordered_frames, out_path)
create_metadata_tile(bbox, ordered_frames, out_path)
return out_path


def main():
"""CLI entrypoint
"""CLI entry point
Example: generate_frame_tile -125 41 -124 42 ascending
"""
parser = argparse.ArgumentParser(description='Create a frame metadata tile for a given bounding box')
Expand Down
2 changes: 1 addition & 1 deletion src/opera_disp_tms/generate_sw_disp_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def create_sw_disp_tile(metadata_path: Path, begin_date: datetime, end_date: dat


def main():
"""CLI entrpypoint
"""CLI entry point
Example:
generate_sw_disp_tile METADATA_ASCENDING_N41W125_N42W124.tif 20170901 20171231
"""
Expand Down
2 changes: 1 addition & 1 deletion src/opera_disp_tms/tmp_s3_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_temporary_aws_credentials(endpoint: str = 'https://cumulus-test.asf.alas


def main():
"""CLI entrypoint for getting temporary S3 credentials
"""CLI entry point for getting temporary S3 credentials
Example: get_tmp_s3_creds --endpoint https://cumulus-test.asf.alaska.edu/s3credentials
"""
parser = argparse.ArgumentParser(description='Get temporary S3 credentials')
Expand Down

0 comments on commit 4815b73

Please sign in to comment.