title: trying to understand a 4d array in python read in with osgeo gdal
body: <p>I'd like to plot an array with the following dimensions: [3x3x180x360]</p>
  <p>it's a 180x360 world map with 3 different opacity layers and 3 different pressure levels. Thus, I would like to plot the map with data of 1 opacity layer at one pressure level.</p>
  <p>How can I access the array and plot the data using <code>plt.imshow()</code> for example?</p>
  <p>Visualizing the data with panoply looks the following way:
  <a href="https://i.stack.imgur.com/MjCA8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MjCA8.png" alt="enter image description here" /></a></p>
  <pre><code>import numpy as np
  from osgeo import gdal
  
  granule = &quot;CER_CldTypHist_GEO-MODIS_Edition4A_407408.202109.hdf&quot;
  hdf_file = gdal.Open(workdir_data + &quot;/&quot; + granule)
  subDatasets = hdf_file.GetSubDatasets()
  cld_amount_liq_md = gdal.Open(subDatasets[68][0]).ReadAsArray() # takes ~5min to read ...
  
  # Shape of cld_amount_liq_md after ReadAsArray() is [64800, 3, 3] hence:
  cld_amount_liq_md  = cld_amount_liq_md.reshape(180,360, 3, 3)
  
  #filtering bad data:
  cld_amount_liq_md[cld_amount_liq_md &gt; 3.40E38] = np.nan
  
  # Plotting -&gt; how can I plot the data?
  plt.imshow(cld_amount_liq_md[?,?,?] ,cmap =&quot;jet&quot;)```
  
  </code></pre>
  <p><strong>Update:</strong>
  Here's additional info due to inputs from the comments:</p>
  <ol>
  <li>How do I get the dimensions from the HDF file?</li>
  </ol>
  <pre><code>from osgeo import gdal
  
  granule = &quot;CER_CldTypHist_GEO-MODIS_Edition4A_407408.202109.hdf&quot;
  hdf_file = gdal.Open(workdir_data + &quot;/&quot; + granule)
  subDatasets = hdf_file.GetSubDatasets()
  
  j=0
  for i in subDatasets:
      print(j, i[1]) # i[0] contains the path to subdataset, i[1] the info as seen in the screenshot
      j+=1
  </code></pre>
  <p><a href="https://i.stack.imgur.com/FRCky.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FRCky.png" alt="enter image description here" /></a></p>
  <p><strong>Link to the HDF4 File</strong>
  Here's the link to the HDF4 File:
  <a href="https://wetransfer.com/downloads/98ba49567c872341f353677956fc0bcf20220708114420/bceff2" rel="nofollow noreferrer">CER_CldTypHist_GEO-MODIS_Edition4A_407408.202109.hdf</a></p>
  <p>The full variable name of the subdataset is: Monthly_Day_Averages/Cloud_Properties_for_9_Cloud_Types_Monthly_Day/cld_amount_liq_md</p>