diff --git a/neonwranglerpy/lib/extract_hsi_to_tif.py b/neonwranglerpy/lib/extract_hsi_to_tif.py index 33c528c..7432721 100644 --- a/neonwranglerpy/lib/extract_hsi_to_tif.py +++ b/neonwranglerpy/lib/extract_hsi_to_tif.py @@ -48,16 +48,16 @@ def h5refl2array(refl_filename, remove_water_bands=True): sns_zn = hdf5_file[sitename]['Reflectance/Metadata/to-sensor_zenith_angle'][()] # get solar angles as array to leverage flightpaths mosaic flightpaths = [ - hdf5_file[sitename][ - 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'][()] + hdf5_file[sitename]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'] + [()] ] sol_zn = [ - hdf5_file[sitename][ - 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'][()] + hdf5_file[sitename]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'] + [()] ] sol_az = [ - hdf5_file[sitename][ - 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'][()] + hdf5_file[sitename]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index'] + [()] ] # turn sol_az and sol_zn into arrays sol_zn = np.array(sol_zn) @@ -68,6 +68,7 @@ def h5refl2array(refl_filename, remove_water_bands=True): sol_az[good_pixels] = solar_angles[pt][1] sol_zn[good_pixels] = solar_angles[pt][2] + # mapInfo_string = str(metadata['mapInfo']) mapInfo_split = mapInfo_string.split(",") @@ -105,9 +106,8 @@ def tile_solar_angle(full_path): file_attrs_string = str(list(hdf5_file.items())) file_attrs_string_split = file_attrs_string.split("'") sitename = file_attrs_string_split[1] - flight_paths = hdf5_file[ - sitename]["Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index" - ].attrs["Data_Files"] + flight_paths = hdf5_file[sitename][ + "Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index"].attrs["Data_Files"] flight_paths = str(flight_paths).split(",") which_paths = np.unique( hdf5_file[sitename]["Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index"] @@ -301,7 +301,8 @@ def generate_raster(h5_path, sns_az_reshaped = sns_az # No need to reshape sns_az sns_zn_reshaped = sns_zn - sol_sens_angle = np.array([sol_az_reshaped, sol_zn_reshaped, sns_az_reshaped, sns_zn_reshaped]) + sol_sens_angle = np.array( + [sol_az_reshaped, sol_zn_reshaped, sns_az_reshaped, sns_zn_reshaped]) solar_tilename = os.path.splitext( os.path.basename(rgb_filename))[0] + "_solar_sensor_angle{}.tif".format(suffix) # Save georeference crop to file