-
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.
- Loading branch information
Showing
17 changed files
with
696 additions
and
40 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,9 +1,9 @@ | ||
name: build-linux | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
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,9 +1,9 @@ | ||
name: build-macos | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
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,9 +1,9 @@ | ||
name: build-windows | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
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,9 +1,9 @@ | ||
name: "Check Manifest" | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: [published] | ||
|
||
|
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: deploy-docs | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
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,9 +1,9 @@ | ||
name: deploy-pypi | ||
|
||
on: | ||
# push: | ||
# branches: | ||
# - main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
File renamed without changes.
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
57 changes: 57 additions & 0 deletions
57
examples/uncertainty_quant/_utils/_load_variables/_get_fill_value.py
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,57 @@ | ||
# SPDX-FileCopyrightText: Copyright 2016, Siavash Ameli <sameli@berkeley.edu> | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# SPDX-FileType: SOURCE | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under | ||
# the terms of the license found in the LICENSE.txt file in the root directory | ||
# of this source tree. | ||
|
||
|
||
# ======= | ||
# Imports | ||
# ======= | ||
|
||
import numpy | ||
|
||
__all__ = ['get_fill_value'] | ||
|
||
|
||
# ============== | ||
# get fill value | ||
# ============== | ||
|
||
def get_fill_value(east_vel_obj, north_vel_obj): | ||
""" | ||
Finds missing value (or fill value) from wither of east of north velocity | ||
objects. | ||
""" | ||
|
||
# Missing Value | ||
if hasattr(east_vel_obj, '_FillValue') and \ | ||
(not numpy.isnan(float(east_vel_obj._FillValue))): | ||
fill_value = numpy.fabs(float(east_vel_obj._FillValue)) | ||
|
||
elif hasattr(north_vel_obj, '_FillValue') and \ | ||
(not numpy.isnan(float(north_vel_obj._FillValue))): | ||
fill_value = numpy.fabs(float(north_vel_obj._FillValue)) | ||
|
||
elif hasattr(east_vel_obj, 'missing_value') and \ | ||
(not numpy.isnan(float(east_vel_obj.missing_value))): | ||
fill_value = numpy.fabs(float(east_vel_obj.missing_value)) | ||
|
||
elif hasattr(north_vel_obj, 'missing_value') and \ | ||
(not numpy.isnan(float(north_vel_obj.missing_value))): | ||
fill_value = numpy.fabs(float(north_vel_obj.missing_value)) | ||
|
||
elif hasattr(east_vel_obj, 'fill_value') and \ | ||
(not numpy.isnan(float(east_vel_obj.fill_value))): | ||
fill_value = numpy.fabs(float(east_vel_obj.fill_value)) | ||
|
||
elif hasattr(north_vel_obj, 'fill_value') and \ | ||
(not numpy.isnan(float(north_vel_obj.fill_value))): | ||
fill_value = numpy.fabs(float(north_vel_obj.fill_value)) | ||
|
||
else: | ||
fill_value = 999.0 | ||
|
||
return fill_value |
65 changes: 65 additions & 0 deletions
65
examples/uncertainty_quant/_utils/_load_variables/_make_array_masked.py
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,65 @@ | ||
# SPDX-FileCopyrightText: Copyright 2016, Siavash Ameli <sameli@berkeley.edu> | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# SPDX-FileType: SOURCE | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under | ||
# the terms of the license found in the LICENSE.txt file in the root directory | ||
# of this source tree. | ||
|
||
|
||
# ======= | ||
# Imports | ||
# ======= | ||
|
||
import numpy | ||
|
||
__all__ = ['make_array_masked'] | ||
|
||
|
||
# ================= | ||
# Make Array masked | ||
# ================= | ||
|
||
def make_array_masked(array, fill_value): | ||
""" | ||
Often the array is not masked, but has nan or inf values. This function | ||
creates a masked array and mask nan and inf. | ||
Input: | ||
- array: is a 2D numpy array. | ||
Output: | ||
- array: is a 2D numpy.ma array. | ||
Note: array should be numpy object not netCDF object. So if you have a | ||
netCDF object, pass its numpy array with array[:] into this function. | ||
""" | ||
|
||
if (not hasattr(array, 'mask')) or (numpy.isscalar(array.mask)): | ||
|
||
# Mask based on the fill values | ||
mask = (array >= fill_value - 1.0) | ||
|
||
# Mask based on nan values | ||
mask_nan = numpy.isnan(array) | ||
if mask_nan.any(): | ||
mask = numpy.logical_or(mask, mask_nan) | ||
|
||
# Mask based on inf values | ||
mask_inf = numpy.isinf(array) | ||
if mask_inf.any(): | ||
mask = numpy.logical_or(mask, mask_inf) | ||
|
||
array = numpy.ma.masked_array(array, mask=mask) | ||
|
||
else: | ||
# This array is masked. But check if any non-masked value is nan or inf | ||
for i in range(array.shape[0]): | ||
for j in range(array.shape[1]): | ||
for k in range(array.shape[2]): | ||
if bool(array.mask[i, j, k]) is False: | ||
if numpy.isnan(array[i, j, k]) or \ | ||
numpy.isinf(array[i, j, k]): | ||
array.mask[i, j, k] = True | ||
array.data[i, j, k] = numpy.nan | ||
|
||
return array |
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
Oops, something went wrong.