Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flex Extract
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flexpart
Flex Extract
Commits
e7708b23
Commit
e7708b23
authored
5 years ago
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
python2 downgrade/ bug fix of queue checks/improvement of grid check/
parent
7c7e672f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/python/mods/checks.py
+30
-13
30 additions, 13 deletions
source/python/mods/checks.py
with
30 additions
and
13 deletions
source/python/mods/checks.py
+
30
−
13
View file @
e7708b23
#!/usr/bin/env python
3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#*******************************************************************************
#*******************************************************************************
# @Author: Anne Philipp (University of Vienna)
# @Author: Anne Philipp (University of Vienna)
...
@@ -23,15 +23,16 @@
...
@@ -23,15 +23,16 @@
# MODULES
# MODULES
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
from
__future__
import
print_function
import
os
import
os
import
sys
import
sys
import
_config
import
_config
try
:
try
:
import
exceptions
import
exceptions
except
ImportError
:
except
ImportError
:
import
builtins
as
exceptions
import
builtins
as
exceptions
from
datetime
import
datetime
from
datetime
import
datetime
import
numpy
as
np
from
mods.tools
import
my_error
,
silent_remove
from
mods.tools
import
my_error
,
silent_remove
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
...
@@ -85,17 +86,28 @@ def check_grid(grid):
...
@@ -85,17 +86,28 @@ def check_grid(grid):
if
gridx
==
gridy
:
if
gridx
==
gridy
:
grid
=
gridx
grid
=
gridx
else
:
else
:
raise
ValueError
(
'
GRID parameter contains two values
'
raise
ValueError
(
'
GRID parameter contains two
'
'
which are unequal %s
'
(
grid
))
'
different values: %s
'
(
grid
))
# # determine grid format
# if float(grid) / 100. >= 0.5:
# # grid is defined in 1/1000 degrees; old format
# grid = '{}/{}'.format(float(grid) / 1000.,
# float(grid) / 1000.)
# elif float(grid) / 100. < 0.5:
# # grid is defined in normal degree; new format
# grid = '{}/{}'.format(float(grid), float(grid))
# determine grid format
# determine grid format
if
float
(
grid
)
/
100.
>=
0.5
:
# assumes that nobody wants grid spacings of 20 deg or more
# grid is defined in 1/1000 degrees; old format
if
float
(
grid
)
>=
20.
:
grid
=
'
{}/{}
'
.
format
(
float
(
grid
)
/
1000.
,
#
grid
is defined in 1/1000 degree; old format
float
(
grid
)
/
1000.
)
grid
=
'
{}/{}
'
.
format
(
float
(
grid
)
/
1000.
,
float
(
grid
)
/
1000.
)
el
if
float
(
grid
)
/
100.
<
0.5
:
el
se
:
# grid is defined in
normal
degree; new format
# grid is defined in degree; new format
grid
=
'
{}/{}
'
.
format
(
float
(
grid
),
float
(
grid
))
grid
=
'
{}/{}
'
.
format
(
float
(
grid
),
float
(
grid
))
return
grid
return
grid
def
check_area
(
grid
,
area
,
upper
,
lower
,
left
,
right
):
def
check_area
(
grid
,
area
,
upper
,
lower
,
left
,
right
):
...
@@ -289,6 +301,7 @@ def check_step(step, mailfail):
...
@@ -289,6 +301,7 @@ def check_step(step, mailfail):
step : list of str
step : list of str
List of forecast steps in format e.g. [001, 002, ...]
List of forecast steps in format e.g. [001, 002, ...]
'''
'''
import
numpy
as
np
if
'
/
'
in
step
:
if
'
/
'
in
step
:
steps
=
step
.
split
(
'
/
'
)
steps
=
step
.
split
(
'
/
'
)
...
@@ -465,8 +478,8 @@ def check_queue(queue, gateway, destination, ecuid, ecgid):
...
@@ -465,8 +478,8 @@ def check_queue(queue, gateway, destination, ecuid, ecgid):
'''
'''
if
queue
in
_config
.
QUEUES_LIST
and
\
if
queue
in
_config
.
QUEUES_LIST
and
\
not
gateway
or
not
destination
or
\
(
not
gateway
or
not
destination
or
not
ecuid
or
not
ecgid
:
not
ecuid
or
not
ecgid
)
:
raise
ValueError
(
'
\n
Environment variables GATEWAY, DESTINATION, ECUID
'
raise
ValueError
(
'
\n
Environment variables GATEWAY, DESTINATION, ECUID
'
'
and ECGID were not set properly!
\n
'
'
and ECGID were not set properly!
\n
'
'
Please check for existence of file
"
ECMWF_ENV
"
'
'
Please check for existence of file
"
ECMWF_ENV
"
'
...
@@ -688,7 +701,7 @@ def check_acctype(acctype, ftype):
...
@@ -688,7 +701,7 @@ def check_acctype(acctype, ftype):
return
acctype
return
acctype
def
check_acctime
(
acctime
,
marsclass
,
purefc
):
def
check_acctime
(
acctime
,
marsclass
,
purefc
,
time
):
'''
Guarantees that the accumulation forecast times were set.
'''
Guarantees that the accumulation forecast times were set.
If it is not set, it tries to set the value for some of the
If it is not set, it tries to set the value for some of the
...
@@ -723,6 +736,8 @@ def check_acctime(acctime, marsclass, purefc):
...
@@ -723,6 +736,8 @@ def check_acctime(acctime, marsclass, purefc):
acctime
=
'
18
'
acctime
=
'
18
'
elif
marsclass
.
upper
()
==
'
OD
'
and
not
purefc
:
# On-demand
elif
marsclass
.
upper
()
==
'
OD
'
and
not
purefc
:
# On-demand
acctime
=
'
00/12
'
acctime
=
'
00/12
'
elif
marsclass
.
upper
()
==
'
OD
'
and
purefc
:
# On-demand
acctime
=
time
[
0
]
else
:
else
:
raise
ValueError
(
'
ERROR: Accumulation forecast time can not
'
raise
ValueError
(
'
ERROR: Accumulation forecast time can not
'
'
automatically be derived!
'
)
'
automatically be derived!
'
)
...
@@ -819,6 +834,8 @@ def check_job_chunk(job_chunk):
...
@@ -819,6 +834,8 @@ def check_job_chunk(job_chunk):
'''
'''
if
not
job_chunk
:
if
not
job_chunk
:
return
job_chunk
return
job_chunk
else
:
job_chunk
=
int
(
job_chunk
)
if
job_chunk
<
0
:
if
job_chunk
<
0
:
raise
ValueError
(
'
ERROR: The number of job chunk is negative!
\n
'
raise
ValueError
(
'
ERROR: The number of job chunk is negative!
\n
'
...
...
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