-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses dynamic fieldnames in "unpackParams"
- Loading branch information
1 parent
4f38b98
commit 71e329b
Showing
3 changed files
with
25 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,31 @@ | ||
function problemStruct = unpackParams(problemStruct) | ||
|
||
%Unpack the params out of the fitParams and otherParams arrays | ||
%back into problem.params | ||
% Unpack the params out of the fitParams and otherParams arrays | ||
% back into problem.params | ||
|
||
% Note that this order of parameters fields is hard-coded by this | ||
% routine, packParams, packParamsPriors, and getFitNames | ||
fields = {"params", "backgroundParams", "scalefactors", "qzshifts",... | ||
"bulkIns", "bulkOuts", "resolutionParams", "domainRatios"}; | ||
|
||
unpacked_counter = 1; | ||
packed_counter = 1; | ||
uppars_counter = 1; | ||
|
||
uppars = zeros(1,length(problemStruct.params)); | ||
for i = 1:length(problemStruct.checks.params) | ||
if problemStruct.checks.params(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.params = uppars; | ||
|
||
%Also the backgrounds | ||
uppars = zeros(1,length(problemStruct.backgroundParams)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.backgroundParams) | ||
if problemStruct.checks.backgroundParams(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.backgroundParams = uppars; | ||
|
||
%Scalefactors | ||
uppars = zeros(1,length(problemStruct.scalefactors)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.scalefactors) | ||
if problemStruct.checks.scalefactors(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.scalefactors = uppars; | ||
|
||
%qzshifts | ||
uppars = zeros(1,length(problemStruct.qzshifts)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.qzshifts) | ||
if problemStruct.checks.qzshifts(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.qzshifts = uppars; | ||
|
||
%Bulk In | ||
uppars = zeros(1,length(problemStruct.bulkIns)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.bulkIns) | ||
if problemStruct.checks.bulkIns(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
|
||
for i = 1:length(fields) | ||
uppars = zeros(1,length(problemStruct.(fields{i}))); | ||
uppars_counter = 1; | ||
for j = 1:length(problemStruct.checks.(fields{i})) | ||
if problemStruct.checks.(fields{i})(j) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.(fields{i}) = uppars; | ||
end | ||
problemStruct.bulkIns = uppars; | ||
|
||
%Bulk Out | ||
uppars = zeros(1,length(problemStruct.bulkOuts)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.bulkOuts) | ||
if problemStruct.checks.bulkOuts(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.bulkOuts = uppars; | ||
|
||
%Resolutions | ||
uppars = zeros(1,length(problemStruct.resolutionParams)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.resolutionParams) | ||
if problemStruct.checks.resolutionParams(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.resolutionParams = uppars; | ||
|
||
%Domain Ratios | ||
uppars = zeros(1,length(problemStruct.domainRatios)); | ||
uppars_counter = 1; | ||
for i = 1:length(problemStruct.checks.domainRatios) | ||
if problemStruct.checks.domainRatios(i) == 1 | ||
uppars(uppars_counter) = problemStruct.fitParams(unpacked_counter); | ||
unpacked_counter = unpacked_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
else | ||
uppars(uppars_counter) = problemStruct.otherParams(packed_counter); | ||
packed_counter = packed_counter + 1; | ||
uppars_counter = uppars_counter + 1; | ||
end | ||
end | ||
problemStruct.domainRatios = uppars; | ||
|
||
|
||
end |