From ee88f995160ad4e7e6fbb967a45777084ad46cd1 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 15 Aug 2024 12:49:59 -0500 Subject: [PATCH 1/3] format lat/lon strings --- src/hyp3_isce2/packaging.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hyp3_isce2/packaging.py b/src/hyp3_isce2/packaging.py index 09d77bc0..dcfb5eb2 100644 --- a/src/hyp3_isce2/packaging.py +++ b/src/hyp3_isce2/packaging.py @@ -76,11 +76,11 @@ def get_product_name(reference: str, secondary: str, pixel_spacing: int, slc: bo orbit_number = ref_manifest_xml.find(relative_orbit_number_query).text.zfill(3) footprint = get_geometry_from_manifest(Path(f'{reference}.SAFE/manifest.safe')) lons, lats = footprint.exterior.coords.xy - lon_lims = [np.min(lons), np.max(lons)] - lat_lims = [np.min(lats), np.max(lats)] - lons = ['E'+str(abs(int(lon))) if lon >= 0 else 'W'+str(abs(int(lon))) for lon in lon_lims] - lats = ['N'+str(abs(int(lat))) if lat >= 0 else 'S'+str(abs(int(lat))) for lat in lat_lims] - name_parts = [platform, orbit_number, lons[0], lons[1], lats[0], lats[1]] + lat_string = lambda lat: ('N' if lat >= 0 else 'S') + f"{('%.1f' % np.abs(lat)).zfill(4)}".replace('.', '_') + lon_string = lambda lon: ('E' if lon >= 0 else 'W') + f"{('%.1f' % np.abs(lon)).zfill(5)}".replace('.', '_') + lat_lims = [lat_string(lat) for lat in [np.min(lats), np.max(lats)]] + lon_lims = [lon_string(lon) for lon in [np.min(lons), np.max(lons)]] + name_parts = [platform, orbit_number, lon_lims[0], lat_lims[0], lon_lims[1], lat_lims[1]] else: platform = reference_split[0] burst_id = reference_split[1] From 51fee239d85cb9ec57351f8da63760b7615b8b53 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 15 Aug 2024 12:58:59 -0500 Subject: [PATCH 2/3] flake8 --- src/hyp3_isce2/packaging.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hyp3_isce2/packaging.py b/src/hyp3_isce2/packaging.py index dcfb5eb2..8ab91f5b 100644 --- a/src/hyp3_isce2/packaging.py +++ b/src/hyp3_isce2/packaging.py @@ -76,8 +76,8 @@ def get_product_name(reference: str, secondary: str, pixel_spacing: int, slc: bo orbit_number = ref_manifest_xml.find(relative_orbit_number_query).text.zfill(3) footprint = get_geometry_from_manifest(Path(f'{reference}.SAFE/manifest.safe')) lons, lats = footprint.exterior.coords.xy - lat_string = lambda lat: ('N' if lat >= 0 else 'S') + f"{('%.1f' % np.abs(lat)).zfill(4)}".replace('.', '_') - lon_string = lambda lon: ('E' if lon >= 0 else 'W') + f"{('%.1f' % np.abs(lon)).zfill(5)}".replace('.', '_') + def lat_string(lat): ('N' if lat >= 0 else 'S') + f"{('%.1f' % np.abs(lat)).zfill(4)}".replace('.', '_') + def lon_string(lon): ('E' if lon >= 0 else 'W') + f"{('%.1f' % np.abs(lon)).zfill(5)}".replace('.', '_') lat_lims = [lat_string(lat) for lat in [np.min(lats), np.max(lats)]] lon_lims = [lon_string(lon) for lon in [np.min(lons), np.max(lons)]] name_parts = [platform, orbit_number, lon_lims[0], lat_lims[0], lon_lims[1], lat_lims[1]] From 4e21974f8740f8060ba729091b2a5dbe6175977c Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 15 Aug 2024 13:01:15 -0500 Subject: [PATCH 3/3] add return --- src/hyp3_isce2/packaging.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hyp3_isce2/packaging.py b/src/hyp3_isce2/packaging.py index 8ab91f5b..dc0fcf73 100644 --- a/src/hyp3_isce2/packaging.py +++ b/src/hyp3_isce2/packaging.py @@ -76,8 +76,8 @@ def get_product_name(reference: str, secondary: str, pixel_spacing: int, slc: bo orbit_number = ref_manifest_xml.find(relative_orbit_number_query).text.zfill(3) footprint = get_geometry_from_manifest(Path(f'{reference}.SAFE/manifest.safe')) lons, lats = footprint.exterior.coords.xy - def lat_string(lat): ('N' if lat >= 0 else 'S') + f"{('%.1f' % np.abs(lat)).zfill(4)}".replace('.', '_') - def lon_string(lon): ('E' if lon >= 0 else 'W') + f"{('%.1f' % np.abs(lon)).zfill(5)}".replace('.', '_') + def lat_string(lat): return ('N' if lat >= 0 else 'S') + f"{('%.1f' % np.abs(lat)).zfill(4)}".replace('.', '_') + def lon_string(lon): return ('E' if lon >= 0 else 'W') + f"{('%.1f' % np.abs(lon)).zfill(5)}".replace('.', '_') lat_lims = [lat_string(lat) for lat in [np.min(lats), np.max(lats)]] lon_lims = [lon_string(lon) for lon in [np.min(lons), np.max(lons)]] name_parts = [platform, orbit_number, lon_lims[0], lat_lims[0], lon_lims[1], lat_lims[1]]