TWA_LIMIT
This function retrieves the time-weighted average (TWA) occupational exposure limit for a chemical using its CAS Registry Number. TWA limits represent allowable average concentration across a standard work period.
The returned JSON includes the numeric value and its source unit (ppm or mg/m^3). Where multiple unit forms are available in the source data, ppm is preferred by the wrapped library.
Excel Usage
=TWA_LIMIT(CASRN, method)
CASRN(str, required): Chemical Abstracts Service Registry Number identifier (-).method(str, optional, default: null): Source method name used for TWA lookup (-).
Returns (str): JSON string containing value and units.
Example 1: Benzene TWA
Inputs:
| CASRN |
|---|
| 71-43-2 |
Excel formula:
=TWA_LIMIT("71-43-2")
Expected output:
"{\"value\": 0.5, \"units\": \"ppm\"}"
Example 2: Furfural TWA
Inputs:
| CASRN |
|---|
| 98-00-0 |
Excel formula:
=TWA_LIMIT("98-00-0")
Expected output:
"{\"value\": 10.0, \"units\": \"ppm\"}"
Example 3: Boron oxide TWA
Inputs:
| CASRN |
|---|
| 1303-00-0 |
Excel formula:
=TWA_LIMIT("1303-00-0")
Expected output:
"{\"value\": 5.0742430905659505e-05, \"units\": \"ppm\"}"
Example 4: Benzene TWA with null method
Inputs:
| CASRN | method |
|---|---|
| 71-43-2 |
Excel formula:
=TWA_LIMIT("71-43-2", )
Expected output:
"{\"value\": 0.5, \"units\": \"ppm\"}"
Python Code
Show Code
import json
from chemicals.safety import TWA
def twa_limit(CASRN, method=None):
"""
Return the Time-Weighted Average exposure limits (TWA) for the desired chemical.
See: https://chemicals.readthedocs.io/chemicals.safety.html
This example function is provided as-is without any representation of accuracy.
Args:
CASRN (str): Chemical Abstracts Service Registry Number identifier (-).
method (str, optional): Source method name used for TWA lookup (-). Default is None.
Returns:
str: JSON string containing value and units.
"""
try:
res = TWA(CASRN, method=method)
if res is None:
return "Error: Data not available"
return json.dumps({"value": res[0], "units": res[1]})
except Exception as e:
return f"Error: {str(e)}"