aerosol package — aerosol-functions 0.0.12 documentation

# aerosol package

## aerosol.functions module

Aerosol number-size distribution is assumed to be a pandas DataFrame where

index:

  time, pandas.DatetimeIndex

columns:

  size bin diameters in meters, float

values:

  normalized concentration dN/dlogDp in cm-3, float

aerosol.functions.air_viscosity(temp)

  Calculate air viscosity using Enskog-Chapman theory

  Parameters:
    tempfloat or numpy.array

      air temperature, unit: K

  Returns:
    float or numpy.array

      viscosity of air, unit: m2 s-1

aerosol.functions.beta(dp, temp, pres, diffusivity, molar_mass)

  Calculate Fuchs Sutugin correction factor

  Sutugin et al. (1971): https://doi.org/10.1016/0021-8502(71)90061-9

  Parameters:
    dpfloat or numpy.array (m,)

      aerosol particle diameter(s), unit: m

    tempfloat or numpy.array (n,1)

      temperature, unit: K

    presfloat or numpy.array (n,1)

      pressure, unit: Pa

    diffusivityfloat or numpy.array (n,1)

      diffusivity of the gas that is condensing, unit: m2/s

    molar_massfloat

      molar mass of the condensing gas, unit: g/mol

  Returns:
    float or numpy.array (n,m)

      Fuchs Sutugin correction factor for each particle diameter and temperature/pressure unit: m2/s

aerosol.functions.binary_diffusivity(temp, pres, Ma, Mb, Va, Vb)

  Binary diffusivity in a mixture of gases a and b

  Fuller et al. (1966): https://doi.org/10.1021/ie50677a007

  Parameters:
    tempfloat or numpy.array

      temperature, unit: K

    presfloat or numpy.array

      pressure, unit: Pa

    Mafloat

      relative molecular mass of gas a, unit: dimensionless

    Mbfloat

      relative molecular mass of gas b, unit: dimensionless

    Vafloat

      diffusion volume of gas a, unit: dimensionless

    Vbfloat

      diffusion volume of gas b, unit: dimensionless

  Returns:
    float or numpy.array

      binary diffusivity, unit: m2 s-1

aerosol.functions.calc_bin_edges(dp)

  Calculate bin edges for log-spaced bin centers

  Parameters:
    dpnumpy.array (n,)

      bin center diameters

  Returns:
    numpy.array (n+1,)

      log bin edges

aerosol.functions.calc_coags(df, dp, temp, pres, dp_start=None)

  Calculate coagulation sink

  Kulmala et al (2012): doi:10.1038/nprot.2012.091

  Parameters:
    dfpandas.DataFrame

      Aerosol number size distribution

    dpfloat or array

      Particle diameter(s) for which you want to calculate the CoagS, unit: m

    temppandas.Series or float

      Ambient temperature corresponding to the data, unit: K If single value given it is used for all data

    prespandas.Series or float

      Ambient pressure corresponding to the data, unit: Pa If single value given it is used for all data

    dp_startfloat, None

      The smallest size that you consider as part of the coagulation sink If None (default) then the smallest size is from dp

  Returns:
    pandas.DataFrame

      Coagulation sink for the given diamater(s), unit: s-1

aerosol.functions.calc_conc(df, dmin, dmax)

  Calculate particle number concentration from aerosol number-size distribution

  Parameters:
    dfpandas.DataFrame

      Aerosol number-size distribution

    dminfloat or array

      Size range lower diameter(s), unit: m

    dmaxfloat or array

      Size range upper diameter(s), unit: m

  Returns:
    pandas.DataFrame

      Number concentration in the given size range(s), unit: cm-3

aerosol.functions.calc_cs(df, temp, pres)

  Calculate condensation sink, assuming that the condensing gas is sulfuric acid in air with aerosol particles.

  Kulmala et al (2012): doi:10.1038/nprot.2012.091

  Parameters:
    dfpandas.DataFrame

      aerosol number size distribution (dN/dlogDp)

    temppandas.Series or float

      Ambient temperature corresponding to the data, unit: K If single value given it is used for all data

    prespandas.Series or float

      Ambient pressure corresponding to the data, unit: Pa If single value given it is used for all data

  Returns:
    pandas.Series

      condensation sink time series, unit: s-1

