
clear; clc; close all;

cd /Volumes/arguk/ASFS/noaa_lab_March4test/

filename = 'f';
Source = 'CR1000X "ASFS" test at NOAA staging area, March 4. Contanct: NOAA-ESRL, C. Cox - christopher.j.cox@noaa.gov. Please do not redistribute.';

x = importdata([filename,'.dat'],',',4);
data.dn = datenum(char(x.textdata(5:end,1)),'yyyy-mm-dd HH:MM:SS');
[yyyy mo dd hh mm u] = datevec(data.dn);
data.year  = yyyy;
data.month = mo;
data.day   = dd;
data.hour  = hh;
data.min   = mm;

fnames = char(x.textdata(2,1));
fnames = strsplit(fnames,',');
for k = 2:length(fnames)
    data.(strrep(fnames{k},'"','')) = x.data(:,k-1);
end


ncid = netcdf.create([filename,'.nc'],'NC_WRITE');

Date_Created = num2str(date);
attPut('Date_Created',Date_Created,ncid)

attPut('Note',Source,ncid)

fnames = fieldnames(data);
for k = 2:length(fnames)
    cdfPut(data.(char(fnames(k))),char(fnames(k)),'double',[],length(data.dn),ncid);  
end

netcdf.close(ncid)

clear; clc;








