Commit eacaa86f authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

use np.savetxt() instead of formatted write to .csv file

parent e81d59a0
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -51,12 +51,6 @@ from ivas_processing_scripts.utils import apply_func_parallel
SEED_RANDOM_NOISE = 0


# function for converting nd numpy array to strings with 2 decimal digits
def csv_formatdata(data):
    for row in data:
        yield ["%0.2f" % v for v in row]


# function for searching sequences of same the same character and replacing it by another string
def replace_char_seq_with_string(str, char_seq, repl_str):
    result = []
+1 −18
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import csv
import logging
import sys
from itertools import groupby, repeat
@@ -49,12 +48,6 @@ from ivas_processing_scripts.utils import apply_func_parallel
SEED_RANDOM_NOISE = 0


# function for converting nd numpy array to strings with 2 decimal digits
def csv_formatdata(data):
    for row in data:
        yield ["%0.2f" % v for v in row]


# function for searching sequences of same the same character and replacing it by another string
def replace_char_seq_with_string(str, char_seq, repl_str):
    result = []
@@ -405,17 +398,7 @@ def generate_OMASA_scene(
        x_meta = np.column_stack((azi, ele))

        # write to .csv output metadata file
        with open(
            y.metadata_files[i - 1],
            "w",
            newline="",
            encoding="utf-8",
        ) as f:
            # create csv writer
            writer = csv.writer(f)

            # write all rows to the .csv file
            writer.writerows(csv_formatdata(x_meta))
        np.savetxt(y.metadata_files[i - 1], x_meta, fmt="%0.2f", delimiter=",", encoding="utf-8")

    y.init_metadata()  # this is needed to populate 'y.object_pos[]'

+1 −18
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import csv
import logging
import sys
from itertools import groupby, repeat
@@ -48,12 +47,6 @@ from ivas_processing_scripts.utils import apply_func_parallel
SEED_RANDOM_NOISE = 0


# function for converting nd numpy array to strings with 2 decimal digits
def csv_formatdata(data):
    for row in data:
        yield ["%0.2f" % v for v in row]


# function for searching sequences of same the same character and replacing it by another string
def replace_char_seq_with_string(str, char_seq, repl_str):
    result = []
@@ -395,17 +388,7 @@ def generate_OSBA_scene(
        x_meta = np.column_stack((azi, ele))

        # write to .csv output metadata file
        with open(
            y.metadata_files[i - 1],
            "w",
            newline="",
            encoding="utf-8",
        ) as f:
            # create csv writer
            writer = csv.writer(f)

            # write all rows to the .csv file
            writer.writerows(csv_formatdata(x_meta))
        np.savetxt(y.metadata_files[i - 1], x_meta, fmt="%0.2f", delimiter=",", encoding="utf-8")

    y.init_metadata()  # this is needed to populate 'y.object_pos[]'