mooncdf

    MoonBit NetCDF Classic data access, slicing, and interoperable writing

    netcdf
    scientific-data
    cdf5
    array
    wasm
    Download zip
    Version
    0.1.2
    License
    Apache-2.0
    Last updated
    7 hours ago
    Downloads
    4

    #MoonCDF

    MoonBit 实现的 NetCDF Classic 科学数组文件库,提供 CDF-1、CDF-2、CDF-5 读写、区域切片、记录追加和 CF 数值解释。面向在 MoonBit、Node 或浏览器中处理气象网格、测站记录与科研数组的开发者。

    当前版本 0.1.2。源码仓库:zhangbowen2006/MoonCDF。Mooncakes 模块 为 zhangbowen2006/mooncdf;参赛报名由作者本人办理。

    #安装 MoonBit 库

    在使用该库的另一个 MoonBit 工程中执行:

    moon add zhangbowen2006/mooncdf@0.1.2

    在消费者的 moon.pkg 中添加测试依赖:

    import { "zhangbowen2006/mooncdf" @cdf } for "test"

    新建 consumer_test.mbt,运行 moon test --target js --deny-warn:

    test "mean excludes missing values" {
    let summary = @cdf.summarize([Some(1.0), None, Some(3.0)])
    assert_eq(summary.mean, Some(2.0))
    }

    Mooncakes 包提供 MoonBit 库和 cmd/demo 示例。JS SDK、CLI 与浏览器工作台需从上述 GitHub 仓库获取完整源码,再按下节构建。

    #运行

    开发环境:MoonBit CLI 0.1.20261021 / moonc 0.10.17+093cb8f9c、Node 24。运行核心和工作台无需 Python 或 NetCDF-C;Python 只用于独立验证。

    cd D:\CodexProjects\MoonCDF moon check --target all --deny-warn moon test --target js --deny-warn moon test --target wasm --deny-warn moon test --target wasm-gc --deny-warn moon run cmd/demo node scripts/build.mjs node --test tests/*.test.mjs node examples/scenarios.mjs js node examples/scenarios.mjs wasm-gc node scripts/serve.mjs

    最后一条启动 本地工作台,打开 generated/examples/js/climate.nc 即可使用。Worker 执行数值、固定宽度文本、质量标志和日历时间视图;可下载区域文件、当前 CSV、原始 CSV,回灌原始 CSV,保留变量与坐标,分块统计。文件不会上传。

    moon run cmd/demo 输出 valid=2, missing=1 与 physical mean=7.5。调用方式见 MoonBit 示例、公共 API 和 JS/TS 声明。Mooncakes 源码包仅含 MoonBit 库与示例;SDK/工作台从完整工程构建。

    #已实现

    范围行为
    Classic 编解码三种格式、11 种存储类型、标量、具名维度、全局/变量属性、Unicode NFC 名称、大端编码、四字节对齐
    记录布局单个无限制维度、多变量交错记录、单窄类型记录变量的无填充特例、空记录、流式记录数推断
    数据访问任意秩 start/count/stride 切片、转置、升/降序坐标范围、按共享维度裁剪相关变量
    文件编辑缺省填充、区域替换、追加、严格模式拼接、格式转换、属性编辑、新增/替换变量、带依赖的变量投影
    CF 数值_FillValue、missing_value、存储域有效范围、_Unsigned、scale/offset 与逆向打包;拒绝静默丢失整数精度
    科学解释六类日历及别名、1582 年切换、时区、理想化日历年份 0、固定字节宽度 UTF-8/Latin-1 文本、精确 64 位枚举与位掩码标志
    数组与扫描任意轴 mean/min/max/sum/count/stddev、可取消分块遍历、整变量分块统计、显式边界直方图
    CSV长表原始值导出、引号/换行解析、精确整数与非有限数、坐标顺序验证、CSV 编辑后回灌新文件
    宿主JS/Wasm GC SDK、TS 声明、CLI、本地浏览器工作台

    格式和算法属于既有标准。与成熟项目的范围、来源及实际区别见 选题调查。

    #三个完整场景

    运行 node examples/scenarios.mjs js 或 wasm-gc,生成五个可独立重读的 .nc 文件及 report.json。示例输入为自写合成数据,不冒充真实观测。

    使用者与问题输入和操作已验证输出
    气象工具开发者读取区域温度整数压缩 time × latitude × longitude 网格,坐标选区,读取起点 [0,1,1]、数量 [1,2,2],处理缺失与缩放形状 [1,2,2],值 [null,46,49,50],有效值 3;时间 2026-12-01T06:00:00.000000;region.nc 保留坐标
    监测系统开发者追加测站记录CDF-5,超出 JS 安全整数的编号;追加 time/quality,省略 temperature记录 2→3;新温度 [-999,-999];编号 9007199254740993、18446744073709551615 精确保留
    科研工具开发者编辑和导出区域替换物理值、转 CDF-5、沿 time/latitude 求均值值 [42.5,null,44,45];形状 [2];均值 [43.25,45]、有效计数 [2,1];原文件不变

    node generated/sdk/cli.mjs inspect generated/examples/js/climate.nc node generated/sdk/cli.mjs read generated/examples/js/region.nc temperature --physical node generated/sdk/cli.mjs scan generated/examples/js/climate.nc temperature node generated/sdk/cli.mjs csv generated/examples/js/region.nc temperature generated/temperature.csv node generated/sdk/cli.mjs --help

    CLI 排他创建输出,目标存在则失败;重复运行导出请更换文件名。原始 CSV 的 axis_* 为原文件索引;物理值 CSV 空字段为缺失。回灌只接受原始值格式。

    #验证与限制

    真实命令、独立库版本和结果见 验证记录。测试含 NetCDF-C 生成的 26 个输入、双向写出、SciPy/NumPy/cftime 对照、真实浏览器及公开 CCSM 气候模型文件。公开样本记录来源及哈希,不随源码分发。

    • 单文件 64 MiB;秩 16;名称最多 256 个 UTF-8 字节;头部条目总数 4,096、属性值合计 1,000,000。
    • 单次结果及完整重写的变量值合计最多 1,000,000。分块扫描可超过此值,但仍受文件大小和 65,536 个分块限制。文件本身仍整体驻内存。
    • 工作台输入 8 MiB、预览 100,000 值。CSV 16 MiB、最多 100,000 数据行,另有限定总单元格数与字段长度。
    • 原始 64 位整数精确,JSON 用十进制字符串;转物理值时,超过 Float64 精确整数范围会报错。
    • 未实现 NetCDF-4/HDF5、压缩、多个无限制维度、超预算大文件、并行 I/O、投影换算或全部 CF 约定。时间不支持闰秒、负年份、自定义日历。
    • 变量投影支持常见 CF 引用,拒绝悬空引用及未支持的扩展 grid_mapping。应用私有属性引用需显式选择。
    • Windows Native 未执行;Linux CI 已实际通过,含 Native、JS、Wasm、Wasm GC 各 83 项和独立消费者各 5 项测试。测试结果不能保证初审或验收通过。

    #来源与许可

    Apache-2.0。依据 NetCDF 规范、CDF-5 规范、CF 1.12 独立编写,有 AI 辅助。未移植 NetCDF-C、SciPy、netcdfjs 的实现。Unicode NFC 使用 moonbit-community/normalization@0.5.2 及传递依赖 ucd@0.5.2。

    0.1.2 维护说明:物理缺失值须显式使用 null;SDK 拒绝 NaN/Infinity 数字、数组空洞和 undefined 元素。原始非有限浮点按接口用字符串 "NaN"、"Infinity"、"-Infinity" 表示。Float32 属性先归一为磁盘精度。运行中可取消任务,旧任务的迟到结果不会覆盖当前文件。详见 维护记录。

    本轮维护还补充中心化缩放标准差、空数组形状处理和 CSV 往返容量检查。CSV 总单元格上限为 1,000,000(含表头),与 100,000 数据行及 16 MiB UTF-8 字节上限同时适用。数值结果仍受 Float64 舍入限制。

    CdfError

    pub(all) suberror CdfError {
    Invalid(String)
    Truncated(String)
    Unsupported(String)
    ResourceLimit(String)
    } derive(
    Debug
    )

    CdfError::to_repr

    automatically derived

    Attribute

    pub(all) struct Attribute {
    name : String
    data_type : DataType
    values : Array[Value]
    } derive(
    Debug
    )

    Attribute::to_repr

    automatically derived

    AxisSelection

    pub(all) struct AxisSelection {
    dimension : String
    start : Int64
    count : Int64
    stride : Int64
    }

    Calendar

    pub(all) enum Calendar {
    Standard
    ProlepticGregorian
    Julian
    NoLeap
    AllLeap
    Days360
    } derive(Eq)

    Calendar::equal

    fn Calendar::equal(Calendar, Calendar) -> Bool
    automatically derived

    Calendar::not_equal

    fn Calendar::not_equal(x : Calendar, y : Calendar) -> Bool
    automatically derived

    CivilTime

    pub(all) struct CivilTime {
    year : Int
    month : Int
    day : Int
    hour : Int
    minute : Int
    second : Int
    microsecond : Int
    } derive(Eq)

    CivilTime::equal

    fn CivilTime::equal(CivilTime, CivilTime) -> Bool
    automatically derived

    CivilTime::format

    fn CivilTime::format(self : CivilTime) -> String

    CivilTime::not_equal

    fn CivilTime::not_equal(x : CivilTime, y : CivilTime) -> Bool
    automatically derived

    DataBlock

    pub struct DataBlock {
    data_type : DataType
    shape : Array[Int64]
    values : Array[Value]
    }

    DataType

    pub(all) enum DataType {
    Int8
    Char8
    Int16
    Int32
    Float32
    Float64
    UInt8
    UInt16
    UInt32
    Int64
    UInt64
    } derive(Eq,
    Debug
    )

    DataType::equal

    fn DataType::equal(DataType, DataType) -> Bool
    automatically derived

    DataType::fill_value

    fn DataType::fill_value(self : DataType) -> Value

    DataType::not_equal

    fn DataType::not_equal(x : DataType, y : DataType) -> Bool
    automatically derived

    DataType::to_repr

    automatically derived

    DataType::width

    fn DataType::width(self : DataType) -> Int

    Dataset

    pub struct Dataset {
    format : Format
    records : Int64
    streaming : Bool
    header_bytes : Int
    record_bytes : Int64
    // private fields
    }

    Dataset::append

    fn Dataset::append(self : Dataset, count : Int64, batches : Array[RecordBatch]) -> Bytes raise CdfError

    Append complete record slabs to a new file. Omitted record variables are initialized using their own fill values. No bytes of the source are changed.

    Dataset::attributes

    fn Dataset::attributes(self : Dataset) -> Array[Attribute]

    Dataset::convert

    fn Dataset::convert(self : Dataset, format : Format) -> Bytes raise CdfError

    Re-encode using the requested Classic format. Extended CDF-5 integer types require CDF-5 output, even when their particular values are small.

    Dataset::coordinate_window

    fn Dataset::coordinate_window(self : Dataset, dimension : String, lower : Double, upper : Double, stride? : Int64) -> AxisSelection raise CdfError

    Select an inclusive range of a one-dimensional monotonic coordinate variable. Ascending and descending order are supported. No sorting, cyclic-longitude wrapping, unit conversion or interpolation is performed implicitly.

    Dataset::dimensions

    fn Dataset::dimensions(self : Dataset) -> Array[Dimension]

    Dataset::document

    fn Dataset::document(self : Dataset) -> Document raise CdfError

    Dataset::flag_section

    fn Dataset::flag_section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64]) -> FlagData raise CdfError

    Dataset::for_each_tile

    fn Dataset::for_each_tile(self : Dataset, name : String, tile_shape : Array[Int64], callback : (Array[Int64], DataBlock) -> Unit raise CdfError) -> Unit raise CdfError

    Invoke callback in row-major tile order. The callback receives independent arrays, can stop a scan by raising CdfError, and cannot mutate the source.

    Dataset::histogram

    fn Dataset::histogram(self : Dataset, name : String, edges : Array[Double], tile_values? : Int) -> Histogram raise CdfError

    Scan physical values through bounded tiles. Edges use the variable's own physical units. This does not infer a distribution model or convert units.

    Dataset::import_csv

    fn Dataset::import_csv(self : Dataset, name : String, text : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64]) -> Bytes raise CdfError

    Import edited long-form raw CSV into a checked section. Original coordinate columns must be retained. Validation finishes before a new file is returned.

    Dataset::physical_section

    fn Dataset::physical_section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64]) -> PhysicalData raise CdfError

    Dataset::plan_tiles

    fn Dataset::plan_tiles(self : Dataset, name : String, tile_shape : Array[Int64]) -> TilePlan raise CdfError

    Plan a bounded traversal without allocating the entire variable. A tile may contain at most result_values. At most 65,536 callbacks are allowed per scan.

    Dataset::project

    fn Dataset::project(self : Dataset, names : Array[String], include_dependencies? : Bool) -> Bytes raise CdfError

    Keep selected variables with their dimension coordinates and explicit CF dependencies. Recursively referenced variables retain their own dependencies. Global attributes are copied verbatim. Unknown application-specific reference attributes cannot be interpreted; applications must list those variables.

    Dataset::replace_section

    fn Dataset::replace_section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], values : Array[Value], stride? : Array[Int64]) -> Bytes raise CdfError

    Apply replacement values to an existing region without modifying the input Dataset or caller-owned arrays. All indices are checked before encoding.

    Dataset::scan_summary

    fn Dataset::scan_summary(self : Dataset, name : String, tile_values? : Int) -> NumericSummary raise CdfError

    Summarize a whole numeric variable through tiles, including variables larger than the single-result limit. Only one raw and one physical tile are held at once. The 64 MiB file limit still applies; this is not streaming file I/O.

    Dataset::section

    fn Dataset::section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64]) -> DataBlock raise CdfError

    Read only selected values. start/count/stride use the stored axis order, with the last axis varying fastest. An empty count selects no values.

    Dataset::subset

    fn Dataset::subset(self : Dataset, selections : Array[AxisSelection]) -> Bytes raise CdfError

    Subset shared dimensions consistently across all variables, including coordinate variables. The returned file is an independent complete result.

    Dataset::text_section

    fn Dataset::text_section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64], encoding? : TextEncoding, trim_spaces? : Bool) -> TextData raise CdfError

    Dataset::time_section

    fn Dataset::time_section(self : Dataset, name : String, start : Array[Int64], count : Array[Int64], stride? : Array[Int64]) -> Array[CivilTime?] raise CdfError

    Dataset::times

    fn Dataset::times(self : Dataset, name : String) -> Array[CivilTime?] raise CdfError

    Dataset::values

    fn Dataset::values(self : Dataset, name : String) -> Array[Value] raise CdfError

    Dataset::variable

    fn Dataset::variable(self : Dataset, name : String) -> VariableInfo raise CdfError

    Dataset::variables

    fn Dataset::variables(self : Dataset) -> Array[VariableInfo]

    Dataset::with_global_attributes

    fn Dataset::with_global_attributes(self : Dataset, attributes : Array[Attribute]) -> Bytes raise CdfError

    Dataset::with_variable

    fn Dataset::with_variable(self : Dataset, variable : Variable, replace? : Bool) -> Bytes raise CdfError

    Add a complete typed variable using existing dimension ids. Replacement is explicit; empty values initialize the new variable from its fill value.

    Dataset::with_variable_attributes

    fn Dataset::with_variable_attributes(self : Dataset, name : String, attributes : Array[Attribute]) -> Bytes raise CdfError

    Replace a variable's attributes through a validated new-file transaction. _FillValue remains storage metadata: changing it never rewrites existing data.

    Dimension

    pub(all) struct Dimension {
    name : String
    length : Int64
    unlimited : Bool
    } derive(Eq,
    Debug
    )

    Dimension::equal

    fn Dimension::equal(Dimension, Dimension) -> Bool
    automatically derived

    Dimension::not_equal

    fn Dimension::not_equal(x : Dimension, y : Dimension) -> Bool
    automatically derived

    Dimension::to_repr

    automatically derived

    Document

    pub(all) struct Document {
    format : Format
    dimensions : Array[Dimension]
    attributes : Array[Attribute]
    variables : Array[Variable]
    } derive(
    Debug
    )

    Document::to_repr

    automatically derived

    FlagData

    pub struct FlagData {
    shape : Array[Int64]
    meanings : Array[String]
    values : Array[Array[String]?]
    }

    Format

    pub(all) enum Format {
    Cdf1
    Cdf2
    Cdf5
    } derive(Eq,
    Debug
    )

    Format::equal

    fn Format::equal(Format, Format) -> Bool
    automatically derived

    Format::not_equal

    fn Format::not_equal(x : Format, y : Format) -> Bool
    automatically derived

    Format::to_repr

    automatically derived

    Histogram

    pub struct Histogram {
    edges : Array[Double]
    counts : Array[Int64]
    underflow : Int64
    overflow : Int64
    missing : Int64
    samples : Int64
    }

    Limits

    pub(all) struct Limits {
    file_bytes : Int
    header_items : Int
    result_values : Int
    rank : Int
    name_bytes : Int
    } derive(
    Debug
    )

    Limits::to_repr

    automatically derived

    NumericSummary

    pub struct NumericSummary {
    count : Int
    missing : Int
    minimum : Double?
    maximum : Double?
    mean : Double?
    population_stddev : Double?
    }

    PhysicalData

    pub struct PhysicalData {
    shape : Array[Int64]
    values : Array[Double?]
    missing : Int
    outside_valid_range : Int
    nonfinite : Int
    scale_factor : Double
    add_offset : Double
    }

    RecordBatch

    pub(all) struct RecordBatch {
    variable : String
    values : Array[Value]
    }

    ReducedData

    pub struct ReducedData {
    shape : Array[Int64]
    values : Array[Double?]
    counts : Array[Int]
    }

    Reduction

    pub(all) enum Reduction {
    Mean
    Minimum
    Maximum
    Sum
    Count
    PopulationStddev
    } derive(Eq)

    Reduction::equal

    fn Reduction::equal(Reduction, Reduction) -> Bool
    automatically derived

    Reduction::not_equal

    fn Reduction::not_equal(x : Reduction, y : Reduction) -> Bool
    automatically derived

    TextData

    pub struct TextData {
    shape : Array[Int64]
    width : Int
    values : Array[String]
    }

    TextEncoding

    pub(all) enum TextEncoding {
    Utf8
    Latin1
    } derive(Eq)

    TextEncoding::equal

    automatically derived

    TextEncoding::not_equal

    fn TextEncoding::not_equal(x : TextEncoding, y : TextEncoding) -> Bool
    automatically derived

    TilePlan

    pub struct TilePlan {
    variable : String
    shape : Array[Int64]
    tile_shape : Array[Int64]
    grid_shape : Array[Int64]
    tiles : Int
    values : Int64
    peak_values : Int
    }

    TimeUnits

    pub struct TimeUnits {
    calendar : Calendar
    source : String
    microseconds_per_unit : Int64
    origin_microseconds : Int64
    }

    Value

    pub(all) enum Value {
    Signed(Int64)
    Unsigned(UInt64)
    Real(Double)
    Character(Byte)
    } derive(Eq,
    Debug
    )

    Value::equal

    fn Value::equal(Value, Value) -> Bool
    automatically derived

    Value::not_equal

    fn Value::not_equal(x : Value, y : Value) -> Bool
    automatically derived

    Value::to_repr

    automatically derived

    Variable

    pub(all) struct Variable {
    name : String
    data_type : DataType
    dimensions : Array[Int]
    attributes : Array[Attribute]
    values : Array[Value]
    } derive(
    Debug
    )

    Variable::to_repr

    automatically derived

    VariableInfo

    pub struct VariableInfo {
    name : String
    data_type : DataType
    dimensions : Array[Int]
    shape : Array[Int64]
    attributes : Array[Attribute]
    offset : Int64
    slab_bytes : Int64
    padded_bytes : Int64
    record : Bool
    }

    attribute_text

    fn attribute_text(attribute : Attribute) -> String raise CdfError

    block_csv

    fn block_csv(block : DataBlock, start? : Array[Int64], stride? : Array[Int64]) -> String raise CdfError

    Long-form raw CSV preserves integer precision and storage order. Every row contains axis_0,...,axis_n,value. Character data uses decimal bytes. NaN and infinities have explicit textual spellings. No missing-value scaling occurs.

    calendar_from_name

    fn calendar_from_name(name : String) -> Calendar raise CdfError

    concatenate

    fn concatenate(inputs : Array[Dataset]) -> Bytes raise CdfError

    Join compatible files along their unlimited dimension. Fixed coordinates and attributes must match; input ordering determines output record order.

    decode_flags

    fn decode_flags(block : DataBlock, attributes : Array[Attribute]) -> FlagData raise CdfError

    CF 1.12 flags: equality-only enumerations, independent bit masks, and combined masks/values. Bit tests preserve the full 64-bit integer, including the high bit. Missing markers are checked before matching. Undeclared codes yield [].

    decode_physical

    fn decode_physical(block : DataBlock, attributes : Array[Attribute]) -> PhysicalData raise CdfError

    decode_text

    fn decode_text(block : DataBlock, encoding? : TextEncoding, trim_spaces? : Bool) -> TextData raise CdfError

    Interpret the last NC_CHAR axis as fixed-width strings. Width is in bytes, including for UTF-8. Only trailing NUL bytes are removed by default; embedded NULs and spaces are preserved. Latin-1 is an explicit alternative to UTF-8.

    decode_time

    fn decode_time(value : Double, units : TimeUnits) -> CivilTime raise CdfError

    default_limits

    fn default_limits() -> Limits

    encode_text

    fn encode_text(shape : Array[Int64], strings : Array[String], width : Int, encoding? : TextEncoding) -> DataBlock raise CdfError

    Encode strings without truncation. shape describes string rows and excludes the final byte width; the returned block includes that last axis.

    encode_time

    fn encode_time(time : CivilTime, units : TimeUnits) -> Double raise CdfError

    histogram_values

    fn histogram_values(values : Array[Double?], edges : Array[Double]) -> Histogram raise CdfError

    Bins are [left,right), except the final bin includes its right edge. Values outside the edges are counted separately, never clamped to an end bin.

    numeric_value

    fn numeric_value(value : Value) -> Double raise CdfError

    Convert a raw numeric scalar without silently rounding 64-bit integers. Read or write Value::Signed/Unsigned directly when exact wider values matter.

    open_bytes

    fn open_bytes(source : Bytes, limits? : Limits) -> Dataset raise CdfError

    pack_physical

    fn pack_physical(values : Array[Double?], kind : DataType, attributes : Array[Attribute]) -> Array[Value] raise CdfError

    Pack finite physical values with explicit scale/offset and ties-to-even rounding. None uses the declared/default fill value. The whole result is validated before the caller receives any packed values.

    parse_block_csv

    fn parse_block_csv(text : String, kind : DataType, shape : Array[Int64], start? : Array[Int64], stride? : Array[Int64]) -> DataBlock raise CdfError

    Read long-form raw CSV with an explicit shape and dtype. Coordinates are verified against the supplied storage order; duplicate, omitted, reordered or out-of-region rows fail instead of silently rearranging the data.

    parse_csv_rows

    fn parse_csv_rows(text : String) -> Array[Array[String]] raise CdfError

    Parse RFC 4180-style rows, accepting CRLF and LF. Quotes, quoted newlines and escaped quotes are supported. Text is bounded to 16 MiB, 100,001 rows, 1,000,000 cells and 65,536 characters per cell. A trailing newline is not a row.

    parse_time_units

    fn parse_time_units(text : String, calendar? : Calendar) -> TimeUnits raise CdfError

    reduce_physical

    fn reduce_physical(shape : Array[Int64], values : Array[Double?], axes : Array[Int], reduction : Reduction, keep_dimensions? : Bool) -> ReducedData raise CdfError

    Reduce any combination of axes in stored row-major order. Missing values do not contribute. A group with no present values yields None (Count yields 0). Sum/stddev overflow is reported instead of emitting a misleading finite value.

    summarize

    fn summarize(values : Array[Double?]) -> NumericSummary raise CdfError

    text_attribute

    fn text_attribute(name : String, value : String) -> Attribute

    transpose

    fn transpose(block : DataBlock, axes : Array[Int]) -> DataBlock raise CdfError

    Permute a block's axes. This changes array order only, retaining the type and exact stored values, including 64-bit integers and floating NaNs.

    write_bytes

    fn write_bytes(document : Document, limits? : Limits) -> Bytes raise CdfError

    Encode a fully validated, self-contained Classic file. Empty variable data requests initialization with the declared or default fill value.