Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gdat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
SPC
gdat
Commits
169b7130
Commit
169b7130
authored
9 months ago
by
Antonia Frank
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in loading of NBI data, NBI zero for all times
parent
59f7cea7
No related branches found
No related tags found
1 merge request
!163
Fix bug in loading of NBI data, NBI zero for all times
Pipeline
#205023
passed
9 months ago
Stage: test
Stage: post-test
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/TCV_IMAS/tcv_get_ids_core_sources.m
+68
-62
68 additions, 62 deletions
matlab/TCV_IMAS/tcv_get_ids_core_sources.m
with
68 additions
and
62 deletions
matlab/TCV_IMAS/tcv_get_ids_core_sources.m
+
68
−
62
View file @
169b7130
...
@@ -380,61 +380,64 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources
...
@@ -380,61 +380,64 @@ if ~isempty(ec_gdat.ec.data) % if EC data available, fill sources
end
end
%% NBI. same tgrid for NBI1 and NBI2
%% NBI. same tgrid for NBI1 and NBI2
check_nbi
=
[
~
isempty
(
powers_gdat
.
nbi1
.
data
),
~
isempty
(
powers_gdat
.
nbi2
.
data
)];
check_nbi
=
[
~
isempty
(
powers_gdat
.
nbi1
.
data
),
~
isempty
(
powers_gdat
.
nbi2
.
data
)];
active_nbi
=
find
(
check_nbi
==
1
);
active_nbi
=
find
(
check_nbi
==
1
);
nb_nbi
=
numel
(
check_nbi
);
nb_nbi
=
numel
(
check_nbi
);
nbi_names
=
{
'nbi1'
,
'nbi2'
};
nbi_names
=
{
'nbi1'
,
'nbi2'
};
if
numel
(
active_nbi
)
>
0
% Setup source structs for active nbi from template
% get tgrid (same for NBI1 & 2 if both active) from active_nbi(1)
main_desc
=
'Source from Neutral Beam Injection'
;
nbi_powers_tgrid
=
powers_gdat
.
(
nbi_names
{
active_nbi
(
1
)})
.
t
;
id_nbi
.
index
=
2
;
id_nbi
.
name
=
'nbi'
;
% find times where NBI is on to define time grid with extra time slice just
% before/after NBI power and at start/end of shot
itime_nbi
=
find
((
powers_gdat
.
(
nbi_names
{
active_nbi
(
1
)})
.
data
>
0
));
if
nbi_powers_tgrid
(
itime_nbi
(
end
))
>=
ohm_tgrid
(
end
)
i_time_end
=
iround
(
nbi_powers_tgrid
,
ohm_tgrid
(
end
));
nbi_tgrid_out
=
[
ohm_tgrid
(
1
),
nbi_powers_tgrid
(
itime_nbi
(
1
)
-
1
:
i_time_end
)
'
];
else
nbi_tgrid_out
=
[
ohm_tgrid
(
1
),
nbi_powers_tgrid
(
itime_nbi
(
1
)
-
1
:
itime_nbi
(
end
)
+
1
)
'
,
ohm_tgrid
(
end
)];
end
nt_nbi_out
=
numel
(
nbi_tgrid_out
);
% Setup source structs for active nbi from template
main_desc
=
'Source from Neutral Beam Injection'
;
id_nbi
.
index
=
2
;
id_nbi
.
name
=
'nbi'
;
for
i_nbi
=
active_nbi
id_nbi
.
description
=
sprintf
(
'NBI%i %s'
,
i_nbi
,
main_desc
);
ids_core_sources
.
source
{
last_index
+
i_nbi
}
=
source_template
;
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
identifier
=
id_nbi
;
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
profiles_1d
(
1
:
nt_nbi_out
)
=
{
profiles_template
};
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
(
1
:
nt_nbi_out
)
=
{
globals_template
};
end
disp
(
'Loading of current & power densities from ASTRA not implemented yet.'
)
disp
(
'Loading of current & power densities from ASTRA not implemented yet.'
)
disp
(
'Checking if ASTRA run available on partition /Lac8_D:'
)
disp
(
'Checking if ASTRA run available on partition /Lac8_D:'
)
[
~
,
hostname
]
=
unix
(
'hostname'
);
[
~
,
hostname
]
=
unix
(
'hostname'
);
if
strcmp
(
hostname
,
'lac8.epfl.ch'
)
if
strcmp
(
hostname
,
'lac8.epfl.ch'
)
unix
(
sprintf
(
'ls /Lac8_D/ASTRA/ | grep
''
%i
''
&& echo File for shotnumber exists! || echo File for shotnumber does not exist!'
,
shot
));
unix
(
sprintf
(
'ls /Lac8_D/ASTRA/ | grep
''
%i
''
&& echo File for shotnumber exists! || echo File for shotnumber does not exist!'
,
shot
));
else
else
unix
(
sprintf
(
'ssh $(whoami)@lac8 "ls /Lac8_D/ASTRA/ | grep
''
%i
''
&& echo File for shotnumber exists! || echo File for shotnumber does not exist! && exit"'
,
shot
));
unix
(
sprintf
(
'ssh $(whoami)@lac8 "ls /Lac8_D/ASTRA/ | grep
''
%i
''
&& echo File for shotnumber exists! || echo File for shotnumber does not exist! && exit"'
,
shot
));
end
end
if
numel
(
active_nbi
)
>
0
for
i_nbi
=
active_nbi
for
i_nbi
=
active_nbi
p_nbi_injected_tmp
=
interpos
(
nbi_powers_tgrid
,
powers_gdat
.
(
nbi_names
{
i_nbi
})
.
data
,
nbi_tgrid_out
);
% get tgrid (same for NBI1 & 2 if both active) from active_nbi(1)
for
ii
=
1
:
nt_nbi_out
nbi_powers_tgrid
=
powers_gdat
.
(
nbi_names
{
i_nbi
})
.
t
;
% globals
% find times where NBI is on to define time grid with extra time slice just
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
{
ii
}
.
time
=
nbi_tgrid_out
(
ii
);
% before/after NBI power and at start/end of shot
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
{
ii
}
.
power
=
p_nbi_injected_tmp
(
ii
);
itime_nbi
=
find
((
powers_gdat
.
(
nbi_names
{
i_nbi
})
.
data
>
0
));
if
~
isempty
(
itime_nbi
)
if
nbi_powers_tgrid
(
itime_nbi
(
end
))
>=
ohm_tgrid
(
end
)
i_time_end
=
iround
(
nbi_powers_tgrid
,
ohm_tgrid
(
end
));
nbi_tgrid_out
=
[
ohm_tgrid
(
1
),
nbi_powers_tgrid
(
itime_nbi
(
1
)
-
1
:
i_time_end
)
'
];
else
nbi_tgrid_out
=
[
ohm_tgrid
(
1
),
nbi_powers_tgrid
(
itime_nbi
(
1
)
-
1
:
itime_nbi
(
end
)
+
1
)
'
,
ohm_tgrid
(
end
)];
end
nt_nbi_out
=
numel
(
nbi_tgrid_out
);
% Setup source structs for active nbi from template
id_nbi
.
description
=
sprintf
(
'NBI%i %s'
,
i_nbi
,
main_desc
);
ids_core_sources
.
source
{
last_index
+
i_nbi
}
=
source_template
;
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
identifier
=
id_nbi
;
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
profiles_1d
(
1
:
nt_nbi_out
)
=
{
profiles_template
};
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
(
1
:
nt_nbi_out
)
=
{
globals_template
};
p_nbi_injected_tmp
=
interpos
(
nbi_powers_tgrid
,
powers_gdat
.
(
nbi_names
{
i_nbi
})
.
data
,
nbi_tgrid_out
);
for
ii
=
1
:
nt_nbi_out
% globals
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
{
ii
}
.
time
=
nbi_tgrid_out
(
ii
);
ids_core_sources
.
source
{
last_index
+
i_nbi
}
.
global_quantities
{
ii
}
.
power
=
p_nbi_injected_tmp
(
ii
);
end
else
disp
(
'NBI power is zero for all times, skip source.'
)
end
end
end
end
% add empty for unused NBI
% add empty for unused NBI
if
numel
(
ids_core_sources
.
source
)
-
last_index
~
=
nb_nbi
if
numel
(
ids_core_sources
.
source
)
-
last_index
=
=
1
% if 1 then add second empty source for NBI2
ids_core_sources
.
source
{
last_index
+
nb_nbi
}
=
[];
ids_core_sources
.
source
{
last_index
+
nb_nbi
}
=
[];
end
end
last_index
=
last_index
+
nb_nbi
;
last_index
=
last_index
+
(
numel
(
ids_core_sources
.
source
)
-
last_index
)
;
end
end
%% DNBI has it's own time grid
%% DNBI has it's own time grid
...
@@ -444,29 +447,32 @@ if ~isempty(powers_gdat.dnbi)
...
@@ -444,29 +447,32 @@ if ~isempty(powers_gdat.dnbi)
% find times where DNBI is on to define time grid with extra time slice just
% find times where DNBI is on to define time grid with extra time slice just
% before/after DNBI power and at start/end of shot
% before/after DNBI power and at start/end of shot
itime_dnbi
=
find
((
powers_gdat
.
dnbi
.
data
>
0
));
itime_dnbi
=
find
((
powers_gdat
.
dnbi
.
data
>
0
));
if
dnbi_powers_tgrid
(
itime_dnbi
(
end
))
>=
ohm_tgrid
(
end
)
if
~
isempty
(
itime_dnbi
)
i_time_end
=
iround
(
dnbi_powers_tgrid
,
ohm_tgrid
(
end
));
if
dnbi_powers_tgrid
(
itime_dnbi
(
end
))
>=
ohm_tgrid
(
end
)
dnbi_tgrid_out
=
[
ohm_tgrid
(
1
),
dnbi_powers_tgrid
(
itime_dnbi
(
1
)
-
1
:
i_time_end
)
'
];
i_time_end
=
iround
(
dnbi_powers_tgrid
,
ohm_tgrid
(
end
));
dnbi_tgrid_out
=
[
ohm_tgrid
(
1
),
dnbi_powers_tgrid
(
itime_dnbi
(
1
)
-
1
:
i_time_end
)
'
];
else
dnbi_tgrid_out
=
[
ohm_tgrid
(
1
),
dnbi_powers_tgrid
(
itime_dnbi
(
1
)
-
1
:
itime_dnbi
(
end
)
+
1
)
'
,
ohm_tgrid
(
end
)];
end
nt_dnbi_out
=
numel
(
dnbi_tgrid_out
);
id_dnbi
.
description
=
'DNBI Source from Neutral Beam Injection'
;
id_dnbi
.
index
=
2
;
id_dnbi
.
name
=
'nbi'
;
ids_core_sources
.
source
{
last_index
+
1
}
=
source_template
;
ids_core_sources
.
source
{
last_index
+
1
}
.
identifier
=
id_dnbi
;
ids_core_sources
.
source
{
last_index
+
1
}
.
profiles_1d
(
1
:
nt_dnbi_out
)
=
{
profiles_template
};
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
(
1
:
nt_dnbi_out
)
=
{
globals_template
};
p_dnbi_injected
=
interpos
(
dnbi_powers_tgrid
,
powers_gdat
.
dnbi
.
data
,
dnbi_tgrid_out
);
for
ii
=
1
:
nt_dnbi_out
% globals
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
{
ii
}
.
time
=
dnbi_tgrid_out
(
ii
);
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
{
ii
}
.
power
=
p_dnbi_injected
(
ii
);
end
last_index
=
last_index
+
1
;
else
else
d
nbi_tgrid_out
=
[
ohm_tgrid
(
1
),
dnbi_powers_tgrid
(
itime_dnbi
(
1
)
-
1
:
itime_dnbi
(
end
)
+
1
)
'
,
ohm_tgrid
(
end
)];
d
isp
(
'DNBI power is zero for all times, skip source.'
)
end
end
nt_dnbi_out
=
numel
(
dnbi_tgrid_out
);
id_dnbi
.
description
=
'DNBI Source from Neutral Beam Injection'
;
id_dnbi
.
index
=
2
;
id_dnbi
.
name
=
'nbi'
;
ids_core_sources
.
source
{
last_index
+
1
}
=
source_template
;
ids_core_sources
.
source
{
last_index
+
1
}
.
identifier
=
id_dnbi
;
ids_core_sources
.
source
{
last_index
+
1
}
.
profiles_1d
(
1
:
nt_dnbi_out
)
=
{
profiles_template
};
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
(
1
:
nt_dnbi_out
)
=
{
globals_template
};
p_dnbi_injected
=
interpos
(
dnbi_powers_tgrid
,
powers_gdat
.
dnbi
.
data
,
dnbi_tgrid_out
);
for
ii
=
1
:
nt_dnbi_out
% globals
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
{
ii
}
.
time
=
nbi_tgrid_out
(
ii
);
ids_core_sources
.
source
{
last_index
+
1
}
.
global_quantities
{
ii
}
.
power
=
p_dnbi_injected
(
ii
);
end
last_index
=
last_index
+
1
;
end
end
%% total
%% total
...
...
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