RCAIDE.save
save#
- save(data, filename, pickle_format=False)[source]#
Converts a RCAIDE data structure to a JSON or Pickle file for storage.
- Parameters:
data (RCAIDE.Framework.Core.Data) – RCAIDE data structure to be saved
filename (str) – Path where the file will be saved, without extension for pickle files
pickle_format (bool, optional) – Flag indicating whether to save as a pickle file (True) or JSON file (False) Default is False (JSON format)
- Return type:
None
Notes
This function supports two file formats:
JSON format (default): Converts the RCAIDE data structure to a JSON string using the build_dict_base and build_dict_r helper functions, then writes it to a file.
Pickle format: Serializes the Python object directly to a binary file. The .pkl extension is automatically added to the filename.
JSON format is human-readable and more portable across different Python versions, while pickle format is more efficient for large data structures but less portable.
See also
RCAIDE.load
,RCAIDE.build_dict_base
,RCAIDE.build_dict_r
- build_dict_base(base)[source]#
Builds a dictionary based on a RCAIDE data structure. This is initial case.
- Assumptions:
Data must be numpy arrays, strings, booleans, floats, ints, or lists. Functions are ignored and all other data raises an error.
- Source:
None
- Parameters:
base – RCAIDE data structure [unitless]
- Returns:
Dictionary built on the data structure [unitless]
- Return type:
base_dict
- build_dict_r(v)[source]#
Builds a dictionary based on a RCAIDE data structure. This the recursive step.
- Assumptions:
Data must be numpy arrays, strings, booleans, floats, ints, or lists. Functions are ignored and all other data raises an error.
- Source:
None
- Parameters:
v – value in a data structure [unitless]
- Returns:
value based on type of v [unitless]
- Return type:
ret