Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymoondb
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alessandro Frigeri
pymoondb
Commits
56b3d479
Commit
56b3d479
authored
6 years ago
by
Alessandro Frigeri
Browse files
Options
Downloads
Patches
Plain Diff
updated example
parent
2392d4d5
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/Apollo11_soils.py
+49
-2
49 additions, 2 deletions
examples/Apollo11_soils.py
moondb/__pycache__/core.cpython-37.pyc
+0
-0
0 additions, 0 deletions
moondb/__pycache__/core.cpython-37.pyc
moondb/core.py
+36
-12
36 additions, 12 deletions
moondb/core.py
with
85 additions
and
14 deletions
examples/Apollo11_soils.py
+
49
−
2
View file @
56b3d479
import
moondb
import
moondb
,
sys
#s0 = moondb.get_specimens(mn=['Apollo 11',])
s
=
moondb
.
SpecimenFilter
()
s
.
missionName
=
[
"
Apollo 11
"
]
res
=
s
.
get_results
()
apollo11_weight
=
0
for
r
in
res
:
if
r
.
weight
is
not
None
:
apollo11_weight
+=
float
(
r
.
weight
.
split
(
'
'
)[
0
])
print
(
apollo11_weight
)
s1
=
moondb
.
SpecimenFilter
()
s1
.
missionName
=
[
"
Apollo 17
"
]
res
=
s1
.
get_results
()
apollo17_weight
=
0
for
r
in
res
:
if
r
.
weight
is
not
None
:
apollo17_weight
+=
float
(
r
.
weight
.
split
(
'
'
)[
0
])
print
(
apollo17_weight
)
moon_missions
=
moondb
.
get_missions
()
weight_cum
=
0
for
m
in
moon_missions
:
s
=
moondb
.
SpecimenFilter
()
s
.
missionName
=
[
m
.
name
]
res
=
s
.
get_results
()
weight
=
0
for
r
in
res
:
if
r
.
weight
is
not
None
:
weight
+=
float
(
r
.
weight
.
split
(
'
'
)[
0
])
weight_cum
+=
weight
print
(
"
MoonDB holds {:.3f} kg of specimens from {}
"
.
format
(
weight
/
1000.0
,
m
.
name
))
print
(
"
MoonDB contains a total of {:.3f} kg of specimen from the Moon!
"
.
format
(
weight_cum
/
1000.0
))
sys
.
exit
(
0
)
f
=
moondb
.
AnalysisFilter
()
f
=
moondb
.
AnalysisFilter
()
f
.
mission
=
[
"
Apollo 11
"
]
f
.
mission
=
[
"
Apollo 11
"
]
...
@@ -6,10 +50,13 @@ f.analyte = ["Na2O","CaO"]
...
@@ -6,10 +50,13 @@ f.analyte = ["Na2O","CaO"]
f
.
specimenType
=
[
"
SOIL
"
]
f
.
specimenType
=
[
"
SOIL
"
]
results
=
f
.
get_results
()
results
=
f
.
get_results
()
for
r
in
results
:
for
r
in
results
:
for
dr
in
r
.
dataResults
:
for
dr
in
r
.
dataResults
:
print
(
dr
.
variable
,
dr
.
value
,
dr
.
unit
)
print
(
dr
)
#print(dr.laboratory,dr.variable,dr.value,dr.unit)
This diff is collapsed.
Click to expand it.
moondb/__pycache__/core.cpython-37.pyc
+
0
−
0
View file @
56b3d479
No preview for this file type
This diff is collapsed.
Click to expand it.
moondb/core.py
+
36
−
12
View file @
56b3d479
...
@@ -128,8 +128,8 @@ def _get_resp(path):
...
@@ -128,8 +128,8 @@ def _get_resp(path):
r
=
resp
.
json
()
r
=
resp
.
json
()
#print(r)
#print(r)
# To be checked with Peng
# To be checked with Peng
if
'
result
'
and
'
count
'
in
r
:
#
if 'result' and 'count' in r:
return
r
[
'
count
'
],
r
[
'
result
'
]
#
return r['count'],r['result']
if
'
results
'
and
'
count
'
in
r
:
if
'
results
'
and
'
count
'
in
r
:
return
r
[
'
count
'
],
r
[
'
results
'
]
return
r
[
'
count
'
],
r
[
'
results
'
]
else
:
else
:
...
@@ -169,35 +169,37 @@ def get_specimens(sc=None,mn=None,ln=None,sty=None,ste=None):
...
@@ -169,35 +169,37 @@ def get_specimens(sc=None,mn=None,ln=None,sty=None,ste=None):
ste: list
ste: list
list of sampling techniques
list of sampling techniques
'''
'''
#print(mn)
sp_list
=
[]
sp_list
=
[]
if
sc
:
if
sc
:
for
s
in
sc
:
for
s
in
sc
:
spec
=
_get_resp
(
'
/specimen/
'
+
s
)
count
,
spec
=
_get_resp
(
'
/specimen/
'
+
s
)
sp_list
.
app
end
(
spec
)
sp_list
.
ext
end
(
spec
)
if
mn
:
if
mn
:
for
n
in
mn
:
for
n
in
mn
:
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
n
)
count
,
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
n
)
sp_list
.
app
end
(
spec
)
sp_list
.
ext
end
(
spec
)
if
ln
:
if
ln
:
for
n
in
ln
:
for
n
in
ln
:
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
n
)
count
,
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
n
)
sp_list
.
app
end
(
spec
)
sp_list
.
ext
end
(
spec
)
if
sty
:
if
sty
:
for
st
in
sty
:
for
st
in
sty
:
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
st
)
count
,
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
st
)
sp_list
.
app
end
(
spec
)
sp_list
.
ext
end
(
spec
)
if
ste
:
if
ste
:
for
st
in
ste
:
for
st
in
ste
:
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
st
)
count
,
spec
=
_get_resp
(
'
/specimenlist/mission/
'
+
st
)
sp_list
.
app
end
(
spec
)
sp_list
.
ext
end
(
spec
)
sp_obj_list
=
[]
sp_obj_list
=
[]
for
s
in
sp_list
:
for
s
in
sp_list
:
# dict unpack
# dict unpack
# print(s)
s_o
=
Specimen
(
**
s
)
s_o
=
Specimen
(
**
s
)
sp_obj_list
.
append
(
s_o
)
sp_obj_list
.
append
(
s_o
)
...
@@ -272,6 +274,28 @@ def get_samplingtechnique():
...
@@ -272,6 +274,28 @@ def get_samplingtechnique():
pass
pass
class
dataFilter
:
def
__init__
(
self
):
pass
def
_toJSON
(
self
):
return
json
.
dumps
(
self
,
default
=
lambda
o
:
o
.
__dict__
,
sort_keys
=
True
,
separators
=
(
"
,
"
,
"
:
"
))
@dataclass
class
SpecimenFilter
:
specimenCode
:
list
=
None
missionName
:
list
=
None
landmarkName
:
list
=
None
specimenType
:
list
=
None
samplingTechnique
:
list
=
None
def
get_results
(
self
):
#res_list = get_specimens(mn=["Apollo 11"])
res_list
=
get_specimens
(
sc
=
self
.
specimenCode
,
mn
=
self
.
missionName
,
ln
=
self
.
landmarkName
,
sty
=
self
.
specimenType
,
ste
=
self
.
samplingTechnique
)
return
res_list
class
AnalysisFilter
:
class
AnalysisFilter
:
def
__init__
(
self
):
def
__init__
(
self
):
...
...
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