Skip to content

Chemistry and Biology¤

Example script showing how to use the ChemistryBiology class to extract information from the KCDB.

Script¤

"""Search the "Chemistry and Biology" metrology domain of the KCDB."""

from msl.kcdb import ChemistryBiology

chem_bio = ChemistryBiology()

#
# Get all reference data for the "Chemistry and Biology" metrology domain
#
print(f"Getting all reference data for {chem_bio.DOMAIN.name}...")
countries = chem_bio.countries()
print(f"  There are {len(countries)} countries")
analytes = chem_bio.analytes()
print(f"  There are {len(analytes)} analytes")
categories = chem_bio.categories()
print(f"  There are {len(categories)} categories")

#
# Find all analytes that are related to "boron"
#
print("All analytes related to 'boron'...")
boron_analytes = chem_bio.filter(analytes, "boron")
for analyte in boron_analytes:
    print(f"  {analyte}")

#
# Search the "Chemistry and Biology" database for NMIs that are capable of
# performing measurements with "boron" analytes and print some information
# about each NMI
#
print("All NMIs that have capabilities with 'boron' analytes...")
for analyte in boron_analytes:
    result = chem_bio.search(analyte=analyte)
    for data in result.data:
        print(f"  {data.nmi_code} ({data.category_value}): {data.nmi_service_code}")

Output¤

Running this script outputs the following, although, some values may change from what you observe when you run this script since information in the KCDB is continually changing.

Getting all reference data for Chemistry and Biology...
  There are 105 countries
  There are 1725 analytes
  There are 15 categories
All analytes related to 'boron'...
  Analyte(id=2, label='boron', value='boron')
All NMIs that have capabilities with 'boron' analytes...
  NIST (Advanced materials): 8395201
  NIST (Advanced materials): 8395202
  NIST (Advanced materials): 8395206
  NIST (Inorganic solutions): 8391106
  KRISS (Inorganic solutions): 105-02-BX2
  BAM (Inorganic solutions): InorgSol-7
  BAM (Inorganic solutions): InorgSol-15
  BAM (Inorganic solutions): InorgSol-16
  SMU (Inorganic solutions): I-10-20
  UME (Water): G3IK-3110
  NIM (Water): Water-2
  VNIIM (Water): 5.1-06
  NMIJ AIST (Water): 5-01-05
  NMIJ AIST (Food): 7505-02
  NRC (Food): MEF-37
  NRC (Water): TEW42
  NMIJ AIST (Inorganic solutions): NMIJ CRM 3627