Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
powspec
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
Container Registry
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CONCERTO
powspec
Commits
f24899e2
Commit
f24899e2
authored
4 years ago
by
alexandre beelen
Browse files
Options
Downloads
Patches
Plain Diff
fix(k_bin_edges) now returns the proper objects
parent
03dcaba5
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
powspec/powspec.py
+9
-7
9 additions, 7 deletions
powspec/powspec.py
with
9 additions
and
7 deletions
powspec/powspec.py
+
9
−
7
View file @
f24899e2
...
@@ -78,15 +78,17 @@ def k_bin_edges(shape, res=1, bins=None, range=None):
...
@@ -78,15 +78,17 @@ def k_bin_edges(shape, res=1, bins=None, range=None):
range: (float, float) or None
range: (float, float) or None
the corresponding range
the corresponding range
"""
"""
nyquist
=
1
/
(
2
*
res
)
nyquist
=
u
.
Quantity
(
1
/
(
2
*
res
)
)
largest_scale
=
1
/
(
np
.
array
(
shape
).
max
()
*
res
)
largest_scale
=
u
.
Quantity
(
1
/
(
np
.
array
(
shape
).
max
()
*
res
)
)
if
range
==
"
tight
"
:
if
range
==
"
tight
"
:
return
bins
,
(
largest_scale
,
nyquist
)
return
bins
,
u
.
Quantity
(
(
largest_scale
,
nyquist
)
)
elif
range
==
"
tight-linear
"
:
elif
range
==
"
tight-linear
"
:
return
np
.
linspace
(
largest_scale
,
nyquist
,
bins
+
1
,
endpoint
=
True
),
None
unit
=
largest_scale
.
unit
return
np
.
linspace
(
largest_scale
.
to
(
unit
).
value
,
nyquist
.
to
(
unit
).
value
,
bins
+
1
,
endpoint
=
True
)
*
unit
,
None
elif
range
==
"
tight-log
"
:
elif
range
==
"
tight-log
"
:
return
np
.
logspace
(
np
.
log10
(
largest_scale
),
np
.
log10
(
nyquist
),
bins
+
1
,
endpoint
=
True
),
None
unit
=
largest_scale
.
unit
return
np
.
logspace
(
np
.
log10
(
largest_scale
.
to
(
unit
).
value
),
np
.
log10
(
nyquist
.
to
(
unit
).
value
),
bins
+
1
,
endpoint
=
True
)
*
unit
,
None
else
:
else
:
return
bins
,
range
return
bins
,
range
...
@@ -160,8 +162,8 @@ def power_spectral_density(img, res=1, bins=100, range=None, apod_size=None):
...
@@ -160,8 +162,8 @@ def power_spectral_density(img, res=1, bins=100, range=None, apod_size=None):
k_freq
=
np
.
sqrt
(
u_freq
[:,
np
.
newaxis
]
**
2
+
v_freq
**
2
)
k_freq
=
np
.
sqrt
(
u_freq
[:,
np
.
newaxis
]
**
2
+
v_freq
**
2
)
hist
,
bin_edges
=
np
.
histogram
(
k_freq
,
bins
=
bins
,
range
=
range
,
weights
=
pow_sqr
)
norm
,
bin_edges
=
np
.
histogram
(
k_freq
,
bins
=
bins
,
range
=
range
)
norm
,
_
=
np
.
histogram
(
k_freq
,
bins
=
bin
s
,
range
=
range
)
hist
,
bin_edges
=
np
.
histogram
(
k_freq
,
bins
=
bin
_edges
,
weights
=
pow_sqr
)
with
np
.
errstate
(
invalid
=
"
ignore
"
):
with
np
.
errstate
(
invalid
=
"
ignore
"
):
hist
/=
norm
hist
/=
norm
...
...
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