Firsly we need to install nassecery libaries if those are not installed

In [ ]:
!pip3 install numpy
!pip3 install matplotlib
!pip3 install mitgcmutils

You can check if the required library is installed or not

In [ ]:
try:
    import MITgcmutils
    print("mitgcmutils is installed.")
except ImportError:
    print("mitgcmutils is not installed.")

Once the libaraires are installed, its time to import to our environment

In [ ]:
import numpy as np
import matplotlib.pyplot as plt
import MITgcmutils as mit

Now, we assigned the path to a variable for further uses. Remember to remove .meta or .data from the path name.

In [ ]:
meta_file = '/usr/bin/soft/MITgcm/verification/global_ocean.cs32x15/run/T.0000072000.001.001'
data_file = '/usr/bin/soft/MITgcm/verification/global_ocean.cs32x15/run/T.0000072000.001.001'

We will use the MITgcmutils to read the data. You can see that the data conatins a 3D data which is (Time, Lat, Lon).

In [ ]:
# Read data using mitgcmutils
data = mit.rdmds(data_file)
data
In [ ]:
data.shape

Here, it is a simple visualization.

In [ ]:
# Define the figure size
fig, ax = plt.subplots(figsize=(20, 3))

# Plot the data
im = ax.imshow(data[1], cmap='viridis')
cbar = plt.colorbar(im, ax=ax)


# Customize the plot
ax.set_title('MITgcm Output Data')
plt.show()