diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7ea011e..e53ea5d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 with: - version: '1.6' + version: '1' - name: Install dependencies run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: Build and deploy diff --git a/src/fuel_results.jl b/src/fuel_results.jl index 8732429..e6437e1 100644 --- a/src/fuel_results.jl +++ b/src/fuel_results.jl @@ -80,8 +80,14 @@ results = solve_op_model!(OpModel) generators = make_fuel_dictionary(sys) """ -function make_fuel_dictionary(sys::PSY.System, mapping::Dict{NamedTuple, String}) - generators = PSY.get_components(PSY.get_available, PSY.StaticInjection, sys) +function make_fuel_dictionary( + sys::PSY.System, + mapping::Dict{NamedTuple, String}; + filter_func = x -> true, + kwargs..., +) + filter_func2 = x -> PSY.get_available(x) && filter_func(x) + generators = PSY.get_components(filter_func2, PSY.StaticInjection, sys) gen_categories = Dict() for category in unique(values(mapping)) gen_categories["$category"] = [] @@ -107,5 +113,5 @@ end function make_fuel_dictionary(sys::PSY.System; kwargs...) mapping = get_generator_mapping(get(kwargs, :generator_mapping_file, nothing)) - return make_fuel_dictionary(sys, mapping) + return make_fuel_dictionary(sys, mapping; kwargs...) end diff --git a/src/get_data.jl b/src/get_data.jl index 31bf10d..2124d36 100644 --- a/src/get_data.jl +++ b/src/get_data.jl @@ -415,7 +415,7 @@ function _get_loads(system::PSY.System, load::PSY.StaticLoad) return [load] end function _get_loads(system::PSY.System, sys::PSY.System) - return PSY.get_components(PSY.StaticLoad, system, PSY.get_available) + return PSY.get_components(PSY.get_available, PSY.StaticLoad, system) end get_base_power(system::PSY.System) = PSY.get_base_power(system) @@ -425,7 +425,7 @@ get_base_power(results::PSI.ProblemResults) = results.base_power function get_load_data( system::PSY.System; aggregation::Union{ - Type{PSY.StandardLoad}, + Type{PSY.StaticLoad}, Type{PSY.Bus}, Type{PSY.System}, Type{<:PSY.AggregationTopology}, @@ -534,7 +534,7 @@ Re-categorizes data according to an aggregation dictionary # Example ```julia -aggregation = PG.make_fuel_dictionary(results_uc.system) +aggregation = PA.make_fuel_dictionary(results_uc.system) categorize_data(gen_uc.data, aggregation) ``` diff --git a/test/test_result_sorting.jl b/test/test_result_sorting.jl index fee07e1..45f3eb1 100644 --- a/test/test_result_sorting.jl +++ b/test/test_result_sorting.jl @@ -63,8 +63,9 @@ problem_results = run_test_prob() @test length(srv.time) == 5 # TODO: make tests for subsetting data - #sub_gen = get_generation_data(results_uc, filter_func = x->get_name(get_bus(x)) == "bus2") - #@test length(sub_gen.data) == 1 + sub_gen = + get_generation_data(results_uc, filter_func = x -> get_name(get_bus(x)) == "bus1") + @test length(sub_gen.data) == 8 end @testset "test curtailment calculations" begin @@ -98,3 +99,18 @@ end fuel_agg = PA.combine_categories(fuel) @test size(fuel_agg) == (48, 8) end + +@testset "Test system data getters" begin + sys = PSI.get_system(results_uc) + load_data1 = PA.get_load_data(sys; aggregation = Bus) + @test length(load_data1.data) == 3 + @test length(load_data1.time) == 24 + + load_data2 = PA.get_load_data(sys, aggregation = StaticLoad) + @test length(load_data2.data) == 3 + @test length(load_data2.time) == 24 + + load_data3 = PA.get_load_data(sys, aggregation = System) + @test length(load_data2.data) == 3 + @test length(load_data2.time) == 24 +end