aerosol.functions.calc_formation_rate(df, dp1, dp2, gr, temp, pres)

  Calculate particle formation rate

  Kulmala et al (2012): doi:10.1038/nprot.2012.091

  Parameters:
    dfpd.DataFrame

      Aerosol particle number size distribution

    dp1float or array

      Lower diameter of the size range(s), unit: m

    dp2float or array

      Upper diameter of the size range(s), unit m

    grfloat or array

      Growth rate for particles out of the size range(s), unit nm h-1

    temppandas.Series or float

      Ambient temperature corresponding to the data, unit: K If single value given it is used for all data

    prespandas.Series or float

      Ambient pressure corresponding to the data, unit: Pa If single value given it is used for all data

  Returns:
    pandas.DataFrame

      particle formation rate(s) for the diameter range(s), unit: cm3 s-1

aerosol.functions.calc_ion_formation_rate(df_particles, df_negions, df_posions, dp1, dp2, gr_negions, gr_posions, temp, pres)

  Calculate ion formation rate

  Kulmala et al (2012): doi:10.1038/nprot.2012.091

  Parameters:
    df_particlespandas.DataFrame

      Aerosol particle number size distribution

    df_negions

      Negative ion number size distribution

    df_posions

      Positive ion number size distribution

    dp1float or numpy.array

      Lower diameter of the size range(s), unit: m

    dp2float or numpy.array

      Upper diameter of the size range(s), unit: m

    gr_negionsfloat or numpy.array

      Growth rate for negative ions out of the size range(s), unit: nm h-1

    gr_posionsfloat or numpy.array

      Growth rate for positive ions out of the size range(s), unit: nm h-1

    temppandas.Series or float

      Ambient temperature corresponding to the data, unit: K If single value given it is used for all data

    prespandas.Series or float

      Ambient pressure corresponding to the data, unit: Pa If single value given it is used for all data

  Returns:
    pandas.DataFrame

      Negative ion formation rate(s), unit : cm3 s-1

    pandas.DataFrame

      Positive ion formation rate(s), unit: cm3 s-1

aerosol.functions.calc_ldsa(df)

  Calculate total LDSA from number size distribution data

  ICRP, 1994. Human respiratory tract model for radiological protection. A report of a task group of the international commission on radiological protection. Ann. ICRP 24 (1-3), 1-482

  Parameters:
    dfpandas.DataFrame

      Aerosol number-size distribution

  Returns:
    pandas.DataFrame

      Total LDSA for alveoli (“al”), trachea/bronchi (“tb”) head-airways (“ha”) and all combiend (“tot”) unit: um2 cm-3

aerosol.functions.calc_lung_df(dp)

  Calculate lung deposition fractions for particle diameters

  ICRP, 1994. Human respiratory tract model for radiological protection. A report of a task group of the international commission on radiological protection. Ann. ICRP 24 (1-3), 1-482

  Parameters:
    dparray

      aerosol particle diameters unit: m

  Returns:
    pandas.DataFrame

      Lung deposition fractions for alveoli (“DF_al”), trachea/bronchi (“DF_tb”) head-airways (“DF_ha”) and all combiend (“DF_tot”)

aerosol.functions.coagulation_coef(dp1, dp2, temp, pres)

  Calculate Brownian coagulation coefficient (Fuchs)

  Parameters:
    dp1float or numpy.array (m,)

      first particle diameter, unit: m

    dp2float or numpy.array (m,)

      second particle diameter, unit: m

    tempfloat or numpy.array (n,1)

      air temperature, unit: K

    presfloat or numpy.array (n,1)

      air pressure, unit: Pa

  Returns:
    float or numpy.array

      Brownian coagulation coefficient (Fuchs),

      for example if all parameters are arrays the function returns a 2d array where the entry at i,j correspoinds to the coagulation coefficient for particle sizes dp1[i] and dp2[i] at temp[j] and pres[j].

      unit m3 s-1

aerosol.functions.datenum2datetime(datenum)

  Convert from matlab datenum to python datetime

  Parameters:
    datenumfloat or int

      A serial date number representing the whole and fractional number of days from 1-Jan-0000 to a specific date (MATLAB datenum)

  Returns:
    pandas.Timestamp

