|
10 | 10 | from dswx_sar.common import _masking_with_ancillary |
11 | 11 | from dswx_sar.common._refine_with_bimodality import ( |
12 | 12 | remove_false_water_bimodality_parallel, |
13 | | - fill_gap_water_bimodality_parallel |
| 13 | + fill_gap_water_bimodality_parallel, |
| 14 | + write_ref_land_from_landcover_and_wbd_streaming |
14 | 15 | ) |
15 | 16 | from dswx_sar.nisar.dswx_ni_runconfig import ( |
16 | 17 | _get_parser, |
@@ -57,29 +58,25 @@ def run(cfg): |
57 | 58 | # read landcover map |
58 | 59 | landcover_map_tif_str = os.path.join( |
59 | 60 | outputdir, 'interpolated_landcover.tif') |
60 | | - landcover_map = _dswx_sar_util.read_geotiff(landcover_map_tif_str) |
| 61 | + |
| 62 | + landcover_map_tif_str = os.path.join(outputdir, "interpolated_landcover.tif") |
| 63 | + reference_water_gdal_str = os.path.join(outputdir, "interpolated_wbd.tif") |
| 64 | + |
61 | 65 | landcover_label = _masking_with_ancillary.get_label_landcover_esa_10() |
62 | 66 |
|
63 | | - reference_water_gdal_str = os.path.join(outputdir, 'interpolated_wbd.tif') |
| 67 | + ref_land_str = os.path.join(outputdir, f"landcover_not_water_{pol_str}.tif") |
64 | 68 |
|
65 | | - # Identify the non-water area from Landcover map |
66 | | - if 'openSea' in landcover_label: |
67 | | - landcover_not_water = (landcover_map != landcover_label['openSea']) &\ |
68 | | - (landcover_map != landcover_label['Permanent water bodies']) |
69 | | - else: |
70 | | - landcover_not_water = \ |
71 | | - (landcover_map != landcover_label['Permanent water bodies']) &\ |
72 | | - (landcover_map != landcover_label['No_data']) |
73 | | - |
74 | | - ref_land_str = os.path.join(outputdir, |
75 | | - f'landcover_not_water_{pol_str}.tif') |
76 | | - _dswx_sar_util.save_raster_gdal( |
77 | | - data=landcover_not_water, |
78 | | - output_file=ref_land_str, |
79 | | - geotransform=im_meta['geotransform'], |
80 | | - projection=im_meta['projection'], |
81 | | - scratch_dir=outputdir) |
82 | | - del landcover_not_water, landcover_map |
| 69 | + write_ref_land_from_landcover_and_wbd_streaming( |
| 70 | + landcover_path=landcover_map_tif_str, |
| 71 | + wbd_path=reference_water_gdal_str, |
| 72 | + out_path=ref_land_str, |
| 73 | + geotransform=im_meta["geotransform"], |
| 74 | + projection=im_meta["projection"], |
| 75 | + landcover_label=landcover_label, |
| 76 | + wbd_threshold=5.0, |
| 77 | + block_x=2048, |
| 78 | + block_y=2048, |
| 79 | + ) |
83 | 80 |
|
84 | 81 | # If the landcover is non-water, |
85 | 82 | # compute the bimnodality one more time |
@@ -168,7 +165,7 @@ def main(): |
168 | 165 | return |
169 | 166 |
|
170 | 167 | if flag_first_file_is_text: |
171 | | - cfg = RunConfig.load_from_yaml(args.input_yaml[0], 'dswx_s1', args) |
| 168 | + cfg = RunConfig.load_from_yaml(args.input_yaml[0], 'dswx_ni', args) |
172 | 169 |
|
173 | 170 | processing_cfg = cfg.groups.processing |
174 | 171 | pol_mode = processing_cfg.polarization_mode |
|
0 commit comments