I have NetCDF files containing subdatasets with 4 dimensions: time, height, latitude, longitude.
Here is an example of the output of GDAL GetSubDatasets():
('NETCDF:"Martinique_ALT22.nc":height', '[30x30x30] height (32-bit floating-point)'),
('NETCDF:"Martinique_ALT22.nc":latitude', '[30x30] latitude (32-bit floating-point)'),
('NETCDF:"Martinique_ALT22.nc":longitude', '[30x30] longitude (32-bit floating-point)'),
('NETCDF:"Martinique_ALT22.nc":Water_Vapor_Concentration', '[2x30x30x30] Water_Vapor_Concentration (32-bit floating-point)')
When opening these subdatasets in Python with gdal.Open() and ReadAsArray(), the first two dimensions are overlapped and I get a 3 dimensions numpy array.
>>> band = gdal.Open(dataset.GetSubDatasets()[-1][0])
>>> array=band.ReadAsArray()
>>> print(array.shape)
(60, 30, 30)
I read somewhere that this is due to the GDAL raster format accepting only 3 dimensions: bands, rows, columns.
Is there a way to keep the first two dimensions separated and extract these subdatasets in 4-dimension numpy arrays?