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

Release v0.16.0 #255

Merged
merged 15 commits into from
May 9, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename hyp3_auorift.io to prevent shadowing builtin io module
jhkennedy committed May 4, 2024
commit 3ebe930a78eac977beeb3e7d88f7746630e3683b
215 changes: 0 additions & 215 deletions src/hyp3_autorift/io.py

This file was deleted.

25 changes: 12 additions & 13 deletions src/hyp3_autorift/process.py
Original file line number Diff line number Diff line change
@@ -24,9 +24,8 @@
from netCDF4 import Dataset
from osgeo import gdal

from hyp3_autorift import geometry, image, io
from hyp3_autorift import geometry, image, utils
from hyp3_autorift.crop import crop_netcdf_product
from hyp3_autorift.utils import get_esa_credentials, upload_file_to_s3_with_publish_access_keys

log = logging.getLogger(__name__)

@@ -255,19 +254,19 @@ def apply_wallis_nodata_fill_filter(array: np.ndarray, nodata: int) -> Tuple[np.


def _apply_filter_function(image_path: str, filter_function: Callable) -> Tuple[str, Optional[str]]:
image_array, image_transform, image_projection, image_nodata = io.load_geospatial(image_path)
image_array, image_transform, image_projection, image_nodata = utils.load_geospatial(image_path)
image_array = image_array.astype(np.float32)

image_filtered, zero_mask = filter_function(image_array, image_nodata)

image_new_path = create_filtered_filepath(image_path)
_ = io.write_geospatial(image_new_path, image_filtered, image_transform, image_projection,
_ = utils.write_geospatial(image_new_path, image_filtered, image_transform, image_projection,
nodata=None, dtype=gdal.GDT_Float32)

zero_path = None
if zero_mask is not None:
zero_path = create_filtered_filepath(f'{Path(image_new_path).stem}_zeroMask{Path(image_new_path).suffix}')
_ = io.write_geospatial(zero_path, zero_mask, image_transform, image_projection,
_ = utils.write_geospatial(zero_path, zero_mask, image_transform, image_projection,
nodata=np.iinfo(np.uint8).max, dtype=gdal.GDT_Byte)

return image_new_path, zero_path
@@ -383,7 +382,7 @@ def process(
orbits.mkdir(parents=True, exist_ok=True)

if (esa_username is None) or (esa_password is None):
esa_username, esa_password = get_esa_credentials()
esa_username, esa_password = utils.get_esa_credentials()

reference_state_vec, reference_provider = downloadSentinelOrbitFile(
reference, directory=str(orbits), esa_credentials=(esa_username, esa_password)
@@ -443,9 +442,9 @@ def process(

# Reproject zero masks if necessary
if reference_zero_path and secondary_zero_path:
_, _ = io.ensure_same_projection(reference_zero_path, secondary_zero_path)
_, _ = utils.ensure_same_projection(reference_zero_path, secondary_zero_path)

reference_path, secondary_path = io.ensure_same_projection(reference_path, secondary_path)
reference_path, secondary_path = utils.ensure_same_projection(reference_path, secondary_path)

bbox = reference_metadata['bbox']
lat_limits = (bbox[1], bbox[3])
@@ -455,12 +454,12 @@ def process(
log.info(f'Secondary scene path: {secondary_path}')

scene_poly = geometry.polygon_from_bbox(x_limits=lat_limits, y_limits=lon_limits)
parameter_info = io.find_jpl_parameter_info(scene_poly, parameter_file)
parameter_info = utils.find_jpl_parameter_info(scene_poly, parameter_file)

if platform == 'S1':
isce_dem = geometry.prep_isce_dem(parameter_info['geogrid']['dem'], lat_limits, lon_limits)

io.format_tops_xml(reference, secondary, polarization, isce_dem, orbits)
utils.format_tops_xml(reference, secondary, polarization, isce_dem, orbits)

import isce # noqa
from topsApp import TopsInSAR
@@ -572,6 +571,6 @@ def main():

if args.publish_bucket:
prefix = get_opendata_prefix(product_file)
upload_file_to_s3_with_publish_access_keys(product_file, args.publish_bucket, prefix)
upload_file_to_s3_with_publish_access_keys(browse_file, args.publish_bucket, prefix)
upload_file_to_s3_with_publish_access_keys(thumbnail_file, args.publish_bucket, prefix)
utils.upload_file_to_s3_with_publish_access_keys(product_file, args.publish_bucket, prefix)
utils.upload_file_to_s3_with_publish_access_keys(browse_file, args.publish_bucket, prefix)
utils.upload_file_to_s3_with_publish_access_keys(thumbnail_file, args.publish_bucket, prefix)
6 changes: 3 additions & 3 deletions src/hyp3_autorift/s1_correction.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
from hyp3lib.get_orb import downloadSentinelOrbitFile
from hyp3lib.scene import get_download_url

from hyp3_autorift import geometry, io
from hyp3_autorift import geometry, utils
from hyp3_autorift.process import DEFAULT_PARAMETER_FILE, get_s1_primary_polarization
from hyp3_autorift.utils import get_esa_credentials
from hyp3_autorift.vend.testGeogrid_ISCE import loadParsedata, runGeogrid
@@ -44,10 +44,10 @@ def generate_correction_data(
lat_limits, lon_limits = geometry.bounding_box(f'{scene}.zip', polarization=polarization, orbits=orbits)

scene_poly = geometry.polygon_from_bbox(x_limits=lat_limits, y_limits=lon_limits)
parameter_info = io.find_jpl_parameter_info(scene_poly, parameter_file)
parameter_info = utils.find_jpl_parameter_info(scene_poly, parameter_file)

isce_dem = geometry.prep_isce_dem(parameter_info['geogrid']['dem'], lat_limits, lon_limits)
io.format_tops_xml(scene, scene, polarization, isce_dem, orbits)
utils.format_tops_xml(scene, scene, polarization, isce_dem, orbits)

reference_meta = loadParsedata(str(scene_path), orbit_dir=orbits, aux_dir=orbits, buffer=buffer)

Loading