Home > NoiseTools > nt_idx_disp.m

# nt_idx_disp

## PURPOSE

nt_idx_disp(name,field,explainflag) - display contents of index file

## SYNOPSIS

function nt_idx_disp(name,field,explainflag)

## DESCRIPTION

    nt_idx_disp(name,field,explainflag) - display contents of index file

      name: name of file
      field: field to display in detail
      explainflag: if true, explain contents of each field

     NoiseTools

## CROSS-REFERENCE INFORMATION

This function calls:

- nt_demean [y,mn]=nt_demean(x,w) - remove weighted mean over cols
- nt_greetings nt_greetings - display message the first time the toolbox is used

This function is called by:

## SOURCE CODE

    0001 function nt_idx_disp(name,field,explainflag)
    0002 %nt_idx_disp(name,field,explainflag) - display contents of index file
    0003 %
    0004 %  name: name of file
    0005 %  field: field to display in detail
    0006 %  explainflag: if true, explain contents of each field
    0007 %
    0008 % NoiseTools
    0009 nt_greetings;
    0010
    0011 if nargin<1; name=pwd; end
    0012 if nargin<2; field=[]; end
    0013 if nargin<3; explainflag=0; end
    0014
    0015 % check name, parse into path, etc.
    0016 if ~ischar(name); error('name should be a string'); end
    0017 avoid=['[',1:31, 127,']'];
    0018 if regexp(name,avoid);
    0019     disp('bad character in file name, skip:'); disp(['   >',name,'<']);
    0020     return;
    0021 end
    0022 if name=='.'; name=pwd; end
    0023 if name(end)=='/'; name=name(1:end-1); end % remove trailing slash
    0024 [PATHSTR,NAME,EXT]=fileparts(name);
    0025 if strcmp(EXT,'idx');
    0026     disp(['warning: ', name, ' might be index file']);
    0027 end
    0028 if isempty(PATHSTR); % interpret relative to current directory
    0029     name=[pwd,filesep,name]; % full path, safe to use 'exist'
    0030 end
    0031 [PATHSTR,NAME,EXT]=fileparts(name);
    0032 if 2==exist(name)
    0033     d=dir(name);
    0034     filename=d.name;            % match case to file system
    0035     PATHSTR=cd(cd(PATHSTR));    % match case to file system
    0036     name=[PATHSTR,filesep,filename];
    0037 elseif 7==exist(name)
    0038     name=cd(cd(name));          % match case to file system
    0039     [PATHSTR,NAME,EXT]=fileparts(name);
    0040 else
    0041     disp(name);
    0042     error('...is neither file nor directory');
    0043 end
    0044
    0045 idxDir=[PATHSTR,filesep,'nt_idx'];
    0046 idxFile=[idxDir,filesep,NAME,EXT,'.idx'];
    0047
    0048 if 2~=exist(idxFile);
    0049     disp(idxFile)
    0050     disp('index file not found');
    0051     return
    0052 end
    0053
    0054 load('-mat',idxFile);  % loads hh, ii
    0055 a.hh=hh;
    0056 a.ii=ii;
    0057
    0058 if ~isempty(field)
    0059     eval(['a=a.',field,';']);
    0060 end
    0061
    0062 if ~explainflag
    0063     if isnumeric(a)
    0064         figure(100); clf; plot(nt_demean(a));
    0065     else
    0066         disp(a);
    0067     end
    0068 elseif ~isempty(a)
    0069     fieldNames=fieldnames(a);
    0070     for iFieldName=1:numel(fieldNames)
    0071         fieldName=fieldNames{iFieldName};
    0072         switch fieldName
    0073             case 'hh'
    0074                 disp('hh: header and metadata');
    0075             case 'ii'
    0076                 disp('ii: index describing the data')
    0077             case 'name'
    0078                 disp('name: name of file or directory that was indexed');
    0079             case 'idxName'
    0080                 disp('idxName: name of index file');
    0081             case 'time_indexed'
    0082                 disp('time_indexed: date/time at which this was indexed (datenumber)');
    0083             case 'failed'
    0084                 disp('failed: 1 = indexing failed');
    0085             case 'isdir'
    0086                 disp('isdir: 1 = directory');
    0087             case 'dir'
    0088                 disp('dir: directory list (for directory) or entry (for file)')
    0089             case 'filelist'
    0090                 disp('filelist: info for each file in this directory');
    0091             case 'isdata'
    0092                 disp('isdata: 1 = file was recognized as containing indexable data');
    0093             case 'nfiles'
    0094                 disp('nfiles: total number of indexed files within this directory & subdirectories');
    0095             case 'bytes'
    0096                 disp('bytes: total number of bytes within this file or directory & subdirectories');
    0097             case 'date'
    0098                 disp('date: directory date field for this file or directory');
    0099             case 'sr'
    0100                 disp('sr: sampling rate, if known');
    0101             case 'depth'
    0102                 disp('depth: depth of the subdirectory hierarchy');
    0103             case 'ndirs'
    0104                 disp('ndirs: total number of directories within this directory & subdirectories');
    0105             case 'nbad'
    0106                 disp('nbad: dunno what this means...');
    0107             case 'ndata'
    0108                 disp('ndata: total number of data files in this directory & subdirectories');
    0109             case 'nskip'
    0110                 disp('nskip: total number of files that were skipped in this directory & subdirectories');
    0111             case 'ext'
    0112                 disp('ext: extension of this file''s name');
    0113             case 'type'
    0114                 disp('type: type of this data file');
    0115             case 'ntypes'
    0116                 disp('ntypes: number of files of each type in this directory & subdirectories');
    0117             case 'size'
    0118                 disp('size: dimensions of matrix being indexed')
    0119             case 'originalsize'
    0120                 disp('originalsize: original dimensions before transposing');
    0121             case 'min'
    0122                 disp('min: minimum over interval of samples');
    0123             case 'max'
    0124                 disp('max: maximum over interval of samples');
    0125             case 'mean'
    0126                 disp('mean: mean over interval of samples');
    0127             case 'var'
    0128                 disp('var: variance over interval of samples')
    0129             case 'card'
    0130                 disp('card: cardinality of interval of samples');
    0131             otherwise
    0132                 disp([fieldName,': ?']);
    0133         end
    0134     end
    0135 end
    0136
    0137