Source code for pycif.plugins.datastreams.fields.noaa_glob_avg.read

import datetime
import os

import numpy as np
import xarray as xr
from netCDF4 import Dataset

from .....utils.netcdf import readnc


[docs] def read( self, name, varnames, dates, files, interpol_flx=False, comp_type=None, **kwargs ): """Get fluxes from pre-computed fluxes and load them into a pyCIF variables Args: self: the fluxes Plugin name: the name of the component tracdir, tracfile: flux directory and file format dates: list of dates to extract interpol_flx (bool): if True, interpolates fluxes at time t from values of surrounding available files """ trcr_data = [] trcr_dates = [] for dd, ff in zip(dates, files): tmp = readnc(ff, [self.varname_init]) trcr_data.append(tmp[0]) trcr_dates.append(dd[0]) # Putting in DataArray xmod = xr.DataArray( trcr_data, coords={"time": trcr_dates}, dims=("time", "lev", "lat", "lon") ) # Converting ppb to ppm for pycif xmod /= 1e3 return xmod