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-1/

Time Series Data Manager

Build a system to manage time series data with dynamically growing dimensions.

Requirements

Create a tool that manages environmental sensor data stored in a netCDF4 file. The system must handle time series data where both the time dimension and the station dimension can grow dynamically as new measurements are added.

Core Functionality

Your implementation should:

  1. Initialize the data file with two unlimited dimensions: time and station
  2. Create variables to store temperature and humidity measurements for each station at each time point
  3. Support adding new time points by appending data for all existing stations
  4. Support adding new stations by extending the station dimension and backfilling historical data
  5. Query the current size of both unlimited dimensions

Data Structure

The file should contain:

  • Two unlimited dimensions: time and station
  • One variable temperature with dimensions (time, station) storing float values
  • One variable humidity with dimensions (time, station) storing float values
  • Attributes on variables indicating units (e.g., temperature.attrs['units'] = 'celsius')

Test Cases

  • Creating a new file initializes both time and station dimensions with size 0 @test
  • Adding the first time point (3 stations) sets time size to 1 and station size to 3 @test
  • Adding a second time point (same 3 stations) increases time to 2 while station remains 3 @test
  • Adding a new station after 2 time points increases station to 4 and pads historical data with fill values @test
  • Querying dimension sizes returns current time and station counts accurately @test

Implementation

@generates

API

class SensorDataManager:
    """Manages environmental sensor time series data in netCDF4 format."""

    def __init__(self, filename: str):
        """Initialize the manager with a netCDF4 file.

        Args:
            filename: Path to the netCDF4 file to create or open
        """
        pass

    def initialize(self) -> None:
        """Create the file structure with unlimited dimensions and variables."""
        pass

    def add_timepoint(self, temperature_data: list, humidity_data: list) -> None:
        """Add a new time point with measurements for all existing stations.

        Args:
            temperature_data: Temperature values for each station
            humidity_data: Humidity values for each station
        """
        pass

    def add_station(self, historical_temps: list, historical_humids: list) -> None:
        """Add a new station with historical data for all existing time points.

        Args:
            historical_temps: Temperature values for each existing time point
            historical_humids: Humidity values for each existing time point
        """
        pass

    def get_dimensions(self) -> tuple:
        """Get current sizes of time and station dimensions.

        Returns:
            Tuple of (time_size, station_size)
        """
        pass

    def close(self) -> None:
        """Close the netCDF4 file."""
        pass

Dependencies { .dependencies }

h5netcdf { .dependency }

Provides netCDF4 file access with support for unlimited dimensions and dynamic resizing.

@satisfied-by

Version

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