Skip to content

Commit

Permalink
more robust masking
Browse files Browse the repository at this point in the history
  • Loading branch information
micah-prime committed Mar 7, 2019
1 parent deb88e3 commit 27c3f29
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/snow_stats
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ def run():
if os.path.isfile(mask):
dsm = nc.Dataset(mask, 'r')
m = dsm.variables['mask'][:]
data = data*m
data[m==0] = np.nan
else:
raise IOError('mask file is incorrect')

for op in ops:
idnan = np.isnan(data)
data_nonan = data[~idnan]
if op == "sum":
tot = np.nansum(data)
print('Sum of {} is:\t\t{}'.format(band, tot))
Expand All @@ -83,10 +85,10 @@ def run():
tot_af = dx**2 * (tot/1000.0) * 0.000810714 / 1000.0
print('Sum of {} in TAF is:\t\t{}'.format(band, tot_af))
if op == 'median':
med = np.nanmedian(data)
med = np.median(data_nonan)
print('Median of {} is:\t\t{}'.format(band, med))
if op == 'mean':
mn = np.nanmean(data)
mn = np.nanmean(data_nonan)
print('Mean of {} is:\t\t{}'.format(band, mn))


Expand Down

0 comments on commit 27c3f29

Please sign in to comment.