{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "'''\n", "\n", "This code is part of the SIPN2 project focused on improving sub-seasonal to seasonal predictions of Arctic Sea Ice. \n", "If you use this code for a publication or presentation, please cite the reference in the README.md on the\n", "main page (https://github.com/NicWayand/ESIO). \n", "\n", "Questions or comments should be addressed to nicway@uw.edu\n", "\n", "Copyright (c) 2018 Nic Wayand\n", "\n", "GNU General Public License v3.0\n", "\n", "\n", "'''\n", "\n", "# Standard Imports\n", "import os\n", "import xarray as xr\n", "import pandas as pd\n", "\n", "# ESIO Imports\n", "from esio import EsioData as ed\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "E = ed.EsioData.load()\n", "\n", "file_in = os.path.join(E.obs['NSIDC_extent']['native'], 'N_seaice_extent_daily_v3.0.csv')\n", "file_out = os.path.join(E.obs['NSIDC_extent']['sipn_nc'], 'N_seaice_extent_daily_v3.0.nc')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dateparse = lambda x: pd.datetime.strptime(x, '%Y %m %d')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(file_in,\n", " skiprows=1,\n", " parse_dates={'datetime': ['YYYY', ' MM', ' DD']}, date_parser=dateparse)\n", "df.set_index('datetime', inplace=True)\n", "df.columns = ['Extent','Missing','Source']\n", "ds = xr.Dataset.from_dataframe(df)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "ds.Extent.attrs['units'] = '10^6 sq km'\n", "ds.Extent.attrs['Missing'] = '10^6 sq km'" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/disk/sipn/nicway/anaconda3/envs/esio/lib/python3.6/site-packages/dask/utils.py:1010: UserWarning: Deprecated, see dask.base.get_scheduler instead\n", " warnings.warn(\"Deprecated, see dask.base.get_scheduler instead\")\n" ] } ], "source": [ "ds.to_netcdf(file_out)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "3.6.4 esio", "language": "python", "name": "esio" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }