|
| 1 | +# DCM |
| 2 | + |
| 3 | +A Python package for reading and writing DCM (Data Conservation Format) files used in various ECU calibration tools such as INCA, MDA, EHANDBOOK, CANape, and more. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Features](#features) |
| 8 | +- [Installation](#installation) |
| 9 | +- [Usage](#usage) |
| 10 | + - [Reading a DCM File](#reading-a-dcm-file) |
| 11 | + - [Writing a DCM File](#writing-a-dcm-file) |
| 12 | + - [Accessing Data](#accessing-data) |
| 13 | + - [Loading Data from Excel](#loading-data-from-excel) |
| 14 | + - [Interpolation Functions](#interpolation-functions) |
| 15 | +- [Examples](#examples) |
| 16 | +- [Dependencies](#dependencies) |
| 17 | +- [License](#license) |
| 18 | +- [Contributing](#contributing) |
| 19 | +- [Contact](#contact) |
| 20 | + |
| 21 | +## Features |
| 22 | + |
| 23 | +- **Read and Write DCM Files**: Parse and generate DCM files used in ECU calibration. |
| 24 | +- **Data Manipulation**: Access and modify parameters, curves, maps, and other calibration data. |
| 25 | +- **Excel Integration**: Load calibration data from Excel files. |
| 26 | +- **Interpolation**: Perform 1D and 2D linear interpolation on calibration data. |
| 27 | +- **Visualization**: Plot characteristic lines and maps using Matplotlib. |
| 28 | +- **Support for Various Data Types**: Handle parameters, parameter blocks, characteristic lines, characteristic maps, distributions, and text strings. |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +Ensure you have Python 3.10 or higher installed. Install the package using `pip`: |
| 33 | + |
| 34 | +```bash |
| 35 | +pip install git+https://github.com/c0sogi/python-dcm.git |
| 36 | +``` |
| 37 | + |
| 38 | +Or if you have the package files locally: |
| 39 | + |
| 40 | +```bash |
| 41 | +pip install . |
| 42 | +``` |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +### Reading a DCM File |
| 47 | + |
| 48 | +```python |
| 49 | +from dcm.dcm import DCM |
| 50 | + |
| 51 | +# Read a DCM file |
| 52 | +dcm = DCM.from_file('path/to/your_file.dcm') |
| 53 | +``` |
| 54 | + |
| 55 | +### Writing a DCM File |
| 56 | + |
| 57 | +```python |
| 58 | +# Write the DCM object to a file |
| 59 | +dcm.write('path/to/output_file.dcm') |
| 60 | +``` |
| 61 | + |
| 62 | +### Accessing Data |
| 63 | + |
| 64 | +```python |
| 65 | +# Access a parameter |
| 66 | +parameter = dcm.parameters['PARAMETER_NAME'] |
| 67 | +print(parameter.value) |
| 68 | + |
| 69 | +# Access a characteristic line (curve) |
| 70 | +curve = dcm.curves['CURVE_NAME'] |
| 71 | +print(curve.series) |
| 72 | + |
| 73 | +# Access a characteristic map |
| 74 | +char_map = dcm.maps['MAP_NAME'] |
| 75 | +print(char_map.dataframe) |
| 76 | +``` |
| 77 | + |
| 78 | +### Loading Data from Excel |
| 79 | + |
| 80 | +You can load calibration data from Excel files into the DCM object. |
| 81 | + |
| 82 | +```python |
| 83 | +# Load maps from an Excel file |
| 84 | +dcm.load_maps('maps.xlsx') |
| 85 | + |
| 86 | +# Load curves from an Excel file |
| 87 | +dcm.load_lines('curves.xlsx') |
| 88 | + |
| 89 | +# Load parameters from an Excel file |
| 90 | +dcm.load_parameters('parameters.xlsx') |
| 91 | + |
| 92 | +# Load parameter blocks from an Excel file |
| 93 | +dcm.load_parameter_blocks('parameter_blocks.xlsx') |
| 94 | +``` |
| 95 | + |
| 96 | +### Interpolation Functions |
| 97 | + |
| 98 | +Perform interpolation using the calibration data. |
| 99 | + |
| 100 | +#### 1D Interpolation (Characteristic Line) |
| 101 | + |
| 102 | +```python |
| 103 | +# Get the interpolation function for a curve |
| 104 | +curve_function = curve.as_function |
| 105 | + |
| 106 | +# Interpolate at specific points |
| 107 | +import numpy as np |
| 108 | +x_values = np.array([1.0, 2.0, 3.0]) |
| 109 | +interpolated_values = curve_function(x_values) |
| 110 | +``` |
| 111 | + |
| 112 | +#### 2D Interpolation (Characteristic Map) |
| 113 | + |
| 114 | +```python |
| 115 | +# Get the interpolation function for a map |
| 116 | +map_function = char_map.as_function |
| 117 | + |
| 118 | +# Interpolate at specific x and y points |
| 119 | +x_values = np.array([1.0, 2.0, 3.0]) |
| 120 | +y_values = np.array([4.0, 5.0, 6.0]) |
| 121 | +interpolated_values = map_function(x_values, y_values) |
| 122 | +``` |
| 123 | + |
| 124 | +## Examples |
| 125 | + |
| 126 | +### Plotting a Characteristic Line |
| 127 | + |
| 128 | +```python |
| 129 | +import matplotlib.pyplot as plt |
| 130 | + |
| 131 | +# Plot the curve |
| 132 | +fig, ax = curve.to_figure() |
| 133 | +plt.show() |
| 134 | +``` |
| 135 | + |
| 136 | +### Plotting a Characteristic Map |
| 137 | + |
| 138 | +```python |
| 139 | +import matplotlib.pyplot as plt |
| 140 | + |
| 141 | +# Plot the map |
| 142 | +fig, ax = char_map.to_figure() |
| 143 | +plt.show() |
| 144 | +``` |
| 145 | + |
| 146 | +### Combining DCM Objects |
| 147 | + |
| 148 | +You can combine DCM objects using set operations: |
| 149 | + |
| 150 | +```python |
| 151 | +# Union of two DCM objects |
| 152 | +combined_dcm = dcm1 | dcm2 |
| 153 | + |
| 154 | +# Difference between two DCM objects |
| 155 | +difference_dcm = dcm1 - dcm2 |
| 156 | + |
| 157 | +# Intersection of two DCM objects |
| 158 | +intersection_dcm = dcm1 & dcm2 |
| 159 | + |
| 160 | +# Modifications between two DCM objects |
| 161 | +modifications_dcm = dcm1 % dcm2 |
| 162 | +``` |
| 163 | + |
| 164 | +## Dependencies |
| 165 | + |
| 166 | +- Python >= 3.10 |
| 167 | +- [NumPy](https://numpy.org/) >= 1.20.0 |
| 168 | +- [Pandas](https://pandas.pydata.org/) >= 1.5.0 |
| 169 | +- [Matplotlib](https://matplotlib.org/) >= 3.0.0 |
| 170 | +- [OpenPyXL](https://openpyxl.readthedocs.io/en/stable/) >= 3.1.0 |
| 171 | + |
| 172 | +## License |
| 173 | + |
| 174 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 175 | + |
| 176 | +## Contributing |
| 177 | + |
| 178 | +Contributions are welcome! Please follow these steps: |
| 179 | + |
| 180 | +1. Fork the repository. |
| 181 | +2. Create a new branch (`git checkout -b feature/YourFeature`). |
| 182 | +3. Commit your changes (`git commit -am 'Add new feature'`). |
| 183 | +4. Push to the branch (`git push origin feature/YourFeature`). |
| 184 | +5. Create a new Pull Request. |
| 185 | + |
| 186 | +Please ensure that your code adheres to the existing style and that all tests pass. |
| 187 | + |
| 188 | +## Contact |
| 189 | + |
| 190 | +Author: c0sogi |
| 191 | +Email: [dcas@naver.com](mailto:dcas@naver.com) or [cosogi1@gmail.com] (mailto:cosogi1@gmail.com) |
| 192 | + |
| 193 | +Feel free to reach out for questions or discussions. |
| 194 | + |
| 195 | +# dcm |
| 196 | + |
| 197 | +A Python package for reading and writing DCM (Data Conservation Format) files used in various ECU calibration tools such as INCA, MDA, EHANDBOOK, CANape, and more. |
| 198 | + |
| 199 | +## Table of Contents |
| 200 | + |
| 201 | +- [Features](#features) |
| 202 | +- [Installation](#installation) |
| 203 | +- [Usage](#usage) |
| 204 | + - [Reading a DCM File](#reading-a-dcm-file) |
| 205 | + - [Writing a DCM File](#writing-a-dcm-file) |
| 206 | + - [Accessing Data](#accessing-data) |
| 207 | + - [Loading Data from Excel](#loading-data-from-excel) |
| 208 | + - [Interpolation Functions](#interpolation-functions) |
| 209 | +- [Examples](#examples) |
| 210 | +- [Dependencies](#dependencies) |
| 211 | +- [License](#license) |
| 212 | +- [Contributing](#contributing) |
| 213 | +- [Contact](#contact) |
| 214 | + |
| 215 | +## Features |
| 216 | + |
| 217 | +- **Read and Write DCM Files**: Parse and generate DCM files used in ECU calibration. |
| 218 | +- **Data Manipulation**: Access and modify parameters, curves, maps, and other calibration data. |
| 219 | +- **Excel Integration**: Load calibration data from Excel files. |
| 220 | +- **Interpolation**: Perform 1D and 2D linear interpolation on calibration data. |
| 221 | +- **Visualization**: Plot characteristic lines and maps using Matplotlib. |
| 222 | +- **Support for Various Data Types**: Handle parameters, parameter blocks, characteristic lines, characteristic maps, distributions, and text strings. |
| 223 | + |
| 224 | +## Installation |
| 225 | + |
| 226 | +Ensure you have Python 3.10 or higher installed. Install the package using `pip`: |
| 227 | + |
| 228 | +```bash |
| 229 | +pip install git+https://github.com/c0sogi/python-dcm.git |
| 230 | +``` |
| 231 | + |
| 232 | +Or if you have the package files locally: |
| 233 | + |
| 234 | +```bash |
| 235 | +pip install . |
| 236 | +``` |
| 237 | + |
| 238 | +## Usage |
| 239 | + |
| 240 | +### Reading a DCM File |
| 241 | + |
| 242 | +```python |
| 243 | +from dcm.dcm import DCM |
| 244 | + |
| 245 | +# Read a DCM file |
| 246 | +dcm = DCM.from_file('path/to/your_file.dcm') |
| 247 | +``` |
| 248 | + |
| 249 | +### Writing a DCM File |
| 250 | + |
| 251 | +```python |
| 252 | +# Write the DCM object to a file |
| 253 | +dcm.write('path/to/output_file.dcm') |
| 254 | +``` |
| 255 | + |
| 256 | +### Accessing Data |
| 257 | + |
| 258 | +```python |
| 259 | +# Access a parameter |
| 260 | +parameter = dcm.parameters['PARAMETER_NAME'] |
| 261 | +print(parameter.value) |
| 262 | + |
| 263 | +# Access a characteristic line (curve) |
| 264 | +curve = dcm.curves['CURVE_NAME'] |
| 265 | +print(curve.series) |
| 266 | + |
| 267 | +# Access a characteristic map |
| 268 | +char_map = dcm.maps['MAP_NAME'] |
| 269 | +print(char_map.dataframe) |
| 270 | +``` |
| 271 | + |
| 272 | +### Loading Data from Excel |
| 273 | + |
| 274 | +You can load calibration data from Excel files into the DCM object. |
| 275 | + |
| 276 | +```python |
| 277 | +# Load maps from an Excel file |
| 278 | +dcm.load_maps('maps.xlsx') |
| 279 | + |
| 280 | +# Load curves from an Excel file |
| 281 | +dcm.load_lines('curves.xlsx') |
| 282 | + |
| 283 | +# Load parameters from an Excel file |
| 284 | +dcm.load_parameters('parameters.xlsx') |
| 285 | + |
| 286 | +# Load parameter blocks from an Excel file |
| 287 | +dcm.load_parameter_blocks('parameter_blocks.xlsx') |
| 288 | +``` |
| 289 | + |
| 290 | +### Interpolation Functions |
| 291 | + |
| 292 | +Perform interpolation using the calibration data. |
| 293 | + |
| 294 | +#### 1D Interpolation (Characteristic Line) |
| 295 | + |
| 296 | +```python |
| 297 | +# Get the interpolation function for a curve |
| 298 | +curve_function = curve.as_function |
| 299 | + |
| 300 | +# Interpolate at specific points |
| 301 | +import numpy as np |
| 302 | +x_values = np.array([1.0, 2.0, 3.0]) |
| 303 | +interpolated_values = curve_function(x_values) |
| 304 | +``` |
| 305 | + |
| 306 | +#### 2D Interpolation (Characteristic Map) |
| 307 | + |
| 308 | +```python |
| 309 | +# Get the interpolation function for a map |
| 310 | +map_function = char_map.as_function |
| 311 | + |
| 312 | +# Interpolate at specific x and y points |
| 313 | +x_values = np.array([1.0, 2.0, 3.0]) |
| 314 | +y_values = np.array([4.0, 5.0, 6.0]) |
| 315 | +interpolated_values = map_function(x_values, y_values) |
| 316 | +``` |
| 317 | + |
| 318 | +## Examples |
| 319 | + |
| 320 | +### Plotting a Characteristic Line |
| 321 | + |
| 322 | +```python |
| 323 | +import matplotlib.pyplot as plt |
| 324 | + |
| 325 | +# Plot the curve |
| 326 | +fig, ax = curve.to_figure() |
| 327 | +plt.show() |
| 328 | +``` |
| 329 | + |
| 330 | +### Plotting a Characteristic Map |
| 331 | + |
| 332 | +```python |
| 333 | +import matplotlib.pyplot as plt |
| 334 | + |
| 335 | +# Plot the map |
| 336 | +fig, ax = char_map.to_figure() |
| 337 | +plt.show() |
| 338 | +``` |
| 339 | + |
| 340 | +### Combining DCM Objects |
| 341 | + |
| 342 | +You can combine DCM objects using set operations: |
| 343 | + |
| 344 | +```python |
| 345 | +# Union of two DCM objects |
| 346 | +combined_dcm = dcm1 | dcm2 |
| 347 | + |
| 348 | +# Difference between two DCM objects |
| 349 | +difference_dcm = dcm1 - dcm2 |
| 350 | + |
| 351 | +# Intersection of two DCM objects |
| 352 | +intersection_dcm = dcm1 & dcm2 |
| 353 | + |
| 354 | +# Modifications between two DCM objects |
| 355 | +modifications_dcm = dcm1 % dcm2 |
| 356 | +``` |
| 357 | + |
| 358 | +## Dependencies |
| 359 | + |
| 360 | +- Python >= 3.10 |
| 361 | +- [NumPy](https://numpy.org/) >= 1.20.0 |
| 362 | +- [Pandas](https://pandas.pydata.org/) >= 1.5.0 |
| 363 | +- [Matplotlib](https://matplotlib.org/) >= 3.0.0 |
| 364 | +- [OpenPyXL](https://openpyxl.readthedocs.io/en/stable/) >= 3.1.0 |
| 365 | + |
| 366 | +## License |
| 367 | + |
| 368 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 369 | + |
| 370 | +## Contributing |
| 371 | + |
| 372 | +Contributions are welcome! Please follow these steps: |
| 373 | + |
| 374 | +1. Fork the repository. |
| 375 | +2. Create a new branch (`git checkout -b feature/YourFeature`). |
| 376 | +3. Commit your changes (`git commit -am 'Add new feature'`). |
| 377 | +4. Push to the branch (`git push origin feature/YourFeature`). |
| 378 | +5. Create a new Pull Request. |
| 379 | + |
| 380 | +Please ensure that your code adheres to the existing style and that all tests pass. |
| 381 | + |
| 382 | +## Contact |
| 383 | + |
| 384 | +Author: c0sogi |
| 385 | +Email: [dcas@naver.com](mailto:dcas@naver.com) or [cosogi1@gmail.com](mailto:cosogi1@gmail.com) |
| 386 | + |
| 387 | +Feel free to reach out for questions or discussions. |
0 commit comments