-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added filter_runmean function and test
- Loading branch information
Showing
2 changed files
with
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,30 @@ | ||
#import pytest | ||
#from datetime import datetime, timedelta | ||
#import yaml | ||
#import numpy as np | ||
#import os | ||
#from copy import deepcopy | ||
# | ||
#from wavy.insitumod import insitu_class as ic | ||
#from wavy.filtermod import apply_land_mask | ||
# | ||
#sd = "2021-8-2 01" | ||
#ed = "2021-8-3 12" | ||
# | ||
##ico = ic(nID,sensor,sd,ed) | ||
##test_dict = deepcopy(ico.vars()) | ||
# | ||
##@pytest.fixture | ||
##def test_data(): | ||
## return os.path.abspath(os.path.join(\ | ||
## os.path.dirname( __file__ ),'data')) | ||
# | ||
#def test_landmask(): | ||
# vardict = { 'latitude':[60.12,62.24, 64.08,65.08, 67.65,68.95], | ||
# 'longitude':[-23.47,-21.54, -19.32,-17.8, -13.97,-10.99]} | ||
# d,m = apply_land_mask(vardict) | ||
# assert len(m[m==False]) == int(2) | ||
# | ||
##def test_cleaners(): | ||
## nID = 'D_Breisundet_wave' | ||
## sensor = 'wavescan' | ||
## ico = ic(nID,sensor,sd,ed,priorOp='square',cleaner='linearGAM',postOp='root',date_incr=1,filterData=True) | ||
## assert len(vars(ico).keys()) == 16 | ||
## assert 'filter' in vars(ico).keys() | ||
## assert 'filterSpecs' in vars(ico).keys() | ||
# | ||
#def test_smoothers(): | ||
# nID = 'D_Breisundet_wave' | ||
# sensor = 'wavescan' | ||
# ico = ic(nID,sd,ed,smoother='blockMean',date_incr=1,filterData=True,sensor=sensor) | ||
# assert len(vars(ico).keys()) == 16 | ||
# assert 'filter' in vars(ico).keys() | ||
# assert 'filterSpecs' in vars(ico).keys() | ||
# | ||
import pytest | ||
from datetime import datetime, timedelta | ||
import yaml | ||
import numpy as np | ||
import os | ||
from copy import deepcopy | ||
from wavy.insitu_module import insitu_class as ic | ||
|
||
|
||
def test_filter_runmean(test_data): | ||
varalias = 'Hs' # default | ||
sd = "2023-8-20 00" | ||
ed = "2023-8-21 00" | ||
nID = 'MO_Draugen_daily' | ||
name = 'Draugen' | ||
ico = ic(nID=nID, sd=sd, ed=ed, varalias=varalias, name=name) | ||
print(ico) | ||
print(vars(ico).keys()) | ||
|
||
ico = ico.populate(path=str(test_data/"insitu/daily/Draugen")) | ||
new = ico.filter_runmean(window=3, | ||
chunk_min=3, | ||
sampling_rate_Hz=1/600) | ||
print(new.vars.time) | ||
print(new.vars.Hs) | ||
assert len(new.vars.time) == 6 | ||
assert not all(np.isnan(v) for v in ico.vars['Hs']) | ||
print(ico.vars.Hs[1:4]) | ||
print(np.mean(ico.vars.Hs[1:4])) | ||
assert new.vars.Hs[2] == np.mean(ico.vars.Hs[1:4]) |
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