{ "cells": [ { "cell_type": "markdown", "id": "5f02ac0c", "metadata": {}, "source": [ "# Example: convert DEPHY forcing to WRF-LES forcing\n", "\n", "This code reads the COMBLE-MIP LES/SCM forcing file that is supplied in the DEPHY format and writes input files that are formatted for WRF-LES (ASCII and NetCDF)\n", "\n", "Contributed by Tim Juliano from NCAR, last updated on 12/1/23" ] }, { "cell_type": "markdown", "id": "8164704b", "metadata": {}, "source": [ "### Import libraries" ] }, { "cell_type": "code", "execution_count": 1, "id": "b6e2c74e", "metadata": { "tags": [] }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "from netCDF4 import Dataset, stringtochar\n", "import os\n", "import datetime as dt" ] }, { "cell_type": "markdown", "id": "e68367d4-8f12-4f95-aeef-87f036044975", "metadata": { "tags": [] }, "source": [ "## Specify local write directory\n", "\n", "If on the ARM JupyterHub, it is recommended to create and specify a local directory that is outside of the COMBLE-MIP repository to write input files in your model's format\n", "\n", "If on the ARM JupyterHub, these files can be conveniently downloaded to your local machine and will remain when you log out" ] }, { "cell_type": "code", "execution_count": 2, "id": "1d3ba6b7-b104-41ec-83a5-dd0f7a331e3a", "metadata": { "tags": [] }, "outputs": [], "source": [ "my_write_dir = '../../../my_input_files/'" ] }, { "cell_type": "markdown", "id": "e495d40a-bcec-4a67-812d-88ff33d51f3e", "metadata": { "tags": [] }, "source": [ "## Read the COMBLE-MIP forcing file\n", "\n", "NOTE: ERROR 1 message can be ignored" ] }, { "cell_type": "code", "execution_count": 3, "id": "1190a330-4b1d-4b69-a2db-3cadc1712b26", "metadata": { "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR 1: PROJ: proj_create_from_database: Open of /opt/conda/share/proj failed\n" ] }, { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 21, lev: 136, zw_grid: 160)\n", "Coordinates:\n", " t0 datetime64[ns] 2020-03-12T22:00:00\n", " lat float32 74.5\n", " lon float32 9.9\n", " * time (time) datetime64[ns] 2020-03-12T22:00:00 ... 2020-03-13T1...\n", " * lev (lev) float64 18.17 37.83 59.35 ... 6.851e+04 7.117e+04\n", " * zw_grid (zw_grid) float64 0.0 20.0 45.0 ... 6.89e+03 6.95e+03 7e+03\n", "Data variables: (12/19)\n", " pressure (lev) float64 ...\n", " u (lev) float64 ...\n", " v (lev) float64 ...\n", " temp (lev) float64 ...\n", " theta (lev) float64 ...\n", " qv (lev) float64 ...\n", " ... ...\n", " theta_nudging (time, lev) float64 ...\n", " qv_nudging (time, lev) float64 ...\n", " w_nudging (time, lev) float64 ...\n", " ts (time) float64 ...\n", " lat_ref (time) float32 ...\n", " lon_ref (time) float32 ...\n", "Attributes: (12/20)\n", " title: Forcing and initial conditions for 13 March 20...\n", " reference: https://arm-development.github.io/comble-mip/\n", " authors: Timothy W. Juliano (NCAR/RAL, tjuliano@ucar.ed...\n", " version: Created on 2023-12-01\n", " format_version: DEPHY SCM format version 2.0\n", " script: create_comble_forcing_v2.3.ipynb\n", " ... ...\n", " z0h: 5.5e-6 m\n", " surface_forcing_moisture: none\n", " z0q: 5.5e-6 m\n", " surface_forcing_wind: z0\n", " z0: 9.0e-4 m\n", " lat: 74.5 deg N