Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
synergy
o3skim
Commits
ac73a291
Commit
ac73a291
authored
Sep 30, 2020
by
BorjaEst
Browse files
Merge branch '21-rename-vrm_zm-to-vmro3_zm'
parents
3c3fb088
b86fbd19
Changes
5
Hide whitespace changes
Inline
Side-by-side
o3skim/sources.py
View file @
ac73a291
...
...
@@ -34,17 +34,17 @@ class Model:
if
'tco3_zm'
in
variables
:
logger
.
debug
(
"Load 'tco3_zm' data"
)
self
.
__get_tco3_zm
(
**
variables
)
if
'v
r
m_zm'
in
variables
:
logger
.
debug
(
"Load 'v
r
m_zm' data"
)
self
.
__get_v
r
m_zm
(
**
variables
)
if
'vm
ro3
_zm'
in
variables
:
logger
.
debug
(
"Load 'vm
ro3
_zm' data"
)
self
.
__get_vm
ro3
_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
,
'_v
r
m_zm'
):
logger
.
debug
(
"Skim 'v
r
m_zm' data"
)
utils
.
to_netcdf
(
path
,
"v
r
m_zm"
,
self
.
_v
r
m_zm
)
if
hasattr
(
self
,
'_vm
ro3
_zm'
):
logger
.
debug
(
"Skim 'vm
ro3
_zm' data"
)
utils
.
to_netcdf
(
path
,
"vm
ro3
_zm"
,
self
.
_vm
ro3
_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 'v
r
m_zm'"
)
def
__get_v
r
m_zm
(
self
,
v
r
m_zm
,
**
kwarg
):
"""Gets and standarises the v
r
m_zm data"""
fnames
=
glob
.
glob
(
v
r
m_zm
[
'dir'
]
+
"/*.nc"
)
@
utils
.
return_on_failure
(
"Error when loading 'vm
ro3
_zm'"
)
def
__get_vm
ro3
_zm
(
self
,
vm
ro3
_zm
,
**
kwarg
):
"""Gets and standarises the vm
ro3
_zm data"""
fnames
=
glob
.
glob
(
vm
ro3
_zm
[
'dir'
]
+
"/*.nc"
)
with
xr
.
open_mfdataset
(
fnames
)
as
dataset
:
dataset
=
dataset
.
rename
({
v
r
m_zm
[
'name'
]:
'v
r
m_zm'
,
v
r
m_zm
[
'coordinades'
][
'time'
]:
'time'
,
v
r
m_zm
[
'coordinades'
][
'plev'
]:
'plev'
,
v
r
m_zm
[
'coordinades'
][
'lat'
]:
'lat'
,
v
r
m_zm
[
'coordinades'
][
'lon'
]:
'lon'
})[
'v
r
m_zm'
].
to_dataset
()
self
.
_v
r
m_zm
=
dataset
.
mean
(
dim
=
'lon'
)
vm
ro3
_zm
[
'name'
]:
'vm
ro3
_zm'
,
vm
ro3
_zm
[
'coordinades'
][
'time'
]:
'time'
,
vm
ro3
_zm
[
'coordinades'
][
'plev'
]:
'plev'
,
vm
ro3
_zm
[
'coordinades'
][
'lat'
]:
'lat'
,
vm
ro3
_zm
[
'coordinades'
][
'lon'
]:
'lon'
})[
'vm
ro3
_zm'
].
to_dataset
()
self
.
_vm
ro3
_zm
=
dataset
.
mean
(
dim
=
'lon'
)
sources_example.yaml
View file @
ac73a291
...
...
@@ -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 v
r
m_zm) which datasets are
# This model has 2 variables (tco3_zm and vm
ro3
_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
# - v
r
m_zm_[YEAR].nc: With v
r
m skimmed data
# - vm
ro3
_zm_[YEAR].nc: With vm
ro3
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 v
r
m data
# Represents the information related to vm
ro3
data
# [FIXED_KEY -- OPTIONAL]
v
r
m_zm
:
# Variable name for v
r
m array inside the dataset
vm
ro3
_zm
:
# Variable name for vm
ro3
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 v
r
m data.
# Coordinades description for vm
ro3
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 v
r
m data.
# The model ERA-5 has only information tco3 data, there is no vm
ro3
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 v
r
m_zm) but in
# This case of ERA-i indeed has 2 variables (tco3_zm and vm
ro3
_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
# - v
r
m_zm_[YEAR].nc: With v
r
m skimmed data
# - vm
ro3
_zm_[YEAR].nc: With vm
ro3
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
:
t
o
c3
name
:
tc
o
3
# 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 v
r
m data
# Represents the information related to vm
ro3
data
# [FIXED_KEY -- OPTIONAL]
v
r
m_zm
:
# Variable name for v
r
m array inside the dataset
vm
ro3
_zm
:
# Variable name for vm
ro3
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 v
r
m data.
# Coordinades description for vm
ro3
data.
# [FIXED_KEY -- MANDATORY]:
coordinades
:
# [FIXED_KEY -- MANDATORY]: [CORRECT_VALUE -- MANDATORY]
...
...
tests/sources_base.yaml
View file @
ac73a291
...
...
@@ -7,7 +7,7 @@ CCMI-1:
time
:
time
lat
:
lat
lon
:
lon
v
r
m_zm
:
vm
ro3
_zm
:
name
:
vmro3
dir
:
Ccmi/mon/vmro3
coordinades
:
...
...
@@ -18,7 +18,7 @@ CCMI-1:
ECMWF
:
ERA-5
:
tco3_zm
:
name
:
t
o
c3
name
:
tc
o
3
dir
:
Ecmwf/Era5
coordinades
:
lon
:
longitude
...
...
@@ -32,7 +32,7 @@ ECMWF:
time
:
time
lat
:
latitude
lon
:
longitude
v
r
m_zm
:
vm
ro3
_zm
:
name
:
vmro3
dir
:
Ecmwf/Erai
coordinades
:
...
...
tests/sources_err.yaml
View file @
ac73a291
ECMWF
:
ERA-i
:
v
r
m_zm
:
# Correct variable
vm
ro3
_zm
:
# Correct variable
name
:
vmro3
dir
:
Ecmwf/Erai
coordinades
:
...
...
tests/test_o3skim.py
View file @
ac73a291
...
...
@@ -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 v
r
m_zm asserts
self
.
assertTrue
(
'time'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_v
r
m_zm
.
coords
)
self
.
assertTrue
(
'plev'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_v
r
m_zm
.
coords
)
self
.
assertTrue
(
'lat'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_v
r
m_zm
.
coords
)
self
.
assertFalse
(
'lon'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_v
r
m_zm
.
coords
)
# CCMI-1 vm
ro3
_zm asserts
self
.
assertTrue
(
'time'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_vm
ro3
_zm
.
coords
)
self
.
assertTrue
(
'plev'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_vm
ro3
_zm
.
coords
)
self
.
assertTrue
(
'lat'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_vm
ro3
_zm
.
coords
)
self
.
assertFalse
(
'lon'
in
ds
[
'CCMI-1'
].
_models
[
'IPSL'
].
_vm
ro3
_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/v
r
m_zm_2000.nc"
))
self
.
assertTrue
(
os
.
path
.
exists
(
"output/CCMI-1_IPSL/vm
ro3
_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/v
r
m_zm_2000.nc"
))
self
.
assertTrue
(
os
.
path
.
exists
(
"output/ECMWF_ERA-i/vm
ro3
_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/v
r
m_zm_2000.nc"
))
self
.
assertTrue
(
os
.
path
.
exists
(
"output/ECMWF_ERA-i/vm
ro3
_zm_2000.nc"
))
# Checks the original data has not been modified
self
.
assert_with_backup
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment