def pandapipesNet(self): if isinstance(self.obj, str): # backwards compatibility from pandapipes import from_json_string return from_json_string(self.obj) else: net = pandapipesNet(get_basic_net_entries()) net.update(self.obj) return net
def from_pickle(filename): """ Load a pandapipes format Network from pickle file. :param filename: The absolute or relative path to the input file or file-like object :type filename: str, file-object :return: net - The pandapipes Network which was saved as pickle :rtype: pandapipesNet :Example: >>> net1 = pandapipes.from_pickle(os.path.join("C:", "example_folder", "example1.p")) >>> net2 = pandapipes.from_pickle("example2.p") #relative path """ net = pandapipesNet(get_raw_data_from_pickle(filename)) transform_net_with_df_and_geo(net, ["junction_geodata"], ["pipe_geodata"]) return net
def create_empty_network(name="", fluid=None, add_stdtypes=True): """ This function initializes the pandapipes datastructure. :param name: name for the network :type name: string, default None :param fluid: A fluid that can be added to the net from the start. Should be either of type\ Fluid (c.f. pandapipes.properties.fluids.Fluid) or a string which refers to a standard\ fluid type used to call `create_fluid_from_lib`. A fluid is required for pipeflow\ calculations, but can also be added later. :type fluid: Fluid or str, default None :param add_stdtypes: flag whether to add a dictionary of typical pump and pipe std types :type add_stdtypes: bool, default True :return: net - pandapipesNet with empty tables :rtype: pandapipesNet :Example: >>> net1 = create_empty_network("my_first_pandapipesNet", "lgas") >>> net2 = create_empty_network() """ net = pandapipesNet(get_default_pandapipes_structure()) add_new_component(net, Junction, True) add_new_component(net, Pipe, True) add_new_component(net, ExtGrid, True) net['controller'] = pd.DataFrame(np.zeros(0, dtype=net['controller']), index=[]) net['name'] = name if add_stdtypes: add_basic_std_types(net) net["name"] = name if fluid is not None: if isinstance(fluid, Fluid): net["fluid"] = fluid elif isinstance(fluid, str): create_fluid_from_lib(net, fluid) else: logger.warning( "The fluid %s cannot be added to the net Only fluids of type Fluid or " "strings can be used." % fluid) return net