Commit ac73a291 authored by BorjaEst's avatar BorjaEst
Browse files

Merge branch '21-rename-vrm_zm-to-vmro3_zm'

parents 3c3fb088 b86fbd19
......@@ -34,17 +34,17 @@ class Model:
if 'tco3_zm' in variables:
logger.debug("Load 'tco3_zm' data")
self.__get_tco3_zm(**variables)
if 'vrm_zm' in variables:
logger.debug("Load 'vrm_zm' data")
self.__get_vrm_zm(**variables)
if 'vmro3_zm' in variables:
logger.debug("Load 'vmro3_zm' data")
self.__get_vmro3_zm(**variables)
def skim(self, path):
if hasattr(self, '_tco3_zm'):
logger.debug("Skim 'tco3_zm' data")
utils.to_netcdf(path, "tco3_zm", self._tco3_zm)
if hasattr(self, '_vrm_zm'):
logger.debug("Skim 'vrm_zm' data")
utils.to_netcdf(path, "vrm_zm", self._vrm_zm)
if hasattr(self, '_vmro3_zm'):
logger.debug("Skim 'vmro3_zm' data")
utils.to_netcdf(path, "vmro3_zm", self._vmro3_zm)
@utils.return_on_failure("Error when loading 'tco3_zm'")
def __get_tco3_zm(self, tco3_zm, **kwarg):
......@@ -59,16 +59,16 @@ class Model:
})['tco3_zm'].to_dataset()
self._tco3_zm = dataset.mean(dim='lon')
@utils.return_on_failure("Error when loading 'vrm_zm'")
def __get_vrm_zm(self, vrm_zm, **kwarg):
"""Gets and standarises the vrm_zm data"""
fnames = glob.glob(vrm_zm['dir'] + "/*.nc")
@utils.return_on_failure("Error when loading 'vmro3_zm'")
def __get_vmro3_zm(self, vmro3_zm, **kwarg):
"""Gets and standarises the vmro3_zm data"""
fnames = glob.glob(vmro3_zm['dir'] + "/*.nc")
with xr.open_mfdataset(fnames) as dataset:
dataset = dataset.rename({
vrm_zm['name']: 'vrm_zm',
vrm_zm['coordinades']['time']: 'time',
vrm_zm['coordinades']['plev']: 'plev',
vrm_zm['coordinades']['lat']: 'lat',
vrm_zm['coordinades']['lon']: 'lon'
})['vrm_zm'].to_dataset()
self._vrm_zm = dataset.mean(dim='lon')
vmro3_zm['name']: 'vmro3_zm',
vmro3_zm['coordinades']['time']: 'time',
vmro3_zm['coordinades']['plev']: 'plev',
vmro3_zm['coordinades']['lat']: 'lat',
vmro3_zm['coordinades']['lon']: 'lon'
})['vmro3_zm'].to_dataset()
self._vmro3_zm = dataset.mean(dim='lon')
......@@ -22,12 +22,12 @@
# In this example, the data source has only one model, therefore it is
# expected to have only one folder output named "CCMI-1_IPSL".
#
# This model has 2 variables (tco3_zm and vrm_zm) which datasets are
# This model has 2 variables (tco3_zm and vmro3_zm) which datasets are
# located in different directories. Therefore the key 'dir' is different
# in both of them. Therefore, the output expected at "CCMI-1_IPSL" is
# 2 type of files:
# - tco3_zm_[YEAR].nc: With tco3 skimmed data
# - vrm_zm_[YEAR].nc: With vrm skimmed data
# - vmro3_zm_[YEAR].nc: With vmro3 skimmed data
#
# This is the precedded -x1- string at the output folder: '[x1]_[y-]'
......@@ -54,16 +54,16 @@ CCMI-1:
lat: lat
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
lon: lon
# Represents the information related to vrm data
# Represents the information related to vmro3 data
# [FIXED_KEY -- OPTIONAL]
vrm_zm:
# Variable name for vrm array inside the dataset
vmro3_zm:
# Variable name for vmro3 array inside the dataset
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
name: vmro3
# Path where to find the netCDF files
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
dir: Ccmi/mon/vmro3
# Coordinades description for vrm data.
# Coordinades description for vmro3 data.
# [FIXED_KEY -- MANDATORY]:
coordinades:
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
......@@ -79,16 +79,16 @@ CCMI-1:
# In this example, the data source has two models, therefore it is
# expected to have two folder outputs ["ECMWF_ERA-5", "ECMWF_ERA-i"].
#
# The model ERA-5 has only information tco3 data, there is no vrm data.
# The model ERA-5 has only information tco3 data, there is no vmro3 data.
# Therefore, only one type of files is expected at "ECMWF_ERA-5":
# - tco3_zm_[YEAR].nc: With tco3 skimmed data
#
# This case of ERA-i indeed has 2 variables (tco3_zm and vrm_zm) but in
# This case of ERA-i indeed has 2 variables (tco3_zm and vmro3_zm) but in
# this case, are located inside the same dataset files, therefore the
# key 'dir' is the same in both variables. The output expected at
# "ECMWF_ERA-5" is 2 type of files:
# - tco3_zm_[YEAR].nc: With tco3 skimmed data
# - vrm_zm_[YEAR].nc: With vrm skimmed data
# - vmro3_zm_[YEAR].nc: With vmro3 skimmed data
#
# This is the precedded -x2- string at the output folder: '[x2]_[y-]'
......@@ -102,7 +102,7 @@ ECMWF:
tco3_zm:
# Variable name for tco3 array inside the dataset
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
name: toc3
name: tco3
# Path where to find the netCDF files
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
dir: Ecmwf/Era5
......@@ -133,16 +133,16 @@ ECMWF:
lat: latitude
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
lon: longitude
# Represents the information related to vrm data
# Represents the information related to vmro3 data
# [FIXED_KEY -- OPTIONAL]
vrm_zm:
# Variable name for vrm array inside the dataset
vmro3_zm:
# Variable name for vmro3 array inside the dataset
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
name: vmro3
# Path where to find the netCDF files
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
dir: Ecmwf/Erai
# Coordinades description for vrm data.
# Coordinades description for vmro3 data.
# [FIXED_KEY -- MANDATORY]:
coordinades:
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
......
......@@ -7,7 +7,7 @@ CCMI-1:
time: time
lat: lat
lon: lon
vrm_zm:
vmro3_zm:
name: vmro3
dir: Ccmi/mon/vmro3
coordinades:
......@@ -18,7 +18,7 @@ CCMI-1:
ECMWF:
ERA-5:
tco3_zm:
name: toc3
name: tco3
dir: Ecmwf/Era5
coordinades:
lon: longitude
......@@ -32,7 +32,7 @@ ECMWF:
time: time
lat: latitude
lon: longitude
vrm_zm:
vmro3_zm:
name: vmro3
dir: Ecmwf/Erai
coordinades:
......
ECMWF:
ERA-i:
vrm_zm: # Correct variable
vmro3_zm: # Correct variable
name: vmro3
dir: Ecmwf/Erai
coordinades:
......
......@@ -78,11 +78,11 @@ class TestO3SKIM_sources(unittest.TestCase):
self.assertTrue('lat' in ds['CCMI-1']._models['IPSL']._tco3_zm.coords)
self.assertFalse('lon' in ds['CCMI-1']._models['IPSL']._tco3_zm.coords)
# CCMI-1 vrm_zm asserts
self.assertTrue('time' in ds['CCMI-1']._models['IPSL']._vrm_zm.coords)
self.assertTrue('plev' in ds['CCMI-1']._models['IPSL']._vrm_zm.coords)
self.assertTrue('lat' in ds['CCMI-1']._models['IPSL']._vrm_zm.coords)
self.assertFalse('lon' in ds['CCMI-1']._models['IPSL']._vrm_zm.coords)
# CCMI-1 vmro3_zm asserts
self.assertTrue('time' in ds['CCMI-1']._models['IPSL']._vmro3_zm.coords)
self.assertTrue('plev' in ds['CCMI-1']._models['IPSL']._vmro3_zm.coords)
self.assertTrue('lat' in ds['CCMI-1']._models['IPSL']._vmro3_zm.coords)
self.assertFalse('lon' in ds['CCMI-1']._models['IPSL']._vmro3_zm.coords)
# Checks the original data has not been modified
self.assert_with_backup()
......@@ -99,14 +99,14 @@ class TestO3SKIM_sources(unittest.TestCase):
# CCMI-1 data skim asserts
self.assertTrue(os.path.isdir("output/CCMI-1_IPSL"))
self.assertTrue(os.path.exists("output/CCMI-1_IPSL/tco3_zm_2000.nc"))
self.assertTrue(os.path.exists("output/CCMI-1_IPSL/vrm_zm_2000.nc"))
self.assertTrue(os.path.exists("output/CCMI-1_IPSL/vmro3_zm_2000.nc"))
# ECMWF data skim asserts
self.assertTrue(os.path.isdir("output/ECMWF_ERA-5"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-5/tco3_zm_2000.nc"))
self.assertTrue(os.path.isdir("output/ECMWF_ERA-i"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/tco3_zm_2000.nc"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/vrm_zm_2000.nc"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/vmro3_zm_2000.nc"))
# Checks the original data has not been modified
self.assert_with_backup()
......@@ -124,7 +124,7 @@ class TestO3SKIM_sources(unittest.TestCase):
# ECMWF data skim asserts
self.assertTrue(os.path.isdir("output/ECMWF_ERA-i"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/vrm_zm_2000.nc"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/vmro3_zm_2000.nc"))
# Checks the original data has not been modified
self.assert_with_backup()
......
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