Skip to content

Implement PET thermal comfort index#27

Merged
oyve merged 3 commits intodevfrom
copilot/implement-pet-thermal-comfort-index
Oct 28, 2025
Merged

Implement PET thermal comfort index#27
oyve merged 3 commits intodevfrom
copilot/implement-pet-thermal-comfort-index

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

  • Explore repository structure and understand existing indices
  • Run build and tests to verify current state
  • Research PET (Physiological Equivalent Temperature) formula and implementation
  • Implement PET calculation function
  • Add PET category/assessment function
  • Create comprehensive tests for PET (31 tests, all passing)
  • Update documentation in README
  • Build and test final implementation
  • Code review and security check
  • Verify ESM and CJS imports work correctly
  • Verify TypeScript types are generated
  • Refactor to reuse existing library functions (actualVaporPressure)

Summary

Successfully implemented the PET (Physiological Equivalent Temperature) thermal comfort index with:

Implementation

  • calculatePET() - Main function calculating PET based on air temperature, humidity, wind speed, and optional mean radiant temperature
  • petCategory() - Categorizes PET values into 9 thermal comfort levels from "Very cold" to "Very hot"
  • simplePET() - Simplified version for when mean radiant temperature is unknown

Latest Update

Refactored to use actualVaporPressure() from humidity.ts instead of duplicating the calculation logic inline, improving code reuse and maintainability.

Features

  • Full TypeScript support with type definitions
  • Dual module support (ESM and CJS)
  • Input validation for humidity (0-100%) and wind speed (≥0)
  • Comprehensive documentation with JSDoc comments
  • 9 thermal comfort categories based on standard PET assessment scales
  • Reuses existing library functions for better code maintainability

Testing

  • 31 comprehensive test cases covering:
    • Basic functionality
    • Input validation
    • Thermal perception categories
    • Edge cases and special scenarios
    • Integration tests
  • All 208 tests pass (177 existing + 31 new)
  • 100% code coverage for PET module

Security

  • No security vulnerabilities detected (CodeQL clean)
  • Proper input validation
  • No unsafe operations

The implementation follows all project conventions including using Kelvin for all temperatures and maintaining consistency with existing thermal comfort indices.

Original prompt

Research and implement PET thermal comfort index , there's already a file PET.ts


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
@oyve
Copy link
Owner

oyve commented Oct 28, 2025

@copilot see if any functions can be reused from the wider code library, i.e. actualVaporPressure exists in humidity.ts for actual vapor pressure?

Copilot AI changed the title [WIP] Implement PET thermal comfort index in PET.ts Implement PET thermal comfort index Oct 28, 2025
Copilot AI requested a review from oyve October 28, 2025 14:48
Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 28, 2025

@copilot see if any functions can be reused from the wider code library, i.e. actualVaporPressure exists in humidity.ts for actual vapor pressure?

Refactored to use actualVaporPressure() from humidity.ts instead of manually calculating (RH / 100) * es. This improves code reuse and maintainability. All tests still pass. (commit 678a70e)

@oyve oyve marked this pull request as ready for review October 28, 2025 14:56
@oyve oyve merged commit 62fcb77 into dev Oct 28, 2025
6 checks passed
@oyve oyve deleted the copilot/implement-pet-thermal-comfort-index branch October 28, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants