본문으로 건너뛰기
cccskills
무료GitHub에 공개

ameriflux-era5-to-ecosim

Convert AmeriFlux ERA5 half-hourly meteorological CSV files into EcoSIM hourly climate forcing NetCDF files, compare generated forcing against overlapping measured tower meteorology when a FULLSET file is available, and report large biases or errors. Use when preparing or validating EcoSIM climate inputs for AmeriFlux sites, checking ERA5 against in situ records, diagnosing forcing discrepancies, or writing climate-quality reports. For non-AmeriFlux paper sites that need a fresh Copernicus CDS ERA5 point download by longitude/latitude, use era5-cds-point-download first.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(3)

  • SKILL.md11.7 KB
  • era5_to_ecosim_converter.py44.1 KB
  • test_converter.py14.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

AmeriFlux ERA5 to EcoSIM Converter

Use When

  • You need to convert AmeriFlux ERA5 CSV forcing data to EcoSIM NetCDF climate forcing.
  • You need hourly TMPH, WINDH, RAINH, DWPTH, SRADH, or PATM variables.
  • You need range-aware quality control, comparison against in situ meteorology, or a JSON quality report for climate forcing.
  • You already have an AmeriFlux-format ERA5 CSV. If the task is to download global CDS ERA5 point data for a non-AmeriFlux literature site, use era5-cds-point-download before any EcoSIM conversion.

Constraints

  • NEVER use it extract soil data.

Overview

This skill converts AmeriFlux ERA5 half-hourly climate forcing data into the EcoSIM hourly climate format. When a matching AmeriFlux FULLSET file is available, it also reads the generated NetCDF back and compares the forcing against measured-only tower records.

For ordinary paper-derived sites outside AmeriFlux/FLUXNET, keep ERA5 acquisition separate: use era5-cds-point-download to retrieve Copernicus CDS point time series by longitude/latitude, inspect source units and accumulation conventions, then adapt or convert the data into the AmeriFlux-format columns expected here only after those units are verified.

Input Data Format

The input is a CSV file with the following columns:

  • TIMESTAMP_START: Start timestamp (YYYYMMDDHHMM)
  • TIMESTAMP_END: End timestamp (YYYYMMDDHHMM)
  • TA_ERA: Air temperature (°C)
  • SW_IN_ERA: Shortwave incoming radiation (W m⁻²)
  • LW_IN_ERA: Longwave incoming radiation (W m⁻²)
  • VPD_ERA: Vapor pressure deficit (hPa in AmeriFlux ERA5 products)
  • PA_ERA: Atmospheric pressure (kPa)
  • P_ERA: Precipitation (mm h⁻¹)
  • WS_ERA: Wind speed (m s⁻¹)

Pay close attention to the source ERA5 time step before conversion. AmeriFlux archives may provide ERA5_HH half-hourly files or ERA5_HR hourly files, and precipitation aggregation must match that cadence to avoid doubling or otherwise distorting the water input.

Output Data Format

Climate NetCDF files are named by the forcing years they contain: <SITE_ID>_ecosim_climate_<first>-<last>.nc (e.g. US-UMB_ecosim_climate_1981-2021.nc). The writer reads the year variable after writing and renames the file, so an --output given without years (or with a stale range) gets the actual range appended; the final path is printed and recorded in the quality report (output_file).

The output is a netCDF file with the following variables:

  • TMPH: Hourly air temperature (°C)
  • WINDH: Hourly wind speed (m s⁻¹)
  • RAINH: Hourly precipitation (mm m⁻² hr⁻¹)
  • DWPTH: Hourly actual atmospheric vapor pressure (kPa), computed as es(TA_ERA) - VPD_ERA/10 with EcoSIM's vapsat0 saturation formula. EcoSIM reads DWPTH as vapor pressure (VPK=min(DWPTH,VPS)), never as a deficit.
  • SRADH: Hourly incident solar radiation (W m⁻²)
  • PATM: Hourly Surface atmospheric pressure (kPa)
  • year: Year AD
  • Z0G: Windspeed measurement height (m)
  • IFLGW: Flag for raising Z0G with vegetation
  • ZNOONG: Mean solar noon on the forcing clock (hour), 12 - lon/15 + utc_offset. AmeriFlux timestamps are local standard time, so ZNOONG must be local too; EcoSIM adds the daily equation of time and caps hourly SRADH by the sun angle from ZNOONG.

Workflow

  1. Data Reading: Reads half-hourly climate data from the input CSV file
  2. Timestamp Parsing: Converts timestamp strings to datetime objects
  3. Data Aggregation: Averages consecutive half-hourly values to create hourly data
  4. Quality Control: Masks physically invalid values before aggregation and fills those gaps by time interpolation.
  5. Variable Mapping: Maps ERA5 variables to ECOSIM variable names and units
  6. NetCDF Creation: Creates a properly formatted netCDF file in ECOSIM format
  7. In Situ Validation: Reads the generated NetCDF and compares it with complete, measured-only hourly tower records from an overlapping AmeriFlux FULLSET file.
  8. Warning Report: Adds comparison metrics and large-difference warnings to the JSON quality report and prints warnings to stderr.

