netCDF4 file access via h5py with hierarchical and legacy APIs for scientific computing
69
Build a weather station data management system that stores and retrieves temperature and precipitation measurements using a hierarchical file format.
Create a Python program that implements the following functionality:
weather_data.nc that organizes weather stations by regionYour solution should:
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()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')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 pointsFile: 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())Provides netCDF4 file format support with hierarchical data organization and efficient array storage.
Install with Tessl CLI
npx tessl i tessl/pypi-h5netcdfdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10