@@ -48,21 +48,25 @@ def h5refl2array(refl_filename, remove_water_bands=True):
48
48
sns_zn = hdf5_file [sitename ]['Reflectance/Metadata/to-sensor_zenith_angle' ][()]
49
49
# get solar angles as array to leverage flightpaths mosaic
50
50
flightpaths = [
51
- hdf5_file [sitename ]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ]
52
- [()]
51
+ hdf5_file [sitename ][
52
+ 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ] [()]
53
53
]
54
54
sol_zn = [
55
- hdf5_file [sitename ]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ]
56
- [()]
55
+ hdf5_file [sitename ][
56
+ 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ] [()]
57
57
]
58
58
sol_az = [
59
- hdf5_file [sitename ]['Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ]
60
- [()]
59
+ hdf5_file [sitename ][
60
+ 'Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index' ] [()]
61
61
]
62
- for pt in range ( len ( solar_angles )):
63
- sol_az [ flightpaths == solar_angles [ pt ][ 0 ]] = solar_angles [ pt ][ 1 ]
64
- sol_zn [ flightpaths == solar_angles [ pt ][ 0 ]] = solar_angles [ pt ][ 2 ]
62
+ # turn sol_az and sol_zn into arrays
63
+ sol_zn = np . array ( sol_zn )
64
+ sol_az = np . array ( sol_az )
65
65
66
+ for pt in range (len (solar_angles )):
67
+ good_pixels = flightpaths == solar_angles [pt ][0 ]
68
+ sol_az [good_pixels ] = solar_angles [pt ][1 ]
69
+ sol_zn [good_pixels ] = solar_angles [pt ][2 ]
66
70
67
71
#
68
72
mapInfo_string = str (metadata ['mapInfo' ])
@@ -101,8 +105,9 @@ def tile_solar_angle(full_path):
101
105
file_attrs_string = str (list (hdf5_file .items ()))
102
106
file_attrs_string_split = file_attrs_string .split ("'" )
103
107
sitename = file_attrs_string_split [1 ]
104
- flight_paths = hdf5_file [sitename ]
105
- ["Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index" ].attrs ["Data_Files" ]
108
+ flight_paths = hdf5_file [
109
+ sitename ]["Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index"
110
+ ].attrs ["Data_Files" ]
106
111
flight_paths = str (flight_paths ).split ("," )
107
112
which_paths = np .unique (
108
113
hdf5_file [sitename ]["Reflectance/Metadata/Ancillary_Imagery/Data_Selection_Index" ]
@@ -291,7 +296,12 @@ def generate_raster(h5_path,
291
296
os .path .basename (rgb_filename ))[0 ] + "_hyperspectral{}.tif" .format (suffix )
292
297
293
298
# stach solar and sensor data to be used for corrections
294
- sol_sens_angle = np .array ([sol_az , sol_zn , sns_az , sns_zn ])
299
+ sol_az_reshaped = sol_az .squeeze () # Remove the extra dimension
300
+ sol_zn_reshaped = sol_zn .squeeze () # Remove the extra dimension
301
+ sns_az_reshaped = sns_az # No need to reshape sns_az
302
+ sns_zn_reshaped = sns_zn
303
+
304
+ sol_sens_angle = np .array ([sol_az_reshaped , sol_zn_reshaped , sns_az_reshaped , sns_zn_reshaped ])
295
305
solar_tilename = os .path .splitext (
296
306
os .path .basename (rgb_filename ))[0 ] + "_solar_sensor_angle{}.tif" .format (suffix )
297
307
# Save georeference crop to file
0 commit comments