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
97f4f4c5
Commit
97f4f4c5
authored
6 years ago
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
better check on grid and arae parameter formats
parent
1d15e270
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
source/python/classes/ControlFile.py
+32
-24
32 additions, 24 deletions
source/python/classes/ControlFile.py
source/python/mods/checks.py
+88
-0
88 additions, 0 deletions
source/python/mods/checks.py
source/python/mods/tools.py
+0
-1
0 additions, 1 deletion
source/python/mods/tools.py
with
120 additions
and
25 deletions
source/python/classes/ControlFile.py
+
32
−
24
View file @
97f4f4c5
...
@@ -60,6 +60,7 @@ import inspect
...
@@ -60,6 +60,7 @@ import inspect
sys
.
path
.
append
(
'
../
'
)
sys
.
path
.
append
(
'
../
'
)
import
_config
import
_config
from
mods.tools
import
my_error
,
silent_remove
from
mods.tools
import
my_error
,
silent_remove
from
mods.checks
import
check_grid_area
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# CLASS
# CLASS
...
@@ -474,32 +475,39 @@ class ControlFile(object):
...
@@ -474,32 +475,39 @@ class ControlFile(object):
print
(
'
Use default value
"
12
"
for flux forecast!
'
)
print
(
'
Use default value
"
12
"
for flux forecast!
'
)
self
.
accmaxstep
=
'
12
'
self
.
accmaxstep
=
'
12
'
# if area was provided (only from commandline)
# decompose area into its 4 components
self
.
grid
,
self
.
area
=
check_grid_area
(
self
.
grid
,
self
.
area
,
if
self
.
area
:
self
.
upper
,
self
.
lower
,
components
=
self
.
area
.
split
(
'
/
'
)
self
.
left
,
self
.
right
)
self
.
upper
,
self
.
left
,
self
.
lower
,
self
.
right
=
components
# convert grid and area components to correct format and input
# convert grid and area components to correct format and input
if
'
N
'
in
self
.
grid
:
# Gaussian output grid
#if 'N' in self.grid: # Gaussian output grid
self
.
area
=
'
G
'
# self.area = 'G'
else
:
# else:
# check on grid format
# if '/' in self.grid:
if
float
(
self
.
grid
)
/
100.
>=
0.5
:
# gridx, gridy = self.grid.split('/')
# grid is defined in 1/1000 degrees; old method
# if gridx == gridy:
self
.
grid
=
'
{}/{}
'
.
format
(
float
(
self
.
grid
)
/
1000.
,
# self.grid = gridx
float
(
self
.
grid
)
/
1000.
)
self
.
area
=
'
{}/{}/{}/{}
'
.
format
(
float
(
self
.
upper
)
/
1000.
,
float
(
self
.
left
)
/
1000.
,
# # check on grid format
float
(
self
.
lower
)
/
1000.
,
# if float(self.grid) / 100. >= 0.5:
float
(
self
.
right
)
/
1000.
)
# # grid is defined in 1/1000 degrees; old format
elif
float
(
self
.
grid
)
/
100.
<
0.5
:
# self.grid = '{}/{}'.format(float(self.grid) / 1000.,
# grid is defined in normal degree; new method
# float(self.grid) / 1000.)
self
.
grid
=
'
{}/{}
'
.
format
(
float
(
self
.
grid
),
float
(
self
.
grid
))
# self.area = '{}/{}/{}/{}'.format(float(self.upper) / 1000.,
self
.
area
=
'
{}/{}/{}/{}
'
.
format
(
float
(
self
.
upper
),
# float(self.left) / 1000.,
float
(
self
.
left
),
# float(self.lower) / 1000.,
float
(
self
.
lower
),
# float(self.right) / 1000.)
float
(
self
.
right
))
# elif float(self.grid) / 100. < 0.5:
# # grid is defined in normal degree; new format
# self.grid = '{}/{}'.format(float(self.grid), float(self.grid))
# self.area = '{}/{}/{}/{}'.format(float(self.upper),
# float(self.left),
# float(self.lower),
# float(self.right))
return
return
...
...
This diff is collapsed.
Click to expand it.
source/python/mods/checks.py
0 → 100644
+
88
−
0
View file @
97f4f4c5
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##*******************************************************************************
# @Author: Anne Philipp (University of Vienna)
#
# @Date: November 2018
#
# @Change History:
#
# @License:
# (C) Copyright 2014-2018.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# @Modul Description:
#
#
# @Module Content:
#
#*******************************************************************************
# ------------------------------------------------------------------------------
# MODULES
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# FUNCTIONS
# ------------------------------------------------------------------------------
def
check_grid_area
(
grid
,
area
,
upper
,
lower
,
left
,
right
):
'''
'''
# if area was provided
# decompose area into its 4 components
if
area
:
components
=
area
.
split
(
'
/
'
)
upper
,
left
,
lower
,
right
=
components
if
'
N
'
in
grid
:
# Gaussian output grid
area
=
'
G
'
return
grid
,
area
if
'
/
'
in
grid
:
gridx
,
gridy
=
grid
.
split
(
'
/
'
)
if
gridx
==
gridy
:
grid
=
gridx
else
:
raise
ValueError
(
'
GRID parameter contains two values
'
'
which are unequal %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 area format
if
(
float
(
upper
)
/
1000.
>=
0.05
and
float
(
lower
)
/
1000.
>=
0.05
and
float
(
left
)
/
1000.
>=
0.05
and
float
(
right
)
/
1000.
>=
0.05
):
# area is defined in 1/1000 degrees; old format
area
=
'
{}/{}/{}/{}
'
.
format
(
float
(
upper
)
/
1000.
,
float
(
left
)
/
1000.
,
float
(
lower
)
/
1000.
,
float
(
right
)
/
1000.
)
elif
(
float
(
upper
)
/
1000.
<
0.05
and
float
(
lower
)
/
1000.
<
0.05
and
float
(
left
)
/
1000.
<
0.05
and
float
(
right
)
/
1000.
<
0.05
):
# area is already in new format
area
=
'
{}/{}/{}/{}
'
.
format
(
float
(
upper
),
float
(
left
),
float
(
lower
),
float
(
right
))
else
:
raise
ValueError
(
'
The area components have different
'
'
formats: %s
'
(
area
))
return
grid
,
area
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/python/mods/tools.py
+
0
−
1
View file @
97f4f4c5
...
@@ -99,7 +99,6 @@ def none_or_int(value):
...
@@ -99,7 +99,6 @@ def none_or_int(value):
return
None
return
None
return
int
(
value
)
return
int
(
value
)
def
get_cmdline_arguments
():
def
get_cmdline_arguments
():
'''
Decomposes the command line arguments and assigns them to variables.
'''
Decomposes the command line arguments and assigns them to variables.
Apply default values for non mentioned arguments.
Apply default values for non mentioned arguments.
...
...
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