nodenames = {'areacode' 'wavedir' 'radius' 'theta' 'phi' 'erosionfactor'};

net = Net();
for i = 1:length(nodenames)
    % create nodes
    node.(nodenames{i}) = Node(nodenames{i}, 0, net);
end

node.areacode.setLevels(2:18);

node.theta.setLevels(0:18:360);
node.theta.addLink(node.areacode);

node.wavedir.setLevels(0:18:360);

node.phi.setLevels([0:18:72 360]);
node.phi.addLink(node.theta);
node.phi.addLink(node.wavedir);
node.phi.setEquation('phi (theta, wavedir) = abs(theta - wavedir)');
node.phi.equationToTable(10, true, true)

node.radius.setLevels([roundoff(1000 ./ (pi*(30:-6:6)/180), -2)-100 15000 1.7959e+308]);
node.radius.addLink(node.areacode);

node.erosionfactor.setLevels(.7:.12:1.42);
node.erosionfactor.addLink(node.radius);
node.erosionfactor.addLink(node.phi);

% net.readCase('curvature_wave_angle.cas', true, 1)

% compile net
net.compile()
% create streamer
stream = Streamer('curvnet2.dne');
% write net
net.write(stream);

%% Caseset (database with the cases)
% caseFile1 = Streamer('curvature_wave_angle.cas');
% nodes    = net.getNodes();
% cases    = Caseset();
% learner  = Learner(Learner.COUNTING_LEARNING);
% cases.addCases(caseFile1,1.0,'null');
% learner.learnCPTs(nodes,cases,1.0);
% caseFile2 = Streamer('jarkus_curvature_ori.cas');
% nodes    = net.getNodes();
% cases    = Caseset();
% cases.addCases(caseFile2,1.0,'null');
% learner.learnCPTs(nodes,cases,1.0);
% 
% net.compile()
% netfileLearned = Streamer('test3_learned.dne');
% net.write(netfileLearned);
% 
% learner.finalize()
% cases.finalize()
% nodes.finalize()

% close net
net.finalize();