{ "cells": [ { "cell_type": "markdown", "id": "9812f46e-d8c2-44ee-9776-5130b6fbc72a", "metadata": {}, "source": [ "# Notebook example on how to read-only with xarray files on the metno s3 store\n", "\n", "key, secret key and endpoint can also be used to browse the store in jupyterlab bucket explorer" ] }, { "cell_type": "code", "execution_count": 39, "id": "97b3aeb3-2da9-48e8-a562-b9437abcca87", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['escience2022/Ada',\n", " 'escience2022/Antoine',\n", " 'escience2022/Dominic',\n", " 'escience2022/ESA_SMOS_sss',\n", " 'escience2022/Remy',\n", " 'escience2022/Sara',\n", " 'escience2022/Zhihong']" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import s3fs\n", "import xarray as xr\n", "import s3fs\n", "s3 = s3fs.S3FileSystem(key=\"K1CQ7M1DMTLUFK182APD\", \n", " secret=\"3JuZAQm5I03jtpijCpHOdkAsJDNLNfZxBpM15Pi0\", \n", " client_kwargs=dict(endpoint_url=\"https://rgw.met.no\"))\n", "s3.ls('escience2022')" ] }, { "cell_type": "code", "execution_count": 40, "id": "177d2f7f-f6c3-4ebd-8906-50690b205819", "metadata": {}, "outputs": [], "source": [ "s3path = \"s3://escience2022/Ada/OBS-ESACCI-OC/OBS_ESACCI-OC_sat_fv3.1_Omon_chl_199709-201712.nc\"" ] }, { "cell_type": "code", "execution_count": 41, "id": "ae14eaa0-6e8c-4e2f-af43-e21d4fdcedde", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 244, lat: 720, lon: 1440, bnds: 2)\n", "Coordinates:\n", " * time (time) datetime64[ns] 1997-09-04 1997-10-01 ... 2017-12-01\n", " * lat (lat) float32 -89.88 -89.62 -89.38 -89.12 ... 89.38 89.62 89.88\n", " * lon (lon) float32 0.125 0.375 0.625 0.875 ... 359.1 359.4 359.6 359.9\n", " depth float64 1.0\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " chl (time, lat, lon) float32 ...\n", " time_bnds (time, bnds) datetime64[ns] 1997-08-21T12:00:00 ... 2017-12-16\n", " lat_bnds (lat, bnds) float64 -90.0 -89.75 -89.75 ... 89.75 89.75 90.0\n", " lon_bnds (lon, bnds) float64 0.0 0.25 0.25 0.5 ... 359.5 359.8 359.8 360.0\n", "Attributes: (12/13)\n", " comment: Data binned using 6 by 6 cells average\n", " history: Created on 2019-05-22 14:28:23\n", " host: n020.cluster.net\n", " mip: Omon\n", " modeling_realm: sat\n", " project_id: OBS\n", " ... ...\n", " source: ftp://oc-cci-data:ELaiWai8ae@oceancolour.org/occci-v3.1/...\n", " tier: 2\n", " title: ESACCI-OC data reformatted for ESMValTool v2.0a1\n", " user: ans033\n", " version: fv3.1\n", " Conventions: CF-1.5