act.qc.QCFilter.get_masked_data

QCFilter.get_masked_data(var_name, rm_assessments=None, rm_tests=None, return_nan_array=False, ma_fill_value=None, return_inverse=False)[source]

Returns a numpy masked array containing data and mask or a numpy float array with masked values set to NaN.

Parameters:
  • var_name (str) – Data variable name.

  • rm_assessments (str or list of str) – Assessment name to exclude from returned data.

  • rm_tests (int or list of int) – Test numbers to exclude from returned data. This is the test number (or bit position number) not the mask number.

  • return_nan_array (boolean) – Return a numpy array with filtered ( or masked) values set to numpy NaN value. If the data is type int will upconvert to numpy float to allow setting NaN value.

  • ma_fill_value (int or float (or str?)) – The numpy masked array fill_value used in creation of the the masked array. If the datatype needs to be upconverted to allow the fill value to be used, data will be upconverted.

  • return_inverse (boolean) – Invert the masked array mask or return data array where mask is set to False instead of True set to NaN. Useful for overplotting where failing.

Returns:

variable (numpy masked array or numpy float array) – Default is to return a numpy masked array with the mask set to True where the test with requested assessment or test number was found set. If return_nan_array is True will return numpy array upconverted to float with locations where the test with requested assessment or test number was found set converted to NaN.

Examples

from act.io.armfiles import read_netcdf
from act.tests import EXAMPLE_IRT25m20s

ds_object = read_netcdf(EXAMPLE_IRT25m20s)
var_name = "inst_up_long_dome_resist"
result = ds_object.qcfilter.add_test(
    var_name, index=[0, 1, 2], test_meaning="Birds!"
)
data = ds_object.qcfilter.get_masked_data(
    var_name, rm_assessments=["Bad", "Indeterminate"]
)
print(data)
masked_array(
    data=[..., 7.670499801635742, 7.689199924468994, 7.689199924468994],
    mask=[..., False, False, False],
    fill_value=1e20,
    dtype=float32,
)