-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range history saver #1
base: main
Are you sure you want to change the base?
Changes from all commits
311ba23
e6a266e
d3533c0
db0a983
c5944fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# from ..configuration.pygnc import batch_range_filepath | ||
|
||
# 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) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a main() function that pulls in the correct constants and calls |
||
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 = 120 # Number of bytes to read and save | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put these constants in ../configuration/range_history_saver.py There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also reference Py4Data/example_range_parse/dataparser_range.py to get the correct value for D (it's not 120). |
||
S = 30 # Save every S instances | ||
read_and_save(input_file, output_file, D, S) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use this as the filepath to open