Skip to content

Commit

Permalink
Added tests for ProfCollection in test_decoders
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Blumberg committed Jan 11, 2019
1 parent 103dd2f commit 1e6fc7d
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ omit =
sharppy/viz/barbs.py
sharppy/viz/preferences.py
sharppy/viz/generic.py
sharppy/databases/check_sars_cal.py

sharppy/io/arw_decoder.py
[report]
exclude_lines =
if __name__ == .__main__.:
Expand Down
93 changes: 93 additions & 0 deletions examples/data/14072800.BNA
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
%TITLE%
BNA 140728/0000 36.25,-86.56
LEVEL HGHT TEMP DWPT WDIR WSPD
-------------------------------------------------------------------
%RAW%
1000.00, 82.00, -9999.00, -9999.00, -9999.00, -9999.00
989.00, 210.00, 32.60, 23.60, 265.00, 10.00
982.00, 271.10, 32.00, 24.00, 264.24, 12.28
943.75, 610.00, 28.10, 22.76, 260.00, 25.00
939.00, 653.08, 27.60, 22.60, 261.26, 25.50
925.00, 780.00, 26.40, 22.10, 265.00, 27.00
910.97, 914.00, 25.23, 21.63, 265.00, 27.00
879.84, 1219.00, 22.58, 20.57, 270.00, 27.99
855.00, 1470.11, 20.40, 19.70, 270.00, 28.83
850.00, 1521.00, 20.40, 19.30, 270.00, 29.00
840.00, 1623.76, 20.80, 17.20, 271.66, 29.66
820.20, 1829.00, 19.10, 15.88, 275.00, 31.00
791.63, 2134.00, 16.58, 13.91, 275.00, 27.99
783.00, 2228.36, 15.80, 13.30, 275.00, 29.54
780.00, 2261.09, 16.00, 12.60, 275.00, 30.08
776.00, 2305.01, 17.80, 5.80, 275.00, 30.81
772.00, 2349.24, 18.20, 1.20, 275.00, 31.54
764.03, 2438.00, 18.08, -6.26, 275.00, 33.00
759.00, 2494.41, 18.00, -11.00, 276.84, 34.11
747.00, 2630.26, 17.20, -11.80, 281.28, 36.77
737.09, 2743.00, 16.25, -12.54, 285.00, 39.01
700.00, 3179.00, 12.60, -15.40, 290.00, 35.99
672.00, 3519.38, 9.60, -14.40, 297.09, 38.13
660.82, 3658.00, 8.33, -9.33, 300.00, 39.01
651.00, 3781.79, 7.20, -4.80, 297.98, 39.81
619.00, 4194.77, 4.40, -6.60, 291.19, 42.53
613.54, 4267.00, 4.54, -10.55, 290.00, 43.01
611.00, 4300.81, 4.60, -12.40, 289.45, 43.17
603.00, 4408.10, 4.00, -15.00, 287.70, 43.69
594.00, 4530.11, 2.80, -15.20, 285.71, 44.29
588.00, 4612.23, 2.20, -10.80, 284.36, 44.69
568.97, 4877.00, 0.39, -15.91, 280.00, 46.00
565.00, 4933.34, 0.00, -17.00, 280.27, 46.05
547.00, 5192.01, -1.70, -13.70, 281.52, 46.31
500.00, 5900.00, -7.50, -15.50, 285.00, 47.01
489.00, 6072.44, -8.70, -14.70, 289.40, 49.64
487.51, 6096.00, -8.85, -14.85, 290.00, 50.00
485.00, 6135.92, -9.10, -15.10, 289.87, 49.87
479.00, 6232.03, -9.30, -13.10, 289.55, 49.56
473.00, 6329.32, -9.30, -14.30, 289.24, 49.24
472.00, 6345.66, -8.90, -15.90, 289.18, 49.18
469.00, 6394.99, -8.10, -26.10, 289.02, 49.02
466.00, 6444.70, -7.90, -37.90, 288.86, 48.86
462.00, 6511.46, -8.10, -52.10, 288.64, 48.64
434.00, 6991.78, -12.10, -41.10, 287.06, 47.07
424.00, 7169.34, -12.70, -29.70, 286.47, 46.48
421.00, 7223.37, -12.70, -31.70, 286.29, 46.30
400.00, 7610.00, -16.30, -35.30, 285.00, 45.01
399.47, 7620.00, -16.37, -35.37, 285.00, 45.01
397.00, 7666.56, -16.70, -35.70, 285.00, 45.31
375.00, 8092.17, -19.50, -35.50, 285.00, 48.05
369.00, 8211.75, -20.30, -29.30, 285.00, 48.83
349.00, 8621.53, -23.70, -28.60, 285.00, 51.52
335.00, 8919.35, -25.70, -31.70, 285.00, 53.49
324.74, 9144.00, -27.00, -39.52, 285.00, 54.99
324.00, 9160.51, -27.10, -40.10, 285.29, 55.17
300.00, 9710.00, -31.30, -45.30, 295.00, 60.99
295.00, 9829.50, -32.10, -46.10, 295.00, 61.09
250.00, 10980.00, -42.10, -53.10, 295.00, 62.00
244.00, 11143.63, -43.50, -54.50, 295.00, 62.77
220.00, 11831.38, -48.50, -56.50, 295.00, 66.01
210.00, 12135.20, -51.10, -60.10, 295.00, 67.47
200.00, 12450.00, -53.90, -62.90, 295.00, 69.00
198.47, 12497.00, -54.16, -63.13, 300.00, 69.00
195.00, 12604.87, -54.76, -63.67, 300.00, 69.00
113.00, 15942.48, -73.30, -80.30, 280.00, 27.00
84.74, 17678.00, -65.25, -75.85, 315.00, 20.01
80.56, 17983.00, -63.83, -75.07, 290.00, 4.99
76.58, 18288.00, -62.42, -74.29, 350.00, 4.99
70.00, 18830.00, -59.90, -72.90, 105.00, 2.99
56.96, 20117.00, -58.31, -73.76, 0.00, 2.99
51.66, 20726.00, -57.55, -74.16, 60.00, 15.00
50.00, 20930.00, -57.30, -74.30, 55.00, 14.01
49.22, 21031.00, -57.11, -74.51, 50.00, 15.00
46.93, 21336.00, -56.53, -75.14, 85.00, 25.99
44.74, 21641.00, -55.95, -75.78, 100.00, 23.00
38.79, 22555.00, -54.22, -77.68, 80.00, 20.01
36.99, 22860.00, -53.64, -78.31, 100.00, 25.00
32.06, 23774.00, -51.91, -80.21, 95.00, 25.99
30.57, 24079.00, -51.33, -80.85, 115.00, 25.99
30.00, 24200.00, -51.10, -81.10, 110.00, 23.00
29.17, 24384.00, -50.99, -81.27, 100.00, 24.01
26.57, 24994.00, -50.62, -81.82, 105.00, 17.00
24.20, 25603.00, -50.25, -82.37, 65.00, 27.99
22.05, 26213.00, -49.88, -82.92, 70.00, 38.00
21.04, 26518.00, -49.70, -83.20, 90.00, 31.99
20.00, 26850.00, -49.50, -83.50, 90.00, 31.99
%END%
48 changes: 0 additions & 48 deletions sharppy/databases/fix_sars_db.py

