NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 21 forks source link

assigning a name to a dataset: SET DATA/NAME, and SET DATA name = file #1976

Open AndrewWittenberg opened 4 years ago

AndrewWittenberg commented 4 years ago

In Ferret v7.52, the DEFINE DATA/AGGREGATE command can be used to assign a name to a dataset, e.g.:

    NOAA/PMEL TMAP
    FERRET v7.52 (optimized)
    Linux 2.6.32-754.23.1.el6.x86_64 64-bit - 12/03/19
     7-May-20 19:11     

yes? union my_data_name = coads_climatology
yes? sho dat/brief
     currently SET data sets:
    2> my_data_name  (default)  Union aggregation

I've found these dataset names to be very useful in scripts, when I don't necessarily know the dataset number in the present context.

So I'd propose extending this naming ability to the SET DATA command (and its aliases like USE), i.e.:

yes? use/name="my_data_name" "/path/to/file.nc"

An alternative syntax could be:

yes? use my_data_name = "/path/to/file.nc"

The latter syntax would be more consistent with that of DEFINE DATA/AGGREGATE, while the former would allow one to assign (or reassign) a name to a dataset that has already been read into Ferret:

yes? use coads_climatology
yes? set data/name="my_data_name" 1

Maybe that argues for supporting both syntaxes?

AnsleyManke commented 4 years ago

I like this idea!

We do have RETURN=dset and RETURN=dsetpath keywords that gets us some of this, but it's not the same convenience as a rename. RETURN=dset does not result in unique names.

All of these syntaxes fit in the established syntax; either opening the dataset with a name, or renaming it later, in essence applying a setting to an open dataset.

! opening dataset with a name  ( do we need this one?)
yes? use my_data_name = "/path/to/file.nc"

! or, opening with /NAME=
yes? use/name=my_data_name = "/path/to/file.nc"  ! opening a new file

yes? use coads_climatology
yes? set data/name="my_data_name" 1 

! or equivalently, since USE is an alias

yes? use coads_climatology
yes? use/name="my_data_name" 1
AnsleyManke commented 4 years ago

I first thought to use the same mechanism as is used for DEFINE DATA/AGG name= and works perfectly. However, it acts like other renaming that we do (set var/name or set axis/name) , and the original dataset name and url is replaced. For reference, the name in question is stored in ds_des_name(iset).

Here we don't really want to replace the name, but only assign a nickname. We'll need to either do this a little differently, or add some logic to save the original name, because of course we still want the original dataset name to appear in data listings and history attributes for netCDF files.

Putting this aside just for the moment - it's easy and we'll get back to it but I think not for the upcoming release.