Commit a6742a45 authored by Alessandro Frigeri's avatar Alessandro Frigeri
Browse files

updated examples

parent 199d7161
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
import moondb,sys

#!/usr/bin/env python3

import moondb,sys

# Let's setup the data filter
f = moondb.AnalysisFilter()
@@ -11,8 +11,10 @@ f.specimenType = ["SOIL"]
results = f.get_results()

for r in results:
   print('\nDataset: ',r.dataset) 
   print('Lab,Specie,value')
   for dr in r.dataResults:
      print(dr.laboratory,dr.variable,dr.value,dr.unit)
      print(",".join([dr.laboratory,dr.variable,dr.value+dr.unit]))
      

+123 −19
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
import moondb
# 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
m = moondb.get_missions()
# Let's get a list of the missions in MoonDB

mlist = moondb.get_missions()

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

%% Output

    {'name': 'Apollo 11'}
    {'name': 'Apollo 12'}
    {'name': 'Apollo 14'}
    {'name': 'Apollo 15'}
    {'name': 'Apollo 16'}
    {'name': 'Apollo 17'}
    {'name': 'Luna 16'}
    {'name': 'Luna 20'}
    {'name': 'Luna 24'}
    ['Apollo 11',
     'Apollo 12',
     'Apollo 14',
     'Apollo 15',
     'Apollo 16',
     'Apollo 17',
     'Luna 16',
     'Luna 20',
     'Luna 24']

%% Cell type:code id: tags:

``` python
f = moondb.Filter()
#f.specimenType = ["SOIL"]
# 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
len(results)
# 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

    37034
    ['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
an = print(results[0])
#
# 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

    {'analysisCode': '15100,3#3#0158', 'analyzedMaterial': 'WHOLE ROCK', 'comment': '0.97 g, 950C', 'dataset': 'IRVING, 1972#TABLE 1', 'citation': 'IRVING, 1972', 'dataResults': [{'unit': 'ppm', 'laboratory': 'UNKNOWN', 'variable': 'H', 'methodName': 'UNKNOWN', 'methodComment': 'COMBUSTION (NEW LINE, YIELDING LOW BLANKS)', 'value': '90.0', 'methodCode': 'UNKNOWN'}, {'unit': 'per mil', 'laboratory': 'UNKNOWN', 'variable': 'DELTA_D', 'methodName': 'UNKNOWN', 'methodComment': 'COMBUSTION (NEW LINE, YIELDING LOW BLANKS)', 'value': '-554.0', 'methodCode': 'UNKNOWN'}, {'unit': 'ppm', 'laboratory': 'UNKNOWN', 'variable': 'C', 'methodName': 'UNKNOWN', 'methodComment': 'COMBUSTION (NEW LINE, YIELDING LOW BLANKS)', 'value': '99.0', 'methodCode': 'UNKNOWN'}, {'unit': 'per mil', 'laboratory': 'UNKNOWN', 'variable': 'DELTA_C13', 'methodName': 'UNKNOWN', 'methodComment': 'COMBUSTION (NEW LINE, YIELDING LOW BLANKS)', 'value': '7.9', 'methodCode': 'UNKNOWN'}]}
    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(anaobj)



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

%% Output

    None
    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
```

examples/specimen.py

100644 → 100755
+18 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

import moondb

s_12023 = moondb.get_specimens(sc=['12023'])[0]

#print(s_12023)

child = moondb.get_specimens(sc=['12023,114'])[0]

#print(' A N A L Y S E S ')
a = child.get_analyses()


print(a[0])

a0_results = a[0].dataResultsObj


print('Result: {} {} {}'.format(a0_results[0].variable,a0_results[0].value,a0_results[0].unit,a0_results[0].methodName))

+3 −16
Original line number Diff line number Diff line
#!/usr/bin/env python3

import moondb,sys


@@ -16,22 +18,7 @@ for m in moon_missions:
   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))


f = moondb.AnalysisFilter()
f.mission = ["Apollo 11"]
f.analyte = ["Na2O","CaO"]
f.specimenType = ["SOIL"]



results = f.get_results()

for r in results:
   for dr in r.dataResults:
      print(dr)
      #print(dr.laboratory,dr.variable,dr.value,dr.unit)
print("\nMoonDB contains a total of {:.3f} kg of specimen from the Moon!".format(weight_cum/1000.0))


−5 B (476 B)

File changed.

No diff preview for this file type.

Loading