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

Resample 30 #1

Open
wants to merge 2 commits into
base: dswx-ni-interface
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/dswx_sar/defaults/algorithm_parameter_ni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ runconfig:
# - first : choose one burst without average.
mosaic_mode: 'first'
resamp_required: True
resamp_method: 'gdal.GRA_NearestNeighbour'
resamp_method: 'nearest'
resamp_out_res_x: 30.0
resamp_out_res_y: 30.0
read_row_blk_size: 1000
Expand Down
37 changes: 19 additions & 18 deletions src/dswx_sar/mosaic_gcov_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def process_rtc_hdf5(
mosaic_prefix: str
Mosaicked output file name prefix
resamp_required: bool
Indicates whether resampling (downsampling) needs to be performed
Indicates whether resampling (downsampling) needs to be performed
on input RTC product in Geotiff.
resamp_method: str
Set GDAL.Warp() resampling algorithms based on its built-in options
Expand Down Expand Up @@ -133,7 +133,7 @@ def process_rtc_hdf5(
)
else:
layover_exist = False

# Mosaic intermediate geotiffs
nlooks_list = []
self.mosaic_rtc_geotiff(
Expand Down Expand Up @@ -244,7 +244,7 @@ def write_rtc_geotiff(
f'{scratch_dir}/{input_prefix}_{data_name}.tif'
temp_gtiff = \
f'{scratch_dir}/{input_prefix}_temp_{data_name}.tif'

# Change EPSG
change_epsg_tif(
input_tif=input_gtiff,
Expand Down Expand Up @@ -429,8 +429,7 @@ def resample_rtc(
A dataclass object representing the geographical grid
configuration for an RTC (Radar Terrain Correction) run.
resamp_method: str
Set GDAL.Warp() resampling algorithms based on its built-in options
Default = gdal.GRA_NearestNeighbour
'average', 'nearest', 'bilinear'
"""

# Check if the file exists
Expand All @@ -445,7 +444,8 @@ def resample_rtc(

# Set GDAL Warp options
# Resampling method
#gdal.GRA_Bilinear, gdal.GRA_NearestNeighbour, gdal.GRA_Cubic, gdal.GRA_Average, etc
# gdal.GRA_Bilinear, gdal.GRA_NearestNeighbour,
# gdal.GRA_Cubic, gdal.GRA_Average, etc

options = gdal.WarpOptions(
xRes=output_res_x,
Expand Down Expand Up @@ -767,13 +767,14 @@ def read_metadata_hdf5(self, input_rtc):
dswx_meta_mapping['RTC_TRACK_NUMBER']][()]
abs_orbit_number = src_h5[
dswx_meta_mapping['RTC_ABSOLUTE_ORBIT_NUMBER']][()]
input_slc_granules = src_h5[
dswx_meta_mapping['RTC_INPUT_L1_SLC_GRANULES']][(0)].decode()
# TODO : After finalzing GCOV spec, this should be revised.
# input_slc_granules = src_h5[
# dswx_meta_mapping['RTC_INPUT_L1_SLC_GRANULES']][(0)].decode()

dswx_metadata_dict = {
'ORBIT_PASS_DIRECTION': orbit_pass_dir,
'LOOK_DIRECTION': look_dir,
'INPUT_L1_SLC_GRANULES': input_slc_granules,
# 'INPUT_L1_SLC_GRANULES': input_slc_granules,
'PRODUCT_VERSION': prod_ver,
'ZERO_DOPPLER_START_TIME': zero_dopp_start,
'ZERO_DOPPLER_END_TIME': zero_dopp_end,
Expand Down Expand Up @@ -866,15 +867,15 @@ def run(cfg):

# Mosaic input RTC into output Geotiff
reader.process_rtc_hdf5(
input_list,
output_dir,
scratch_dir,
mosaic_mode,
mosaic_prefix,
resamp_required,
resamp_method,
resamp_out_res_x,
resamp_out_res_y,
input_list=input_list,
output_dir=scratch_dir,
scratch_dir=scratch_dir,
mosaic_mode=mosaic_mode,
mosaic_prefix=mosaic_prefix,
resamp_required=resamp_required,
resamp_method=resamp_method,
resamp_out_res_x=resamp_out_res_x,
resamp_out_res_y=resamp_out_res_y,
)

if __name__ == "__main__":
Expand Down
12 changes: 4 additions & 8 deletions src/dswx_sar/pre_processing_ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,11 @@ def run(cfg):
2 * temp_raster_set[1, :, :])
output_image_set.append(span)
else:
if mosaic_flag:
intensity_path = \
f'{scratch_dir}/{mosaic_prefix}_{pol}.tif'
intensity_path = \
f'{scratch_dir}/{mosaic_prefix}_{pol}.tif'

intensity = dswx_sar_util.get_raster_block(
intensity_path, block_param)
else:
intensity = dswx_sar_util.read_geotiff(
ref_filename, band_ind=polind)
intensity = dswx_sar_util.get_raster_block(
intensity_path, block_param)
# need to replace 0 value in padded area to NaN.
intensity[intensity == 0] = np.nan
if filter_flag:
Expand Down