|
8 | 8 | import h5py
|
9 | 9 | import journal
|
10 | 10 | import numpy as np
|
11 |
| -import pybind_isce3 as isce3 |
| 11 | + |
12 | 12 | from osgeo import osr
|
| 13 | + |
| 14 | +import pybind_isce3 as isce3 |
13 | 15 | from pybind_nisar.h5 import cp_h5_meta_data
|
14 | 16 | from pybind_nisar.products.readers import SLC
|
15 | 17 |
|
@@ -108,6 +110,8 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
|
108 | 110 | with h5py.File(input_hdf5, 'r', libver='latest', swmr=True) as src_h5, \
|
109 | 111 | h5py.File(output_hdf5, 'w', libver='latest', swmr=True) as dst_h5:
|
110 | 112 |
|
| 113 | + dst_h5.attrs['Conventions'] = np.string_("CF-1.8") |
| 114 | + |
111 | 115 | # Copy of identification
|
112 | 116 | identification_excludes = 'productType'
|
113 | 117 | if is_insar:
|
@@ -136,7 +140,9 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
|
136 | 140 | if is_geocoded:
|
137 | 141 | cp_h5_meta_data(src_h5, dst_h5, f'{src_meta_path}/attitude',
|
138 | 142 | f'{dst_meta_path}/attitude')
|
139 |
| - if dst != 'GCOV': |
| 143 | + if dst not in ['GCOV', 'GSLC']: |
| 144 | + # the lines below should be deleted after radar-grid |
| 145 | + # cubes are added to all L2 workflows |
140 | 146 | cp_h5_meta_data(src_h5, dst_h5,
|
141 | 147 | f'{src_meta_path}/geolocationGrid',
|
142 | 148 | f'{dst_meta_path}/radarGrid',
|
@@ -354,18 +360,20 @@ def prep_ds_gslc_gcov(cfg, dst, dst_h5):
|
354 | 360 | dst_parent_path = os.path.join(common_parent_path,
|
355 | 361 | f'{dst}/grids/frequency{freq}')
|
356 | 362 |
|
357 |
| - set_get_geo_info(dst_h5, dst_parent_path, geogrids[freq]) |
| 363 | + yds, xds = set_get_geo_info(dst_h5, dst_parent_path, geogrids[freq]) |
358 | 364 |
|
359 | 365 | # GSLC specfics datasets
|
360 | 366 | if dst == 'GSLC':
|
361 | 367 | for polarization in pol_list:
|
362 | 368 | dst_grp = dst_h5[dst_parent_path]
|
363 |
| - descr = 'Geocoded RSLC for {polarization} channel' |
| 369 | + long_name = f'geocoded single-look complex image {polarization}' |
| 370 | + descr = f'Geocoded SLC image ({polarization})' |
364 | 371 | _create_datasets(dst_grp, shape, ctype, polarization,
|
365 |
| - descr=descr, units=None, grids="projection") |
| 372 | + descr=descr, units='', grids="projection", |
| 373 | + long_name=long_name, yds=yds, xds=xds) |
366 | 374 |
|
367 | 375 | # set GCOV polarization values (diagonal values only)
|
368 |
| - if dst == 'GCOV': |
| 376 | + elif dst == 'GCOV': |
369 | 377 | pol_list = [(p + p).upper() for p in pol_list]
|
370 | 378 |
|
371 | 379 | _add_polarization_list(dst_h5, dst, common_parent_path, freq, pol_list)
|
@@ -793,8 +801,8 @@ def prep_ds_insar(cfg, dst, dst_h5):
|
793 | 801 |
|
794 | 802 | def _create_datasets(dst_grp, shape, ctype, dataset_name,
|
795 | 803 | chunks=(128, 128), descr=None, units=None, grids=None,
|
796 |
| - data=None, |
797 |
| - standard_name=None, long_name=None): |
| 804 | + data=None, standard_name=None, long_name=None, |
| 805 | + yds=None, xds=None): |
798 | 806 | if len(shape) == 1:
|
799 | 807 | if ctype == np.string_:
|
800 | 808 | ds = dst_grp.create_dataset(dataset_name,
|
@@ -822,6 +830,12 @@ def _create_datasets(dst_grp, shape, ctype, dataset_name,
|
822 | 830 | if long_name is not None:
|
823 | 831 | ds.attrs['long_name'] = np.string_(long_name)
|
824 | 832 |
|
| 833 | + if yds is not None: |
| 834 | + ds.dims[0].attach_scale(yds) |
| 835 | + |
| 836 | + if xds is not None: |
| 837 | + ds.dims[1].attach_scale(xds) |
| 838 | + |
825 | 839 |
|
826 | 840 | def _add_polarization_list(dst_h5, dst, common_parent_path, frequency, pols):
|
827 | 841 | '''
|
@@ -868,20 +882,19 @@ def set_get_geo_info(hdf5_obj, root_ds, geo_grid, z_vect=None, flag_cube=False):
|
868 | 882 | x_standard_name = "projection_x_coordinate"
|
869 | 883 | y_standard_name = "projection_y_coordinate"
|
870 | 884 |
|
871 |
| - # EPSG |
872 |
| - descr = ("EPSG code corresponding to coordinate system used" + |
873 |
| - " for representing radar grid") |
874 |
| - epsg_dataset_name = os.path.join(root_ds, 'epsg') |
875 |
| - if epsg_dataset_name in hdf5_obj: |
876 |
| - del hdf5_obj[epsg_dataset_name] |
877 |
| - epsg_dataset = hdf5_obj.create_dataset(epsg_dataset_name, |
878 |
| - data=np.array(epsg_code, "i4")) |
879 |
| - epsg_dataset.attrs["description"] = np.string_(descr) |
880 |
| - epsg_dataset.attrs["units"] = "" |
881 |
| - epsg_dataset.attrs["long_name"] = np.string_("EPSG code") |
882 |
| - |
883 |
| - if not flag_cube: |
884 |
| - |
| 885 | + if flag_cube: |
| 886 | + # EPSG |
| 887 | + descr = ("EPSG code corresponding to coordinate system used" + |
| 888 | + " for representing radar grid") |
| 889 | + epsg_dataset_name = os.path.join(root_ds, 'epsg') |
| 890 | + if epsg_dataset_name in hdf5_obj: |
| 891 | + del hdf5_obj[epsg_dataset_name] |
| 892 | + epsg_dataset = hdf5_obj.create_dataset(epsg_dataset_name, |
| 893 | + data=np.array(epsg_code, "i4")) |
| 894 | + epsg_dataset.attrs["description"] = np.string_(descr) |
| 895 | + epsg_dataset.attrs["units"] = "" |
| 896 | + epsg_dataset.attrs["long_name"] = np.string_("EPSG code") |
| 897 | + else: |
885 | 898 | # xCoordinateSpacing
|
886 | 899 | descr = (f'Nominal spacing in {x_coord_units}'
|
887 | 900 | ' between consecutive pixels')
|
|
0 commit comments