Add snowfall equivalent calculations based on temperature#20
Conversation
Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
- Created src/phenomena/snow.ts with functions to convert liquid precipitation to snow depth - Implemented snowToLiquidRatio() with step-wise temperature-based ratios - Implemented snowfallEquivalent() to calculate snow depth from liquid precipitation - Added continuous version with snowToLiquidRatioContinuous() and snowfallEquivalentContinuous() - Added reverse calculation with snowToLiquidEquivalent() - Created comprehensive test suite with 22 tests covering all functions - Build script automatically added snow module to package.json exports Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
- Add explanation of 1.25 factor derivation in linear interpolation formula - Reduce test tolerance from 10 to 2 for better precision - Maintain consistent tolerance values across continuous ratio tests Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
|
@copilot Is the snowToLiquidRatio linear? Could we plot it to a graph and get a more correct value for all temperatures, and not just intervals? |
The Both functions are available:
Would you prefer to make the linear version the default, or keep both options available for different use cases? |
|
@copilot only keep the linear function, but keep all tests to make sure we get the same results |
- Removed step-wise snowToLiquidRatio() in favor of linear interpolation - Removed snowToLiquidRatioContinuous() and snowfallEquivalentContinuous() (now redundant) - Updated snowToLiquidRatio() to use linear interpolation (5:1 at 0°C to 30:1 at -20°C) - Updated all tests to work with continuous ratios while maintaining coverage - All 146 tests passing (15 snow-related tests) Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
Done. Simplified to use only the linear function. The All 15 snow tests updated and passing, maintaining full coverage with continuous values instead of step-wise intervals. (cf75d07) |
Implements liquid precipitation to snow depth conversion using temperature-dependent snow-to-liquid ratios with linear interpolation.
Changes
src/phenomena/snow.ts- New module with three conversion functions:snowToLiquidRatio()- Linear interpolation from 5:1 at 0°C to 30:1 at -20°C for smooth, continuous ratios across all temperaturessnowfallEquivalent()- Converts liquid precipitation to snow depth using linear ratiossnowToLiquidEquivalent()- Reverse conversion from snow depth to liquidtests/phenomena/snow.test.ts- 15 comprehensive tests covering temperature ranges, edge cases, and round-trip conversionspackage.json- Export added automatically via build scriptUsage
Ratios based on meteorological observations where colder temperatures produce lower-density snow. Uses linear interpolation to provide smooth, continuous values across all temperatures instead of step-wise intervals.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.