

cd('E:\Google Drive\Projects\HI-SCALE SGP\Data\ARM_Data\ACSM a1');


currdir = dir;
time = [];
org = [];
nit = [];
am = [];
sul = [];
chl = [];

for i = 1:length(currdir)
	
	cdfcheck = ~isempty(strfind(currdir(i).name,'.cdf')) || ~isempty(strfind(currdir(i).name,'.nc'));
	if cdfcheck == 0
		continue
	end
	currfile = currdir(i).name;
	datestartidx = 17;
	year_range = datestartidx : datestartidx +3;
	month_range = datestartidx +4 : datestartidx +5;
	day_range = datestartidx +6 : datestartidx +7;
	startdate = [str2num(currfile(year_range)), str2num(currfile(month_range)), str2num(currfile(day_range)), 0, 0, 0];
	sec_time = ncread(currfile,'time');
	
	currtimemat = repmat(startdate,length(sec_time),1);
	currtimemat(:,6) = currtimemat(:,6) + sec_time;
	currtimemat = datetime(currtimemat);
	time = [time ; currtimemat];
	
	currorg = ncread(currfile,'total_organics');
	org = [org; currorg];
	
	currnit = ncread(currfile,'nitrate');
	nit = [nit; currnit];
	
	curram = ncread(currfile,'ammonium');
	am = [am; curram];
	
	currsul = ncread(currfile,'sulfate');
	sul = [sul; currsul];
	
	currchl = ncread(currfile,'chloride');
	chl = [chl; currchl];
	
end