aerosol.functions.datetime2datenum(dt)

  Convert from python datetime to matlab datenum

  Parameters:
    dtdatetime object
  Returns:
    float

      A serial date number representing the whole and fractional number of days from 1-Jan-0000 to a specific date (MATLAB datenum)

aerosol.functions.diam2mob(dp, temp, pres, ne)

  Convert electrical mobility diameter to electrical mobility in air

  Parameters:
    dpfloat or numpy.array (m,)

      particle diameter(s), unit : m

    tempfloat or numpy.array (n,1)

      ambient temperature, unit: K

    presfloat or numpy.array (n,1)

      ambient pressure, unit: Pa

    neint

      number of charges on the aerosol particle

  Returns:
    float or numpy.array

      particle electrical mobility or mobilities, unit: m2 s-1 V-1

aerosol.functions.dndlogdp2dn(df)

  Convert from normalized number concentrations to unnormalized number concentrations.

  Parameters:
    dfpandas.DataFrame

      Aerosol number-size distribution (dN/dlogDp)

  Returns:
    pandas.DataFrame

      Aerosol number size distribution (dN)

aerosol.functions.mean_free_path(temp, pres)

  Calculate mean free path in air

  Parameters:
    tempfloat or numpy.array

      air temperature, unit: K

    presfloat or numpy.array

      air pressure, unit: Pa

  Returns:
    float or numpy.array

      mean free path in air, unit: m

aerosol.functions.mob2diam(Zp, temp, pres, ne)

  Convert electrical mobility to electrical mobility diameter in air

  Parameters:
    Zpfloat

      particle electrical mobility or mobilities, unit: m2 s-1 V-1

    tempfloat

      ambient temperature, unit: K

    presfloat

      ambient pressure, unit: Pa

    neinteger

      number of charges on the aerosol particle

  Returns:
    float

      particle diameter, unit: m

aerosol.functions.particle_diffusivity(dp, temp, pres)

  Particle brownian diffusivity in air

  Parameters:
    dpfloat or numpy.array (m,)

      particle diameter, unit: m

    tempfloat or numpy.array (n,1)

      air temperature, unit: K

    presfloat or numpy.array (n,1)

      air pressure, unit: Pa

  Returns:
    float or numpy.array (m,) or (n,m)

      Brownian diffusivity in air for particles of size dp, and at each temperature/pressure value unit m2 s-1

aerosol.functions.particle_mean_free_path(dp, temp, pres)

  Particle mean free path in air

  Parameters:
    dpfloat or numpy.array (m,)

      particle diameter, unit: m

    tempfloat or numpy.array (n,1)

      air temperature, unit: K

    presfloat or numpy.array (n,1)

      air pressure, unit: Pa

  Returns:
    float or numpy.array (m,) or (n,m)

      Particle mean free path for each dp, unit: m

aerosol.functions.particle_thermal_speed(dp, temp)

  Particle thermal speed

  Parameters:
    dpfloat or numpy.array (m,)

      particle diameter, unit: m

    tempfloat or numpy.array (n,1)

      air temperature, unit: K

  Returns:
    float or numpy.array (m,) or (n,m)

      Particle thermal speed for each dp at each temperature point, unit: m s-1

aerosol.functions.slipcorr(dp, temp, pres)

  Slip correction factor in air

  Parameters:
    dpfloat or numpy array (m,)

      particle diameter, unit m

    tempfloat or numpy.array (n,1)

      air temperature, unit K

    presfloat or numpy.array (n,1)

      air pressure, unit Pa

  Returns:
    float or numpy.array (m,) or (n,m)

      Cunningham slip correction factor for each particle diameter, if temperature and pressure and arrays then for each particle diameter at different pressure/temperature values. unit dimensionless

aerosol.functions.surf_dist(df)

  Calculate the aerosol surface area size distribution

  Parameters:
    dfpd.DataFrame

      Aerosol number-size distribution

  Returns:
    pd.DataFrame

      Aerosol surface area-size distribution unit: m2 cm-3

