-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added read_asc function with docstring and testcase * update whatsnew
- Loading branch information
1 parent
ea1a2a8
commit 74e119b
Showing
3 changed files
with
101 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Wed Oct 11 10:48:06 2023 | ||
@author: veenstra | ||
""" | ||
|
||
import os | ||
import pytest | ||
import numpy as np | ||
import dfm_tools as dfmt | ||
|
||
|
||
@pytest.mark.unittest | ||
def test_read_write_asc(): | ||
lat_range = np.arange(-8,2,0.25) | ||
lon_range = np.arange(-10,1,0.25) | ||
data = np.cos(lon_range) * lat_range[np.newaxis].T | ||
file_asc = './dummy.asc' | ||
dfmt.write_bathy_toasc(file_asc, lon_sel_ext=lon_range, lat_sel_ext=lat_range, elev_sel_ext=data, asc_fmt='%14.9f',nodata_val=-999) | ||
|
||
ds_asc = dfmt.read_asc(file_asc) | ||
|
||
assert (np.abs(ds_asc['lon'].to_numpy() - lon_range) < 1e-9).all() | ||
assert (np.abs(ds_asc['lat'].to_numpy() - lat_range) < 1e-9).all() | ||
assert (np.abs(ds_asc['data'].to_numpy() - data) < 1e-9).all() | ||
|
||
os.remove(file_asc) |