diff --git a/src/epochs.jl b/src/epochs.jl index 181d3f1..24a4bd8 100644 --- a/src/epochs.jl +++ b/src/epochs.jl @@ -124,6 +124,10 @@ for f in (:year, :month, :day, :hour, :minute, :second, :millisecond) @eval Dates.$f(epoch::CDFDateTime) = Dates.$f(DateTime(epoch)) end +Epoch(s::AbstractString) = Epoch(DateTime(s)) +Epoch16(s::AbstractString) = Epoch16(DateTime(s)) +TT2000(s::AbstractString) = TT2000(DateTime(s)) + Dates.value(epoch::Epoch) = epoch.instant Dates.value(epoch::Epoch16) = ComplexF64(epoch.seconds, epoch.picoseconds) Dates.value(epoch::TT2000) = epoch.instant.value diff --git a/src/loading/attribute.jl b/src/loading/attribute.jl index 3405bc9..67f47f3 100644 --- a/src/loading/attribute.jl +++ b/src/loading/attribute.jl @@ -64,12 +64,14 @@ function vattrib(cdf::CDFDataset, varnum::Integer) for offset in offsets is_global(buffer, offset, RecordSizeType) && continue adr = ADR(buffer, offset, RecordSizeType) - @assert min(adr.AgrEDRhead, adr.AzEDRhead) == 0 - head = max(adr.AgrEDRhead, adr.AzEDRhead) - found = _search_aedr_entries(buffer, head, RecordSizeType, cdf_encoding, varnum) - isnothing(found) && continue - name = String(adr.Name) - attributes[name] = _get_attributes(name, found, cdf) + for head in (adr.AgrEDRhead, adr.AzEDRhead) + head == 0 && continue + found = _search_aedr_entries(buffer, head, RecordSizeType, cdf_encoding, varnum) + isnothing(found) && continue + name = String(adr.Name) + attributes[name] = _get_attributes(name, found, cdf) + break + end end return attributes end @@ -101,10 +103,13 @@ function vattrib(cdf, varnum, name) is_global(buffer, offset, RecordSizeType) && continue adr = ADR(buffer, offset, RecordSizeType) adr.Name != name_bytes && continue - @assert min(adr.AgrEDRhead, adr.AzEDRhead) == 0 - head = max(adr.AgrEDRhead, adr.AzEDRhead) - value = _search_aedr_entries(buffer, head, RecordSizeType, cdf_encoding, varnum) - return _get_attributes(name, value, cdf) + for head in (adr.AgrEDRhead, adr.AzEDRhead) + head == 0 && continue + found = _search_aedr_entries(buffer, head, RecordSizeType, cdf_encoding, varnum) + isnothing(found) && continue + return _get_attributes(name, found, cdf) + end + return nothing end return nothing end