Functions#

This is a list of general functions used in the PIA software

SPDX-FileCopyrightText: 2021 IMKAAF/KIT

SPDX-License-Identifier: EUPL-1.2

pia.functions.Saturation(T_0, T, p_0, p)#

Calculates the saturation ratio with respect to Liquid water, assuming ice saturated conditions at T_0, p_0.

Parameters:
  • T_0 (float) – Temperature at start point in Kelvin

  • T (float) – Temperature for calculations in Kelvin

  • p_0 (float) – Pressure at start point

  • p (float) – Pressure for calculations

Returns:

S

Return type:

float

pia.functions.T_adiabatic(T_0, p_0, p)#

Calculates the temperature for an adiabatic cooling.

Parameters:
  • T_0 (float) – start temperature in Kelvin

  • p_0 (float) – start pressure

  • p (float) – pressure during cooling

Returns:

T_ad

Return type:

float

pia.functions.assign_run_mode(instrument_data, pine_id, num_runs, pfr_file)#

Assigns run id and run mode (1,2,3) to instrument data according to run times.

pia.functions.calculate_concentration(flow, count, time_del)#

Concentration in stdL-1

Parameters:
  • flow (float)

  • count (int) – particle count

  • time_del (float) – time interval

Returns:

count / (flow * time_del / 60)

Return type:

float

pia.functions.calculate_corrected_run_mode_for_gaps(data, del_t)#

For the opc gaps test, empty bins at the begin and the end of the expansion have to be removed.

Parameters:
  • data (pd.DataFrame)

  • del_t (int)

Returns:

data

Return type:

pd.DataFrame

pia.functions.choose_time_interval(data_frame, start, stop)#

slices a time interval of a dataframe

Parameters:
  • data_frame (pd.DataFrame) – needed column: “date”

  • start (date)

  • stop (date)

Returns:

df – sliced dataframe

Return type:

pd.DataFrame

pia.functions.fill_missing_data(df)#

Calculates missing values following ACTRIS EBAS guidelines. “The number format of the missing value code (number of digits left and right of the decimal point, use of exponential notation or not) specifies the number format of the corresponding data column in the data section. The missing value code is usually generated by filling all digits with a 9. This applies also for numbers in exponential notation. In any case, the absolute value of the missing values code needs to be 1 to 2 orders of magnitude larger than the largest valid value ever expected.” (https://ebas-submit.nilu.no/templates/comments/missing_value_tags)

pia.functions.find_opc_gaps(saqc_data, data_df, campaign, pine_id, operation_id, pfr_file, df_concentrations, chamber, cirrus_mode, ice_threshold, metadata, actris)#

Function to find gaps in the binned opc data.

Parameters:
  • saqc_data (SaQC object)

  • data_df (pd.DataFrame)

  • campaign (str)

  • pine_id (str)

  • operation_id (int)

  • pfr_file (pd.DataFrame)

  • df_concentrations (pd.DataFrame)

  • chamber (int or None)

  • cirrus_mode (boolean)

  • ice_threshold (pd.DataFrame or None)

  • metadata (dict)

  • settings (dict)

Returns:

gaps_results

Return type:

pd:DataFrame

pia.functions.group_for_mean(date_list, time_delta, data)#
pia.functions.make_df_grid_log(num_bins, min_d, max_d)#

Creates a logarithmic grid

Parameters:
  • num_bins (int) – number of bins

  • min_d (float) – smallest bin

  • max_d (float) – biggest bin

Returns:

  • grid (pd.DataFrame) – DataFrame with bin sizes

  • distribution_bins (list) – list with bin names

pia.functions.make_time_grid(run_t, dt)#

Creates a time grid for a time interval of length run_t with bin sizes dt

Parameters:
  • run_t (float)

  • dt (int)

Returns:

t_grid

Return type:

np.array

pia.functions.saturation_pressure_ice(T)#

Calculates the saturation vapour pressure over ice for temperature T in Kelvin.

Parameters:

T (float)

Returns:

p_ice

Return type:

float

pia.functions.saturation_pressure_liquid(T)#

Calculates the saturation vapour pressure over supercooled water for temperature in Kelvin.

Parameters:

T (float)

Returns:

p_liq

Return type:

float