CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-h5netcdf

tessl install tessl/pypi-h5netcdf@1.6.0

netCDF4 file access via h5py with hierarchical and legacy APIs for scientific computing

Agent Success

Agent success rate when using this tile

69%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.83x

Baseline

Agent success rate without this tile

83%

task.mdevals/scenario-5/

Scientific Data Validator with Extended Types

Build a scientific data validation system that stores measurement data with boolean quality flags and uses advanced compression features.

Requirements

You need to create a system that:

  1. Creates a data file that stores temperature measurements with associated boolean quality control flags indicating whether each measurement passed validation
  2. Uses advanced compression (scale-offset filter) to reduce storage size for the temperature data
  3. Stores the data in a group structure with both the measurements and flags accessible
  4. Provides a function to write measurement data along with quality flags to the file
  5. Provides a function to read back the measurements and their associated quality flags

Specifications

Data Structure

  • Create a file with a group called "sensors"
  • Within the sensors group, create:
    • A dimension "time" with 100 elements
    • A variable "temperature" (32-bit float) that stores temperature readings, using the time dimension
    • A variable "valid_flags" (boolean) that stores quality control flags, using the time dimension
  • Apply scale-offset compression to the temperature variable

Write Function

Create a function write_sensor_data(filename, temperatures, flags) that:

  • Takes a filename, an array of temperature values (floats), and an array of boolean flags
  • Creates the file structure described above
  • Writes the temperature and flag data to the appropriate variables
  • Returns successfully when complete

Read Function

Create a function read_sensor_data(filename) that:

  • Opens the specified file in read mode
  • Reads the temperature values and boolean flags from the sensors group
  • Returns both arrays as a tuple (temperatures, flags)

Test Cases

  • Creating a file with 100 temperature values (ranging from 20.0 to 30.0) and corresponding boolean flags (alternating True/False), then reading it back returns the same data @test
  • The temperature variable has scale-offset compression applied @test
  • The valid_flags variable has boolean dtype @test

Implementation

@generates

API

def write_sensor_data(filename: str, temperatures: list, flags: list) -> None:
    """
    Write sensor data with quality flags to a file.

    Args:
        filename: Path to the output file
        temperatures: List of temperature measurements (floats)
        flags: List of boolean quality control flags
    """
    pass

def read_sensor_data(filename: str) -> tuple:
    """
    Read sensor data and quality flags from a file.

    Args:
        filename: Path to the input file

    Returns:
        Tuple of (temperatures array, flags array)
    """
    pass

Dependencies { .dependencies }

h5netcdf { .dependency }

Provides netCDF4 file format access with support for extended HDF5 features.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/h5netcdf@1.6.x
tile.json