-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for beams, obs, time utilities. Fixed polar plot error.
- Loading branch information
Showing
6 changed files
with
128 additions
and
33 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
import ECHO | ||
import numpy as np | ||
from scipy.interpolate import interp1d | ||
|
||
|
||
''' | ||
Tests to make: | ||
*create simple test beams | ||
*test that plots won't work on incorrect types (efield, hpx, power, etc) | ||
*test | ||
Beams use pyuvdata and/or healpy | ||
''' | ||
|
||
def test_createBeam(): | ||
#test that beams can't be made with invalid beam types | ||
with pytest.raises(AssertionError): | ||
testbeam=ECHO.Beam(beam_type='hpx') | ||
|
||
#make a beam with each valid beam_type | ||
testbeam=ECHO.Beam(beam_type='healpy') | ||
testbeam=ECHO.Beam(beam_type='efield') | ||
testbeam=ECHO.Beam(beam_type='power') | ||
|
||
return | ||
|
||
def test_beamplots(): | ||
testbeam = ECHO.Beam(beam_type='healpy') #has no beams yet, plotting should fail | ||
with pytest.raises(AssertionError): | ||
testbeam.plot_efield() | ||
testbeam.plot_efield_interp() | ||
testbeam.plot_power() | ||
testbeam.plot_power_interp() | ||
testbeam.plot_escatter() | ||
testbeam.plot_escatter_interp() | ||
testbeam.plot_powscatter() | ||
testbeam.plot_powscatter_interp() | ||
|
||
return |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
import ECHO | ||
import numpy as np | ||
from scipy.interpolate import interp1d | ||
|
||
|
||
''' | ||
Tests to make: | ||
*test that object initializes properly | ||
Beams use pyuvdata and/or healpy | ||
''' | ||
lat, lon = (33.448376, -112.074036) | ||
frequency = 75.00 | ||
description = "This is an observation object." | ||
|
||
def test_createObs(): | ||
#test that observations are created properly | ||
testobs = ECHO.Observation(lat, lon, frequency, description) | ||
assert (testobs.lat == lat), "Latitude not correct." | ||
assert (testobs.lon == lon), "Longitude not correct." | ||
assert (testobs.ref_frequency == frequency), "Frequency not correct." | ||
assert (testobs.description == description), "Description not correct." | ||
return | ||
|
||
def test_sortieList(): | ||
#test that the sortie list increments properly | ||
testobs = ECHO.Observation(lat, lon, frequency, description) | ||
testobs.addSortie(tlog='tlog_file', ulog='ulog_file', data='rx_data_file') | ||
assert (len(testobs.sortie_list)==1) | ||
assert (testobs.num_sorties ==1) | ||
return |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
|
||
import ECHO | ||
import numpy as np | ||
from scipy.interpolate import interp1d | ||
|
||
|
||
''' | ||
Tests to make: | ||
''' | ||
|
||
def test_findpeak(): | ||
f = np.linspace(50, 100, 51, endpoint=True) | ||
x = np.array([ 8.45090674, 10.04123532, 11.519111 , 11.31353706, 10.93862423, | ||
10.14809911, 10.56714626, 9.35886578, 8.95918093, 7.81729457, | ||
4.37170954, 7.56457857, 8.78697872, 12.04254699, 7.90141348, | ||
9.28847377, 9.65893591, 5.47728162, 11.4554848 , 5.68049579, | ||
10.05662662, 13.03766057, 9.50115484, 7.63408106, 11.65752125, | ||
9.99689695, 9.83531587, 9.11961106, 8.2682244 , 11.24434912, | ||
12.93292398, 9.79594562, 8.22141003, 8.68508538, 8.50393763, | ||
10.83899931, 12.2772833 , 15.7622897 , 14.55045571, 9.2609078 , | ||
9.0943069 , 7.27017967, 12.93086491, 11.28801567, 7.95531201, | ||
11.79401846, 9.71806665, 8.5215067 , 9.26962276, 13.13287041, | ||
10.83630832]) | ||
maxfreq, peak, peakrms = ECHO.time_utils.find_peak(f, x,fmin=50, fmax=100) | ||
assert(maxfreq[0] == 87.), "Incorrect frequency." | ||
assert(peak == 15.7622897), "Incorrect peak value." | ||
return |