Source code for pycif.plugins.datastreams.meteos.dummy_csv.read

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pandas as pd
import xarray as xr
import numpy as np


[docs] def read(meteo, name, varnames, dates, files, **kwargs): """Reads meteorology and links to the working directory Args: meteo (dictionary): dictionary defining the domain. Should include dirmeteo to be able to read the meteorology datei (datetime.datetime): initial date for the inversion window datef (datetime.datetime): end date for the inversion window workdir (str): path to the working directory where meteo files should be copied logfile (str): path to the log file **kwargs (dictionary): extra arguments Return: None """ ref_file = "" ref_meteo = pd.DataFrame() for dd, ff in zip(dates, files): if ff != ref_file: ds = pd.read_csv(ff, index_col="date", parse_dates=True) ref_meteo = pd.concat([ref_meteo, ds.loc[[dd[0]]]]) xmod = xr.DataArray( ref_meteo[name].values[:, np.newaxis, np.newaxis, np.newaxis], coords={"time": ref_meteo[name].index.values}, dims=("time", "lev", "lat", "lon") ) return xmod