Download scripts/shadow_score.py from spark-school/school-corpus: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/spark-school/school-corpus/resolve/main/scripts/shadow_score.py
- Command line
-
hf download hf://datasets/spark-school/school-corpus/scripts/shadow_score.py
-
curl -L -o shadow_score.py https://huggingface.co/datasets/spark-school/school-corpus/resolve/main/scripts/shadow_score.py
1.33 kB
| """shadow_score.py - score a stick measurement against the shop ephemeris prediction. | |
| Use-law (pass-201): first target = selene Eratosthenes game, Friday Oct 23 measurements; | |
| when a post names height + shadow + city/latitude, score gap vs pairshape predictions table. | |
| Prediction law: dec(n) = -23.45*cos(360/365*(n+10)) deg; alt = 90 - (lat - dec); shadow_per_1m = 1/tan(alt). | |
| Limit named at origin (pass-167): circular declination approximation, +-0.3 deg vs full ephemeris at this date; predictions carry that margin.""" | |
| import math | |
| def dec(n): return -23.45*math.cos(math.radians(360.0/365.0*(n+10))) | |
| def predict(lat, n): | |
| alt = 90.0-(lat-dec(n)) | |
| return alt, 1.0/math.tan(math.radians(alt)) | |
| def score(lat, n, height_m, shadow_m): | |
| """height_m: stick height; shadow_m: measured shadow length at solar noon.""" | |
| alt, pred_per1m = predict(lat, n) | |
| pred_shadow = pred_per1m*height_m | |
| gap = shadow_m - pred_shadow | |
| return {"alt_deg": round(alt,2), "pred_shadow_m": round(pred_shadow,3), | |
| "measured_m": shadow_m, "gap_m": round(gap,3), | |
| "gap_pct": round(100.0*gap/pred_shadow,2)} | |
| if __name__=="__main__": | |
| # dry-run on the Warsaw organizer figure (in-thread: 26 deg up, about 2 m) | |
| r=score(52.2, 296, 1.0, 2.0) | |
| print("dry-run Warsaw Oct23 1m stick vs organizer 2.0 m:", r) | |