Browser=>Filter Channel NamesΒΆ

This command can be used to rename channel names in NC files. To access the command right click inside the NC Editor.

../../_images/nc_name_filter-en.png
Original Name
Original channel name in the original data file.
Channel Name
Channel name in the netCDF data file.
Show Device Names
For MDF files the device name is added to the channel name, separated by a backslash (aaa.bbb\device). If the option is not selected, the device name is removed (\device).

First Filter

The first filter can be used to split the channel name at the separator charachter. Elements can be removed at the beginning or the end of the name. More filter of this type can be specified in the text box.

Execute

The filter is applied and the result is displayed in the Channel Name column.
More Filters

If More Filters is enabled, filter can be specified in the text box, one filter in each line. Each filter has the following form:

match filter-name parameter

To disable a filter, add a comment character # at the beginning of a line.

match: In front of the filter-name an optionial search pattern can be set. see strmatch. The search pattern must end with a @ character.

Example:

es_* @ upper

All channels starting with es_ will be converted to upper case.

*_[1-3] @ lower

All channels starting with _1, _2 or _3 will be converted to lower case.

filter-name

Name Description
separator

Splits the channel name at a separator in tokens. separator has three parameters: Separator, Number (range 0 to 9) and action (one of the four strings: hide from right, show from right, hide from left, show from left).

separator . 1 show from right

aaa.bbb => bbb
a.b.c => c
separator . 1 hide from right

aaa.bbb => aaa
a.b.c => a.b
lower Changes the case to small characters.
upper Changes the case to upper characters.
replace

Replaces the text. Example:

replace . _

aaa.bbb => aaa_bbb

TIME* @ replace TIME_ Time

TIME_1 => Time1
remove

Removes characters. The command can remove all occurrences, remove characters at the beginning (from left) or at the end (from right) of the name. Example:

remove $

$aaa.bbb => aaa.bbb

remove .ext from right

x122.ext => x122

remove mot_ from left

mot_n => n

Use new names for attribute long_name and title

If this option is marked the new name is used to update the channel attributes long_name and title.

Example

The following example automates the channel name filtering. The function OnImportUpdateNCFile is a callback function, that will be invoked if defined. In this example it is checked, if the data file was created with the ODS5 import filter and contains a certain value in a global attribute. The filter fucntion nc_name_filter removes the characters Ext from the end of the channel name. The first function parameter is a vector with all channel names. The second paramete is the filter string:

def OnImportUpdateNCFile(ssNCName)
{
    ncid = nc_open(ssNCName, NC_WRITE);
   if (ncid == -1) {
      return FALSE;
   }

   if (nc_attinq_datatype(ncid, -1, "TestCell") != NC_CHAR) {
      nc_close(ncid);
      return TRUE;
   }
   ssAtt = nc_attget(ncid, -1, "TestCell");
   if (strfind(ssAtt, "Xp2")[1] == 0) {
      nc_close(ncid);
      return TRUE;
   }

   if (nc_attinq_datatype(ncid, -1, "Creator") != NC_CHAR) {
      nc_close(ncid);
      return TRUE;
   }
   ssAtt = nc_attget(ncid, -1, "Creator");
   if (strfind(ssAtt, "ODS51")[1] == 0) {
      nc_close(ncid);
      return TRUE;
   }

   if (_nc_need_org_name(ncid)) {
      _nc_write_org_names(ncid);
   }
   sv = NC_GetOrgNames(ncid);
   // remove the string "Mit" from the string end.
   sv = nc_name_filter(sv, "remove Ext from right");
   _nc_rename_all(ncid, sv, TRUE);
   nc_close(ncid);
   return sv;
}

Comment

Kommentar

New filter functions can be added. See file nc_name_filter.ic.

See also

The Data Editor

id-781728