Source code for pycif.plugins.datastreams.meteos.lmdz_massflx_old.read
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from .....utils.netcdf import readnc
[docs]
def read(
self,
name,
varnames,
dates,
tracdir,
tracfile,
interpol_flx=False,
tracer=None,
model=None,
filetypes=["defstoke", "fluxstoke", "fluxstokev", "phystoke"],
**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
filetypes ([str]): list of file radicals to copy in the working
directory
**kwargs (dictionary): extra arguments
Return:
????????
Notes: At some point, include option to compute mass fluxes for LMDz,
with different physics What is needed to do that? Possible only on CCRT?
Flexibility to define new domains Can be very heavy and not necessarily
relevant
"""
filetype = "defstoke"
for date in dates:
meteo_file = f"{filetype}.an{date.year}.m{date.month:02d}.nc"
target = os.path.join(tracdir, meteo_file)
# If the 'defstoke_file' input argument is provided
target = getattr(self, "defstoke_file", target)
if not os.path.isfile(target):
# Trying without the date in filename
target = os.path.join(tracdir, "defstoke.nc")
# Loading information on time steps
if not hasattr(self, "offtstep"):
variables = readnc(target, ["dtvr", "istdyn"])
offtstep = variables[0][0, 0] * variables[1][0, 0]
self.offtstep = offtstep