This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial version of Severn test script
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
|
||
import glob | ||
import netCDF4 as netcdf | ||
import numpy as np | ||
|
||
|
||
def read_data(filenames): | ||
"""Read data from NetCDF files.""" | ||
S = [] | ||
W = [] | ||
H = [] | ||
Q = [] | ||
for ncfile in filenames: | ||
with netcdf.Dataset(ncfile) as f: | ||
S.append(f['Reach_Timeseries']['S_90m'][:, 0].data) | ||
W.append(np.mean(f['XS_Timseries']['W'][:].data, axis=1)) | ||
H.append(np.mean(f['XS_Timseries']['H_90m'][:].data, axis=1)) | ||
Q.append(f['Reach_Timseries']['Q'][:, 0].data) | ||
Q, H, W, S = np.array(Q).T, np.array(H).T, np.array(W).T, np.array(S).T | ||
return Q, H, W, S | ||
|
||
|
||
def main(): | ||
"""Main driver routine.""" | ||
ncfiles = glob.glob("../Severn/*.nc") | ||
Q, H, W, S = read_data(ncfiles) |