I am trying to calculate the dewpoint temperature with the metpy function metpy.calc.dewpoint_from_specific_humidity(pressure, temperature, specific humidity) from ERA5 gridded data, however I get an error:
ds = xarray.open_dataset('/dir/file.nc')
Td = metpy.calc.dewpoint_from_specific_humidity(ds.pressure_level, ds.temperature, ds.specific_humidity)
ValueError: operands could not be broadcast together with shapes (732,25,17,33) (25,732,17,33)
The shapes are the coordinates of the xarray (time:732, pressure level:25, latitude:17, longitude:33). It seems like the order is switched and the function can´t calculate because of the switched dimensions. Is there a way to fix this?
It would be nice if someone could help me!
Best, Lena