Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
edbc5565
Commit
edbc5565
authored
11 years ago
by
Laura Nervo
Browse files
Options
Downloads
Patches
Plain Diff
Updated and generalized use of gtUpdateDifspotGrainIDs
Signed-off-by:
Laura Nervo
<
laura.nervo@esrf.fr
>
parent
234e05c5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
4_grains/gtUpdateDifspotGrainIDs.m
+33
-13
33 additions, 13 deletions
4_grains/gtUpdateDifspotGrainIDs.m
with
33 additions
and
13 deletions
4_grains/gtUpdateDifspotGrainIDs.m
+
33
−
13
View file @
edbc5565
function
gtUpdateDifspotGrainIDs
(
grain
,
parameters
)
function
gtUpdateDifspotGrainIDs
(
table
,
variable
,
type
,
lastcolumn
,
queryname
,
queryvalues
,
values
)
% GTUPDATEDIFSPOTIDS Updates table's column with values adding a new column
% gtUpdateDifspotGrainIDs(table, variable, type, lastcolumn, queryname, queryvalues, values)
% ------------------------------------------------------------------------------------------
% Adds/updates values to a specific set of rows in a table in the db
%
% Usage:
% for ii=1:length(dir('4_grains/phase_01/grain_*.mat'))
% gr{ii} = load(sprintf('4_grains/phase_01/grain_%04d.mat',ii),'difspotID');
% end
% difspotID = gtIndexAllGrainValues(gr, 'difspotID',[],[],[],false);
% gtUpdateDifspotGrainIDs([parameters.acq.name 'difspot'], 'grainID', 'int', 'integral', 'difspotID', difspotID, 1:length(gr))
%
% Version 002 08-11-2013 by LNervo
%if it doesn't already exist, we may need to add a grainid column to
% if it doesn't already exist, we may need to add a grainid column to
%difspot table
% difspot table
[
a
,
b
,
c
,
d
,
e
,
f
]
=
mym
(
sprintf
(
'show columns from %sdifspot like "grainID"'
,
parameters
.
acq
.
name
));
[
a
,
~
,
~
,
~
,
~
,
~
]
=
mym
([
'SHOW COLUMNS FROM '
table
' LIKE "'
variable
'"'
]);
if
isempty
(
a
)
if
isempty
(
a
)
%add the field
%add the field
mym
(
sprintf
(
'ALTER TABLE graintracking.
%sdifspot
ADD COLUMN
grainID INT AFTER integral'
,
parameters
.
acq
.
name
)
);
mym
(
[
'ALTER TABLE graintracking.
'
table
'
ADD COLUMN
'
variable
' '
type
' AFTER '
lastcolumn
]
);
disp
(
'adding
grainID field to the difspot
table'
)
disp
(
[
'adding
column '
variable
' to the '
table
'
table'
]
)
end
end
%then loop through, updating according to the grain structure information
for
i
=
1
:
length
(
grain
)
% then loop through, updating according to the grain structure information
disp
(
sprintf
(
'doing grain %d'
,
i
))
for
ii
=
1
:
length
(
queryvalues
)
ids
=
grain
{
i
}
.
difspots
;
fprintf
(
'done %04d'
,
values
(
ii
))
for
j
=
1
:
length
(
ids
)
ids
=
queryvalues
{
ii
};
mysqlcmd
=
dbUpdate
(
sprintf
(
'%sdifspot'
,
parameters
.
acq
.
name
),
'difspotID'
,
ids
(
j
),
'GrainID'
,
i
);
for
jj
=
1
:
length
(
ids
)
mysqlcmd
=
gtDBUpdate
(
table
,
queryname
,
ids
(
jj
),
variable
,
values
(
ii
));
mym
(
mysqlcmd
);
mym
(
mysqlcmd
);
end
end
fprintf
(
'\b\b\b\b\b\b\b\b\b\b'
)
end
end
disp
(
' '
)
disp
([
'updated column '
variable
' from '
table
' table'
])
end
% end of function
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment