import numpy as np
import rasterio
Rasterio with NetCDF, VSIS3, and earthaccess
def open_data():
= "NETCDF:earthaccess_data/20020601090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc:analysed_sst"
src with rasterio.open(src) as src_da:
= src_da.read(1, masked=True)
ma = ma.astype("float32", casting="unsafe")
ma 0], out=ma, casting="unsafe")
np.multiply(ma, src_da.scales[0], out=ma, casting="unsafe")
np.add(ma, src_da.offsets[return ma.filled(fill_value=np.nan)
if __name__ == "__main__":
= open_data() da