{ "cells": [ { "cell_type": "markdown", "id": "673fe77c-ddf2-4ed7-acf5-5ace55bc2408", "metadata": {}, "source": [ "# Map SPECIATE species to CRACMM\n", "\n", "---\n", " author: Nash Skipper\n", " date: 2024-08-09\n", "\n", " updated: Michael Pye\n", " date: 2025-02-27\n", "---\n", "\n", "## Notebook Description\n", "This notebook identifies the CRACMM species for each SPECIATE species using the mapper. The cracmm_mapper function depends on [rdkit](https://www.rdkit.org/).\n", "\n", "## Download Notebook\n", "Click [here](https://github.com/USEPA/CRACMM/blob/main/utilities/SPECIATE_map2cracmm.ipynb) to access the Jupyter Notebook file directly in GitHub where it can be downloaded. " ] }, { "cell_type": "markdown", "id": "7c57651a-9587-441e-b71e-967dfc77fd48", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "code", "execution_count": null, "id": "a65b1911-c6f4-4000-8ce9-b3ee223045de", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import warnings\n", "import os" ] }, { "cell_type": "code", "execution_count": 2, "id": "a49350b5-da68-446a-af87-07ca7f166464", "metadata": {}, "outputs": [], "source": [ "## Install rdkit if not already installed\n", "\n", "# !python -m pip install --user rdkit\n", "\n", "# to install in the current kernel:\n", "# %pip install rdkit" ] }, { "cell_type": "code", "execution_count": null, "id": "cfa001a4-8cef-4235-8c04-6729e0856b06", "metadata": {}, "outputs": [], "source": [ "# set location of mapper downloaded from https://github.com/USEPA/CRACMM/\n", "# import sys\n", "# utildir = '/path/to/cracmm/utilities/directory' \n", "# sys.path.append(utildir)\n", "\n", "# Import the python utilities\n", "import cracmm1_mapper as cracmm1 # includes: get_cracmm_roc(smiles,koh,log10cstar) (Version 1)\n", "import cracmm2_mapper as cracmm2 # includes: get_cracmm_roc(smiles,koh,log10cstar) (Version 2)" ] }, { "cell_type": "code", "execution_count": null, "id": "df86d78d-fb71-4b0a-af22-6bc0666e3d90", "metadata": {}, "outputs": [], "source": [ "datadir = '../emissions/SPECIATEInputs/' # data files of mappings\n", "\n", "outputdir = os.path.join(os.getcwd(), 'output/')" ] }, { "cell_type": "code", "execution_count": 5, "id": "45da1ab2-b614-4370-a961-d06d7c2ec4e3", "metadata": {}, "outputs": [], "source": [ "pd.set_option('display.max_rows', None)\n", "pd.options.mode.copy_on_write = True\n", "warnings.simplefilter('ignore') # ignore warnings (comment out to see warnings for species that could not be mapped)\n", "csvout_kw = dict(sep=',', na_rep='', float_format=None, columns=None, header=True, index=False)" ] }, { "cell_type": "markdown", "id": "fbd43488-a11a-4550-8070-ea244ebe82b5", "metadata": {}, "source": [ "## SPECIATE Mapping\n", "\n", "[Input SPECIATE file](https://github.com/USEPA/CRACMM/tree/main/emissions/SPECIATEInputs)" ] }, { "cell_type": "code", "execution_count": null, "id": "701463bf-9f0e-4455-8586-ef6e13072fd2", "metadata": {}, "outputs": [], "source": [ "filename = datadir + 'SPECIATEv5.2x_fromCRACMM.csv' \n", "df = pd.read_csv(filename)\n", "# for checking if any species mapping changed\n", "orig_map_colname = 'CRACMM1' # select mechanism version to compare new mapping to" ] }, { "cell_type": "markdown", "id": "cfe8152c-21f0-4a08-87d1-68f9e24a27fe", "metadata": {}, "source": [ "### Calculate C* from Vapor Pressure\n", "\n", "$$ C^* \\text{must have units of } {\\mu g \\over m^3} $$\n", "$$ C^* = {p * M * 10^6 \\over R * T} $$\n", "$$ \\text{p and M are from the input csv file} $$\n", "$$ p = \\text{vapor pressure} \\left( Pa \\right) $$\n", "$$ M = \\text{molecular weight} \\left( g \\over mol\\right ) $$\n", "$$ R = 8.314 \\text{ } {m^3 * Pa \\over mol * K} $$\n", "$$ T = 298 \\text{ } K $$" ] }, { "cell_type": "code", "execution_count": 7, "id": "215f1617-12f5-4b38-82b0-ed5bd59e48a2", "metadata": {}, "outputs": [], "source": [ "vp_k = 'VP_Pascal_OPERA'\n", "mw_k = 'SPEC_MW'\n", "R = 8.314\n", "T = 298\n", "df['log10Cstar_ugm3'] = np.log10(df[vp_k] * df[mw_k]*10**6 / (R * T))" ] }, { "cell_type": "markdown", "id": "12df431b-3eaa-4cf8-abc2-2305c54f54f0", "metadata": {}, "source": [ "### Run CRACMM2 Mapper and see mapping changes from CRACMM1 to CRACMM2" ] }, { "cell_type": "code", "execution_count": null, "id": "6658a911-385c-44cd-b207-444874af434f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the species mappings below changed from CRACMM2alpha\n" ] }, { "data": { "text/html": [ "
\n", " | SPECIES_NAME | \n", "CRACMM2alpha | \n", "CRACMM2 | \n", "
---|---|---|---|
856 | \n", "Carbon monoxide | \n", "SLOWROC | \n", "UNKCRACMM | \n", "
857 | \n", "Carbon dioxide | \n", "SLOWROC | \n", "UNKCRACMM | \n", "