def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         f"solar_{a}":
         InputSolarSeriesArea(config.next_file(f"solar_{a}.txt"))
         for a in config.area_names()
     }
     return children
Exemple #2
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         f"miscgen-{a}":
         InputMiscGenArea(config.next_file(f"miscgen-{a}.txt"))
         for a in config.area_names()
     }
     return children
def test_validate_section():
    data = {"section": {"params": 42}}

    node = IniFileNode(config=StudyConfig(Path()), types={"wrong-section": {}})
    assert node.check_errors(data=data) == [
        "section wrong-section not in IniFileNode"
    ]
    with pytest.raises(ValueError):
        node.check_errors(data, raising=True)

    node = IniFileNode(
        config=StudyConfig(Path()), types={"section": {"wrong-params": 42}}
    )
    assert node.check_errors(data=data) == [
        "param wrong-params of section section not in IniFileNode"
    ]
    with pytest.raises(ValueError):
        node.check_errors(data, raising=True)

    node = IniFileNode(
        config=StudyConfig(Path()), types={"section": {"params": str}}
    )
    assert node.check_errors(data=data) == [
        "param params of section section in IniFileNode bad type"
    ]
Exemple #4
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         thermal: OutputSimulationTsNumbersThermalAreaThermal(
             config.next_file(thermal + ".txt"))
         for thermal in config.get_thermal_names(self.area)
     }
     return children
Exemple #5
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "areas": OutputSimulationModeMcAllAreas(config.next_file("areas")),
         "grid": OutputSimulationModeMcAllGrid(config.next_file("grid")),
         "links": OutputSimulationModeMcAllLinks(config.next_file("links")),
     }
     return children
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         area:
         OutputSimulationTsNumbersHydroArea(config.next_file(area + ".txt"))
         for area in config.area_names()
     }
     return children
Exemple #7
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         area: OutputSimulationTsNumbersThermalArea(config.next_file(area),
                                                    area)
         for area in config.area_names()
     }
     return children
Exemple #8
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "energy":
         InputHydroPreproAreaEnergy(config.next_file("energy.txt")),
         "prepro":
         InputHydroPreproAreaPrepro(config.next_file("prepro.ini")),
     }
     return children
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = {
            a: Area(config.next_file(a), area=a) for a in config.area_names()
        }

        for s in config.set_names():
            children[f"@ {s}"] = Set(config.next_file(f"@ {s}"), set=s)
        return children
Exemple #10
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "ui": InputAreasUi(config.next_file("ui.ini")),
         "optimization": InputAreasOptimization(
             config.next_file("optimization.ini")
         ),
     }
     return children
Exemple #11
0
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = dict()

        for timing in config.get_filters_year(self.set):
            children[f"values-{timing}"] = Values(
                config.next_file(f"values-{timing}.txt"), timing, self.set)

        return children
Exemple #12
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         a: InputLoadPreproArea(config.next_file(a))
         for a in config.area_names()
     }
     children["correlation"] = InputLoadPreproCorrelation(
         config.next_file("correlation.ini"))
     return children
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         a: InputAreasItem(config.next_file(a))
         for a in config.area_names()
     }
     children["list"] = InputAreasList(config.next_file("list.txt"))
     children["sets"] = InputAreasSets(config.next_file("sets.ini"))
     return children
Exemple #14
0
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = {
            l: InputLinkAreaLink(config.next_file(f"{l}.txt"))
            for l in config.get_links(self.area)
        }
        children["properties"] = InputLinkAreaProperties(
            config.next_file("properties.ini"), area=self.area)

        return children
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "allocation": InputHydroAllocation(config.next_file("allocation")),
         "common": InputHydroCommon(config.next_file("common")),
         "prepro": InputHydroPrepro(config.next_file("prepro")),
         "series": InputHydroSeries(config.next_file("series")),
         "hydro": InputHydroIni(config.next_file("hydro.ini")),
     }
     return children
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "data":
         InputThermalPreproAreaThermalData(config.next_file("data.txt")),
         "modulation":
         InputThermalPreproAreaThermalModulation(
             config.next_file("modulation.txt")),
     }
     return children
def test_get(tmp_path: Path) -> None:
    (tmp_path / "my-study/a/b").mkdir(parents=True)
    (tmp_path / "my-study/a/b/c").touch()
    config = StudyConfig(study_path=tmp_path / "my-study",
                         areas=dict(),
                         outputs=dict())
    config = config.next_file("a").next_file("b").next_file("c")

    node = RawFileNode(config=config)
    assert node.get() == "file/my-study/a/b/c"
Exemple #18
0
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = {
            bind: BindingConstraintsItem(config.next_file(f"{bind}.txt"))
            for bind in config.bindings
        }

        children["bindingconstraints"] = BindingConstraintsIni(
            config.next_file("bindingconstraints.ini"))

        return children
Exemple #19
0
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = {}

        if self.simulation.by_year:
            children["mc-ind"] = OutputSimulationModeMcInd(
                config.next_file("mc-ind"), self.simulation)
        if self.simulation.synthesis:
            children["mc-all"] = OutputSimulationModeMcAll(
                config.next_file("mc-all"))

        return children
