@@ -610,55 +610,6 @@ def agent_concatenation(
610610 return result
611611
612612
613- def aggregate_technology_model (
614- data : xr .DataArray | xr .Dataset ,
615- dim : str = "asset" ,
616- drop : str | Sequence [str ] = "installed" ,
617- ) -> xr .DataArray | xr .Dataset :
618- """Aggregate together assets with the same installation year.
619-
620- The assets of a given agent, region, and technology but different installation year
621- are grouped together and summed over.
622-
623- Example:
624- We first create a random set of agent assets and aggregate them.
625- Some of these agents own assets from the same technology but potentially with
626- different installation year. This function will aggregate together all assets
627- of a given agent with same technology.
628-
629- >>> from muse.examples import random_agent_assets
630- >>> from muse.utilities import agent_concatenation, aggregate_technology_model
631- >>> rng = np.random.default_rng(1234)
632- >>> agent_assets = {i: random_agent_assets(rng) for i in range(5)}
633- >>> assets = agent_concatenation(agent_assets)
634- >>> reduced = aggregate_technology_model(assets)
635-
636- We can check that the tuples (agent, technology) are unique (each agent works in
637- a single region):
638-
639- >>> ids = list(zip(reduced.agent.values, reduced.technology.values))
640- >>> assert len(set(ids)) == len(ids)
641-
642- And we can check they correspond to the right summation:
643-
644- >>> for agent, technology in set(ids):
645- ... techsel = assets.technology == technology
646- ... agsel = assets.agent == agent
647- ... expected = assets.sel(asset=techsel & agsel).sum("asset")
648- ... techsel = reduced.technology == technology
649- ... agsel = reduced.agent == agent
650- ... actual = reduced.sel(asset=techsel & agsel)
651- ... assert len(actual.asset) == 1
652- ... assert (actual == expected).all()
653- """
654- if isinstance (drop , str ):
655- drop = (drop ,)
656- return reduce_assets (
657- data ,
658- [cast (str , u ) for u in data .coords if u not in drop and data [u ].dims == (dim ,)],
659- )
660-
661-
662613def check_dimensions (
663614 data : xr .DataArray | xr .Dataset ,
664615 required : Iterable [str ] = (),
0 commit comments