Skip to content

Commit

Permalink
Fix missing vrt
Browse files Browse the repository at this point in the history
  • Loading branch information
gr4n0t4 committed May 19, 2023
1 parent f2bd113 commit 3fe7761
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
63 changes: 36 additions & 27 deletions ERS_NRB/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,30 +263,6 @@ def nrb_processing(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None
gs_path = finder(nrbdir, [r'gs\.tif$'], regex=True)[0]
measure_paths = finder(nrbdir, ['[hv]{2}-g-lin.tif$'], regex=True)

###################################################################################################################
# log-scaled gamma nought & color composite
print("log-scaled gamma nought & color composite")
if len(measure_paths) > 1:
log_vrts = []
for item in measure_paths:
log = item.replace('lin.tif', 'log.vrt')
lin = item.replace('lin.tif', 'lin.vrt')

log_vrts.append(log)
if not os.path.isfile(lin):
ancil.vrt_pixfun(src=[item, gs_path], dst=lin, fun='mul',
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)
ancil.vrt_relpath(lin)

if not os.path.isfile(log):
ancil.vrt_pixfun(src=lin, dst=log, fun='log10', scale=10,
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)

cc_path = re.sub('[hv]{2}', 'cc', measure_paths[0]).replace('.tif', '.vrt')
cc_path = re.sub('[hv]{2}', 'cc', log_vrts[0])
ancil.create_rgb_vrt(outname=cc_path, infiles=measure_paths, overviews=overviews,
overview_resampling=ovr_resampling)
###################################################################################################################
# Data mask
print("Data mask")
if not config['dem_type'] == 'GETASSE30' and not os.path.isfile(wbm):
Expand All @@ -295,7 +271,7 @@ def nrb_processing(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None
dm_path = gs_path.replace('-gs.tif', '-dm.tif')
with Raster(gs_path) as ras_gs:
extent = ras_gs.extent

###################################################################################################################
ancil.create_data_mask(outname=dm_path, valid_mask_list=snap_dm_tile_overlap, src_files=files,
extent=extent, epsg=epsg, driver=driver, creation_opt=write_options['layoverShadowMask'],
overviews=overviews, overview_resampling=ovr_resampling, wbm=wbm)
Expand All @@ -307,12 +283,12 @@ def nrb_processing(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None
extent=extent, epsg=epsg, driver=driver, creation_opt=write_options['acquisitionImage'],
overviews=overviews)
###################################################################################################################
# sigma nought RTC
# sigma & gamma nought RTC
print("sigma nought RTC")
for item in measure_paths:
sigma0_rtc_lin = item.replace('g-lin.tif', 's-lin.vrt')
sigma0_rtc_log = item.replace('g-lin.tif', 's-log.vrt')

if not os.path.isfile(sigma0_rtc_lin):
ancil.vrt_pixfun(src=[item, gs_path], dst=sigma0_rtc_lin, fun='mul',
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)
Expand All @@ -322,7 +298,40 @@ def nrb_processing(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None
ancil.vrt_pixfun(src=sigma0_rtc_lin, dst=sigma0_rtc_log, fun='log10', scale=10,
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)

gamma0_rtc_log = item.replace('lin.tif', 'log.vrt')
gamma0_rtc_lin = item.replace('lin.tif', 'lin.vrt')

if not os.path.isfile(gamma0_rtc_lin):
ancil.vrt_pixfun(src=[item, gs_path], dst=gamma0_rtc_lin, fun='mul',
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)
ancil.vrt_relpath(gamma0_rtc_lin)

if not os.path.isfile(gamma0_rtc_log):
ancil.vrt_pixfun(src=gamma0_rtc_lin, dst=gamma0_rtc_log, fun='log10', scale=10,
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)
###################################################################################################################
# log-scaled gamma nought & color composite
if len(measure_paths) > 1:
print("log-scaled gamma nought & color composite")
log_vrts = []
for item in measure_paths:
log = item.replace('lin.tif', 'log.vrt')
lin = item.replace('lin.tif', 'lin.vrt')
log_vrts.append(log)
## The file should be already present (previous step)
if not os.path.isfile(lin):
ancil.vrt_pixfun(src=[item, gs_path], dst=lin, fun='mul',
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)
ancil.vrt_relpath(lin)
## The file should be already present (previous step)
if not os.path.isfile(log):
ancil.vrt_pixfun(src=lin, dst=log, fun='log10', scale=10,
options={'VRTNodata': 'NaN'}, overviews=overviews, overview_resampling=ovr_resampling)

cc_path = re.sub('[hv]{2}', 'cc', measure_paths[0]).replace('.tif', '.vrt')
cc_path = re.sub('[hv]{2}', 'cc', log_vrts[0])
ancil.create_rgb_vrt(outname=cc_path, infiles=measure_paths, overviews=overviews,
overview_resampling=ovr_resampling)
####################################################################################################################
# metadata
print("metadata")
Expand Down
5 changes: 5 additions & 0 deletions docs/about/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.1.8 | 2023-05-19
------------------
* Fix missing vrt
`Full Changelog <https://github.com/SAR-ARD/ERS_NRB/compare/0.1.7...0.1.8>`_

0.1.7 | 2023-05-09
------------------
* Fix metadata clipping
Expand Down
2 changes: 1 addition & 1 deletion docs/general/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ repository for available versions.

::

pip install git+https://github.com/SAR-ARD/ERS_NRB.git@0.1.7
pip install git+https://github.com/SAR-ARD/ERS_NRB.git@0.1.8

0 comments on commit 3fe7761

Please sign in to comment.