-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
a7a4ea0
commit 14cf664
Showing
1 changed file
with
12 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import tempfile | ||
|
||
import xarray as xr | ||
import xradar as xd | ||
from open_radar_data import DATASETS | ||
|
||
import xradar as xd | ||
|
||
|
||
def test_compare_sweeps(): | ||
# Fetch the radar data file | ||
filename = DATASETS.fetch("cfrad.20080604_002217_000_SPOL_v36_SUR.nc") | ||
|
||
# Open the data tree | ||
dtree = xd.io.open_cfradial1_datatree(filename) | ||
|
||
# Create a temporary file to store the modified data tree | ||
with tempfile.NamedTemporaryFile(mode="w+b") as temp_file: | ||
# Save the modified data tree to the temporary file | ||
xd.io.to_cfradial1(dtree.copy(), temp_file.name, calibs=True) | ||
|
||
# Open the modified data tree | ||
dtree1 = xd.io.open_cfradial1_datatree(temp_file.name) | ||
|
||
# Iterate through sweep keys and compare DataArrays | ||
for grp in dtree1.groups: | ||
if "sweep" in grp: | ||
data = dtree1[grp] | ||
dtree1[grp] | ||
|
||
# Compare the values of the DataArrays for all sweeps | ||
for sweep_num in range(9): # Assuming there are 9 sweeps | ||
xr.testing.assert_equal(dtree[f'sweep_{sweep_num}'].ds, dtree1[f'sweep_{sweep_num}'].ds) | ||
|
||
xr.testing.assert_equal( | ||
dtree[f"sweep_{sweep_num}"].ds, dtree1[f"sweep_{sweep_num}"].ds | ||
) |