This file was deleted.

40 changes: 37 additions & 3 deletions sharppy/tests/test_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,54 @@ def test_decoder():
assert len(decoders) > 0

dec = spc_decoder.SPCDecoder(files[0])
profs = dec.getProfiles()
profs._backgroundCopy("")

# Test Interpolation
profs.interp()
assert profs.isInterpolated() == True
profs.resetInterpolation()
assert profs.isInterpolated() == False

# Test setting storm motion vectors
profs.modifyStormMotion('right', 0, 0)
profs.modifyStormMotion('left', 0, 0)
profs.resetStormMotion()

# Try modify
profs.modify(0, tmpc=35)
profs.modify(0, u=0)
tmp = profs._profs[""][0].tmpc
tmp[0:2] = 35
profs.modify(-999, tmpc=tmp, idx_range=[0,1])
profs.resetModification('tmpc')
profs.resetModification('u')

# Load in a BUFKIT file
dec = buf_decoder.BufDecoder(files[1])
profs = dec.getProfiles()
stn_id = dec.getStnId()

# Test some of the characteristics of the ProfCollection
assert profs.isEnsemble() == False
assert profs.isInterpolated() == False
assert profs.isModified() == False
assert profs.getAnalogDate() is None
assert profs.hasCurrentProf() == True

# Try to load in the UWYO file
dec = uwyo_decoder.UWYODecoder(files[2])

# Load in the PECAN-type files
dec = pecan_decoder.PECANDecoder(files[3])
dec = pecan_decoder.PECANDecoder(files[4])
assert dec.getProfiles().isEnsemble() == True

# Test some of the characteristics of this ProfCollection
assert dec.getProfiles().isEnsemble() == True
profs = dec.getProfiles()
profs.advanceHighlight(1)
profs.advanceHighlight(-1)
profs.advanceTime(1)
profs.advanceTime(-1)
#print(profs)
test_decoder()

#test_decoder()

0 comments on commit 1e6fc7d

Please sign in to comment.