NREL-ditto 0.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. nrel_ditto-0.0.7/.gitignore +178 -0
  2. nrel_ditto-0.0.7/PKG-INFO +30 -0
  3. nrel_ditto-0.0.7/pyproject.toml +113 -0
  4. nrel_ditto-0.0.7/src/ditto/__init__.py +1 -0
  5. nrel_ditto-0.0.7/src/ditto/enumerations.py +18 -0
  6. nrel_ditto-0.0.7/src/ditto/readers/__init__.py +0 -0
  7. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/__init__.py +31 -0
  8. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/cim_mapper.py +8 -0
  9. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/common.py +3 -0
  10. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/__init__.py +0 -0
  11. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_bus.py +61 -0
  12. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_capacitor.py +43 -0
  13. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_load.py +48 -0
  14. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_regulator.py +56 -0
  15. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_transformer.py +38 -0
  16. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/distribution_voltage_source.py +36 -0
  17. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/matrix_branch.py +42 -0
  18. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/components/matrix_impedance_switch.py +63 -0
  19. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/controllers/__init__.py +0 -0
  20. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/controllers/regulator_controller.py +77 -0
  21. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/__init__.py +0 -0
  22. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/capacitor_equipment.py +94 -0
  23. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/distribution_transformer_equipment.py +64 -0
  24. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/load_equipment.py +104 -0
  25. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/matrix_branch_equipment.py +56 -0
  26. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/voltage_source_equipment.py +62 -0
  27. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/equipment/winding_equipment.py +115 -0
  28. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/length_units.py +26 -0
  29. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/queries.py +674 -0
  30. nrel_ditto-0.0.7/src/ditto/readers/cim_iec_61968_13/reader.py +202 -0
  31. nrel_ditto-0.0.7/src/ditto/readers/opendss/__init__.py +0 -0
  32. nrel_ditto-0.0.7/src/ditto/readers/opendss/common.py +138 -0
  33. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/__init__.py +0 -0
  34. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/branches.py +405 -0
  35. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/buses.py +60 -0
  36. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/cables.py +83 -0
  37. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/capacitors.py +109 -0
  38. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/conductors.py +50 -0
  39. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/fuses.py +0 -0
  40. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/loads.py +127 -0
  41. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/loadshapes.py +141 -0
  42. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/pv_systems.py +136 -0
  43. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/sources.py +128 -0
  44. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/storage.py +0 -0
  45. nrel_ditto-0.0.7/src/ditto/readers/opendss/components/transformers.py +231 -0
  46. nrel_ditto-0.0.7/src/ditto/readers/opendss/controllers/__init__.py +0 -0
  47. nrel_ditto-0.0.7/src/ditto/readers/opendss/controllers/regulators.py +0 -0
  48. nrel_ditto-0.0.7/src/ditto/readers/opendss/graph_utils.py +201 -0
  49. nrel_ditto-0.0.7/src/ditto/readers/opendss/reader.py +124 -0
  50. nrel_ditto-0.0.7/src/ditto/readers/reader.py +28 -0
  51. nrel_ditto-0.0.7/src/ditto/writers/__init__.py +0 -0
  52. nrel_ditto-0.0.7/src/ditto/writers/abstract_writer.py +12 -0
  53. nrel_ditto-0.0.7/src/ditto/writers/opendss/__init__.py +34 -0
  54. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/__init__.py +0 -0
  55. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_branch.py +39 -0
  56. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_bus.py +39 -0
  57. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_capacitor.py +67 -0
  58. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_load.py +108 -0
  59. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_regulator.py +57 -0
  60. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_transformer.py +54 -0
  61. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/distribution_vsource.py +60 -0
  62. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/geometry_branch.py +17 -0
  63. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/matrix_impedance_branch.py +17 -0
  64. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/matrix_impedance_fuse.py +18 -0
  65. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/matrix_impedance_switch.py +21 -0
  66. nrel_ditto-0.0.7/src/ditto/writers/opendss/components/sequence_impedance_branch.py +17 -0
  67. nrel_ditto-0.0.7/src/ditto/writers/opendss/controllers/__init__.py +0 -0
  68. nrel_ditto-0.0.7/src/ditto/writers/opendss/controllers/distribution_regulator_controller.py +64 -0
  69. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/__init__.py +0 -0
  70. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/bare_conductor_equipment.py +46 -0
  71. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/distribution_transformer_equipment.py +84 -0
  72. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/geometry_branch_equipment.py +58 -0
  73. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/matrix_impedance_branch_equipment.py +38 -0
  74. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/matrix_impedance_fuse_equipment.py +25 -0
  75. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/matrix_impedance_switch_equipment.py +17 -0
  76. nrel_ditto-0.0.7/src/ditto/writers/opendss/equipment/sequence_impedance_branch_equipment.py +47 -0
  77. nrel_ditto-0.0.7/src/ditto/writers/opendss/opendss_mapper.py +67 -0
  78. nrel_ditto-0.0.7/src/ditto/writers/opendss/write.py +307 -0
