aodn / imos-toolbox

Graphical tool for QC'ing and NetCDF'ing oceanographic datasets
GNU General Public License v3.0
46 stars 31 forks source link

Modify Nortek Signature parser logic to handle ad2cp/mat and OceanContour nc/mat #775

Open sspagnol opened 2 years ago

sspagnol commented 2 years ago

Maybe I'm missing something, but when when I'm loading a Nortek signature file, since the insrument is identified as a Nortek Signature then the toolbox wants to use signatureParser. This obviously does not work for OceanContour processed and exported file. If I'm missing something obvious to do this please let me know, otherwise...

Could signatureParser code be split out to say AD2CP.ad2cp_reader and AD2CP.mat_reader (this code pulled out from current large case statements) and the logic be rewritten like

if ~iscellstr(filename), error('filename must be a cell array of strings'); end

% only one file supported
filename = filename{1};
[~, ~, ext] = fileparts(filename);

switch lower(ext)
   case '.ad2cp'
      sample_data = AD2CP.ad2cp_reader(filename);
   case '.nc'
      sample_data = sample_data = OceanContour.readOceanContourFile(filename);
   case '.mat'
      % some test to determine if OceanContour mat file or SignatureViewer mat file, this might involve loading the structure,
      % in which case maybe pass the structure to below functions rather than filename
      is_ocean_contour_matfile = <some test to determine if OceanContour mat file or SignatureViewer mat file>
      if is_ocean_contour_matfile 
         sample_data = AD2CP.mat_reader(filename);
      else
         sample_data = sample_data = OceanContour.readOceanContourFile(filename);
      end
    otherwise
        error('Data format not supported');
hugo-sardi commented 2 years ago

have you tried to update the instruments.txt file and check if the instrument name matches the ones in there? I got something like:

NORTEK, Signature 1000, oceanContour
NORTEK, Signature 500, oceanContour