Commit 8d4d8314 authored by Alessandro Frigeri's avatar Alessandro Frigeri
Browse files

updated example

parent 20e68697
Loading
Loading
Loading
Loading
Loading

examples/example1.ipynb

deleted100644 → 0
+0 −175
Original line number Diff line number Diff line
%% Cell type:markdown id: tags:

## MoonDB Jupyter notebook workbook
#### Alessandro Frigeri, IAPS/INAF, Rome Italy



%% Cell type:code id: tags:

``` python
# First we import the moondb module
%load_ext autoreload
%autoreload 2

%aimport moondb

print(moondb.__file__)
```

%% Output

    The autoreload extension is already loaded. To reload it, use:
      %reload_ext autoreload
    /home/alf/gitwrk/pymoondb/moondb/__init__.py

%% Cell type:code id: tags:

``` python
# Let's get a list of the missions in MoonDB

mlist = moondb.get_missions()

[m.name for m in mlist]
```

%% Output

    ['Apollo 11',
     'Apollo 12',
     'Apollo 14',
     'Apollo 15',
     'Apollo 16',
     'Apollo 17',
     'Luna 16',
     'Luna 20',
     'Luna 24']

%% Cell type:code id: tags:

``` python
# Now, we want to know how many specimens are available from the Apollo 17 missions

f = moondb.SpecimenFilter()
mission = 'Apollo 17'
f.missionName = [ mission ]
results = f.get_results()
specimen_list = [r for r in results]

print("MoonDB holds {} specimens from  Apollo 17.".format(len(specimen_list)))
```

%% Output

    MoonDB holds 2991 specimens from  Apollo 17.

%% Cell type:code id: tags:

``` python
# Get a list of type of specimen of Apollo 17 available in MoonDB
s_list = [s.specimenType for s in specimen_list]
list(sorted(set(s_list)))
```

%% Output

    ['COMPOSITE',
     'ROCK',
     'ROCK/Basalt/Ilmenite Basalt',
     'ROCK/Basalt/Unclassified Basalt',
     'ROCK/Breccia/Fragmental Breccia',
     'ROCK/Breccia/Impact Melt Breccia',
     'ROCK/Breccia/Regolith Breccia',
     'ROCK/Breccia/Unclassified Breccia',
     'ROCK/Crustal/Crustal:Cataclasite',
     'ROCK/Crustal/Crustal:Norite',
     'ROCK/Crustal/Crustal:Troctolite',
     'SOIL/Soil:1-2mm',
     'SOIL/Soil:2-4mm',
     'SOIL/Soil:4-10mm',
     'SOIL/Soil:<1mm',
     'SOIL/Soil:Unsieved',
     'Unknown']

%% Cell type:code id: tags:

``` python
```

%% Cell type:code id: tags:

``` python
```

%% Cell type:code id: tags:

``` python
#
# Let's see the analyses done on the first specimen
#

s_list = [s for s in specimen_list]

print(len(s_list))

s0 = s_list[0]

an_list = [a for a in s0.get_analyses()]
```

%% Output

    2991

%% Cell type:code id: tags:

``` python
# now we check the results of the first analysis

#result_of

print(an_list[0].dataResultsObj)
```

%% Output

    [result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY (code MC-ICP-MS), result of CACULATED (code CALC)]

%% Cell type:code id: tags:

``` python



print(mission+" specimen: ",s0.specimenName)
for r in an_list[0].dataResultsObj:
   print('Result: {} {} {} ({})'.format(r.variable,r.value,r.unit,r.methodName))
```

%% Output

    Apollo 17 specimen:  76535,16
    Result: Os 8.5 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Ir 55.0 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Ru 81.0 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Pt 54.0 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Pd 89.0 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Re 9.0 ppb (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Re187_Os188 5.1 Not Applicable (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: Os187_Os188 0.1511 Not Applicable (MULTICOLLECTOR INDUCTIVELY COUPLED PLASMA MASS SPECTROMETRY)
    Result: G_Os(T) -348.0 Not Applicable (CACULATED)

%% Cell type:code id: tags:

``` python
```

%% Cell type:code id: tags:

``` python
```

%% Cell type:code id: tags:

``` python
```
−417 B (12.8 KiB)

File changed.

No diff preview for this file type.

+3 −3
Original line number Diff line number Diff line
@@ -235,17 +235,17 @@ def get_specimens(sc=None,mn=None,ln=None,sty=None,ste=None):

   if ln:
      for n in ln:
         count,spec = _get_resp('/specimenlist/mission/'+n) 
         count,spec = _get_resp('/specimenlist/landmark/'+n) 
         sp_list.extend(spec)

   if sty:
      for st in sty:
         count,spec = _get_resp('/specimenlist/mission/'+st) 
         count,spec = _get_resp('/specimenlist/specimentype/'+st) 
         sp_list.extend(spec)

   if ste:
      for st in ste:
         count,spec = _get_resp('/specimenlist/mission/'+st) 
         count,spec = _get_resp('/specimenlist/samplingtechnique/'+st) 
         sp_list.extend(spec)

   sp_obj_list = []