From 311ba231b0016dc8b47d0b4a79bded6cf5e5200c Mon Sep 17 00:00:00 2001 From: Jacob Willis Date: Mon, 18 Dec 2023 15:31:32 -0500 Subject: [PATCH 1/4] stubbed out task --- flight/pygnc/configuration/pygnc.py | 1 + flight/pygnc/tasks/range_history_saver.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 flight/pygnc/tasks/range_history_saver.py diff --git a/flight/pygnc/configuration/pygnc.py b/flight/pygnc/configuration/pygnc.py index 2611801..ca1656a 100644 --- a/flight/pygnc/configuration/pygnc.py +++ b/flight/pygnc/configuration/pygnc.py @@ -2,3 +2,4 @@ import warnings batch_sensor_gps_filepath = os.path.expanduser("~/sense.bin") +batch_range_filepath = os.path.expanduser("~/range.bin") diff --git a/flight/pygnc/tasks/range_history_saver.py b/flight/pygnc/tasks/range_history_saver.py new file mode 100644 index 0000000..7dceb96 --- /dev/null +++ b/flight/pygnc/tasks/range_history_saver.py @@ -0,0 +1,5 @@ +from ..configuration.pygnc import batch_range_filepath + +def main(): + print(f"Open {batch_range_filepath}") + pass \ No newline at end of file From e6a266eb60874eed13a4ee3a47206e6932575947 Mon Sep 17 00:00:00 2001 From: Paulo Fisch Date: Mon, 18 Dec 2023 16:57:29 -0500 Subject: [PATCH 2/4] works with dummy files. Need to check if number of bytes is right and file paths --- flight/pygnc/tasks/range_history_saver.py | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/flight/pygnc/tasks/range_history_saver.py b/flight/pygnc/tasks/range_history_saver.py index 7dceb96..cdf6249 100644 --- a/flight/pygnc/tasks/range_history_saver.py +++ b/flight/pygnc/tasks/range_history_saver.py @@ -1,5 +1,25 @@ -from ..configuration.pygnc import batch_range_filepath +# from ..configuration.pygnc import batch_range_filepath -def main(): - print(f"Open {batch_range_filepath}") - pass \ No newline at end of file + # print(f"Open {batch_range_filepath}") + # read files from range filepath then read D bytes every S time steps +def read_and_save(input_file, output_file, D, S): + with open(input_file, 'rb') as infile, open(output_file, 'wb') as outfile: + print(f"Reading {input_file} and saving every {S}th measurement to {output_file}") + count = 0 + while True: + data = infile.read(D) + if not data: + break # End of file + count += 1 + if count % S == 0: + outfile.write(data) + +if __name__ == "__main__": + # Replace 'input_file.bin' and 'output_file.bin' with your actual file names + input_file = 'range.txt' + output_file = 'sparse_measurements.bin' + + # Replace 100 and 5 with your desired values for D and S + D = 12 # Number of bytes to read and save + S = 30 # Save every S instances + read_and_save(input_file, output_file, D, S) \ No newline at end of file From d3533c01121a020bed175de11247bf4c88fcb023 Mon Sep 17 00:00:00 2001 From: Paulo Fisch Date: Mon, 18 Dec 2023 17:32:10 -0500 Subject: [PATCH 3/4] works with dummy files. Need to check file paths --- flight/pygnc/tasks/range_history_saver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/pygnc/tasks/range_history_saver.py b/flight/pygnc/tasks/range_history_saver.py index cdf6249..ce4aa66 100644 --- a/flight/pygnc/tasks/range_history_saver.py +++ b/flight/pygnc/tasks/range_history_saver.py @@ -20,6 +20,6 @@ def read_and_save(input_file, output_file, D, S): output_file = 'sparse_measurements.bin' # Replace 100 and 5 with your desired values for D and S - D = 12 # Number of bytes to read and save + D = 120 # Number of bytes to read and save S = 30 # Save every S instances read_and_save(input_file, output_file, D, S) \ No newline at end of file From db0a983b3384ea3facda4e87879bfbf884ac7045 Mon Sep 17 00:00:00 2001 From: Jacob Willis Date: Tue, 19 Dec 2023 10:15:00 -0500 Subject: [PATCH 4/4] example range data file for testing history saver --- .../example_scenario/batch_range_sensor_data.bin | Bin 0 -> 2586 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 scenarios/example_scenario/batch_range_sensor_data.bin diff --git a/scenarios/example_scenario/batch_range_sensor_data.bin b/scenarios/example_scenario/batch_range_sensor_data.bin new file mode 100644 index 0000000000000000000000000000000000000000..9b11956255143b1bc1a310287e5e446e73a68aa1 GIT binary patch literal 2586 zcmcK5dsxg_7zglEP0Ey!a!pO6gjSj^E>m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