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

# Abrir arquivo NetCDF
ds = xr.open_dataset("mdepth_hycom_corrected.nc")

# Selecionar variável
var_name = "mdepth"  # nome da variável
var = ds[var_name]

# Detectar automaticamente fill/missing values
fill = var.attrs.get('_FillValue') or var.attrs.get('missing_value')

# Substituir valores de fill por NaN
if fill is not None:
    var = var.where(var != fill)

# Plot
plt.figure(figsize=(8,6))
var.plot(cmap='viridis')  # ou outro cmap de sua preferência
plt.title(f"{var_name} sem fill values")
plt.show()
