From a8aa58b1ebb0732fac71f4b14691dc5b487b1996 Mon Sep 17 00:00:00 2001 From: Michael Joyce Date: Thu, 12 Dec 2024 09:36:14 -0800 Subject: [PATCH] Update compression API with default max error value Update the compress file and variable functions with a default `max_error` value for parity between the API and CLI. --- tropess_compression/compress_tropess_file.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tropess_compression/compress_tropess_file.py b/tropess_compression/compress_tropess_file.py index 38023e9..d14e4e3 100644 --- a/tropess_compression/compress_tropess_file.py +++ b/tropess_compression/compress_tropess_file.py @@ -14,7 +14,7 @@ logger = logging.getLogger() -def compress_variable(data_file_input, data_file_output, var_name, max_error, progress_bar=False): +def compress_variable(data_file_input, data_file_output, var_name, max_error=DEFAULT_MAX_ERROR, progress_bar=False): # Read input data fill_value = data_file_input[var_name]._FillValue @@ -55,7 +55,7 @@ def find_compression_vars(root): return list(find_compression_vars(data_file_input)) -def compress_file(input_filename, output_filename, max_error, progress_bar=False): +def compress_file(input_filename, output_filename, max_error=DEFAULT_MAX_ERROR, progress_bar=False): # Open input file, find which variables will be compressed data_file_input = netCDF4.Dataset(input_filename, 'r') @@ -101,7 +101,7 @@ def main(): if args.verbose: logging.basicConfig(level=logging.DEBUG, force=True) - compress_file(args.input_filename, args.output_filename, args.max_error, progress_bar=args.verbose) + compress_file(args.input_filename, args.output_filename, max_error=args.max_error, progress_bar=args.verbose) if __name__ == '__main__': - main() \ No newline at end of file + main()