'How to compute an additional variable data array from the values of other variables

I have a oceanic weather dataset over three dimension (time, x, y) which includes two data arrays with two different variables (Hs, Te) I want to compute a third data array (power generated) based on the values of the other two data arrays, but I cannot do it arithmetically. I have a 2D pandas dataframe (power matrix) which gives the power output depending on the combination of Hs and Te. [enter image description here][1]

I have tried to input the Hs and Te data arrays using loc and iloc in but it does not take multidimensional indexes.

Is there a way I can use Hs, and Te, for every given timestep and coordinates, to calculate the power output from the matrix and assign it to the third data array?

I will really appreciate it if someone can help me!

Here is a bit of what i have tried.

def get_gen(ds, power_matrix):
    Hs= ds['wave_height']
    Te= ds['wave_period']
    power_mat =power_matrix
    power = power_mat.loc[[Hs], [Te]]
    return power

test = get_gen(ds, power_matrix)```





  [1]: https://i.stack.imgur.com/sp5FU.png


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source