scripts.analysis.aerosol_gas_tables =================================== .. py:module:: scripts.analysis.aerosol_gas_tables Functions --------- .. autoapisummary:: scripts.analysis.aerosol_gas_tables.aerosol_gas_tables scripts.analysis.aerosol_gas_tables.list_files scripts.analysis.aerosol_gas_tables.Get_files scripts.analysis.aerosol_gas_tables.set_dic_SE scripts.analysis.aerosol_gas_tables.fill_dic_SE scripts.analysis.aerosol_gas_tables.make_Dic_scn_var_comp scripts.analysis.aerosol_gas_tables.SEbudget scripts.analysis.aerosol_gas_tables.calc_budget_data scripts.analysis.aerosol_gas_tables.make_table Module Contents --------------- .. py:function:: aerosol_gas_tables(adfobj) Calculate aerosol and gaseous budget tables **Default set of variables:** change in lib/adf_variable_defaults.yaml GAS_VARIABLES: ['CH4','CH3CCL3', 'CO', 'O3', 'ISOP', 'MTERP', 'CH3OH', 'CH3COCH3'] AEROSOL_VARIABLES: ['AOD','SOA', 'SALT', 'DUST', 'POM', 'BC', 'SO4'] Default output for tables: **Gases:** CH4_BURDEN (Tg), CH4_CHEM_LOSS (Tg/yr), CH4_LIFETIME (years) CH3CCL3_BURDEN (Tg), CH3CCL3_CHEM_LOSS (Tg/yr), CH3CCL3_LIFETIME (days) CO_EMIS (Tg/yr), CO_BURDEN (Tg), CO_CHEM_LOSS (Tg/yr), CO_CHEM_PROD (Tg/yr), CO_DRYDEP (Tg/yr) CO_TDEP (Tg/yr), CO_LIFETIME (days), CO_TEND (Tg/yr) O3_BURDEN (Tg), O3_CHEM_LOSS (Tg/yr), O3_CHEM_PROD (Tg/yr), O3_DRYDEP (Tg/yr), O3_TDEP (Tg/yr) O3_LIFETIME (days), O3_TEND (Tg/yr), O3_STE (Tg/yr) LNOx_PROD (Tg N/yr) ISOP_EMIS (Tg/yr), ISOP_BURDEN (Tg) Monoterpene_EMIS (Tg/yr), Monoterpene_BURDEN (Tg) Methanol_EMIS (Tg/yr), Methanol_BURDEN (Tg), Methanol_DRYDEP (Tg/yr), Methanol_WETDEP (Tg/yr), Methanol_TDEP (Tg/yr) Acetone_EMIS (Tg/yr), Acetone_BURDEN (Tg), Acetone_DRYDEP (Tg/yr), Acetone_WETDEP (Tg/yr), Acetone_TDEP (Tg/yr) **Aerosols:** AOD_mean SOA_BURDEN (Tg), SOA_CHEM_LOSS (Tg/yr), SOA_DRYDEP (Tg/yr), SOA_WETDEP (Tg/yr), SOA_GAEX (Tg/yr), SOA_LIFETIME (days) SALT_EMIS (Tg/yr), SALT_BURDEN (Tg), SALT_DRYDEP (Tg/yr), SALT_WETDEP (Tg/yr), SALT_LIFETIME (days) DUST_EMIS (Tg/yr), DUST_BURDEN (Tg), DUST_DRYDEP (Tg/yr), DUST_WETDEP (Tg/yr), DUST_LIFETIME (days) POM_EMIS (Tg/yr), POM_BURDEN (Tg), POM_DRYDEP (Tg/yr), POM_WETDEP (Tg/yr), POM_LIFETIME (days) BC_EMIS (Tg/yr), BC_BURDEN (Tg), BC_DRYDEP (Tg/yr), BC_WETDEP (Tg/yr), BC_LIFETIME (days) SO4_EMIS_elevated (Tg S/yr), SO4_BURDEN (Tg S), SO4_DRYDEP (Tg S/yr), SO4_WETDEP (Tg S/yr), SO4_GAEX (Tg S/yr) SO4_LIFETIME (days), SO4_AQUEOUS (Tg S/yr), SO4_NUCLEATION (Tg S/yr) **List of variable names and descriptions for clarity** - ListVars: list of all available variables from given history file - GAS_VARIABLES: list fo necessary CAM gaseous variables - AEROSOL_VARIABLES: list fo necessary CAM aerosol variables - AEROSOLS: list of necessary aerosols for computations MODIFICATION HISTORY: Behrooz Roozitalab, 02, NOV, 2022: VERSION 1.00 - Initial version Justin Richling, 27 Nov, 2023 - updated to fit to ADF and check with old AMWG chem/aerosol tables - fixed: * added difference bewtween cases column to tables Behrooz Roozitalab, 8 Aug, 2024 - fixed: * lifetime inconsitencies * Removed redundant calculations to improve the speed * Verified the results against the NCL script. .. py:function:: list_files(adfobj, directory, start_year, end_year, h_case) This function extracts the files in the directory that are within the chosen dates and history number. .. py:function:: Get_files(adfobj, data_dir, start_year, end_year, h_case, **kwargs) This function retrieves the files, latitude, and longitude information in all the directories within the chosen dates. .. py:function:: set_dic_SE(ListVars, ext1_SE) Initialize dictionary to house all the relevant tabel data .. py:function:: fill_dic_SE(adfobj, dic_SE, variables, ListVars, ext1_SE, AEROSOLS, MW, AVO, gr, Mwair) Function for dealing with conversion factors for different components and filling the main data dictionary 'dic_SE' Input dictionary and return updated dictionary 'dic_SE' :param variables: - list of main variables? :type variables: list :param ListVars: - list of ??????? :type ListVars: list :returns: * dic_SE : dict - full dictionary of derived variables * *Some conversion factors need density or Layer's pressure, that will be accounted for when reading the files.* * *We convert everying to kg/m2/s or kg/m2 or kg/s, so that final Tg/yr or Tg results are consistent* .. py:function:: make_Dic_scn_var_comp(adfobj, variables, current_dir, dic_SE, current_files, ext1_SE, AEROSOLS) This function retrieves the files, latitude, and longitude information in all the directories within the chosen dates. current_dir: list - showing the directories to look for files. always end with '/' current_files: list - List of CAM history files start_year: string - Starting year end_year: string - Ending year kwargs ------ ext1_SE: string - specify if the files are for only a region, which changes to variable names. ex: if you saved files for a only a box region ($LL_lat$,$LL_lon$,$UR_lat$,$UR_lon$), the 'lat' variable will be saved as: 'lat_$LL_lon$e_to_$UR_lon$e_$LL_lat$n_to_$UR_lat$n' for instance: 'lat_65e_to_91e_20n_to_32n' :returns: * Dic_crit: - dictionary for critical values for current case Dic_scn_var_comp: - full dictionary of all variables and components for current case * **NOTE** (*The LNO is lightning NOx, which should be reported explicitly rather as CO_LNO, O3_LNO, ...*) .. py:function:: SEbudget(adfobj, dic_SE, data_dir, files, var, ext1_SE, **kwargs) Function used for getting the data for the budget calculation. This is the chunk of code that takes the longest by far. Example: ~70/75 mins per case for 9 years ** This is for both chemistry and aeorosl calculations dic_SE: dictionary specyfing what variables to get. For example, for precipitation you can define SE as: dic_SE['PRECT']={'PRECC'+ext1_SE:8.64e7,'PRECL'+ext1_SE:8.64e7} - It means to sum the file variables "PRECC" and "PRECL" for my arbitrary desired variable named "PRECT" - It also has the option to apply conversion factors. For instance, PRECL and PRECC are in m/s. 8.64e7 is used to convernt m/s to mm/day data_dir: string of the directory that contains the files. always end with '/' files: list of the files to be read var: string showing the variable to be extracted. -> this will be the individual componnent, ie O3_CHMP, SOA_WDF, etc. .. py:function:: calc_budget_data(current_var, Dic_scn_var_comp, area, trop, inside, num_yrs, duration, AEROSOLS) Function to run through desired table values for calculations for the table entries .. py:function:: make_table(adfobj, vars, chem_type, Dic_scn_var_comp, areas, trops, case_names, nicknames, durations, insides, num_yrs, AEROSOLS) Create CSV table for aeorosols and gases, if applicable Table includes column values of variable, case(s), difference (if applicable) If this is a single model vs model run: 4 columns first column: variables names, second column: test case variable values third column: baseline case variable values final column: difference of test and baseline. If this is a model vs obs run: 2 columns first column: variables names, second column: test case variable values