Skip to content

Commit e47de88

Browse files
committed
Fix Variable Calculator bug and add docstrings
1 parent 5dce599 commit e47de88

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

pyteltools/slf/Serafin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def _get_var_index(self, var_ID):
540540
"""!
541541
@brief Handle data request by variable ID
542542
@param var_ID <str>: the ID of the requested variable
543-
@return index <int> the index (0-based) of the requested variable
543+
@return index <int> the index of the frame (0-based)
544544
"""
545545
if self.header is None:
546546
raise SerafinRequestError('Cannot extract variable from empty list (forgot read_header ?)')
@@ -553,7 +553,7 @@ def _get_var_index(self, var_ID):
553553
def read_var_in_frame(self, time_index, var_ID):
554554
"""!
555555
@brief Read a single variable in a frame
556-
@param time_index <float>: 0-based index of simulation time from the target frame
556+
@param time_index <int>: the index of the frame (0-based)
557557
@param var_ID <str>: variable ID
558558
@return <numpy 1D-array>: values of the variables, of length equal to the number of nodes
559559
"""
@@ -570,7 +570,7 @@ def read_var_in_frame(self, time_index, var_ID):
570570
def read_var_in_frame_as_3d(self, time_index, var_ID):
571571
"""!
572572
@brief Read a single variable in a 3D frame
573-
@param time_index <float>: 0-based index of simulation time from the target frame
573+
@param time_index <int>: the index of the frame (0-based)
574574
@param var_ID <str>: variable ID
575575
@return <numpy 2D-array>: values of the variables with shape (planes number, number of 2D nodes)
576576
"""
@@ -582,7 +582,7 @@ def read_var_in_frame_as_3d(self, time_index, var_ID):
582582
def read_var_in_frame_at_layer(self, time_index, var_ID, iplan):
583583
"""!
584584
@brief Read a single variable in a frame at specific layer
585-
@param time_index <float>: 0-based index of simulation time from the target frame
585+
@param time_index <int>: the index of the frame (0-based)
586586
@param var_ID <str>: variable ID
587587
@param iplan <int>: 1-based index of layer
588588
@return <numpy 1D-array>: values of the variables, of length equal to the number of nodes

pyteltools/slf/expression/pool.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ def evaluate_expressions(self, augmented_path, input_stream, selected_expression
311311
yield time_value, value_array
312312

313313
def decode(self, input_stream, time_index, node_code):
314+
"""
315+
@param input_stream <slf.Serafin.Read>: the input Serafin
316+
@param time_index <int>: the index of the frame (0-based)
317+
@param node_code <str>: expression abbreviation (?)
318+
@return <(numpy 1D-array, ???)>: node_values, node_object
319+
"""
314320
if node_code == 'COORDX':
315321
return self.x, None
316322
elif node_code == 'COORDY':
@@ -328,6 +334,11 @@ def decode(self, input_stream, time_index, node_code):
328334
return None, self.expressions[index]
329335

330336
def _evaluate_expressions(self, input_stream, time_index, path):
337+
"""!
338+
@param input_stream <slf.Serafin.Read>: the input Serafin
339+
@param time_index <int>: the index of the frame (0-based)
340+
@param path <[str]>: list of expressions (?)
341+
"""
331342
# evaluate each node on the augmented path
332343
values = {node: None for node in path}
333344
for node in path:
@@ -357,6 +368,9 @@ def clear(self):
357368
self.representative = None
358369

359370
def get_data(self, input_data):
371+
"""!
372+
@param input_data <slf.datatypes.SerafinData>: input SerafinData stream
373+
"""
360374
self.input_data = input_data
361375
self.nb_pools = len(input_data)
362376

@@ -467,7 +481,7 @@ def output_headers(self, selected_names):
467481
output_header = data.header.copy()
468482
output_header.empty_variables()
469483
for name in selected_names:
470-
output_header.add_variables_str('DUMMY', name, '')
484+
output_header.add_variable_str('DUMMY', name, '')
471485
yield output_header
472486

473487
def build_augmented_path(self, selected_expressions):

pyteltools/slf/variables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def do_calculations_in_frame(equations, input_serafin, time_index, selected_outp
2929
@brief Return the selected 2D variables values in a single time frame
3030
@param equations <[slf.variables_utils.Equation]>: list of all equations necessary to compute selected variables
3131
@param input_serafin <Serafin.Read>: input stream for reading necessary variables
32-
@param time_index <int>: the position of time frame to read
32+
@param time_index <int>: the index of the frame (0-based)
3333
@param selected_output_IDs <[str]>: the short names of the selected output variables
3434
@param output_float_type <numpy.dtype>: float32 or float64 according to the output file type
3535
@param is_2d <bool>: True if input data is 2D

0 commit comments

Comments
 (0)