Skip to content

Commit 841b2a2

Browse files
committed
docs: improve README and dataset display formatting
1 parent 66f6c02 commit 841b2a2

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
# CommonDataFormat.jl
22

3-
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaspacephysics.github.io/CommonDataFormat.jl/dev/)
43
[![Build Status](https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/CommonDataFormat.jl/actions/workflows/CI.yml?query=branch%3Amain)
54
[![Coverage](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/CommonDataFormat.jl)
65

7-
A Julia package for reading Common Data Format (CDF) files, widely used in space physics for storing multidimensional data arrays and metadata. See [CDFDatasets.jl](https://github.com/JuliaSpacePhysics/CDFDatasets.jl) for a high-level interface.
6+
A Julia package for reading [Common Data Format (CDF)](https://cdf.gsfc.nasa.gov/) files, widely used in space physics for storing multidimensional data arrays and metadata. See [CDFDatasets.jl](https://github.com/JuliaSpacePhysics/CDFDatasets.jl) for a high-level interface.
7+
8+
**Installation**: at the Julia REPL, run `using Pkg; Pkg.add("CommonDataFormat")`
9+
10+
**Documentation**: [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaspacephysics.github.io/CommonDataFormat.jl/dev/)
811

912
## Features
1013

1114
- **Pure Julia implementation** - No external dependencies on CDF libraries
1215
- **Efficient data access** - Memory-mapped access for data and attributes, super fast decompression using [`LibDeflate`](https://github.com/jakobnissen/LibDeflate.jl)
1316
- **[DiskArrays.jl](https://github.com/JuliaIO/DiskArrays.jl) integration** - Lazy representation of data on hard disk with AbstractDiskArray interface
1417

15-
## Installation
16-
17-
```julia
18-
using Pkg
19-
Pkg.add("CommonDataFormat")
20-
```
21-
2218
## Quick Start
2319

2420
```julia

docs/src/index.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ CurrentModule = CommonDataFormat
44

55
# CommonDataFormat.jl
66

7-
A Julia package for reading Common Data Format (CDF) files.
7+
A Julia package for reading [Common Data Format (CDF)](https://cdf.gsfc.nasa.gov/) files, widely used in space physics for storing multidimensional data arrays and metadata. See [CDFDatasets.jl](https://github.com/JuliaSpacePhysics/CDFDatasets.jl) for a high-level interface.
8+
9+
## Installation
10+
11+
```julia
12+
using Pkg
13+
Pkg.add("CommonDataFormat")
14+
```
15+
16+
## Quick Start
17+
18+
```@example cdf
19+
using CommonDataFormat
20+
21+
# Load a CDF file
22+
omni_file = joinpath(pkgdir(CommonDataFormat), "data/omni_coho1hr_merged_mag_plasma_20240901_v01.cdf")
23+
ds = CDFDataset(omni_file)
24+
```
825

926
## API Reference
1027

src/dataset.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,18 @@ Base.haskey(cdf::CDFDataset, var_name::String) = var_name in keys(cdf)
113113

114114
Base.iterate(cdf::CDFDataset, state = 1) = state > length(cdf) ? nothing : (cdf[keys(cdf)[state]], state + 1)
115115

116-
function Base.show(io::IO, ::MIME"text/plain", cdf::CDFDataset)
117-
println(io, typeof(cdf), ":", cdf.filename)
118-
println(io, "variables")
119-
for var in keys(cdf)
120-
println(io, " $var")
116+
function Base.show(io::IO, m::MIME"text/plain", cdf::CDFDataset)
117+
println(io, typeof(cdf))
118+
println(io, "path: ", cdf.filename)
119+
println(io, "variables:")
120+
for key in keys(cdf)
121+
var = cdf[key]
122+
print(io, " $key : ", size(var), " ", DataType(var.vdr.data_type))
123+
!isempty(var) && print(io, " [", var[1], "", var[end], "]")
124+
println(io)
121125
end
122126
println(io, cdf.cdr)
127+
print(io, "attributes: ")
128+
show(io, m, cdf.attrib)
123129
return
124130
end

src/records/records.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,13 @@ function Base.show(io::IO, cdr::CDR)
8585
flag_info = decode_cdr_flags(cdr.flags)
8686

8787
println(io, "CDR (CDF Descriptor Record):")
88-
# println(io, " Record Size: $(cdr.header.record_size) bytes")
89-
# println(io, " Record Type: $(cdr.header.record_type)")
90-
println(io, " GDR Offset: $(string(cdr.gdr_offset, base = 16, pad = 8))")
9188
println(io, " Version: $(cdr.version).$(cdr.release).$(cdr.increment)")
9289
println(io, " Encoding: $(cdr.encoding)")
9390
println(io, " Flags: 0x$(string(cdr.flags, base = 16, pad = 8))")
9491
println(io, " - Majority: $(majority(cdr))")
9592
println(io, " - Single File Format: $(flag_info.single_file_format)")
9693
println(io, " - Checksum Used: $(flag_info.checksum_used)")
9794
println(io, " - MD5 Checksum: $(flag_info.md5_checksum)")
98-
return println(io, " Identifier: $(cdr.identifier)")
95+
println(io, " Identifier: $(cdr.identifier)")
96+
return
9997
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ end
2828
@test ds.compression == CDF.NoCompression
2929
@test first(ds) == ds["var"]
3030
@test occursin("Version: 3.9.0", string(ds))
31+
display(ds)
3132
end
3233

3334
@testset "Compressed cdf file (gzip)" begin

0 commit comments

Comments
 (0)