aerosol.functions.tubeloss(diam, flowrate, tubelength, temp, pres)

  Calculate diffusional particle losses to walls of straight cylindrical tube assuming a laminar flow regime

  Parameters:
    diamnumpy.array (m,)

      Particle diameters for which to calculate the losses, unit: m

    flowratenumpy.array (n,)

      unit: L/min

    tubelengthfloat

      Length of the cylindrical tube unit: m

    tempnumpy.array (n,)

      temperature unit: K

    presnumpy.array (n,)

      air pressure unit: Pa

  Returns:
    numpy.array (n,m)

      Fraction of particles passing through. Each column represents diameter and each each row represents different temperature pressure and flowrate value

aerosol.functions.vol_dist(df)

  Calculate the aerosol volume size distribution

  Parameters:
    dfpd.DataFrame

      Aerosol number-size distribution

  Returns:
    pd.DataFrame

      Aerosol volume-size distribution unit: m3 cm-3

## aerosol.plotting module

aerosol.plotting.generate_log_ticks(min_exp, max_exp)

  Generate ticks and ticklabels for log axis

  Parameters:
    min_expint

      The exponent in the smallest power of ten

    max_expint

      The exponent in the largest power of ten

  Returns:
    numpy.array

      minor tick values

    numpy.array

      major tick values

    list of strings

      major tick labels (powers of ten)

aerosol.plotting.generate_timeticks(t_min, t_max, minortick_interval, majortick_interval, ticklabel_format)
  Parameters:
    t_minpandas timestamp
    t_maxpandas timestamp
    majortick_intervalpandas date frequency string

      See for all options here: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases

    minortick_intervalpandas date frequency string
    ticklabel_formatpython date format string

      See for all options here: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-code

  Returns:
    pandas DatetimeIndex

      minor tick values

    pandas DatetimeIndex

      major tick values

    pandas Index containing strings

      major tick labels

aerosol.plotting.plot_aerosol_dist(v, ax, cmap=<matplotlib.colors.LinearSegmentedColormap object>, norm=<matplotlib.colors.Normalize object>, xminortick_interval='1H', xmajortick_interval='2H', xticklabel_format='%H:%M')

  Plot aerosol particle number-size distribution surface plot

  Parameters:
    vpandas.DataFrame or list of pandas.DataFrames

      Aerosol number size distribution (continuous index)

    axaxes object

      axis on which to plot the data

    cmapmatplotlib colormap

      Colormap to use, default is rainbow

    normmatplotlib.colors norm

      Define how to normalize the colors. Default is linear normalization

    xminortick_intervalpandas date frequency string

      See for all options here: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases

    xmajortick_intervalpandas date frequency string
    xticklabel_formatstr

      See for all options here: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-code

  Returns:
    colorbar handle

aerosol.plotting.rotate_xticks(ax, degrees)
  Parameters:
    axmatplotlib axes
    degreesint or float

      number of degrees to rotate the xticklabels

aerosol.plotting.subplot_aerosol_dist(vlist, grid, cmap=<matplotlib.colors.LinearSegmentedColormap object>, norm=<matplotlib.colors.Normalize object>, xminortick_interval='1H', xmajortick_interval='2H', xticklabel_format='%H:%M', keep_inner_ticklabels=False, hspace_padding=None, vspace_padding=None, subplot_labels=None, label_color='black', label_size=10, column_titles=None, fill_order='row', **kwargs)

  Plot aerosol size distributions (subplots)

  Parameters:
    vlistlist of pandas.DataFrames

      Aerosol size distributions (continuous index)

    gridtuple (rows,columns)

      define number of rows and columns

    cmapmatplotlib colormap

      Colormap to use, default is rainbow

    normmatplotlib.colors norm

      Define how to normalize the colors. Default is linear normalization

    xminortick_intervalstr

      A pandas date frequency string. See for all options here: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases

    xmajortick_intervalstr

      A pandas date frequency string

    xticklabel_formatstr

      Date format string. See for all options here: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-code

    keep_inner_ticklabelsbool

      If True, use ticklabels in all subplots. If False, use ticklabels only on outer subplots.

    subplot_paddingnumber or None

      Adjust space between subplots

    subplot_labelslist of str or None

      The labels to put to labels the subplots with

    label_colorstr
    label_sizefloat
    column_titleslist of strings or None
    fill_orderstr

      “rows” fills the subplots row by row “columns” fills the subplots column by column

    **kwargsoptional parameters passed to matplotlib imshow()
  Returns:
    figure object
    array of axes objects
    colorbar handle