import numpy as np
import xarray as xr
import matplotlib.pyplot as plt

fill_value = 1.267651e30

# Substituir fill_value por NaN
mdepth_valid = ds.mdepth.where(ds.mdepth != fill_value, np.nan)

# Limitar a profundidade máxima para visualização
mdepth_clipped = mdepth_valid.clip(max=6000)  # máximo de 6000 m, ajuste se quiser

# Plot
plt.figure(figsize=(10,6))
im = plt.imshow(
    mdepth_clipped,
    origin='lower',           # se quiser ajustar a orientação
    cmap='viridis_r',         # invertido: profundidades maiores mais escuras
    interpolation='none'
)
plt.colorbar(im, label='Depth (m)')
plt.title('Bathymetry (mdepth) sem valores fill e com escala limitada')
plt.xlabel('Longitude index')
plt.ylabel('Latitude index')
plt.show()
