File: Weather.pm

package info (click to toggle)
libhipi-perl 0.94-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,048 kB
  • sloc: perl: 471,918; ansic: 22; makefile: 10
file content (43 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#########################################################################################
# Package        HiPi::Interface::Common::Weather
# Description  : Common weather utils
# Copyright    : Copyright (c) 2020 Mark Dootson
# License      : This is free software; you can redistribute it and/or modify it under
#                the same terms as the Perl 5 programming language system itself.
#########################################################################################

package HiPi::Interface::Common::Weather;

#########################################################################################

use strict;
use warnings;
use parent qw( HiPi::Interface );

our $VERSION ='0.82';

sub new {
    my ($class, %params) = @_;
    my $self = $class->SUPER::new(%params);
    return $self;
}

sub sea_level_pressure {
    my( $class, $pressure, $altitude, $temperature, $gravity) = @_;
    $gravity ||= 9.81;   # acceleration due to gravity
    my $dgc    = 287.0; # dry gas constant
    
    # Po = ((P * 1000) * Math.exp((g*Zg)/(Rd *  (Tv_avg + 273.15))))/1000;
    
    my $result = (($pressure * 1000) * exp(($gravity * $altitude)/($dgc *  ($temperature + 273.15))))/1000;
    
    $result = sprintf("%.2f", $result);
    return $result;
}


1;

__END__