File Coverage

blib/lib/HiPi/Interface/Common/Weather.pm
Criterion Covered Total %
statement 9 18 50.0
branch n/a
condition 0 2 0.0
subroutine 3 5 60.0
pod 0 2 0.0
total 12 27 44.4


line stmt bran cond sub pod time code
1             #########################################################################################
2             # Package HiPi::Interface::Common::Weather
3             # Description : Common weather utils
4             # Copyright : Copyright (c) 2020 Mark Dootson
5             # License : This is free software; you can redistribute it and/or modify it under
6             # the same terms as the Perl 5 programming language system itself.
7             #########################################################################################
8              
9             package HiPi::Interface::Common::Weather;
10              
11             #########################################################################################
12              
13 1     1   444 use strict;
  1         3  
  1         29  
14 1     1   5 use warnings;
  1         2  
  1         47  
15 1     1   7 use parent qw( HiPi::Interface );
  1         2  
  1         6  
16              
17             our $VERSION ='0.82';
18              
19             sub new {
20 0     0 0   my ($class, %params) = @_;
21 0           my $self = $class->SUPER::new(%params);
22 0           return $self;
23             }
24              
25             sub sea_level_pressure {
26 0     0 0   my( $class, $pressure, $altitude, $temperature, $gravity) = @_;
27 0   0       $gravity ||= 9.81; # acceleration due to gravity
28 0           my $dgc = 287.0; # dry gas constant
29            
30             # Po = ((P * 1000) * Math.exp((g*Zg)/(Rd * (Tv_avg + 273.15))))/1000;
31            
32 0           my $result = (($pressure * 1000) * exp(($gravity * $altitude)/($dgc * ($temperature + 273.15))))/1000;
33            
34 0           $result = sprintf("%.2f", $result);
35 0           return $result;
36             }
37              
38              
39             1;
40              
41             __END__