Commit 7daf662f authored by Elise Potier's avatar Elise Potier
Browse files

VPRM inputs cleaning and doc

parent 4b1a2352
Write here the README about the plugin.
Example of relevant information: type of files treated, including format of names and shape of data, time resolution, and any specific treatment that prevents the plugin from working with another type of files.
Use rst syntax since this README will be automatically displayed in the documentation
This module read VPRM netcdf daily files at hourly resolution
It need corner file in the same directory as the flux files
......@@ -21,4 +20,13 @@ input_arguments = {
"default": "let's say it's not mandatory",
"accepted": str
"corners_file": {
"doc": ""
"file of the corner coordinates"
"assumed in the same directory as data"
"accepted": str,
"default": 'corners_5km'
......@@ -36,9 +36,6 @@ def fetch(ref_dir, ref_file, input_dates, target_dir, tracer=None, **kwargs):
if os.path.isfile(files_3d[0]):
list_dates[dd] = [[dd, dd + datetime.timedelta(hours=1)]]
#list_dates[dd] = [[dd + i*datetime.timedelta(hours=1) for i in range(24)]]
#list_dates[dd] = [dates_3d]
list_files[dd] = [files_3d]
# the to fetch is a forecast
......@@ -47,6 +44,4 @@ def fetch(ref_dir, ref_file, input_dates, target_dir, tracer=None, **kwargs):[0], target_file)
return list_files, list_dates
......@@ -20,7 +20,6 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
# setup of the domain in section "Initializes domain"
print('Here, read the horizontal grid e.g. longitudes and latitudes')
# Looking for a reference file to read lon/lat in
list_file = glob.glob("{}/*nc".format(ref_dir))
......@@ -45,8 +44,7 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
raise Exception(
"VPRM domain could not be initialized as no file was found"
print('Domain file for template fluxes:',domain_file)
print('Order the centers and corners latitudes and longitudes increasing order')
print('Domain file for VPRM fluxes:',domain_file)
# Read lon/lat in
nc = xr.open_dataset(domain_file, decode_times=False)
......@@ -62,18 +60,13 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
nlon = lon.shape[1]
nlat = lat.shape[0]
info("nlon : {}".format(nlon))
corner_file = "{}/{}".format(ref_dir, '')
cornersf = tracer.corners_file
corner_file = "{}/{}".format(ref_dir, cornersf)
info('corner_file: {}'.format(corner_file))
# Read lon/lat in corner_file
nc = xr.open_dataset(corner_file, decode_times=False)
lonc = nc["XLONG_C"].values[0,:,:]
latc = nc["XLAT_C"].values[0,:,:]
info("nlonc : {}".format(lonc.shape[0]))
#print('Here, read the vertical information, from the same file as the horizontal information or from another')
#print('Get the number of vertical levels')
#print('Get or deduce the coefficients XXX et si on n\'est pas en sigma??XXX from bottom to top.')
#print('If no vetical dimension for emissions, provide dummy vertical')
punit = "Pa"
nlevs = 1
sigma_a = np.array([0])
......@@ -103,15 +96,12 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
Setup.load_setup(setup, level=1)
# if lon and lat are vectors, convert into a grid with
# zlon, zlat = np.meshgrid(lon, lat)
setup.domain.zlon = lon # longitudes of centers
setup.domain.zlat = lat # latitudes of centers
setup.domain.zlonc = lonc # longitudes of corners
setup.domain.zlatc = latc # latitudes of corners
return setup.domain
......@@ -6,7 +6,6 @@ import xarray as xr
from netCDF4 import Dataset
from .....utils.netcdf import readnc
from logging import info
def read(
......@@ -19,32 +18,25 @@ def read(
"""Get fluxes from raw files and load them into a pyCIF
"""Get fluxes from VPRM files and load them into a pyCIF
# list of the various fields read:
data = []
outdate = []
for dd, ff in zip(dates, files):
print('Here put the reading of ', [varnames],' in ',ff,' for ',dd)
print('Reading of ', [varnames],' in ',ff,' for ',dd)
nc = xr.open_dataset(ff[0], decode_times=False)
read_field = nc[varnames][dd[0].hour].values
print('e.g. get a 3d array read_field')
# if only one level for emissions, create the axis:
xmod = xr.DataArray(
np.array(data)[:, np.newaxis, ...],
coords={"time": outdate},
dims=("time", "lev", "lat", "lon"),
return xmod
Markdown is supported
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