Source code for pycif.plugins.domains.flexpart.read_domain

import numpy as np


[docs] def read_grid(domain, **kwargs): """Read the FLEXPART domain from coordinate text files. .. note:: This function is not currently used in practice: ``read_grid`` always raises ``AttributeError`` (``ficlon``/``ficlat`` are not defined in ``input_arguments``), so ``create_domain`` is called as the fallback. Loads 1-D longitude and latitude arrays from ``domain.ficlon`` / ``domain.ficlat``, derives half-step corners, and builds 2-D meshgrids. Sets on *domain*: ``nlon``, ``nlat``, ``zlon``, ``zlat``, ``zlonc``, ``zlatc``. Args: domain: FLEXPART domain plugin instance. **kwargs: unused. """ zlon = np.loadtxt(domain.ficlon) zlat = np.loadtxt(domain.ficlat) nlon = zlon.size nlat = zlat.size # Corner coordinates dlon = np.ptp(zlon) / (nlon - 1) / 2. zlonc = zlon - dlon zlonc = np.append(zlonc, zlonc[-1] + 2 * dlon) dlat = np.ptp(zlat) / (nlat - 1) / 2. zlatc = zlat - dlat zlatc = np.append(zlatc, zlatc[-1] + 2 * dlat) # Meshgrids zlon, zlat = np.meshgrid(zlon, zlat) zlonc, zlatc = np.meshgrid(zlonc, zlatc) # Saving information to domain attributes domain.nlon = nlon domain.nlat = nlat domain.zlon = zlon domain.zlat = zlat domain.zlonc = zlonc domain.zlatc = zlatc