Commit 4e419284 authored by Antoine Berchet's avatar Antoine Berchet
Browse files

CAMS working for interpolation

parent 8d625035
......@@ -15,8 +15,9 @@ _fullname = "CAMS netcdf files"
input_arguments={
"aibi_name": {
"doc": "to choose ai bi vertical coordinate names"
" instead of hyam and hybm",
"doc": "To choose ai/bi vertical coordinate names"
" instead of hyam and hybm; this depends on the version of the CAMS "
"product to be read",
"default": False,
"accepted": bool
},
......
......@@ -6,6 +6,7 @@ import xarray as xr
from .....utils.classes.setup import Setup
import copy
def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
# Looking for a reference file to read lon/lat in
......@@ -67,6 +68,7 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
else :
sigma_a = nc["hyam"].values
sigma_b = nc["hybm"].values
nlevs = sigma_a.size
# Initializes domain
......
......@@ -31,16 +31,16 @@ def read(
comp_type: type of boundary conditions to generate
"""
if ddi is None:
raise Exception("CAMS netCDF read function was called "
"without specifying ddi")
# Variable name to extract
var2extract = name
if varnames != "":
var2extract = varnames
# Reading fields for periods within the simulation window
xout = []
opened_file = ""
......@@ -49,7 +49,7 @@ def read(
if dd_file != opened_file:
ds = xr.open_dataset(dd_file)
opened_file = dd_file
ntimes = ds.dims["time"]
freq = pd.DatetimeIndex([dd[0]]).days_in_month[0] * 24 / ntimes
......@@ -59,13 +59,13 @@ def read(
lat = ds['latitude']
conc = ds[var2extract].values[date_index]
if lat[1] < lat[0] and conc.ndim==4:
if lat[1] < lat[0] and conc.ndim == 4:
conc = conc[:, :, ::-1, :]
elif lat[1] < lat[0] and conc.ndim==3:
conc = conc[ :, ::-1, :]
elif lat[1] < lat[0] and conc.ndim == 3:
conc = conc[:, ::-1, :]
xout.append(conc)
xmod = xr.DataArray(
np.array(xout),
coords={"time": np.array(dates)[:, 0]},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment