@@ -171,18 +171,22 @@ def __init__(self, **kwargs):
171171
172172 # instantiate topology object and load grid data
173173 self .topology = Topology (config = self .config )
174- self .import_ding0_grid (
175- path = kwargs .get ("ding0_grid" , None ),
176- legacy_ding0_grids = kwargs .get ("legacy_ding0_grids" , True ),
177- )
174+ if kwargs .get ("ding0_grid" , None ) is not None :
175+ self .import_ding0_grid (
176+ path = kwargs .get ("ding0_grid" , None ),
177+ legacy_ding0_grids = kwargs .get ("legacy_ding0_grids" , True ),
178+ )
179+ elif kwargs .get ("pypsa_csv_dir" , None ) is not None :
180+ self .import_pypsa_csv (kwargs .get ("pypsa_csv_dir" ),
181+ snapshot_range = kwargs .get ("snapshot_range" ))
178182 self .legacy_grids = kwargs .get ("legacy_ding0_grids" , True )
179-
180183 # instantiate other data classes
181184 self .results = Results (self )
182185 self .opf_results = OPFResults ()
183- self .timeseries = timeseries .TimeSeries (
184- timeindex = kwargs .get ("timeindex" , pd .DatetimeIndex ([]))
185- )
186+ if kwargs .get ("pypsa_csv_dir" , None ) is None :
187+ self .timeseries = timeseries .TimeSeries (
188+ timeindex = kwargs .get ("timeindex" , pd .DatetimeIndex ([]))
189+ )
186190 self .electromobility = Electromobility (edisgo_obj = self )
187191 self .heat_pump = HeatPump ()
188192 self .dsm = DSM ()
@@ -3421,6 +3425,16 @@ def copy(self, deep=True):
34213425
34223426 return cpy
34233427
3428+ def import_pypsa_csv (self , path , snapshot_range ):
3429+ """
3430+ Imports grid topology and timeseries from a PyPSA CSV export.
3431+ """
3432+ # Lazy import to avoid circular dependencies
3433+ from edisgo .io .pypsa_csv_import import populate_edisgo_from_pypsa_csv
3434+
3435+ if path is not None :
3436+ populate_edisgo_from_pypsa_csv (self , path , snapshot_range = snapshot_range )
3437+
34243438
34253439def import_edisgo_from_pickle (filename , path = "" ):
34263440 """
0 commit comments