Source code for pycif.plugins.datastreams.fluxes.wrfchem.times_in_wrf_file
import netCDF4 as nc
import datetime as dtm
[docs]
def times_in_wrf_file(filename):
"""Returns the times in netcdf file as datetime object"""
# This is from ctdas' wrfchem_helper.py
ncf = nc.Dataset(filename)
times_nc = ncf.variables["Times"][:]
ncf.close()
# Hope the utf-8 always works...
times_chr = [str(times_nc[nt, :], "utf-8")
for nt in range(times_nc.shape[0])]
times_dtm = [dtm.datetime.strptime(t_chr, "%Y-%m-%d_%H:%M:%S")
for t_chr in times_chr]
return times_dtm