"""Interaction with the NIST ISODB."""frompygapsimportloggerfrompygaps.parsing.jsonimportisotherm_from_jsonfrompygaps.utilities.exceptionsimportParsingError_ISODB_API="https://adsorption.nist.gov/isodb/api"
[docs]defisotherm_from_isodb(filename):""" Load an isotherm from the NIST ISODB. Parameters ---------- filename : str ISODB filename to retrieve using the API. Returns ------- Isotherm The isotherm from ISODB. """importrequestsurl=fr"{_ISODB_API}/isotherm/{filename}.json"try:resp=requests.get(url,timeout=5)exceptrequests.exceptions.Timeout:logger.warning('Connection timeout')returnNoneexceptrequests.exceptions.ConnectionError:logger.warning('Connection error')returnNonetry:returnisotherm_from_json(resp.text,fmt="NIST")exceptParsingError:logger.warning('Could not parse isotherm. Check if the service is up.')returnNone