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

Weather Station Data Manager

Build a weather station data management system that stores and retrieves temperature and precipitation measurements using a hierarchical file format.

Requirements

Create a Python program that implements the following functionality:

File Structure

  • Create a file named weather_data.nc that organizes weather stations by region
  • Use a hierarchical structure with regions as top-level containers
  • Each region should contain multiple station datasets

Data Storage

  • Store temperature data as floating-point arrays with dimensions for time and station
  • Store precipitation data with the same dimensional structure
  • Configure storage to use compression to reduce file size
  • Implement automatic padding for missing measurements using a fill value of -999.9

Data Access

  • Read temperature measurements for specific time ranges using array slicing
  • Retrieve all measurements from a specific station
  • Calculate average temperature across all stations for a given time period
  • Extract precipitation data using multi-dimensional indexing

Metadata Management

  • Attach units, description, and valid range information to each dataset
  • Store creation timestamp and data source information at the file level

Implementation Details

Your solution should:

  1. Create the file with proper organization and dimensions
  2. Write sample weather data (at least 10 time points for 3 stations across 2 regions)
  3. Implement functions to query the data using different indexing patterns
  4. Properly handle file opening and closing

Test Cases { .tests }

Test 1: File Creation and Structure { .test }

File: test_weather.py

def test_file_structure():
    """Verify the file has proper hierarchical organization"""
    # File should exist and contain regional organization
    # Each region should have temperature and precipitation variables
    assert file_exists('weather_data.nc')
    assert has_regional_hierarchy()

Test 2: Data Write with Compression { .test }

File: test_weather.py

def test_compressed_storage():
    """Verify data is stored with compression enabled"""
    # Temperature and precipitation variables should use compression
    assert uses_compression('temperature')
    assert uses_compression('precipitation')

Test 3: Array Slicing Access { .test }

File: test_weather.py

def test_time_range_query():
    """Test retrieval of data for specific time ranges"""
    # Should retrieve temperature data for time indices 2 through 5
    temps = get_temperature_range(2, 5)
    assert temps.shape[0] == 4  # 4 time points

Test 4: Fill Value Handling { .test }

File: test_weather.py

def test_missing_data_handling():
    """Verify missing measurements use the fill value"""
    # Unwritten data should return the fill value -999.9
    data = read_uninitialized_region()
    assert all(val == -999.9 for val in data.flatten())

Dependencies { .dependencies }

h5netcdf { .dependency }

Provides netCDF4 file format support with hierarchical data organization and efficient array storage.

Version

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