Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102810972
gbms_gk_Cabpj_input.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 10:22
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Feb 26, 10:22 (2 d)
Engine
blob
Format
Raw Data
Handle
24430766
Attached To
rCOSOLVER COSOlver
gbms_gk_Cabpj_input.py
View Options
#!/usr/bin/env python
# generates GK collision matrices for different kperp
import
os
import
sys
import
numpy
as
np
import
h5py
as
h5
# directories
cwd
=
os
.
getcwd
()
scandir_name
=
'gk.sugama'
scandir_path
=
os
.
path
.
join
(
cwd
,
scandir_name
)
# Define kperp scan (should be changed manually...)
#coordkperp =
coordkperp
=
np
.
loadtxt
(
os
.
path
.
join
(
scandir_path
,
'kperp.log.txt'
))
# Define size of matrices (all matrices are assumed to have the same size)
Pmaxi
=
20
Jmaxi
=
6
Pmaxe
=
20
Jmaxe
=
6
# Create ouput file in the current directory
output_name
=
'gk.sugama.h5'
outh5
=
h5
.
File
(
os
.
path
.
join
(
cwd
,
'gk.sugama.h5'
),
'w'
)
outh5
.
create_dataset
(
'/dims_i'
,
data
=
[
Pmaxi
,
Jmaxi
])
outh5
.
create_dataset
(
'/dims_e'
,
data
=
[
Pmaxe
,
Jmaxe
])
outh5
.
create_dataset
(
'/coordkperp'
,
data
=
coordkperp
)
outh5
.
create_dataset
(
'/Nkperp'
,
data
=
np
.
alen
(
coordkperp
))
# gather
for
ikperp
,
kperp
in
enumerate
(
coordkperp
):
# scanfiles_<num> directory
job_directory
=
os
.
path
.
join
(
scandir_path
,
"scanfiles_"
+
"{0:05d}"
.
format
(
ikperp
))
print
(
'Read '
+
job_directory
+
' ...'
)
# files path
eicolls_file
=
os
.
path
.
join
(
job_directory
,
'ei.h5'
)
iecolls_file
=
os
.
path
.
join
(
job_directory
,
'ie.h5'
)
selfcolls_file
=
os
.
path
.
join
(
job_directory
,
'self.h5'
)
# Open the h5 files in read mode
eih5
=
h5
.
File
(
eicolls_file
,
'r'
)
ieh5
=
h5
.
File
(
iecolls_file
,
'r'
)
selfh5
=
h5
.
File
(
selfcolls_file
,
'r'
)
# Flush Cabpj
# ei
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ceipj/CeipjF/"
,
data
=
eih5
[
'/Ceipj/CeipjF'
])
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ceipj/CeipjT/"
,
data
=
eih5
[
'/Ceipj/CeipjT'
])
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ceipj/fort.f90"
,
data
=
eih5
[
'/files/fort.f90'
])
# ie
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ciepj/CiepjF/"
,
data
=
ieh5
[
'/Ciepj/CiepjF'
])
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ciepj/CiepjT/"
,
data
=
ieh5
[
'/Ciepj/CiepjT'
])
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Ciepj/fort.f90"
,
data
=
ieh5
[
'/files/fort.f90'
])
# ee
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Caapj/Ceepj"
,
data
=
selfh5
[
'/Caapj/Ciipj'
])
# ii
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Caapj/Ciipj"
,
data
=
selfh5
[
'/Caapj/Ciipj'
])
outh5
.
create_dataset
(
"{0:05d}"
.
format
(
ikperp
)
+
"/Caapj/fort.f90"
,
data
=
selfh5
[
'/files/fort.f90'
])
eih5
.
close
()
ieh5
.
close
()
selfh5
.
close
()
# close file
outh5
.
close
()
Event Timeline
Log In to Comment