Skip to content

Commit

Permalink
ColocatedDataLists class
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisblake committed Aug 7, 2023
1 parent e6837ab commit 7e2da85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions pyaerocom/colocation_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@
logger = logging.getLogger(__name__)


ColocatedDataLists = namedtuple(
"ColocatedDataLists", ["colocateddata_for_statistics", "colocateddata_for_profile_viz"]
)
# ColocatedDataLists = namedtuple(
# "ColocatedDataLists", ["colocateddata_for_statistics", "colocateddata_for_profile_viz"]
# )


class ColocatedDataLists(NamedTuple):
colocateddata_for_statistics: list[ColocatedData]
colocateddata_for_profile_viz: list[ColocatedData]


def _colocate_vertical_profile_gridded(
Expand Down Expand Up @@ -332,7 +337,7 @@ def colocate_vertical_profile_gridded(
colocation_layer_limits: list[dict] = None,
profile_layer_limits: list[dict] = None,
**kwargs,
) -> NamedTuple:
) -> ColocatedDataLists:
"""
Colocated vertical profile data with gridded (model) data
Expand Down Expand Up @@ -492,7 +497,7 @@ def colocate_vertical_profile_gridded(
coldata.data.attrs["just_for_viz"] = 1

colocated_data_lists = ColocatedDataLists(
output_prep[0], output_prep[1]
*output_prep
) # put the list of prepared output into namedtuple object s.t. both position and named arguments can be used
# breakpoint()
return colocated_data_lists
2 changes: 1 addition & 1 deletion pyaerocom/colocation_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ def _run_helper(self, model_var: str, obs_var: str):
if self.save_coldata:
self._save_coldata(coldata)

elif isinstance(coldata, ColocatedDataLists):
elif isinstance(coldata, ColocatedDataLists): # look into intertools chain.from_iterable
for i_list in coldata:
for coldata_obj in i_list:
coldata_obj.data.attrs["model_name"] = self.get_model_name()
Expand Down

0 comments on commit 7e2da85

Please sign in to comment.