Exemple #20
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         f"values-{timing}": Values(
             config.next_file(f"values-{timing}.txt"),
             timing,
             self.area,
             self.link,
         )
         for timing in config.get_filters_year(self.area, self.link)
     }
     return children
def test_validate(tmp_path: Path) -> None:
    file = tmp_path / "file"
    file.touch()

    node = RawFileNode(config=StudyConfig(study_path=file))
    assert node.check_errors(data=None) == []

    node = RawFileNode(config=StudyConfig(study_path=tmp_path / "nofile"))
    assert "not exist" in node.check_errors(data=None)[0]

    with pytest.raises(ValueError):
        node.check_errors(data=None, raising=True)
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "resources": Resources(config.next_file("resources")),
         "simulations": SettingsSimulations(
             config.next_file("simulations")
         ),
         "comments": Comments(config.next_file("comments.txt")),
         "generaldata": GeneralData(config.next_file("generaldata.ini")),
         "scenariobuilder": ScenarioBuilder(
             config.next_file("scenariobuilder.dat")
         ),
     }
     return children
Exemple #23
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "areas":
         OutputSimulationModeMcAllGridAreas(config.next_file("areas.txt")),
         "digest":
         OutputSimulationModeMcAllGridDigest(
             config.next_file("digest.txt")),
         "links":
         OutputSimulationModeMcAllGridLinks(config.next_file("links.txt")),
         "thermal":
         OutputSimulationModeMcAllGridThermals(
             config.next_file("thermal.txt")),
     }
     return children
Exemple #24
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = dict()
     for area in config.area_names():
         for file in [
                 "creditmodulations",
                 "inflowPattern",
                 "maxpower",
                 "reservoir",
                 "waterValues",
         ]:
             name = f"{file}_{area}"
             children[name] = InputHydroCommonCapacityItem(
                 config.next_file(f"{name}.txt"))
     return children
Exemple #25
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "hydro":
         OutputSimulationTsNumbersHydro(config.next_file("hydro")),
         "load":
         OutputSimulationTsNumbersLoad(config.next_file("load")),
         "solar":
         OutputSimulationTsNumbersSolar(config.next_file("solar")),
         "wind":
         OutputSimulationTsNumbersWind(config.next_file("wind")),
         "thermal":
         OutputSimulationTsNumbersThermal(config.next_file("thermal")),
     }
     return children
def test_parse_outputs(tmp_path: Path) -> None:
    study_path = build_empty_files(tmp_path)
    output_path = study_path / "output/20201220-1456eco-hello/"
    output_path.mkdir(parents=True)

    (output_path / "about-the-study").mkdir()
    file = output_path / "about-the-study/parameters.ini"
    content = """
    [general]
    nbyears = 1
    year-by-year = true
    
    [output]
    synthesis = true
    """
    file.write_text(content)

    (output_path / "checkIntegrity.txt").touch()

    config = StudyConfig(
        study_path,
        outputs={
            1:
            Simulation(
                name="hello",
                date="20201220-1456",
                mode="economy",
                nbyears=1,
                synthesis=True,
                by_year=True,
                error=False,
            )
        },
    )
    assert ConfigPathBuilder.build(study_path) == config
Exemple #27
0
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         "conversion":
         InputWindPreproAreaConversation(
             config.next_file("conversion.txt")),
         "data":
         InputWindPreproAreaData(config.next_file("data.txt")),
         "k":
         InputWindPreproAreaK(config.next_file("k.txt")),
         "translation":
         InputWindPreproAreaTranslation(
             config.next_file("translation.txt")),
         "settings":
         InputWindPreproAreaSettings(config.next_file("settings.ini")),
     }
     return children
 def build(self, config: StudyConfig) -> TREE:
     children: TREE = {
         str("{:05d}".format(scn)): OutputSimulationModeMcIndScn(
             config.next_file("{:05d}".format(scn)))
         for scn in range(1, self.simulation.nbyears + 1)
     }
     return children
    def build(self, config: StudyConfig) -> TREE:
        children: TREE = {}

        for area in config.area_names():
            children[area] = _OutputSimulationModeMcAllLinksBis(config, area)

        return children
Exemple #30
0
def test_get(tmp_path: Path):
    path = tmp_path / "file.ini"
    path.write_text(content)

    thermals = [
        ThermalCluster(id="01_solar", enabled=True),
        ThermalCluster(id="02_wind_on", enabled=True),
        ThermalCluster(id="03_wind_off", enabled=True),
        ThermalCluster(id="04_res", enabled=True),
        ThermalCluster(id="05_nuclear", enabled=True),
        ThermalCluster(id="06_coal", enabled=True),
        ThermalCluster(id="07_gas", enabled=True),
        ThermalCluster(id="08_non-res", enabled=True),
        ThermalCluster(id="09_hydro_pump", enabled=True),
    ]

    areas = {
        n: Area(links=[],
                thermals=thermals,
                filters_year=[],
                filters_synthesis=[])
        for n in ["de", "fr", "es", "it"]
    }

    node = ScenarioBuilder(
        StudyConfig(study_path=path, areas=areas, outputs=dict()))

    assert node.get(["Default Ruleset", "t,it,0,09_hydro_pump"]) == 1