Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toargridding
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-public
toargridding
Commits
bf926512
Commit
bf926512
authored
10 months ago
by
Simon Grasse
Browse files
Options
Downloads
Patches
Plain Diff
follow EM102 convention
parent
446ba0ce
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!11
Creation of first beta release version
,
!10
change in metadata of notebook
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/toargridding/defaultLogging.py
+4
-2
4 additions, 2 deletions
src/toargridding/defaultLogging.py
src/toargridding/metadata.py
+6
-7
6 additions, 7 deletions
src/toargridding/metadata.py
src/toargridding/static_metadata.py
+6
-3
6 additions, 3 deletions
src/toargridding/static_metadata.py
with
16 additions
and
12 deletions
src/toargridding/defaultLogging.py
+
4
−
2
View file @
bf926512
...
@@ -46,7 +46,8 @@ class toargridding_defaultLogging:
...
@@ -46,7 +46,8 @@ class toargridding_defaultLogging:
Throws an exception if the name of the handler is already known.
Throws an exception if the name of the handler is already known.
"""
"""
if
name
in
self
.
registeredHandlers
:
if
name
in
self
.
registeredHandlers
:
raise
ValueError
(
f
"
There is already a registered handler with the name
{
name
}
.
"
)
msg
=
f
"
There is already a registered handler with the name
{
name
}
.
"
raise
ValueError
(
msg
)
if
formatter
is
not
None
:
if
formatter
is
not
None
:
handler
.
setFormatter
(
formatter
)
handler
.
setFormatter
(
formatter
)
self
.
logger
.
addHandler
(
handler
)
self
.
logger
.
addHandler
(
handler
)
...
@@ -128,7 +129,8 @@ class toargridding_defaultLogging:
...
@@ -128,7 +129,8 @@ class toargridding_defaultLogging:
"""
"""
sn
=
Path
(
scriptName
)
sn
=
Path
(
scriptName
)
if
not
sn
.
is_file
:
if
not
sn
.
is_file
:
raise
ValueError
(
f
"
Expecting name to a script.
{
sn
}
is not a file.
"
)
msg
=
f
"
Expecting name to a script.
{
sn
}
is not a file.
"
raise
ValueError
(
msg
)
path
=
sn
.
parent
/
"
log
"
path
=
sn
.
parent
/
"
log
"
path
.
mkdir
(
exist_ok
=
True
)
path
.
mkdir
(
exist_ok
=
True
)
fn
=
path
/
f
"
{
sn
.
stem
}
.log
"
fn
=
path
/
f
"
{
sn
.
stem
}
.log
"
...
...
This diff is collapsed.
Click to expand it.
src/toargridding/metadata.py
+
6
−
7
View file @
bf926512
...
@@ -57,9 +57,8 @@ class TimeSample:
...
@@ -57,9 +57,8 @@ class TimeSample:
@sampling.setter
@sampling.setter
def
sampling
(
self
,
sampling
:
str
):
def
sampling
(
self
,
sampling
:
str
):
if
sampling
not
in
ALLOWED_SAMPLING_VALUES
:
if
sampling
not
in
ALLOWED_SAMPLING_VALUES
:
raise
ValueError
(
msg
=
f
"
sampling:
{
sampling
}
is not in the list of supported samplings for toargridding:
{
ALLOWED_SAMPLING_VALUES
}
"
f
"
sampling:
{
sampling
}
is not in the list of supported samplings for toargridding:
{
ALLOWED_SAMPLING_VALUES
}
"
raise
ValueError
(
msg
)
)
self
.
_sampling
=
sampling
self
.
_sampling
=
sampling
def
as_datetime_index
(
self
)
->
pd
.
DatetimeIndex
:
def
as_datetime_index
(
self
)
->
pd
.
DatetimeIndex
:
...
@@ -145,7 +144,8 @@ class Metadata:
...
@@ -145,7 +144,8 @@ class Metadata:
@statistic.setter
@statistic.setter
def
statistic
(
self
,
stat
:
str
):
def
statistic
(
self
,
stat
:
str
):
if
stat
not
in
STATISTICS_LIST
:
if
stat
not
in
STATISTICS_LIST
:
raise
ValueError
(
f
"
invalid statistic:
{
stat
}
"
)
msg
=
f
"
invalid statistic:
{
stat
}
"
raise
ValueError
(
msg
)
self
.
_statistic
=
stat
self
.
_statistic
=
stat
def
get_id
(
self
)
->
str
:
def
get_id
(
self
)
->
str
:
...
@@ -225,9 +225,8 @@ def get_global_attributes(metadata: Metadata) -> dict:
...
@@ -225,9 +225,8 @@ def get_global_attributes(metadata: Metadata) -> dict:
if
key
not
in
dynamic_cf_attributes
:
if
key
not
in
dynamic_cf_attributes
:
dynamic_cf_attributes
[
key
]
=
value
dynamic_cf_attributes
[
key
]
=
value
else
:
else
:
raise
ValueError
(
msg
=
f
'
{
key
}
is already has the value
{
dynamic_cf_attributes
[
key
]
}
. Prohibited overriding with
"
{
value
}
"
!
'
f
'
{
key
}
is already has the value
{
dynamic_cf_attributes
[
key
]
}
. Prohibited overriding with
"
{
value
}
"
!
'
raise
ValueError
(
msg
)
)
cf_attributes
=
dynamic_cf_attributes
|
global_cf_attributes
cf_attributes
=
dynamic_cf_attributes
|
global_cf_attributes
return
cf_attributes
return
cf_attributes
...
...
This diff is collapsed.
Click to expand it.
src/toargridding/static_metadata.py
+
6
−
3
View file @
bf926512
...
@@ -70,7 +70,8 @@ class TOARVariable:
...
@@ -70,7 +70,8 @@ class TOARVariable:
try
:
try
:
return
cls
.
get_from_name
(
name
=
name
)
return
cls
.
get_from_name
(
name
=
name
)
except
ValueError
:
except
ValueError
:
raise
ValueError
(
f
"
TOAR Database contains no variable with cf_standardname or name
'
{
name
}
'"
)
msg
=
f
"
TOAR Database contains no variable with cf_standardname or name
'
{
name
}
'"
raise
ValueError
(
msg
)
@classmethod
@classmethod
def
get_from_cf_standardname
(
cls
,
standard_name
:
str
)
->
"
TOARVariable
"
:
def
get_from_cf_standardname
(
cls
,
standard_name
:
str
)
->
"
TOARVariable
"
:
...
@@ -89,7 +90,8 @@ class TOARVariable:
...
@@ -89,7 +90,8 @@ class TOARVariable:
for
var
in
cls
.
vars
:
for
var
in
cls
.
vars
:
if
var
.
standard_name
==
standard_name
:
if
var
.
standard_name
==
standard_name
:
return
var
return
var
raise
ValueError
(
f
"
TOAR Database contains no variable with cf_standardname
{
standard_name
}
"
)
msg
=
f
"
TOAR Database contains no variable with cf_standardname
{
standard_name
}
"
raise
ValueError
(
msg
)
@classmethod
@classmethod
def
get_from_name
(
cls
,
name
:
str
)
->
"
TOARVariable
"
:
def
get_from_name
(
cls
,
name
:
str
)
->
"
TOARVariable
"
:
...
@@ -108,7 +110,8 @@ class TOARVariable:
...
@@ -108,7 +110,8 @@ class TOARVariable:
for
var
in
cls
.
vars
:
for
var
in
cls
.
vars
:
if
var
.
name
==
name
:
if
var
.
name
==
name
:
return
var
return
var
raise
ValueError
(
f
"
TOAR Database contains no variable
{
name
}
"
)
msg
=
f
"
TOAR Database contains no variable
{
name
}
"
raise
ValueError
(
msg
)
@property
@property
def
toar_id
(
self
):
def
toar_id
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment