Skip to content

Add iterator for SimDir and NCCatalog #400

Description

@ph-kev

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

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 OutputVars in SimDir. I don't think the order matters here. This can also be done for NCCatalog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions