Closed buchmann-dhi closed 2 months ago
Thanks @buchmann-dhi
After discussion with @ecomodeller, I suggest a solution like this:
Just before the above mentioned line...
source = DfsFileFactory.DfsGenericOpen(filename)
source.ReadStaticItemNext()
DfsItem("Direction", (100095-2400), Float)
This could easily be encapsulated in a function _is_directions_in_rad() for better readability.
Notes:
int(EUMUnit.degree) = 2401
int(EUMUnit.radian) = 2400
Sounds good @jsmariegaard I would maybe suggest a small change to the suggestion: Define a conversion factor to be used in any case. If the input is already degree (2401), then set it to unity. If input is 2400, then use 180/np.pi. This opens for the possibility of other conversions (although rad and deg are probably all that will be needed). Comments?
_spectral.py read() converts rad2deg In _spectral.py, directions are automatically (and always) converted from radian to degree with:
https://github.com/DHI/mikeio/blob/7a01cc74d92470ba6ecc1d6b86fb94c478ba7051/mikeio/dfsu/_spectral.py#L138
However, sometimes (depending on Mike user settings), output may already be in degrees. In this case, the conversion is unwanted resulting in much too large values for the directions.
It seems necessary to test the unit type before blindly applying rad2deg.
Reproduction:
Expected output:
System information: