{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "a9c794eb", "metadata": {}, "outputs": [], "source": [ "# module to get sunrise and sunset times\n", "#import nbimporter\n", "from SunTimes import rise_set_func, rise_set" ] }, { "cell_type": "code", "execution_count": 3, "id": "2a8b2103", "metadata": {}, "outputs": [], "source": [ "# modules to read NetCDF4 files\n", "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import os" ] }, { "cell_type": "code", "execution_count": 5, "id": "bfe2f7e8", "metadata": {}, "outputs": [], "source": [ "# import hourly era5 data\n", "fpath = '/tiger/scratch/gpfs/GEOCLIM/demetray/era5/era5.2m_temperature.2000-07.nc'\n", "ds = xr.open_dataset(fpath)" ] }, { "cell_type": "code", "execution_count": 6, "id": "4d4a6164", "metadata": {}, "outputs": [], "source": [ "# transform longitude [0, 360) -> [-180, 180)\n", "ds = ds.roll(longitude=ds.longitude.size//2)\n", "lon_new = ds.longitude.where(ds.longitude<180, other=ds.longitude-360).values\n", "ds = ds.assign_coords(longitude=lon_new)\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "fbfcd836-732b-40be-b9e3-1938867483d8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'longitude' (longitude: 1440)>\n",
"array([ 0. , 0.25, 0.5 , ..., -0.75, -0.5 , -0.25], dtype=float32)\n",
"Coordinates:\n",
" * longitude (longitude) float32 0.0 0.25 0.5 0.75 ... -1.0 -0.75 -0.5 -0.25array([ 0. , 0.25, 0.5 , ..., -0.75, -0.5 , -0.25], dtype=float32)
array([ 0. , 0.25, 0.5 , ..., -0.75, -0.5 , -0.25], dtype=float32)