Source code for pycif.plugins.datastreams.fluxes.CarbonMonitor.get_domain

import numpy as np
from logging import debug

from .....utils.classes.setup import Setup
from .....utils.classes.domains import Domain


[docs] def get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None): """Build a synthetic global regular lat/lon domain. Unlike most other flux plugins, this does not read a reference file: the grid is built purely from ``tracer.nlon``/``tracer.nlat``, spanning a fixed -90/90 latitude and -180/180 longitude extent, with a single dummy vertical (surface) level. Args: ref_dir (str): unused, kept for interface compatibility. ref_file (str): unused, kept for interface compatibility. input_interval (list): unused, kept for interface compatibility. target_dir (str): unused, kept for interface compatibility. tracer: the tracer Plugin, giving access to ``nlon``/``nlat``. Returns: Domain: a domain class object, with the definition of the center grid cells coordinates, as well as corners. """ nlon = tracer.nlon nlat = tracer.nlat print(nlon, nlat) lat_max = 90 lat_min = -90 lon_min = -180 lon_max = 180 dlat = (lat_max - lat_min) / nlat dlon = (lon_max - lon_min) / nlon latc = [lat_min + x*dlat for x in range(nlat+1)] lonc = [lon_min + x*dlon for x in range(nlon+1)] zlonc, zlatc = np.meshgrid(lonc, latc) print(zlonc.shape) lat = [lat_min + dlat / 2 + x*dlat for x in range(nlat)] lon = [lon_min + dlon / 2 + x*dlon for x in range(nlon)] zlon, zlat = np.meshgrid(lon, lat) print(zlon.shape) # Initializes domain # Vertical definition (surface level) pressure_unit = "Pa" nlev = 1 sigma_a_mid = np.array([0]) sigma_b_mid = np.array([1]) # Put it to a domain Plugin domain = Domain(nlon=nlon, nlat=nlat, zlon=zlon, zlat=zlat, zlonc=zlonc, zlatc=zlatc, nlev=nlev, pressure_unit=pressure_unit, sigma_b_mid=sigma_b_mid, sigma_a_mid=sigma_a_mid, ) return domain