xarray-contrib / xwrf

A lightweight interface for working with the Weather Research and Forecasting (WRF) model output in Xarray.
https://xwrf.readthedocs.io/
Apache License 2.0
56 stars 16 forks source link

[FEATURE]: Make xwrf fall back to XTIME if Times is not included in WRF file #169

Closed lpilz closed 2 months ago

lpilz commented 2 months ago

Description

For now, the processing of WRF files which don't include the Times variable is not possible even though the data should also be available in the XTIME coordinate. I would propose that we fall back on the XTIME variable if the Times variable is not available.

Implementation

Add this to postprocess.py:_decode_times. Check if XTIME already is a datetime variable and if not, call the default xarray cf decoder.

Tests

Drop the Times variable from the raw dataset before .xwrf.postprocess() and compare both Time coordinates.

Questions

Is there anything we have to make transparent to the users? Like could there be floating-point inaccuracies which warrant a warning?

lpilz commented 2 months ago

I decided to just error if the XTIME is not a datetime dtype as it seemed unnecessarily complicated to implement the default xarray decoding.