Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Waveform_Extractor
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
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
Mingxin Li
Waveform_Extractor
Commits
d2ce00a6
Commit
d2ce00a6
authored
4 years ago
by
Roland Haas
Browse files
Options
Downloads
Patches
Plain Diff
make power.py loadable as a module
parent
b4b0cf4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
POWER/power.py
+60
-59
60 additions, 59 deletions
POWER/power.py
with
60 additions
and
59 deletions
POWER/power.py
+
60
−
59
View file @
d2ce00a6
...
...
@@ -635,62 +635,63 @@ def eq_29(sim_path, radii_list, modes):
### argparse machinery:
def
dir_path
(
string
):
if
os
.
path
.
isdir
(
string
):
return
string
else
:
print
(
"
Not a directory: %s
"
%
(
string
))
# raise NotADirectoryError(string)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Choose extrapolation method
'
)
parser
.
add_argument
(
"
method
"
,
choices
=
[
"
POWER
"
,
"
Nakano
"
]
,
help
=
"
Extrapolation method to be used here
"
)
parser
.
add_argument
(
'
-r
'
,
"
--radii
"
,
type
=
int
,
help
=
"
For POWER method; Number of radii to be used
"
,
default
=
7
)
parser
.
add_argument
(
'
-m
'
,
"
--modes
"
,
type
=
str
,
help
=
"
For Nakano method; modes to use, l,m. Leave blank to extrapolate over all available modes
"
)
parser
.
add_argument
(
"
path
"
,
type
=
dir_path
,
help
=
"
Simulation to be used here
"
)
args
=
parser
.
parse_args
()
if
args
.
method
==
"
POWER
"
:
print
(
"
Extrapolating with POWER method...
"
)
all_radii
,
all_modes
=
getModesInFile
(
args
.
path
)
radii
=
all_radii
[
0
:
args
.
radii
]
modes
=
all_modes
strains
=
POWER
(
args
.
path
,
radii
,
modes
)
#Create data directories
sim
=
os
.
path
.
split
(
args
.
path
)[
-
1
]
main_directory
=
"
Extrapolated_Strain
"
sim_dir
=
main_directory
+
"
/
"
+
sim
if
not
os
.
path
.
exists
(
main_directory
):
os
.
makedirs
(
main_directory
)
if
not
os
.
path
.
exists
(
sim_dir
):
os
.
makedirs
(
sim_dir
)
for
i
,
(
el
,
em
)
in
enumerate
(
modes
):
np
.
savetxt
(
"
./Extrapolated_Strain/
"
+
sim
+
"
/
"
+
sim
+
"
_radially_extrapolated_strain_l
"
+
str
(
el
)
+
"
_m
"
+
str
(
em
)
+
"
.dat
"
,
strains
[
i
])
elif
args
.
method
==
"
Nakano
"
:
print
(
"
Extrapolating with Nakano method...
"
)
all_radii
,
all_modes
=
getModesInFile
(
args
.
path
)
radii
=
all_radii
[
0
:
args
.
radii
]
modes
=
[(
0
,
0
),
(
1
,
0
),
(
1
,
1
),
(
2
,
-
1
),
(
2
,
0
),
(
2
,
1
),
(
2
,
2
),
(
3
,
-
2
),
(
3
,
-
1
),
(
3
,
0
),
(
3
,
1
),
(
3
,
2
),
(
3
,
3
)]
strains
=
eq_29
(
args
.
path
,
radii
,
modes
)
#Create data directories
sim
=
os
.
path
.
split
(
args
.
path
)[
-
1
]
main_directory
=
"
Extrapolated_Strain(Nakano_Kerr)
"
sim_dir
=
main_directory
+
"
/
"
+
sim
if
not
os
.
path
.
exists
(
main_directory
):
os
.
makedirs
(
main_directory
)
if
not
os
.
path
.
exists
(
sim_dir
):
os
.
makedirs
(
sim_dir
)
strain
=
iter
(
strains
)
for
(
el
,
em
)
in
modes
:
for
r
in
radii
:
fn
=
"
%s_f2_l%d_m%d_r%.2f_Looped.dat
"
%
(
sim
,
el
,
em
,
r
)
np
.
savetxt
(
"
./Extrapolated_Strain(Nakano_Kerr)/
"
+
sim
+
"
/
"
+
fn
,
next
(
strain
))
if
__name__
==
"
__main__
"
:
def
dir_path
(
string
):
if
os
.
path
.
isdir
(
string
):
return
string
else
:
print
(
"
Not a directory: %s
"
%
(
string
))
# raise NotADirectoryError(string)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Choose extrapolation method
'
)
parser
.
add_argument
(
"
method
"
,
choices
=
[
"
POWER
"
,
"
Nakano
"
]
,
help
=
"
Extrapolation method to be used here
"
)
parser
.
add_argument
(
'
-r
'
,
"
--radii
"
,
type
=
int
,
help
=
"
For POWER method; Number of radii to be used
"
,
default
=
7
)
parser
.
add_argument
(
'
-m
'
,
"
--modes
"
,
type
=
str
,
help
=
"
For Nakano method; modes to use, l,m. Leave blank to extrapolate over all available modes
"
)
parser
.
add_argument
(
"
path
"
,
type
=
dir_path
,
help
=
"
Simulation to be used here
"
)
args
=
parser
.
parse_args
()
if
args
.
method
==
"
POWER
"
:
print
(
"
Extrapolating with POWER method...
"
)
all_radii
,
all_modes
=
getModesInFile
(
args
.
path
)
radii
=
all_radii
[
0
:
args
.
radii
]
modes
=
all_modes
strains
=
POWER
(
args
.
path
,
radii
,
modes
)
#Create data directories
sim
=
os
.
path
.
split
(
args
.
path
)[
-
1
]
main_directory
=
"
Extrapolated_Strain
"
sim_dir
=
main_directory
+
"
/
"
+
sim
if
not
os
.
path
.
exists
(
main_directory
):
os
.
makedirs
(
main_directory
)
if
not
os
.
path
.
exists
(
sim_dir
):
os
.
makedirs
(
sim_dir
)
for
i
,
(
el
,
em
)
in
enumerate
(
modes
):
np
.
savetxt
(
"
./Extrapolated_Strain/
"
+
sim
+
"
/
"
+
sim
+
"
_radially_extrapolated_strain_l
"
+
str
(
el
)
+
"
_m
"
+
str
(
em
)
+
"
.dat
"
,
strains
[
i
])
elif
args
.
method
==
"
Nakano
"
:
print
(
"
Extrapolating with Nakano method...
"
)
all_radii
,
all_modes
=
getModesInFile
(
args
.
path
)
radii
=
all_radii
[
0
:
args
.
radii
]
modes
=
[(
0
,
0
),
(
1
,
0
),
(
1
,
1
),
(
2
,
-
1
),
(
2
,
0
),
(
2
,
1
),
(
2
,
2
),
(
3
,
-
2
),
(
3
,
-
1
),
(
3
,
0
),
(
3
,
1
),
(
3
,
2
),
(
3
,
3
)]
strains
=
eq_29
(
args
.
path
,
radii
,
modes
)
#Create data directories
sim
=
os
.
path
.
split
(
args
.
path
)[
-
1
]
main_directory
=
"
Extrapolated_Strain(Nakano_Kerr)
"
sim_dir
=
main_directory
+
"
/
"
+
sim
if
not
os
.
path
.
exists
(
main_directory
):
os
.
makedirs
(
main_directory
)
if
not
os
.
path
.
exists
(
sim_dir
):
os
.
makedirs
(
sim_dir
)
strain
=
iter
(
strains
)
for
(
el
,
em
)
in
modes
:
for
r
in
radii
:
fn
=
"
%s_f2_l%d_m%d_r%.2f_Looped.dat
"
%
(
sim
,
el
,
em
,
r
)
np
.
savetxt
(
"
./Extrapolated_Strain(Nakano_Kerr)/
"
+
sim
+
"
/
"
+
fn
,
next
(
strain
))
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