用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill model-calibration命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
This skill includes search capability in 13F, such as fuzzy search a fund information using possibly inaccurate name, or fuzzy search a stock cusip info using its name.
基于 SOC 职业分类
正在显示 SKILL.md
| name | model-calibration |
| description | Calculating RMSE metrics and parameter calibration for lake model validation |
Model calibration involves adjusting parameters to minimize differences between simulations and observations. RMSE (Root Mean Squared Error) is a standard metric for measuring model performance.
RMSE = sqrt(mean((simulated - observed)^2))
import numpy as np
import pandas as pd
def calculate_rmse(simulated, observed):
"""Calculate RMSE between matched pairs"""
if len(simulated) == 0:
return np.nan
residuals = simulated - observed
rmse = np.sqrt(np.mean(residuals**2))
return rmse
def calculate_metrics(sim_temps, obs_temps, depths=None, dates=None):
"""
Calculate multiple RMSE metrics
Parameters:
- sim_temps: matched simulated temperatures
- obs_temps: matched observed temperatures
- depths: depth of each match (for deep water filtering)
- dates: datetime of each match (for seasonal filtering)
Returns:
- overall_rmse: RMSE of all matched pairs
- annual_deep_rmse: RMSE of pairs at depths >= 13m
- summer_deep_rmse: RMSE of summer (Jun-Sep) pairs at depths >= 13m
"""
overall_rmse = calculate_rmse(sim_temps, obs_temps)
# Annual deep water (depths >= 13m)
if depths is not None:
deep_mask = np.array(depths) >= 13
annual_deep_rmse = calculate_rmse(
sim_temps[deep_mask],
obs_temps[deep_mask]
)
else:
annual_deep_rmse = np.nan
# Summer deep water (Jun-Sep, depths >= 13m)
if dates is not None and depths is not None:
summer_mask = (np.array([d.month for d in dates]) >= 6) & \
(np.array([d.month for d in dates]) <= 9)
deep_mask = np.array(depths) >= 13
combined_mask = summer_mask & deep_mask
summer_deep_rmse = calculate_rmse(
sim_temps[combined_mask],
obs_temps[combined_mask]
)
else:
summer_deep_rmse = np.nan
return {
'overall_rmse': overall_rmse,
'annual_deep_rmse': annual_deep_rmse,
'summer_deep_rmse': summer_deep_rmse
}
Critical: Use exact datetime + rounded-depth matching (no interpolation)
def match_obs_to_sim(obs_df, sim_temps, sim_z, sim_dates, round_depth=1):
"""
Match observations to simulation output
obs_df: DataFrame with columns [datetime, depth, temp]
sim_temps: [time, depth] array
sim_z: depth values
sim_dates: datetime for each time step
round_depth: rounding for depth matching
Returns: matched simulation temps, observed temps, and metadata
"""
import pandas as pd
obs_df['depth_rounded'] = (obs_df['depth'] / round_depth).round() * round_depth
matched_sim = []
matched_obs = []
matched_depths = []
matched_dates = []
for idx, row in obs_df.iterrows():
obs_datetime = pd.Timestamp(row['datetime'])
obs_depth = row['depth_rounded']
obs_temp = row['temp']
# Find exact datetime match
time_matches = [i for i, d in enumerate(sim_dates)
if d == obs_datetime]
# Find exact depth match
depth_matches = [i for i, z in enumerate(sim_z)
if z == obs_depth]
# Need both to match
if time_matches and depth_matches:
t_idx = time_matches[0]
z_idx = depth_matches[0]
sim_temp = sim_temps[t_idx, z_idx]
matched_sim.append(sim_temp)
matched_obs.append(obs_temp)
matched_depths.append(obs_depth)
matched_dates.append(obs_datetime)
return (np.array(matched_sim), np.array(matched_obs),
matched_depths, matched_dates)
Run model with one parameter varied at a time to identify most influential parameters.
For 5 parameters with small ranges, can do grid search:
Always verify final parameters are within published ranges:
def validate_parameters(params):
ranges = {
'Kw': (0.1, 0.5),
'coef_mix_hyp': (0.3, 0.7),
'wind_factor': (0.7, 1.3),
'lw_factor': (0.7, 1.3),
'ch': (0.0005, 0.002)
}
for param, (min_val, max_val) in ranges.items():
if not (min_val <= params[param] <= max_val):
raise ValueError(f"{param} out of range: {params[param]}")
return True
For Lake Mendota:
Model is successful when ALL three thresholds are met.