Source code for oasislmf.pytools.data_layer.conversions.correlations
"""This file defines the functions that convert correlations."""importsysfrompathlibimportPathfromoasislmf.pytools.data_layer.oasis_files.correlationsimportCorrelationsData
[docs]defconvert_csv_to_bin(file_path:str,file_out_path:str="")->None:""" Converts the correlations data from a CSV file to a binary file. Args: file_path: (str) path to the file being converted Returns: None """CorrelationsData.from_csv(file_path=file_path).to_bin(file_path=Path(file_path).with_suffix(".bin")ifnotfile_out_pathelsefile_out_path)
[docs]defconvert_bin_to_csv(file_path:str,file_out_path:str="")->None:""" Converts the correlations data from a binary file to a CSV file. Args: file_path: (str) path to the file being converted Returns: None """CorrelationsData.from_bin(file_path=file_path).to_csv(file_out_pathiffile_out_pathelsesys.stdout.buffer)