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