Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor launch file [WIP] #34

Draft
wants to merge 7 commits into
base: ustar_cp_refactor_main
Choose a base branch
from

Conversation

isaacaka
Copy link

First pass on refactoring launch.m. Split the single big main function into multiple sub-functions which are then called by the main function.

Closes #26

Copy link
Member

@dorchard dorchard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry only time for partial comments)

Comment on lines +183 to +210
function [input_folder, output_folder] = check_path(input_folder, output_folder)

% check input path
if 0 == exist('input_folder')
input_folder = [pwd '/'];
elseif length(input_folder) < 2
if input_folder(2) ~= ':'
input_folder = [pwd '/' input_folder];
end
end
if input_folder(length(input_folder)) ~= '\' && input_folder(length(input_folder)) ~= '/'
input_folder = [input_folder '/'];
end
end
if output_folder(length(output_folder)) ~= '\' && output_folder(length(output_folder)) ~= '/'
output_folder = [output_folder '/'];
end
mkdir(output_folder);

%by alessio
USTAR_INDEX = 1;
NEE_INDEX = 2;
TA_INDEX = 3;
PPFD_INDEX = 4;
RG_INDEX = 5;
input_columns_names = {'USTAR' 'NEE' 'TA' 'PPFD_IN' 'SW_IN' };
% check output path
if 0 == exist('output_folder')
output_folder = [pwd '/'];
elseif length(output_folder) < 2
if output_folder(2) ~= ':'
output_folder = [pwd '/' output_folder];
end
end
if output_folder(length(output_folder)) ~= '\' && output_folder(length(output_folder)) ~= '/'
output_folder = [output_folder '/'];
end
mkdir(output_folder);

%by alessio
fprintf('\n\nUstar Threshold Computation by Alan Barr\n\ninput in %s\noutput in %s\n\n', input_folder, output_folder);
d = dir([input_folder,'*_qca_ustar_*.csv']);
error_str = {};
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that there is a single function for checking a path which could be extracted from this and reused (the code looks the same between checking input and output paths)

dataset = textscan(fid,'%[^\n]');dataset = dataset{1};

function [exitcode, site, year, lat, lon, timezone, htower, timeres, sc_negl, notes] ...
= not_valid_header(dataset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - definitely makes sense to split this out and then I think we can abstract this and replace a lot of repetition

@dorchard
Copy link
Member

We decided to build on this PR with the rest of the refactoring and testing. @isaacaka to add a checklist of the items in the PR first post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants