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

Final GUNW 3.0 Packaging Updates #161

Merged
merged 19 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ tests/**/*.json
!tests/test_data/ref_metadata.xml
!tests/test_data/sec_manifest.xml
!tests/test_data/sec_metadata.xml
!tests/test_data/topsProc.xml

# Test for overlapping orbits
!tests/set_test_data/S1A_OPER_AUX_POEORB_OPOD_20230705T080713_V20230614T225942_20230616T005942.EOF
Expand Down
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ 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).

## [0.3.2]

### Changed
* Upgraded to `hyp3lib=>3,<4` from `>=2,<3`

## [0.3.1]

### Added
Expand All @@ -31,6 +26,9 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed
* The CLI now *requires* `frame_id` (use `frame_id = -1` for old API and what is now considered a "non"-standard product)
* Water mask now uses `tile-mate` to download and merge ESA World cover tiles on
* All water masks applied to processing/packaging use ESA 10 meter world cover: ionosphere processing, browse imagery, and global attributes associate with mean coherence
* Some function names associated to writing global attributes in the netcdf file were renamed to be more descriptive e.g. `record_stats` became `record_stats_as_global_attrs`

## [0.3.0]

Expand Down
368 changes: 0 additions & 368 deletions Untitled.ipynb

This file was deleted.

3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ dependencies:
- setuptools_scm
- shapely
- tqdm
- dem_stitcher>=2.4.0
- dem_stitcher>=2.5.5
- aiohttp # only needed for manifest and swath download
- tile_mate>=0.0.7
2 changes: 1 addition & 1 deletion isce2_topsapp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def localize_data(
# For ionospheric correction computation
if water_mask_flag:
out_water_mask = download_water_mask(
out_slc["extent"], water_name="SWBD")
out_slc["extent"], water_mask_name="esa_world_cover_2021_10m")

out_aux_cal = download_aux_cal()

Expand Down
4 changes: 2 additions & 2 deletions isce2_topsapp/delivery_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from matplotlib import cm

from isce2_topsapp.packaging import DATASET_VERSION
from isce2_topsapp.water_mask import get_water_mask_raster
from isce2_topsapp.water_mask import get_water_mask_raster_for_browse_image

TEMPLATE_DIR = (Path(__file__).parent/'templates').absolute()
SCHEMA_PATH = TEMPLATE_DIR/'daac_ingest_schema.json'
Expand Down Expand Up @@ -94,7 +94,7 @@ def get_wrapped_ifg(nc_path: Path) -> np.ndarray:
unw, _ = open_science_grid(nc_path, 'unwrappedPhase')

mask_cc = get_connected_component_mask(cc)
mask_water = get_water_mask_raster(profile)
mask_water = get_water_mask_raster_for_browse_image(profile)
mask = mask_cc | mask_water

wrapped = np.zeros(mask.shape)
Expand Down
29 changes: 24 additions & 5 deletions isce2_topsapp/localize_mask.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from pathlib import Path

import numpy as np
import rasterio
from isce.components.isceobj.Alos2Proc.runDownloadDem import download_wbd
from shapely.geometry import box
from tile_mate import get_raster_from_tiles

from .localize_dem import fix_image_xml


def download_water_mask(
extent: list, water_name: str = "SWBD", buffer: float = 0.1
extent: list, water_mask_name: str = "esa_world_cover_2021_10m", buffer: float = 0.1
) -> dict:
output_dir = Path(".").absolute()

Expand All @@ -19,7 +23,23 @@ def download_water_mask(
np.ceil(extent_buffered[3]),
]

if water_name == "SWBD":
if water_mask_name == 'esa_world_cover_2021_10m':
X, p = get_raster_from_tiles(extent_buffered, tile_shortname='esa_world_cover_2021')
mask = (X == 80).astype(np.uint8)
mask[mask.astype(bool)] = 255
mask_filename = 'water_mask_derived_from_esa_world_cover_2021_10m.geo'

# Remove esa nodata, change gdal driver to ISCE, and generate VRT as in localize DEM
p_isce = p.copy()
p_isce['nodata'] = None
p_isce['driver'] = 'ISCE'

with rasterio.open(mask_filename, 'w', **p_isce) as ds:
ds.write(mask)

mask_filename = fix_image_xml(mask_filename)

elif water_mask_name == "SWBD":
# Download SRTM-SWDB water mask
# Water mask dataset extent
# Latitude S55 - N60
Expand All @@ -38,8 +58,7 @@ def download_water_mask(
'Skip downloading water mask!!')
mask_filename = ''

elif water_name == "GSHHS":
# from water_mask import get_water_mask_raster
raise NotImplementedError("TODO, GSHHS not yet available")
else:
raise NotImplementedError("Water mask not available")

return {"water_mask": mask_filename}
Loading
Loading