Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
METRo projects
metro
Commits
91d97160
Commit
91d97160
authored
Apr 08, 2008
by
François Fortin
Browse files
round roadcast levels
parent
952ea954
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/frontend/data_module/metro_data.py
View file @
91d97160
...
...
@@ -238,6 +238,46 @@ class Metro_data:
raise
ERROR_METRO_DATA
,
MESSAGE_READONLY
def
set_matrix_multiCol
(
self
,
sCol_name
,
lColOfList
):
"""
Name: set_matrix_col
Parameters: I sCol_name : column name
I npData_col : column to insert in the matrix.
Returns: 0 if success
Descriptions: Append a new column of data to the matrix. Matix column
will be accessible with the name specified by sCol_name.
Column will be treated as extended
"""
# FFTODO set multi col
lCol_list
=
self
.
index_of_matrix_col
(
sCol_name
)
if
not
self
.
is_readonly
():
if
lCol_list
[
-
1
]
>
len
(
self
.
npMatrix
[
0
,:]):
sOutOfBoundError
=
_
(
"Array does not contain this indice: %s"
)
\
%
str
(
lCol_list
)
raise
ERROR_METRO_DATA
,
sOutOfBoundError
# FFTODO need to activate that check
# elif len(self.npMatrix[:,lColOfList[0]]) != len(lColOfList[0]):
# sLengthError = _("Array does not have the right lenght.\n") + \
# _("Array length: %d \n") % len(lColOfList[0]) + \
# _("Matrix length: %d \n") % len(self.npMatrix[:,lColOfList[0]])
# raise ERROR_METRO_DATA, sLengthError
else
:
iInCol
=
0
for
iCol
in
lCol_list
:
self
.
npMatrix
[:,
iCol
]
=
lColOfList
[
iInCol
]
iInCol
+=
1
else
:
metro_logger
.
print_message
(
metro_logger
.
LOGGER_MSG_DEBUG
,
MESSAGE_READONLY
)
raise
ERROR_METRO_DATA
,
MESSAGE_READONLY
def
append_matrix_row
(
self
,
lData_row
):
"""
Name: append_matrix_row
...
...
src/frontend/executable_module/metro_postprocess_round_roadcast.py
View file @
91d97160
...
...
@@ -64,14 +64,47 @@ class Metro_postprocess_round_roadcast(Metro_postprocess):
metro_config
.
get_value
(
'DEFAULT_ROADCAST_PREDICTION_PRECISION'
)
if
roadcast_data
!=
None
:
self
.
__round_roadcast
(
roadcast_data
.
get_subsampled_data
())
self
.
__round_roadcast_header
(
roadcast_data
.
get_subsampled_data
())
self
.
__round_roadcast_data
(
roadcast_data
.
get_subsampled_data
())
else
:
metro_logger
.
print_message
(
metro_logger
.
LOGGER_MSG_WARNING
,
_
(
"No roadcast!"
))
pRoadcast
.
set_data_collection
(
roadcast_data
)
def
__round_roadcast
(
self
,
roadcast_data
):
def
__round_roadcast_header
(
self
,
roadcast
):
if
'VERTICAL_LEVELS'
in
roadcast
.
get_header
():
# Get the default value for the accurary of "float" of the roadcast
iDefault_precision
=
\
metro_config
.
get_value
(
'DEFAULT_ROADCAST_PREDICTION_PRECISION'
)
dData_types
=
metro_config
.
get_value
(
'XML_DATATYPE_STANDARD'
)
dExtended_data_type
=
metro_config
.
get_value
(
'XML_DATATYPE_EXTENDED'
)
dData_types
.
update
(
dExtended_data_type
)
sCurrent_data_type
=
'VERTICAL_LEVELS'
# get precision
if
'CHILD'
in
dData_types
[
sCurrent_data_type
]:
if
len
(
dData_types
[
sCurrent_data_type
][
'CHILD'
])
==
1
and
\
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
][
'DATA_TYPE'
]
==
'REAL'
:
# If the accuracy have been specified: use it.
# Otherwhise use the default value for the roadcast.
if
'PRECISION'
in
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
]:
iPrecision
=
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
][
'PRECISION'
]
else
:
iPrecision
=
iDefault_precision
lLevels
=
roadcast
.
get_header_value
(
'VERTICAL_LEVELS'
)
lRounded
=
[
round
(
x
,
iPrecision
)
for
x
in
lLevels
]
roadcast
.
set_header_value
(
'VERTICAL_LEVELS'
,
lRounded
)
def
__round_roadcast_data
(
self
,
roadcast_data
):
# Get the matrix columns definition
lStandard_roadcast
=
metro_config
.
get_value
(
\
...
...
@@ -84,10 +117,17 @@ class Metro_postprocess_round_roadcast(Metro_postprocess):
iDefault_precision
=
\
metro_config
.
get_value
(
'DEFAULT_ROADCAST_PREDICTION_PRECISION'
)
dData_types
=
metro_config
.
get_value
(
'XML_DATATYPE_STANDARD'
)
dExtended_data_type
=
metro_config
.
get_value
(
'XML_DATATYPE_EXTENDED'
)
dData_types
.
update
(
dExtended_data_type
)
# Process of each column of roadcast
iItem_id
=
0
for
dRoadcast_item
in
lRoadcast_items
:
sCurrent_data_type
=
dRoadcast_item
[
'DATA_TYPE'
]
# If this column contains float data
if
dRoadcast_item
[
'DATA_TYPE'
]
==
'REAL'
:
...
...
@@ -102,6 +142,19 @@ class Metro_postprocess_round_roadcast(Metro_postprocess):
npCol
=
roadcast_data
.
get_matrix_col
(
dRoadcast_item
[
'NAME'
])
npCol
=
numpy
.
around
(
npCol
,
iPrecision
)
roadcast_data
.
set_matrix_col
(
dRoadcast_item
[
'NAME'
],
npCol
)
iItem_id
=
iItem_id
+
1
# If this column as only one child who is a REAL: its probably a list of float
elif
'CHILD'
in
dData_types
[
sCurrent_data_type
]:
if
len
(
dData_types
[
sCurrent_data_type
][
'CHILD'
])
==
1
and
\
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
][
'DATA_TYPE'
]
==
'REAL'
:
# If the accuracy have been specified: use it.
# Otherwhise use the default value for the roadcast.
if
'PRECISION'
in
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
]:
iPrecision
=
dData_types
[
sCurrent_data_type
][
'CHILD'
][
0
][
'PRECISION'
]
else
:
iPrecision
=
iDefault_precision
npCol
=
roadcast_data
.
get_matrix_col
(
dRoadcast_item
[
'NAME'
])
npCol
=
numpy
.
around
(
npCol
,
iPrecision
)
roadcast_data
.
set_matrix_multiCol
(
dRoadcast_item
[
'NAME'
],
npCol
)
src/frontend/metro_config.py
View file @
91d97160
...
...
@@ -613,7 +613,7 @@ def set_default_value( ):
'CHILD'
:[{
'NAME'
:
"DEPTH"
,
'XML_TAG'
:
"depth"
,
'DATA_TYPE'
:
'REAL'
,
'PRECISION'
:
2
}
'PRECISION'
:
3
}
]},
...
...
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