Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cosmic_dustbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Glatzle
cosmic_dustbox
Commits
93355fbf
Commit
93355fbf
authored
Feb 22, 2019
by
Martin Glatzle
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into dev
parents
ef4dd5f0
d61c15e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
17 deletions
+36
-17
cosmic_dustbox/__init__.py
cosmic_dustbox/__init__.py
+2
-0
cosmic_dustbox/crefin.py
cosmic_dustbox/crefin.py
+17
-15
cosmic_dustbox/sdist.py
cosmic_dustbox/sdist.py
+2
-2
cosmic_dustbox/tests/test_crefin.py
cosmic_dustbox/tests/test_crefin.py
+15
-0
No files found.
cosmic_dustbox/__init__.py
View file @
93355fbf
"""
Toolbox for cosmic dust species and mixtures and their properties.
"""
from
.
import
sdist
from
.
import
crefin
cosmic_dustbox/crefin.py
View file @
93355fbf
...
...
@@ -25,7 +25,7 @@ class Crefin(object):
Attributes
----------
f : callable
_
f : callable
Directly taken from parameters.
"""
...
...
@@ -33,7 +33,7 @@ class Crefin(object):
"""
See class docstring.
"""
self
.
f
=
f
self
.
_
f
=
f
return
def
__call__
(
self
,
a
,
wave
):
...
...
@@ -56,7 +56,7 @@ class Crefin(object):
2-D array of crefin values. The first axis corresponds to grain
size and the second to photon wavelength.
"""
return
self
.
f
(
return
self
.
_
f
(
a
.
to
(
_u
.
micron
,
equivalencies
=
_u
.
spectral
()).
value
,
wave
.
to
(
_u
.
micron
,
equivalencies
=
_u
.
spectral
()).
value
)
...
...
@@ -122,20 +122,22 @@ class Crefin(object):
if
bounds_error
and
not
a_bounds_error
:
def
f
(
aa
,
lam
):
r
=
_np
.
clip
(
aa
,
_np
.
amin
(
a
),
_np
.
amax
(
a
))
rowind_unsorted
=
_np
.
argsort
(
r
)
colind_unsorted
=
_np
.
argsort
(
lam
)
return
(
rinterpolation
(
lam
,
r
)
+
1j
*
iinterpolation
(
lam
,
r
))[
rowind_unsorted
][:,
colind_unsorted
]
n
=
rinterpolation
(
lam
,
r
)
+
1j
*
iinterpolation
(
lam
,
r
)
if
_np
.
prod
(
r
.
shape
)
*
_np
.
prod
(
lam
.
shape
)
>
1
:
rowind_unsorted
=
_np
.
argsort
(
r
)
colind_unsorted
=
_np
.
argsort
(
lam
)
return
n
[
rowind_unsorted
][:,
colind_unsorted
]
else
:
return
_np
.
atleast_2d
(
n
)
else
:
def
f
(
a
,
lam
):
rowind_unsorted
=
_np
.
argsort
(
lam
)
colind_unsorted
=
_np
.
argsort
(
r
)
return
(
rinterpolation
(
lam
,
a
)
+
1j
*
iinterpolation
(
lam
,
a
))[
rowind_unsorted
][:,
colind_unsorted
]
n
=
rinterpolation
(
lam
,
a
)
+
1j
*
iinterpolation
(
lam
,
a
)
if
_np
.
prod
(
r
.
shape
)
*
_np
.
prod
(
lam
.
shape
)
>
1
:
rowind_unsorted
=
_np
.
argsort
(
lam
)
colind_unsorted
=
_np
.
argsort
(
r
)
return
n
[
rowind_unsorted
][:,
colind_unsorted
]
else
:
return
_np
.
atleast_2d
(
n
)
return
cls
(
f
)
...
...
cosmic_dustbox/sdist.py
View file @
93355fbf
...
...
@@ -128,11 +128,11 @@ class SizeDist(object):
elif
callable
(
other
):
def
func
(
sizes
):
return
self
.
func
(
sizes
)
+
other
(
sizes
)
return
self
.
__class__
(
self
.
sizeMin
,
self
.
sizeMax
,
func
)
return
SizeDist
(
self
.
sizeMin
,
self
.
sizeMax
,
func
)
else
:
def
func
(
sizes
):
return
other
+
self
.
func
(
sizes
)
return
self
.
__class__
(
self
.
sizeMin
,
self
.
sizeMax
,
func
)
return
SizeDist
(
self
.
sizeMin
,
self
.
sizeMax
,
func
)
# make addition commutative
__radd__
=
__add__
...
...
cosmic_dustbox/tests/test_crefin.py
View file @
93355fbf
...
...
@@ -52,6 +52,21 @@ class TestFromData(TestCase):
a
=
crefin
.
Crefin
.
fromData
(
c
.
a2
,
c
.
lam2
,
c
.
n2
)
return
def
test_single_element
(
self
):
c
=
self
.
__class__
a
=
crefin
.
Crefin
.
fromData
(
c
.
a2
,
c
.
lam2
,
c
.
n2
)
n
=
a
(
np
.
array
([
1e-9
])
*
u
.
micron
,
np
.
array
([
8
])
*
u
.
micron
)
self
.
assertTrue
return
def
test_single_element_no_bounds
(
self
):
c
=
self
.
__class__
a
=
crefin
.
Crefin
.
fromData
(
c
.
a2
,
c
.
lam2
,
c
.
n2
)
return
def
test_normal_no_bounds
(
self
):
c
=
self
.
__class__
a
=
crefin
.
Crefin
.
fromData
(
c
.
a2
,
c
.
lam2
,
c
.
n2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment