def test_roundtrip(self): ds = create_ensemble_data() for vn in utils.available_variables(ds): v = utils.get_variable(vn) orig = ds.copy(deep=True) expected = v.decompress(v.compress(ds), ds) # make sure two passes yields the same result actual = v.decompress(v.compress(expected), ds) actual.identical(expected)
def infer_variable(fcst): """ This attempts to infer which variable is held in a particular forecast. It assumes there is a single variable. """ variable = utils.available_variables(fcst) variable = set(variable).symmetric_difference(fcst.coords.keys()) if len(variable) > 1: raise ValueError("More than one possible variable (%s) " "please specify which you'd like to plot" % (', '.join([v.variable_name for v in variable]))) return variable.pop()