emissions.py
The emissions
object is primarily built off of geopandas
. It has the following attributes:
Inputs
file_path
: the file path of the raw emissions dataoutput_dir
: a filepath string for the output directoryf_out
: a string containing the filename pattern to be used in output filesunits
: units associated with the emissions (e.g., μg/s)name
: a plain English name tied to the emissions data, either provided or automatically generated from the filepathdetails_to_keep
: any additional details to be preserved throughout the processing (e.g., sector, fuel type) (not fully built out yet)filter_dict
: filters the emissions inputs based on inputted dictionary (not fully built out yet)load_file
: a Boolean indicating whether or not the file should be loaded (for debugging)verbose
: a Boolean indicating whether or not detailed logging statements should be printeddebug_mode
: a Boolean indicating whether or not to output debug statements
Attributes
valid_file
: a Boolean indicating whether or not the file provided is validvalid_units
: a Boolean indicating whether or not emissions units are compatible with the programvalid_emissions
: a Boolean indicating whether or not emissions passed required testsfile_type
: the type of file being used to provide raw emissions data (for now, only.shp
is allowed)geometry
: geospatial information associated with the emissions inputcrs
: the inherent coordinate reference system associated with the emissions inputemissions_data
: complete, detailed emissions data from the sourceemissions_data_clean
: simplified emissions in each grid cell
Calculated Attributes
PM25
: primary PM2.5 emissions in each grid cellNH3
: ammonia emissions in each grid cellVOC
: VOC compound emissions in each grid cellNOX
: NOx emissions in each grid cellSOX
: SOx emissions in each grid cellL0_flag
,L1_flag
,L2_flag
,isrm_hole_flag
: Booleans indicating whether each layer should be calculated based on emissions release heights
Internal Functions
get_file_path
: returns the file pathget_name
: returns the name associated with the emissions (emissions_name
)get_unit_conversions
: returns two dictionaries of built-in unit conversionscheck_path
: uses thepath
library to check if the providedfile_path
exists and if the file is a filecheck_units
: checks that the provided units are valid against theget_unit_conversions
dictionariesload_emissions
: detects the filetype of the emissions file and calls the appropriate load functioncheck_id
: checks for I_CELL and J_CELL and adds them if they are missingload_shp
: loads the emissions data from a shapefileload_feather
: loads the emissions data from a feather fileload_csv
: loads the emissions data from a csv filecheck_height
: checks that the height column is present in the emissions file; if not, assumes emissions are released at ground-levelcheck_emissions
: runs a number of checks on the emissions data to ensure data are valid before running anythingmap_pollutant_names
: replaces pollutant names if they are not found in the emissions data based on near-misses (e.g., PM2.5 for PM25)filter_emissions
: filters the emissions based on thefilter_dict
inputcheck_geo_types
: checks what geometries are present in the emissions shapefile (e.g., points, polygons, multipolygons); if points exist, usesbuffer_emis
to convert to polygonscheck_polygon_area
: checks if the maximum polygon area exceeds 2500 km^2 and outputs a warning to the user if sobuffer_emis
converts points to polygons by adding a buffer ofdist
clean_up
: simplifies the emissions data by removing unnecessary dimensions, converting units as appropriate, and updating the column namesconvert_units
: converts units from provided units to μg/s using the unit dictionaries built-insplit_polutants
: converts the emissions layer into separate objects for each pollutantwhich_layers
: determines theL0_flag
,L1_flag
,L2_flag
, andlinear_interp_flag
variables based on the HEIGHT column of the emissions data
External Functions
visualize_emissions
: creates a simple map of emissions for a provided pollutantget_pollutant_layer
: pulls a single pollutant layer based onpol_name