@@ -0,0 +1,178 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ tests/dump_from_tests/
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+ tests/dump_from_tests/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105
+ #poetry.lock
106
+
107
+ # pdm
108
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109
+ #pdm.lock
110
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111
+ # in version control.
112
+ # https://pdm.fming.dev/#use-with-ide
113
+ .pdm.toml
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+
165
+
166
+ #ditto ignores
167
+
168
+ *.csv
169
+ *.json
170
+ *.txt
171
+ *.TXT
172
+ *.swp
173
+ *.swo
174
+ *.DSV
175
+ *.dsv
176
+ *.dbl
177
+ *.DBL
178
+ .qodo
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: NREL-ditto
3
+ Version: 0.0.7
4
+ Summary: Many to one to many distrbution system model converter
5
+ Project-URL: Documentation, https://github.com/NREL-Distribution-Suites/ditto#readme
6
+ Project-URL: Issues, https://github.com/NREL-Distribution-Suites/ditto/issues
7
+ Project-URL: Source, https://github.com/NREL-Distribution-Suites/ditto
8
+ Author-email: Aadil Latif <aadil.latif@gmail.com>
9
+ License-Expression: MIT
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: grid-data-models==2.0.0
19
+ Requires-Dist: nrel-altdss-schema==0.0.1
20
+ Requires-Dist: opendssdirect-py
21
+ Requires-Dist: rdflib
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == 'dev'
24
+ Requires-Dist: ruff; extra == 'dev'
25
+ Provides-Extra: doc
26
+ Requires-Dist: autodoc-pydantic; extra == 'doc'
27
+ Requires-Dist: myst-parser; extra == 'doc'
28
+ Requires-Dist: pydata-sphinx-theme; extra == 'doc'
29
+ Requires-Dist: sphinx; extra == 'doc'
30
+ Requires-Dist: sphinxcontrib-mermaid; extra == 'doc'
@@ -0,0 +1,113 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "NREL-ditto"
7
+ dynamic = ["version"]
8
+ description = 'Many to one to many distrbution system model converter '
9
+ requires-python = ">=3.11"
10
+ license = "MIT"
11
+ keywords = []
12
+ authors = [
13
+ { name = "Aadil Latif", email = "aadil.latif@gmail.com" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: Implementation :: CPython",
22
+ "Programming Language :: Python :: Implementation :: PyPy",
23
+ ]
24
+ dependencies = [
25
+ "opendssdirect.py",
26
+ "grid-data-models==2.0.0",
27
+ "rdflib",
28
+ "NREL-altdss-schema==0.0.1",
29
+ ]
30
+
31
+ [project.urls]
32
+ Documentation = "https://github.com/NREL-Distribution-Suites/ditto#readme"
33
+ Issues = "https://github.com/NREL-Distribution-Suites/ditto/issues"
34
+ Source = "https://github.com/NREL-Distribution-Suites/ditto"
35
+
36
+ [tool.hatch.version]
37
+ path = "src/ditto/__init__.py"
38
+
39
+ [project.optional-dependencies]
40
+ doc = [
41
+ "sphinxcontrib-mermaid",
42
+ "pydata-sphinx-theme",
43
+ "autodoc_pydantic",
44
+ "myst-parser",
45
+ "sphinx",
46
+ ]
47
+ dev = [
48
+ "pytest",
49
+ "ruff"
50
+ ]
51
+
52
+
53
+
54
+ [tool.pytest.ini_options]
55
+ minversion = "6.0"
56
+ addopts = "-ra"
57
+ testpaths = [
58
+ "tests",
59
+ ]
60
+
61
+ [tool.ruff]
62
+ # Exclude a variety of commonly ignored directories.
63
+ exclude = [
64
+ ".git",
65
+ ".ruff_cache",
66
+ ".venv",
67
+ "_build",
68
+ "build",
69
+ "dist",
70
+ "env",
71
+ "venv",
72
+ ]
73
+
74
+ line-length = 99
75
+ indent-width = 4
76
+ target-version = "py311"
77
+
78
+ [tool.ruff.lint]
79
+ # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
80
+ select = [
81
+ "C901", # McCabe complexity
82
+ "E4", # Subset of pycodestyle (E)
83
+ "E7",
84
+ "E9",
85
+ "F", # Pyflakes
86
+ "W", # pycodestyle warnings
87
+ ]
88
+ ignore = []
89
+
90
+ # Allow fix for all enabled rules (when `--fix`) is provided.
91
+ fixable = ["ALL"]
92
+ unfixable = []
93
+
94
+ [tool.ruff.format]
95
+ quote-style = "double"
96
+ indent-style = "space"
97
+ skip-magic-trailing-comma = false
98
+ line-ending = "auto"
99
+ docstring-code-format = true
100
+ docstring-code-line-length = "dynamic"
101
+
102
+ [tool.ruff.lint.per-file-ignores]
103
+ "__init__.py" = ["E402", "F401"]
104
+ "**/{tests,docs,tools}/*" = ["E402"]
105
+
106
+ [tool.hatch.metadata]
107
+ allow-direct-references = true
108
+
109
+ [tool.hatch.build.targets.wheel]
110
+ packages = ["src/ditto"]
111
+
112
+ [tool.hatch.build.targets.sdist]
113
+ include = ["src/ditto"]
@@ -0,0 +1 @@
1
+ __version__ = "0.0.7"
@@ -0,0 +1,18 @@
1
+ from enum import Enum
2
+
3
+
4
+ class OpenDSSFileTypes(str, Enum):
5
+ MASTER_FILE = "Master.dss"
6
+ COORDINATE_FILE = "BusCoords.dss"
7
+ WIRES_FILE = "WireData.dss"
8
+ LINE_GEOMETRIES_FILE = "LineGeometry.dss"
9
+ LINECODES_FILE = "LineCodes.dss"
10
+ SWITCH_CODES_FILE = "SwitchCodes.dss"
11
+ FUSE_CODES_FILE = "FuseCodes.dss"
12
+ TRANSFORMERS_FILE = "Transformers.dss"
13
+ CAPACITORS_FILE = "Capacitors.dss"
14
+ LINES_FILE = "Lines.dss"
15
+ LOADS_FILE = "Loads.dss"
16
+ SWITCH_FILE = "Switches.dss"
17
+ FUSE_FILE = "Fuses.dss"
18
+ REGULATOR_CONTROLLERS_FILE = "RegControllers.dss"
File without changes
@@ -0,0 +1,31 @@
1
+ from ditto.readers.cim_iec_61968_13.components.distribution_bus import DistributionBusMapper
2
+ from ditto.readers.cim_iec_61968_13.components.distribution_capacitor import (
3
+ DistributionCapacitorMapper,
4
+ )
5
+ from ditto.readers.cim_iec_61968_13.components.distribution_load import DistributionLoadMapper
6
+ from ditto.readers.cim_iec_61968_13.components.distribution_transformer import (
7
+ DistributionTransformerMapper,
8
+ )
9
+ from ditto.readers.cim_iec_61968_13.equipment.distribution_transformer_equipment import (
10
+ DistributionTransformerEquipmentMapper,
11
+ )
12
+ from ditto.readers.cim_iec_61968_13.equipment.matrix_branch_equipment import (
13
+ MatrixImpedanceBranchEquipmentMapper,
14
+ )
15
+ from ditto.readers.cim_iec_61968_13.components.matrix_branch import MatrixImpedanceBranchMapper
16
+ from ditto.readers.cim_iec_61968_13.components.distribution_voltage_source import (
17
+ DistributionVoltageSourceMapper,
18
+ )
19
+ from ditto.readers.cim_iec_61968_13.equipment.voltage_source_equipment import (
20
+ VoltageSourceEquipmentMapper,
21
+ )
22
+ from ditto.readers.cim_iec_61968_13.controllers.regulator_controller import (
23
+ RegulatorControllerMapper,
24
+ )
25
+ from ditto.readers.cim_iec_61968_13.components.distribution_regulator import (
26
+ DistributionRegulatorMapper,
27
+ )
28
+
29
+ from ditto.readers.cim_iec_61968_13.components.matrix_impedance_switch import (
30
+ MatrixImpedanceSwitchMapper,
31
+ )
@@ -0,0 +1,8 @@
1
+ from abc import ABC
2
+
3
+ from gdm.distribution import DistributionSystem
4
+
5
+
6
+ class CimMapper(ABC):
7
+ def __init__(self, system: DistributionSystem):
8
+ self.system = system
@@ -0,0 +1,3 @@
1
+ from gdm.distribution.enums import Phase
2
+
3
+ phase_mapper = {"A": Phase.A, "B": Phase.B, "C": Phase.C}
@@ -0,0 +1,61 @@
1
+ from gdm.distribution.components import DistributionBus
2
+ from gdm.distribution.common import VoltageLimitSet
3
+ from gdm.quantities import PositiveVoltage
4
+ from infrasys.location import Location
5
+ from gdm.distribution.enums import (
6
+ VoltageTypes,
7
+ LimitType,
8
+ )
9
+
10
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
11
+ from ditto.readers.cim_iec_61968_13.common import phase_mapper
12
+
13
+
14
+ class DistributionBusMapper(CimMapper):
15
+ def __init__(self, system):
16
+ super().__init__(system)
17
+
18
+ def parse(self, row):
19
+ phases = row["phase"].split(",")
20
+ self.n_phase = len(phases)
21
+ return DistributionBus(
22
+ name=self.map_name(row),
23
+ coordinate=self.map_coordinate(row),
24
+ rated_voltage=self.map_rated_voltage(row),
25
+ phases=self.map_phases(row),
26
+ voltagelimits=self.map_voltagelimits(row),
27
+ voltage_type=self.map_voltage_type(row),
28
+ )
29
+
30
+ def map_name(self, row):
31
+ return row["bus"]
32
+
33
+ def map_coordinate(self, row):
34
+ X, Y = row["x"], row["y"]
35
+ crs = None
36
+ location = Location(x=X, y=Y, crs=crs)
37
+ return location
38
+
39
+ # Nominal voltage is only defined by transformers
40
+ def map_rated_voltage(self, row):
41
+ return PositiveVoltage(float(row["rated_voltage"]) / 1.732, "volt")
42
+
43
+ def map_phases(self, row):
44
+ phases = row["phase"].split(",")
45
+ all_phases = [phase_mapper[phase] for phase in phases]
46
+ return all_phases
47
+
48
+ def map_voltagelimits(self, row):
49
+ return [
50
+ VoltageLimitSet(
51
+ limit_type=LimitType.MIN,
52
+ value=PositiveVoltage(float(row["rated_voltage"]) * 0.95, "volt"),
53
+ ),
54
+ VoltageLimitSet(
55
+ limit_type=LimitType.MAX,
56
+ value=PositiveVoltage(float(row["rated_voltage"]) * 1.05, "volt"),
57
+ ),
58
+ ]
59
+
60
+ def map_voltage_type(self, row):
61
+ return VoltageTypes.LINE_TO_GROUND.value
@@ -0,0 +1,43 @@
1
+ from gdm.distribution.components import DistributionBus, DistributionCapacitor
2
+
3
+ from ditto.readers.cim_iec_61968_13.equipment.capacitor_equipment import CapacitorEquipmentMapper
4
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
5
+ from ditto.readers.cim_iec_61968_13.common import phase_mapper
6
+
7
+
8
+ class DistributionCapacitorMapper(CimMapper):
9
+ def __init__(self, system):
10
+ super().__init__(system)
11
+
12
+ def parse(self, row):
13
+ return DistributionCapacitor(
14
+ name=self.map_name(row),
15
+ bus=self.map_bus(row),
16
+ phases=self.map_phases(row),
17
+ controllers=self.map_controllers(row),
18
+ equipment=self.map_equipment(row),
19
+ )
20
+
21
+ def map_name(self, row):
22
+ return row["capacitor"]
23
+
24
+ def map_bus(self, row):
25
+ bus_name = row["bus"]
26
+ bus = self.system.get_component(component_type=DistributionBus, name=bus_name)
27
+ return bus
28
+
29
+ def map_phases(self, row):
30
+ phases = row["phase"]
31
+ if phases is None:
32
+ phases = ["A", "B", "C"]
33
+ else:
34
+ phases = phases.split(",")
35
+ return [phase_mapper[phase] for phase in phases]
36
+
37
+ def map_controllers(self, row):
38
+ return []
39
+
40
+ def map_equipment(self, row):
41
+ mapper = CapacitorEquipmentMapper(self.system)
42
+ equipment = mapper.parse(row)
43
+ return equipment
@@ -0,0 +1,48 @@
1
+ from gdm.distribution.components import DistributionLoad, DistributionBus
2
+
3
+ from ditto.readers.cim_iec_61968_13.equipment.load_equipment import LoadEquipmentMapper
4
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
5
+ from ditto.readers.cim_iec_61968_13.common import phase_mapper
6
+
7
+
8
+ class DistributionLoadMapper(CimMapper):
9
+ def __init__(self, system):
10
+ super().__init__(system)
11
+
12
+ def parse(self, row):
13
+ return DistributionLoad(
14
+ name=self.map_name(row),
15
+ bus=self.map_bus(row),
16
+ phases=self.map_phases(row),
17
+ equipment=self.map_equipment(row),
18
+ )
19
+
20
+ def map_name(self, row):
21
+ return row["load"]
22
+
23
+ def map_bus(self, row):
24
+ bus_name = row["bus"]
25
+ bus = self.system.get_component(component_type=DistributionBus, name=bus_name)
26
+ return bus
27
+
28
+ def map_phases(self, row):
29
+ bus_name = row["bus"]
30
+ bus = self.system.get_component(component_type=DistributionBus, name=bus_name)
31
+ phases = row["phase"]
32
+
33
+ if phases is None:
34
+ phases = ["A", "B", "C"]
35
+ else:
36
+ phases = phases.split(",")
37
+ phases = [phase_mapper[phase] for phase in phases]
38
+
39
+ if row["grounded"] == "false" and len(phases) == 1:
40
+ diff = list(set(bus.phases).difference(phases))
41
+ if diff:
42
+ phases.append(sorted(diff)[0].value)
43
+ return phases
44
+
45
+ def map_equipment(self, row):
46
+ mapper = LoadEquipmentMapper(self.system)
47
+ equipment = mapper.parse(row)
48
+ return equipment
@@ -0,0 +1,56 @@
1
+ from gdm.distribution.components import DistributionBus, DistributionRegulator
2
+ from gdm.distribution.controllers import RegulatorController
3
+ from gdm.distribution.enums import Phase
4
+
5
+ from ditto.readers.cim_iec_61968_13.equipment.distribution_transformer_equipment import (
6
+ DistributionTransformerEquipmentMapper,
7
+ )
8
+
9
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
10
+ from ditto.readers.cim_iec_61968_13.common import phase_mapper
11
+
12
+
13
+ class DistributionRegulatorMapper(CimMapper):
14
+ def __init__(self, system):
15
+ super().__init__(system)
16
+
17
+ def parse(self, row):
18
+ return DistributionRegulator(
19
+ name=self.map_name(row),
20
+ buses=self.map_bus(row),
21
+ equipment=self.map_equipment(row),
22
+ winding_phases=self.map_winding_phases(row),
23
+ controllers=self.map_controllers(row),
24
+ )
25
+
26
+ def map_name(self, row):
27
+ return row["xfmr"]
28
+
29
+ def map_winding_phases(self, row):
30
+ if "wdg_1_phase" in row:
31
+ phase_1 = [phase_mapper[phs] for phs in row["wdg_1_phase"].replace("N", "")]
32
+ else:
33
+ phase_1 = [Phase.A, Phase.B, Phase.C]
34
+
35
+ if "wdg_2_phase" in row:
36
+ phase_2 = [phase_mapper[phs] for phs in row["wdg_2_phase"].replace("N", "")]
37
+ else:
38
+ phase_2 = [Phase.A, Phase.B, Phase.C]
39
+
40
+ return [phase_1, phase_2]
41
+
42
+ def map_bus(self, row):
43
+ bus_1_name = row["bus_1"]
44
+ bus_2_name = row["bus_2"]
45
+ bus_1 = self.system.get_component(DistributionBus, bus_1_name)
46
+ bus_2 = self.system.get_component(DistributionBus, bus_2_name)
47
+ return [bus_1, bus_2]
48
+
49
+ def map_equipment(self, row):
50
+ xfmr_equip_mapper = DistributionTransformerEquipmentMapper(self.system)
51
+ xfmr_equip = xfmr_equip_mapper.parse(row)
52
+ return xfmr_equip
53
+
54
+ def map_controllers(self, row):
55
+ reg_controllers = self.system.get_component(RegulatorController, row["xfmr"])
56
+ return [reg_controllers]
@@ -0,0 +1,38 @@
1
+ from gdm.distribution.components import DistributionBus, DistributionTransformer
2
+ from gdm.distribution.enums import Phase
3
+
4
+ from ditto.readers.cim_iec_61968_13.equipment.distribution_transformer_equipment import (
5
+ DistributionTransformerEquipmentMapper,
6
+ )
7
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
8
+
9
+
10
+ class DistributionTransformerMapper(CimMapper):
11
+ def __init__(self, system):
12
+ super().__init__(system)
13
+
14
+ def parse(self, row):
15
+ return DistributionTransformer(
16
+ name=self.map_name(row),
17
+ buses=self.map_bus(row),
18
+ equipment=self.map_equipment(row),
19
+ winding_phases=self.map_winding_phases(row),
20
+ )
21
+
22
+ def map_name(self, row):
23
+ return row["xfmr"]
24
+
25
+ def map_winding_phases(self, row):
26
+ return [[Phase.A, Phase.B, Phase.C], [Phase.A, Phase.B, Phase.C]]
27
+
28
+ def map_bus(self, row):
29
+ bus_1_name = row["bus_1"]
30
+ bus_2_name = row["bus_2"]
31
+ bus_1 = self.system.get_component(DistributionBus, bus_1_name)
32
+ bus_2 = self.system.get_component(DistributionBus, bus_2_name)
33
+ return [bus_1, bus_2]
34
+
35
+ def map_equipment(self, row):
36
+ xfmr_equip_mapper = DistributionTransformerEquipmentMapper(self.system)
37
+ xfmr_equip = xfmr_equip_mapper.parse(row)
38
+ return xfmr_equip
@@ -0,0 +1,36 @@
1
+ from gdm.distribution.components import DistributionBus, DistributionVoltageSource
2
+
3
+ from ditto.readers.cim_iec_61968_13.equipment.voltage_source_equipment import (
4
+ VoltageSourceEquipmentMapper,
5
+ )
6
+ from ditto.readers.cim_iec_61968_13.cim_mapper import CimMapper
7
+ from ditto.readers.cim_iec_61968_13.common import phase_mapper
8
+
9
+
10
+ class DistributionVoltageSourceMapper(CimMapper):
11
+ def __init__(self, system):
12
+ super().__init__(system)
13
+
14
+ def parse(self, row):
15
+ return DistributionVoltageSource(
16
+ name=self.map_name(row),
17
+ bus=self.map_bus(row),
18
+ phases=self.map_phases(),
19
+ equipment=self.map_equipment(row),
20
+ )
21
+
22
+ def map_name(self, row):
23
+ return row["source"]
24
+
25
+ def map_bus(self, row):
26
+ bus_name = row["bus"]
27
+ bus = self.system.get_component(component_type=DistributionBus, name=bus_name)
28
+ return bus
29
+
30
+ def map_phases(self):
31
+ return [phase_mapper[phase] for phase in ["A", "B", "C"]]
32
+
33
+ def map_equipment(self, row):
34
+ mapper = VoltageSourceEquipmentMapper(self.system)
35
+ equipment = mapper.parse(row)
36
+ return equipment