Physical Range Checks

The converter must ensure derived climate values are in legitimate ranges before writing EcoSIM NetCDF:

  • TMPH from TA_ERA: -90 to 60 degC.
  • WINDH from WS_ERA: 0 to 75 m s^-1.
  • RAINH from P_ERA: non-negative source precipitation.
  • DWPTH from VPD_ERA and TA_ERA: non-negative source vapor pressure deficit; resulting vapor pressure clipped to [0, es(TA)].
  • SRADH from SW_IN_ERA: 0 to 1400 W m^-2.
  • PATM from PA_ERA: kPa bounds centered on site elevation when ALTIG is available, otherwise broad physical fallback bounds.

For sentinel values, non-finite values, and values outside these bounds, mask the value and interpolate along the half-hourly time axis. Use nearest-edge filling only at the beginning or end of the available source period. Emit a JSON quality report when --quality-report is supplied.

Time Registration (ERA5 vs Tower Clock)

Some AmeriFlux releases ship an ERA5 file whose clock is offset from the tower record (e.g. US-Ton 5-7, US-Ne1 4-7, and US-Wkg 4-7 are 1 h late; their tower SW_IN_F is on local standard time). Mean bias cannot detect this, so the converter coregisters ERA5 with the tower before QC and hourly aggregation:

  1. Find the FULLSET file (--in-situ, or auto-discovery beside the ERA5 CSV) and load measured SW_IN_F (QC 0).
  2. Cross-correlate SW_IN_ERA with tower SW_IN_F over lags of +/-3 h in source-timestep steps; require at least 2000 paired steps.
  3. Treat a non-zero best lag as real only when it raises the correlation by at least 0.01 over zero lag and agrees with the diurnal-centroid lag within 0.5 h; otherwise report ambiguous and do not shift.
  4. In --time-registration auto (default), shift every ERA5 variable onto the tower clock, keep the original record span, and fill the shifted-out edge steps from the nearest valid value. check reports without shifting; off skips the check. --time-shift-hours applies a known lag (positive = ERA5 late) without a tower file.
  5. Infer ZNOONG after registration, so it follows the corrected (tower) clock.

The quality report's time_registration block records status (registered, corrected, misregistered in check mode, ambiguous, unverified without a tower file, insufficient_overlap, manual, skipped), the lag, correlations by lag, centroid lag, and applied_shift_hours. After a correction, confirm that the in situ SRADH diurnal_centroid_lag_hours is near zero. A record without a tower file is unverified: its clock is assumed, not checked.

Solar Noon and Forcing Clock

  • The UTC offset of the CSV clock is not stored in AmeriFlux files. By default the converter infers it as the whole hour nearest to (SW_IN_ERA diurnal centroid) - (12 - lon/15); rounding lon/15 is wrong for sites far from their zone meridian (US-UMB at -84.7 deg is UTC-5). Pass --utc-offset to override.
  • The quality report's solar_noon block records ZNOONG, the offset and its source, and the centroid mismatch; a mismatch above 0.75 h is a warning.

In Situ Comparison

For AmeriFlux sites, compare against observations whenever possible:

  1. Use --in-situ <FULLSET_HH_or_HR.csv> when the observation file is known. Otherwise, auto-discover a matching FULLSET_HH or FULLSET_HR CSV beside the ERA5 input.
  2. Prefer TA_F, WS_F, P_F, VPD_F, SW_IN_F, and PA_F, but retain only records whose corresponding *_F_QC value is 0 (measured). Do not validate ERA5 against records whose QC value indicates gap filling or ERA substitution.
  3. If consolidated fields are unavailable, use direct measured columns such as TA, WS, P, VPD, SW_IN, or PA when present.
  4. Convert measured VPD_F to vapor pressure with measured TA_F (both QC 0). Average temperature, wind, vapor pressure, shortwave radiation, and pressure to hourly values. Sum precipitation. Require every source interval within an hour to be measured.
  5. Compare the observations against values read back from the generated NetCDF, not merely against the pre-write DataFrame.
  6. Record paired hours, forcing and observed means, mean bias, MAE, RMSE, Pearson correlation, and relative bias. For precipitation, emphasize total bias over paired intervals.
  7. Require at least 720 paired measured hours before issuing difference warnings by default. Use --comparison-min-pairs only when a shorter validation period is scientifically justified.

Use these broad operational warning screens:

EcoSIM variableLarge-difference screen
TMPHabsolute mean bias > 2 degC or RMSE > 5 degC
WINDHabsolute mean bias > 1.5 m s-1, RMSE > 3 m s-1, or relative mean bias > 50% when absolute bias is at least 0.5 m s-1
RAINHabsolute relative total bias > 30% when measured total is at least 10 mm
DWPTHabsolute mean bias > 0.30 kPa, RMSE > 0.75 kPa, or relative mean bias > 40% when absolute bias is at least 0.15 kPa
SRADHabsolute mean bias > 40 W m-2, RMSE > 150 W m-2, or relative mean bias > 30% when absolute bias is at least 20 W m-2
PATMabsolute mean bias > 2 kPa or RMSE > 4 kPa

