<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Tutorial on how to use Parcels on NEMO curvilinear grids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Parcels also supports [curvilinear grids](https://www.nemo-ocean.eu/doc/node108.html) such as those used in the [NEMO models](https://www.nemo-ocean.eu/).\n",
    "\n",
    "We will be using the example data in the `NemoCurvilinear_data/` directory. These fiels are a purely zonal flow on an aqua-planet (so zonal-velocity is 1 m/s and meridional-velocity is 0 m/s everywhere, and no land). However, because of the curvilinear grid, the `U` and `V` fields vary north of 26N."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from parcels import FieldSet, ParticleSet, JITParticle, ParticleFile, plotTrajectoriesFile\n",
    "from parcels import AdvectionRK4\n",
    "import numpy as np\n",
    "from datetime import timedelta as delta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can create a `FieldSet` just like we do for normal grids. Note that we need to provide an extra filename for the `mesh_mask` file that holds information on the Curvilinear grid."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/delandmeter/anaconda2/envs/py2_parcels/lib/python2.7/site-packages/xarray/conventions.py:416: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using dummy netCDF4.datetime objects instead, reason: dates out of range\n",
      "  result = decode_cf_datetime(example_value, units, calendar)\n",
      "/Users/delandmeter/anaconda2/envs/py2_parcels/lib/python2.7/site-packages/xarray/conventions.py:435: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using dummy netCDF4.datetime objects instead, reason: dates out of range\n",
      "  calendar=self.calendar)\n",
      "WARNING: Casting lon data to np.float32\n",
      "WARNING: Casting lat data to np.float32\n",
      "WARNING: Casting time data to np.float64\n",
      "WARNING: Casting depth data to np.float32\n"
     ]
    }
   ],
   "source": [
    "filenames = {'U': 'NemoCurvilinear_data/U_purely_zonal-ORCA025_grid_U.nc4',\n",
    "             'V': 'NemoCurvilinear_data/V_purely_zonal-ORCA025_grid_V.nc4',\n",
    "             'mesh_mask': 'NemoCurvilinear_data/mesh_mask.nc4'}\n",
    "variables = {'U': 'U',\n",
    "             'V': 'V'}\n",
    "dimensions = {'lon': 'glamf', 'lat': 'gphif'}\n",
    "field_set = FieldSet.from_nemo(filenames, variables, dimensions, mesh='spherical', allow_time_extrapolation=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the `FieldSet.from_nemo()` function assumes some default values for the `mesh_mask` file. If your `mesh_mask` file has different variables and dimensions, you can set these with a dictionary such as the default one below, and add that as `dimensions=dimensions` to the call of `FieldSet.from_nemo()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "variables['mesh_mask'] = {'cosU': 'cosU',\n",
    "                          'sinU': 'sinU',\n",
    "                          'cosV': 'cosV',\n",
    "                          'sinV': 'sinV'}\n",
    "dimensions['mesh_mask'] = {'U': {'lon': 'glamu', 'lat': 'gphiu'},\n",
    "                           'V': {'lon': 'glamv', 'lat': 'gphiv'},\n",
    "                           'F': {'lon': 'glamf', 'lat': 'gphif'}}"
   ]<commit_msg>Removing info about mesh_mask dimensions and variables from curvilinear tutorial<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Tutorial on how to use Parcels on NEMO curvilinear grids"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Parcels also supports [curvilinear grids](https://www.nemo-ocean.eu/doc/node108.html) such as those used in the [NEMO models](https://www.nemo-ocean.eu/).\n",
    "\n",
    "We will be using the example data in the `NemoCurvilinear_data/` directory. These fiels are a purely zonal flow on an aqua-planet (so zonal-velocity is 1 m/s and meridional-velocity is 0 m/s everywhere, and no land). However, because of the curvilinear grid, the `U` and `V` fields vary north of 26N."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from parcels import FieldSet, ParticleSet, JITParticle, ParticleFile, plotTrajectoriesFile\n",
    "from parcels import AdvectionRK4\n",
    "import numpy as np\n",
    "from datetime import timedelta as delta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can create a `FieldSet` just like we do for normal grids. Note that we need to provide an extra filename for the `mesh_mask` file that holds information on the Curvilinear grid."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/delandmeter/anaconda2/envs/py2_parcels/lib/python2.7/site-packages/xarray/conventions.py:416: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using dummy netCDF4.datetime objects instead, reason: dates out of range\n",
      "  result = decode_cf_datetime(example_value, units, calendar)\n",
      "/Users/delandmeter/anaconda2/envs/py2_parcels/lib/python2.7/site-packages/xarray/conventions.py:435: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using dummy netCDF4.datetime objects instead, reason: dates out of range\n",
      "  calendar=self.calendar)\n",
      "WARNING: Casting lon data to np.float32\n",
      "WARNING: Casting lat data to np.float32\n",
      "WARNING: Casting time data to np.float64\n",
      "WARNING: Casting depth data to np.float32\n"
     ]
    }
   ],
   "source": [
    "filenames = {'U': 'NemoCurvilinear_data/U_purely_zonal-ORCA025_grid_U.nc4',\n",
    "             'V': 'NemoCurvilinear_data/V_purely_zonal-ORCA025_grid_V.nc4',\n",
    "             'mesh_mask': 'NemoCurvilinear_data/mesh_mask.nc4'}\n",
    "variables = {'U': 'U',\n",
    "             'V': 'V'}\n",
    "dimensions = {'lon': 'glamf', 'lat': 'gphif'}\n",
    "field_set = FieldSet.from_nemo(filenames, variables, dimensions, mesh='spherical', allow_time_extrapolation=True)"
   ]
{'fraction_non_alphanumeric': 0.1490646634261305, 'fraction_numerical': 0.01399322433348063, 'mean_word_length': 3.150366748166259, 'pattern_counts': {'":': 54, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972917', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2278, 'n_words': 604}