-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mlee03
authored and
mlee03
committed
Nov 6, 2023
1 parent
b6227d5
commit b571feb
Showing
7 changed files
with
45 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import pytest | ||
import numpy as np | ||
import pytest | ||
|
||
from pace.util.grid.eta import set_hybrid_pressure_coefficients | ||
|
||
|
||
km = 79 | ||
eta_file='./input/eta79.txt' | ||
eta_file = "./input/eta79.txt" | ||
ak_79, bk_79 = np.loadtxt(eta_file, unpack=True) | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_set_hybrid_pressure_coefficients_nofile( ) : | ||
def test_set_hybrid_pressure_coefficients_nofile(): | ||
|
||
""" File does not exist. Test should fail """ | ||
|
||
pressure_data = set_hybrid_pressure_coefficients( km=90 ) | ||
|
||
pressure_data = set_hybrid_pressure_coefficients(km=90) | ||
|
||
def test_set_hybrid_pressure_coefficients_correct( ) : | ||
|
||
def test_set_hybrid_pressure_coefficients_correct(): | ||
|
||
""" Good values of ak, bk. Test should pass """ | ||
|
||
ks = 18 | ||
ptop = 300.0 | ||
|
||
pressure_data = set_hybrid_pressure_coefficients( km ) | ||
if( not np.array_equal(ak_79,pressure_data.ak) ) : | ||
pressure_data = set_hybrid_pressure_coefficients(km) | ||
|
||
if not np.array_equal(ak_79, pressure_data.ak): | ||
raise ValueError("Unexpected values in ak array") | ||
|
||
if( not np.array_equal(bk_79,pressure_data.bk) ) : | ||
if not np.array_equal(bk_79, pressure_data.bk): | ||
raise ValueError("Unexpected values in bk array") | ||
|
||
if( ks != pressure_data.ks ) : | ||
if ks != pressure_data.ks: | ||
raise ValueError("Unexpected ks value") | ||
|
||
if( ptop != pressure_data.ptop) : | ||
if ptop != pressure_data.ptop: | ||
raise ValueError("Unexpected ptopt value") | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_set_hybrid_pressure_coefficients_nonincreasing( ) : | ||
def test_set_hybrid_pressure_coefficients_nonincreasing(): | ||
|
||
""" | ||
Array bk is not monotonically increasing. | ||
Test is expected to fail | ||
""" | ||
|
||
ak_cp = ak_79k[:] | ||
ak_cp = ak_79[:] | ||
bk_cp = bk_79[:] | ||
|
||
bk_cp[10]=0.1 #random number | ||
ak_cp[13]=1.4 #random number | ||
|
||
pressure_data = set_hybrid_pressure_coefficients( km ) | ||
bk_cp[10] = 0.1 # random number | ||
ak_cp[13] = 1.4 # random number | ||
|
||
|
||
pressure_data = set_hybrid_pressure_coefficients(km) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters