Commit 39431e78 authored by BorjaEst's avatar BorjaEst
Browse files

Add log text at utils module

parent 2dc2df7b
......@@ -4,6 +4,9 @@ import os
import yaml
import netCDF4
import xarray as xr
import logging
logger = logging.getLogger('o3skim.utils')
......@@ -12,15 +15,18 @@ def cd(newdir):
prevdir = os.getcwd()
logger.debug("Temp dir change to: '%s'", newdir)
logger.debug("Restore directory: '%s'", prevdir)
def load(yaml_file):
"""Loads the .yaml file with the sources configurations"""
with open(yaml_file, "r") as ymlfile:
return yaml.load(ymlfile)
config = yaml.load(ymlfile)
logging.debug("Configuration data: %s", config)
return config
def create_empty_netCDF(fname):
......@@ -34,5 +40,6 @@ def to_netcdf(path, name, dataset):
"""Creates or appends data to named netcdf files"""
years, dsx = zip(*dataset.groupby("time.year"))
fnames = [path + "/" + name + "" % y for y in years]"Save dataset into: %s", fnames)
[create_empty_netCDF(fn) for fn in fnames if not os.path.isfile(fn)]
xr.save_mfdataset(dsx, fnames, mode='a')
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