CliMA / CliMA/ClimaAnalysis.jl

Add iterator for `SimDir` and `NCCatalog`

Open
#400 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Julia
Stars
12
Forks
5
Avg merge
6d 17h
Merged PRs (30d)
3

Description

If I want to iterate over all possible `OutputVar`s that are available in `SimDir`, I would need to write

```julia
vars = []
for short_name in ClimaAnalysis.available_vars(simdir)
for reduction in ClimaAnalysis.available_reductions(simdir; short_name)
for period in ClimaAnalysis.available_periods(simdir; short_name, reduction)
for coord_type in ClimaAnalysis.available_coord_types(
simdir;
short_name,
reduction,
period,
)
push!(vars, get(simdir; short_name, reduction, period, coord_type))
end
end
end
end
```

which is verbose. Something better than this would be to create a new struct `SimDirIterator` that implements the iterator interface that Julia expects. This would iterate through all the `OutputVar`s in `SimDir`. I don't think the order matters here. This can also be done for `NCCatalog`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the SimDir and NCCatalog definitions and the available_vars, available_reductions, available_periods, available_coord_types, and get entry points. Review Julia's iterator interface, then verify that iteration visits every available OutputVar for both container types, regardless of order.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.