{ "cells": [ { "cell_type": "markdown", "id": "032b441f-3c1f-47c4-aa3e-9604f3f9604f", "metadata": {}, "source": [ "### Sea Surface Temperature Update\n", "\n", "Updates SSTs in model dump files during an AUS2200 run. Useful for creating runs in which SST evolves over time according to known historical data." ] }, { "cell_type": "code", "execution_count": 1, "id": "536e05d0-caab-42dc-be02-25dd5f1ca5e2", "metadata": {}, "outputs": [], "source": [ "import iris\n", "import mule\n", "import xarray as xr\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "id": "5dbb0ae7-2685-45e3-baf7-56817b2cae68", "metadata": {}, "outputs": [], "source": [ "dump_fn = '/scratch/ly62/dr4292/cylc-run/u-cs142-20160603T0000-continuous-140E-evolvingSST/share/cycle/20160606T1800Z/aus2200/d0198/RA3/ics/umnsaa_da006'\n", "dump_out = '/scratch/ly62/dr4292/cylc-run/u-cs142-20160603T0000-continuous-140E-evolvingSST/share/cycle/20160606T1800Z/aus2200/d0198/RA3/ics/umnsaa_da006_newsst'\n", "era5_fn = '/scratch/ly62/dr4292/cylc-run/u-cs142-20160603T0000-continuous-140E-evolvingSST/share/cycle/20160606T1800Z/ec/um/ec_cb006'" ] }, { "cell_type": "code", "execution_count": 3, "id": "4550de27-01d1-4b97-b171-f2397126dfb1", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/g/data/hh5/public/apps/cms_conda/envs/analysis3-24.01/lib/python3.10/site-packages/iris/fileformats/_ff.py:722: _WarnComboLoadingDefaulting: The stash code m01s00i060 is on a grid 22 which has not been explicitly handled by the fieldsfile loader. Assuming the data is on a P grid.\n", " warnings.warn(\n" ] } ], "source": [ "cubes = iris.load(dump_fn)" ] }, { "cell_type": "code", "execution_count": 4, "id": "e3270e2f-bc23-4ee4-9ea9-e3416809c008", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/g/data/hh5/public/apps/cms_conda/envs/analysis3-24.01/lib/python3.10/site-packages/iris/fileformats/_ff.py:722: _WarnComboLoadingDefaulting: The stash code m01s00i060 is on a grid 22 which has not been explicitly handled by the fieldsfile loader. Assuming the data is on a P grid.\n", " warnings.warn(\n" ] } ], "source": [ "era5 = iris.load(era5_fn)" ] }, { "cell_type": "code", "execution_count": 5, "id": "d2233fb7-da18-4507-afdb-70e3ce974465", "metadata": {}, "outputs": [], "source": [ "for f in cubes:\n", " s=f.attributes['STASH']\n", " if s.model==1 and s.section==0 and s.item == 24:\n", " um_sst = xr.DataArray.from_iris(f)\n", " break" ] }, { "cell_type": "code", "execution_count": 6, "id": "908a171e-5ab5-479d-be31-f80ebd318aee", "metadata": {}, "outputs": [], "source": [ "for f in era5:\n", " s=f.attributes['STASH']\n", " if s.model==1 and s.section==0 and s.item == 24:\n", " era5_sst = xr.DataArray.from_iris(f)\n", " break" ] }, { "cell_type": "code", "execution_count": 7, "id": "e93fe638-e98d-4e98-8a24-7a2a4f975a81", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'surface_temperature' (latitude: 2170, longitude: 2650)> Size: 23MB\n",
"dask.array<filled, shape=(2170, 2650), dtype=float32, chunksize=(2170, 2650), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * latitude (latitude) float32 9kB -49.28 -49.26 -49.24 ... -6.357 -6.337\n",
" * longitude (longitude) float32 11kB 113.8 113.8 113.8 ... 166.2 166.2\n",
" pseudo_level int64 8B ...\n",
" realization int64 8B ...\n",
" time datetime64[ns] 8B ...\n",
"Attributes:\n",
" standard_name: surface_temperature\n",
" units: K\n",
" source: Data from Met Office Unified Model\n",
" um_version: 12.2\n",
" STASH: m01s00i024<xarray.DataArray 'surface_temperature' (latitude: 2120, longitude: 2600)> Size: 22MB\n",
"dask.array<filled, shape=(2120, 2600), dtype=float32, chunksize=(2120, 2600), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * latitude (latitude) float32 8kB -48.79 -48.77 -48.75 ... -6.852 -6.832\n",
" * longitude (longitude) float32 10kB 114.3 114.3 114.3 ... 165.7 165.7\n",
" pseudo_level int64 8B ...\n",
" realization int64 8B ...\n",
" time datetime64[ns] 8B ...\n",
"Attributes:\n",
" standard_name: surface_temperature\n",
" units: K\n",
" source: Data from Met Office Unified Model\n",
" um_version: 12.2\n",
" STASH: m01s00i024<xarray.DataArray 'land_binary_mask' (latitude: 2120, longitude: 2600)> Size: 44MB\n",
"dask.array<filled, shape=(2120, 2600), dtype=int64, chunksize=(2120, 2600), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * latitude (latitude) float32 8kB -48.79 -48.77 -48.75 ... -6.852 -6.832\n",
" * longitude (longitude) float32 10kB 114.3 114.3 114.3 ... 165.7 165.7\n",
" pseudo_level int64 8B ...\n",
" realization int64 8B ...\n",
" time datetime64[ns] 8B ...\n",
"Attributes:\n",
" standard_name: land_binary_mask\n",
" source: Data from Met Office Unified Model\n",
" um_version: 12.2\n",
" STASH: m01s00i030