CliMA / CliMA/ClimaAnalysis.jl
Base.show for a few types?
- Dominant language
- Julia
- Stars
- 12
- Forks
- 5
- Avg merge
- 7d 2h
- Merged PRs (30d)
- 2
Description
It would be useful to think of useful output from a few structs that can be printed in REPL, as opposed to the default, which is largely not so useful as I see it.
E.g.:
```julia
julia> simdir = ClimaAnalysis.SimDir(output_dir)
ClimaAnalysis.Sim.SimDir{Dict{Any, Any}, Dict{Any, Any}}("output/les_isdac_box/output_0007", Dict{Any, Any}("cl" => Dict{Any, Any}("average" => Dict{Any, Any}("1h" => "output/les_isdac_box/output_0007/cl_1h_average.nc"), "inst" => Dict{Any, Any}("10m" => "output/les_isdac_box/output_0007/cl_10m_inst.nc")), "hussn" => Dict{Any, Any}("average" => Dict{Any, Any}("1h" => "output/les_isdac_box/output_0007/hussn_1h_average.nc")), "rhoa" => Dict{Any, Any}("average" => Dict{Any, Any}("1h" => "output/les_isdac_box/output_0007/rhoa_1h_average.nc"), "inst" => Dict{Any, Any}("10m" => "output/les_isdac_box/output_0007/rhoa_10m_inst.nc")), "evspsbl" => Dict{Any, Any}("average" => Dict{Any, Any}("1h" => "output/les_isdac_box/output_0007/evspsbl_1h_average.nc"), "inst" => Dict{Any, Any}("10m" => "output/les_isdac_box/output_0007/evspsbl_10m_inst.nc")), "hus" => Dict{Any, Any}("average" => Dict{Any, Any}("1
[...]
[...]
[...]
[...]
# maybe an abbreviated version of summary(simdir)?
julia> simdir = ClimaAnalysis.SimDir(output_dir)
Output directory: output/les_isdac_box/output_0007
Available variables: cl, hussn, rhoa, evspsbl # either short like this
Variables: cl [average (1h), inst (10m)], hussn [average (1h)], rhoa [average (1h), inst (10m)], evspsbl [average (1h), inst (10m)] # or longer like this?
```
and
```julia
julia> get(simdir; short_name="hus", reduction="inst")
ClimaAnalysis.Var.OutputVar{Vector{Float32}, Array{Float32, 4}, String, Dict{Union{AbstractString, Symbol}, Any}, Interpolations.Extrapolation{Float32, 4, Interpolations.GriddedInterpolation{Float32, 4, Array{Float32, 4}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, NTuple{4, Vector{Float32}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Throw{Nothing}}}(Dict("units" => "kg kg^-1", "short_name" => "hus", "long_name" => "Specific Humidity, Instantaneous", "start_date" => "2010-01-01T00:00:00", "comments" => "Mass of all water phases per mass of air"), OrderedCollections.OrderedDict{String, Vector{Float32}}("time" => [0.0, 599.8271, 1199.4447, 1798.8295, 2398.014, 2996.9983, 3595.7825, 4194.335, 4792.6885, 5390.843 … 16122.558, 16716.803, 17310.842, 17904.678, 18498.31, 19091.74, 19
[...]
[... maaaany more lines due to interpolations struct ...]
[...]
julia> get(simdir; short_name="hus", reduction="inst")
Variable: Specific Humidity, Instantaneous (hus) [kg kg^-1]
Dimensions: time (0s -- 21463s), x (0m -- 3200m), y (0m -- 3200m), z (83m -- 2416m)]
```
alternatively, draw inspiration from [DimensionalData.jl](https://rafaqz.github.io/DimensionalData.jl/stable/dimarrays#Dimensional-Indexing) for a more visual representation.
```julia
╭────────────────────────────╮
│ 10×7×5 DimArray{Float64,3} │
├────────────────────────────┴─────────────────────────────────────────── dims ┐
↓ X, → Y, ↗ Z
└──────────────────────────────────────────────────────────────────────────────┘
[:, :, 1]
0.0760848 0.0641884 0.680225 0.683696 0.0205228 0.563623 0.673966
0.0992684 0.970459 0.330777 0.241056 0.0196808 0.669021 0.107475
0.206406 0.444708 0.11996 0.322115 0.225865 0.802122 0.421692
0.94412 0.0192911 0.351413 0.468968 0.269685 0.150126 0.215458
0.917457 0.162553 0.184309 0.719495 0.221163 0.4231 0.721331
0.916702 0.794163 0.880796 0.839618 0.380161 0.180894 0.375182
0.48817 0.498764 0.904961 0.392377 0.625435 0.786147 0.769313
0.339888 0.358625 0.290734 0.0778416 0.451425 0.879774 0.605324
0.481184 0.828395 0.870276 0.0323182 0.195774 0.467484 0.255916
0.758865 0.680352 0.679221 0.920736 0.0375522 0.296639 0.139067
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the Base.show methods and the SimDir and OutputVar entry points mentioned in the issue, then inspect how get and summary currently expose metadata. Done means agreeing on a focused REPL representation for these structs that avoids dumping internal details while showing useful directory, variable, dimension, and unit information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100