Best option for derived variables #349
Replies: 3 comments 5 replies
-
|
Some quick feedback... In Method 1, I think you're taking the difference of two datasets (so xarray doesn't know that variable This seems related to this discussion [@mzelinka]. Maybe someone with more xarray experience can weigh in – it seems like this will be a very common operation. |
Beta Was this translation helpful? Give feedback.
-
|
Based on my short experience (days) with xcdat, but also reading through #296 and https://xcdat.readthedocs.io/en/latest/api.html#overview, I think one challenge for users transitioning from CDAT to xcdat is that there is nothing truly equivalent to a "TransientVariable". To get the full functionality of xcdat, a user should always work with datasets. However, because datasets can contain multiple data variables, the syntax for manipulating variables becomes a little heavier and less intuitive (see examples above). I wonder if it would be possible to introduce a distinction between single-variable datasets and multivariable datasets. A single-variable dataset would be more like a CDAT TransientVariable. Is it possible for xcdat to overload arithmetic operations between datasets so that they behave more intuitively when dealing with single variable datasets? Assume
would return a new single-variable dataset with the data content being the difference between FSNT and FLNT. For single-variable datasets, the internal data variable name could be generic (
If this could be done, I think it would make working with xcdat significantly more intuitive (without breaking any current functionality). Tagging @tomvothecoder and @pochedls. |
Beta Was this translation helpful? Give feedback.
-
|
@pochedls : I don't have a good sense of what is possible or not, so thanks for entertaining my suggestions. I realize that xcdat does not create its own class. In fact, it's rather cool how xcdat adds functionality directly to xarray datasets through accessors. I did not know that was possible. If accessors can also be used to define The API for multi-variable datasets would not be impacted, and could be used as well for single-variables datasets. There would just be an additional (more intuitive) API option for single-variable datasets, something like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm just getting started with xcdat by trying to convert some of my existing scripts from CDAT to xcdat.
Let's start with a simple and common scenario: read a few variables from separate monthly time series files, calculate annual averages and then compute some derived quantities from them.
Bellow are different methods I tried.
Q: Is there a preferred way to accomplish this? Maybe even a better/cleaner method?
(Input files for my test are on Chrysalis.)
Beta Was this translation helpful? Give feedback.
All reactions