Treat these as failure-detection screens, not universal ERA5 performance criteria. A warning requires diagnosis of units, timestamp convention, accumulation interval, source-product processing, and representativeness. Never apply an automatic multiplicative correction from these metrics. If no suitable observations are found, record not_available in the quality report rather than treating the comparison as passed.

Usage

To execute the skill, run the following command from the project root. The resulting JSON will be saved to the ./result/ directory:

python .agents/skills/ameriflux-era5-to-ecosim/era5_to_ecosim_converter.py \
  --input data/AMF_US-Ha1_FLUXNET_FULLSET_1991-2020_3-5/AMF_US-Ha1_FLUXNET_ERA5_HR_1981-2021_3-5.csv \
  --output result/US-Ha1/US-Ha1_ecosim_climate.nc \
  --site-id US-Ha1 \
  --in-situ data/AMF_US-Ha1_FLUXNET_FULLSET_1991-2020_3-5/AMF_US-Ha1_FLUXNET_FULLSET_HH_1991-2020_3-5.csv \
  --quality-report result/US-Ha1/US-Ha1_era5_quality_report.json \
  [--utc-offset -5] [--time-registration auto|check|off] [--time-shift-hours 1]

Omit --in-situ to use automatic discovery. Use --skip-in-situ-comparison only when the task explicitly excludes tower validation.

Key Features

  • Handles physically invalid source data by interpolation before NetCDF writing
  • Properly converts precipitation from half-hourly to hourly values (summing)
  • Averages temperature, wind speed, and solar radiation over half-hour periods
  • Compares generated values with measured-only AmeriFlux meteorology when available
  • Emits variable-specific warnings for large bias or RMSE
  • Supports multiple years of data
  • Creates valid netCDF files with proper metadata

Limitations

  • Calendar padding that is not present in the source data may still use EcoSIM fill values.
  • In situ comparison depends on overlapping FULLSET observations and their QC flags.
  • Warning thresholds diagnose large discrepancies but do not establish that ERA5 or the tower is universally correct.
  • Does not automatically bias-correct climate forcing.

Requirements

  • Python 3.6+
  • pandas
  • numpy
  • netCDF4

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Extract EPA/NADP tDEP atmospheric deposition and NADP precipitation chemistry rasters for an AmeriFlux or EcoSIM site. Use when deriving atmospheric chemistry inputs such as NH4, NO3, SO4, Ca, or precipitation pH for EcoSIM forcing workflows.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

Extract AmeriFlux BASE-BADM/BIF crop management records into EcoSIM-editable plant-management and soil-management Excel workbooks that can be converted to EcoSIM NetCDF files. Use when asked to derive EcoSIM planting, harvest, fertilizer, or tillage management inputs from AMF *_BIF_*.xlsx or BIF CSV files, especially for crop sites where management details live in GRP_DM_* records and DM_COMMENT fields.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

Sort AmeriFlux BASE-BADM BIF variables from Excel or CSV files into observation, management-event, static metadata, and plotting-ready target time-series tables. Use when Codex is asked to sort AmeriFlux BIF variables into time series; organize BADM/BIF variables by date; pivot AMF *_BIF_*.xlsx files by GROUP_ID; output total LAI, leaf mass per area, above-ground biomass, canopy height, fruit yield, or total yield time series; write MATLAB readers for BIF time-series plotting; or prepare dated AmeriFlux site observations and management records for EcoSIM workflows.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

Create EcoSIM Fortran namelist files and workable EcoSIM run folders for AmeriFlux site runs from site-specific grid, plant management, climate forcing, and greenhouse-gas inputs. Use when preparing or updating an EcoSIM `.namelist`, run folder, runfolder, run directory, or executable-ready site case for AmeriFlux or FLUXNET sites, especially after generating `*_ecosim_grid.nc`, `*_ecosim_climate_<first>-<last>.nc`, and `*_pft_mgmt.nc` inputs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

Extract AmeriFlux site metadata and map it to EcoSIM JSON variables. Use when a task needs site latitude, longitude, elevation, mean annual temperature, Koppen climate code, or vegetation type for an AmeriFlux site ID or flux-site name.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

Extract dominant-component soil profile variables for EcoSIM grid or template inputs from gSSURGO, with FAO HWSD v2.0 fallback when gSSURGO data are unavailable or incomplete. Use when deriving soil depth, bulk density, field capacity, wilting point, hydraulic conductivity, texture, rock fraction, pH, CEC, or soil organic carbon; or when converting EcoSIM grid NetCDF files to editable Excel workbooks and back.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bioepic-data/ecosim-agent32026년 10월 16일 업데이트

bioepic-data의 스킬 모두 보기

이 스킬의 문제 신고