#!/usr/bin/env python # coding: utf-8 # # DataArray - Arithmetic # # We can basic arithmetic operations (plus, minus, multiplication and division) with DataArrays, both with scalars, numpy arrays and other DataArrays. The output will in all cases be a new DataArray. # In[1]: import mikeio # In[2]: fn1 = "../tests/testdata/oresundHD_run1.dfsu" da1 = mikeio.read(fn1, items="Surface elevation")[0] fn2 = "../tests/testdata/oresundHD_run2.dfsu" da2 = mikeio.read(fn2, items="Surface elevation")[0] # ## Multiply or add scalar # # We can scale a DataArray or add a constant using *, +, / and - # In[3]: da1.values.mean() # In[4]: da1_A = da1 + 1 da1_B = da1 - 1 da1_A.values.mean(), da1_B.values.mean() # In[5]: da1_C = da1 * 2 da1_D = da1 / 2 da1_C.values.mean(), da1_D.values.mean() # ## Difference between two DataArrays # # Assume that we have two calibration runs and we wan't to find the difference... # In[6]: da_diff = da1-da2 da_diff.plot(title="Difference"); # In[7]: da_diff = da1/da2 da_diff.plot(title="da1/da2");