-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary operations are not internal #23
Comments
It is not clear to me what you mean. Can your provide all information in the issue template, |
Sorry, I apologise for having been too short.
I will use the "msl" datavar. If I sum that datavar with itself, the result is not a datavar, but a matrix:
The same occurs when I multiply by a scalar:
So, I am really asking for a new feature: that the result of operations with datavars, should be also datavars. |
But why? If you do a broadcast like that all of the variable attributes like "units" will likely be invalid, and actually misleading to keep. What do you lose making them a regular Array? |
Well, the only case I have faced so far, is when attempting to store the results into a NetCDF, just no not to have to re-compose the dimensions before to save to disk. |
Actually, it is sometimes the case that attributes are wrong or missing in a NetCDF/Zarr file and that one wants to use the data without recreating a big file on the disk. It would be nice to have a wrapper type (like WrapperDataset, WrapperVariable, but with a better name :-)) that allows you to edit attributes (and maybe other thinks) in memory without affecting the data on the disk. For example: ds_orig = NCDataset("original_file_with_missing_units.nc")
nctemp_orig = ds_orig["temp"];
nctemp = WrapperVariable(nctemp);
nctemp.attrib["units"] = "degree Celsuis" # nctemp has now the correct units but the file is not changed I am wondering if such wrapper classes can not also be useful here to correct units (or other metadata), like ds_orig = NCDataset("velocity.nc")
ncu = ds_orig["u"];
ncu2 = ncu.^2 # automatically create a WrapperVariable? computation eager or lazy?
ncu2.attrib["units"] = "m2 s-2" # the file will not be changed There is also a |
And not only the attributes, but also the values should also be modifiable, so that, for example, you can convert longitudes in the range [0,360] to the range [-180, 180]. |
I agree very much on not duplicating efforts. Rasters.jl also does all this, pretty similar to YAX (it's Dimensional data underneath for both now) but Rasters wraps CommonDataModel and can read GRIB if you need GRIB. You can then easily convert a Raster to YAX too. But I'm wondering what selection is more powerful here than in YAX? |
Wow! I tested Rasters a long time ago but after your post, I have tested it again right now. It correctly reads the grib files and I can change values and attributes, which means that the dataset is independent of the file. |
Great! I don't want to discourage doing this directly with the other packages like NCDatasets.jl. But Rasters is pretty commited to using CommonDataModel.jl for file IO standardisation now, and doing that lazily with So it's probably best we don't all try to cover the same functionality. |
If I have a dataset ds, then the result of
ds + ds
is a matrix, not a dataset.I have followed the example of the groupby function, that calculates anomalies, and we end up with a matrix, not a dataset. This prevents the use of the result again in the gropuby function if we want to calculate the standard deviations in order to get the standardized anomalies. The groupby function needs a dataset and does not work with a matrix.
The text was updated successfully, but these errors were encountered: