NOAA-PMEL/PyFerret

SET VARIABLE/NAME= fails for ensemble datasets

Opened this issue · 0 comments

This was reported by Ryo Furue @ryofurue 8/7/2022 @ryofurue

Here is his example script:

! create sample datasets
set data coads_climatology
let myvar = sst[L=@MAX]
save/clobber/file=[myvar1.nc](http://myvar1.nc/) myvar
let myvar = sst[L=@MIN]
save/clobber/file=[myvar2.nc](http://myvar2.nc/) myvar
cancel data/all
cancel var/all

! testing renaming for a single dataset.
set data [myvar1.nc](http://myvar1.nc/)
set var/name=myvar_org myvar
let myvar = myvar_org/2
save/clobber/file=[tmp1.nc](http://tmp1.nc/) myvar
cancel data/all
cancel var/all

! testing renaming for an ensemble.
ensemble a = {"[myvar1.nc](http://myvar1.nc/)", "[myvar2.nc](http://myvar2.nc/)"}
set var/name=myvar_org myvar
let myvar = myvar_org/2
save/clobber/file=[tmp.nc](http://tmp.nc/) myvar

which results in the error,
**ERROR: variable unknown or not in data set: MYVAR_ORG

Variable renaming works by replacing the variable with the desired new name in the data structures that describe a dataset that is open in PyFerret. The solution here would for the code in set_var.F that does SET VARIABLE/NAME check whether the dataset is an ensemble, and change the variable-names in the member files using CD_RENAME_VAR . This would be in addition to the name change in the ensemble dataset.

The same would also apply to Timeseries and Forecast aggregations; and for Union aggregations we'd need to go find the member dataset with the variable to be renamed.