qaqc

class qaqc.ApplyFlags(df_index, precision, flags=False)[source]

Bases: object

Apply flags from multiple sources to create a final set of flagged data.

Take flags from Provisional, QaRules, and manual flags from ../qa_param.yaml and combine them to create a single set of data flags. Create documentation why things were flagged and provide tools to evaluate the final flag set.

affirm_CLOG_flagged_UC()[source]

During CLOG events, only U and C flags are used.

Sometimes GCE manually adds Q flags to cover clog periods. These Q flags will be overwritten by higher precedence flags such as U and C. However, dry periods during a CLOG event do not have a flag, allowing them to be filled with GCE manual flags such as Q.

Returns:

updatess instance variables

affirm_NaN_flagged_M()[source]

Check that any NA values are flagged as missing (M) and all M flags have NAN values.

self.flags[‘SetNA’] and self.flags[‘M’] will become the same with a warning.

Returns:

updates instance variables

affirm_only_one_flag()[source]

Check that only one flag is assigned at a time.

Final data can only contain one flag per time step. Only one flag will be retained. All others will be cleared in order of precedence. Flags take precedence in the following order:

  1. M - missing flag

  2. U - undercatch during a clog

  3. C - cumulative estimate of total precip since last measurement following clog

  4. E - estimated value

  5. Q - questionable value

Returns:

updates instance variables

affirm_zero_flagged_E()[source]

Check that anywhere the data was set to 0 also contains either an E flag or a manual flag.

If the data was set to 0, but has no E flag or manual flag, then an E flag will be added with a warning.

Returns:

updatess instance variables

apply_0_val()[source]

Insert 0 values into the data.

Where the data has been flagged to change values to 0 in the variable self.flags[‘Set0’], insert 0 values. This only changes the adjusted precip values (`self.data[‘adj_precip’]) and does not alter the raw data values.

Returns:

updates instance variables

apply_GCE_flags()[source]

Add GCE flags to final data.

This will only add flags where no other process has assigned one. If no other flags have been added, all GCE flags will be applied to the data. This method is intended to be used after other QA processes.

Returns:

updates instance variable self.flags.

apply_NAN_val()[source]

Insert NA values into the data.

Where the data has been flagged to change values to NA in the variable self.flags[‘SetNA’], insert NA values. This only changes the adjusted precip values (`self.data[‘adj_precip’]) and does not alter the raw data values. This method also adds a missing (M) flag for each NA value.

Returns:

updates instance variables

apply_QaRules_flags(auto_qa_event, flags)[source]

Add QaRule flags. Flags are an accumulation of rows that are True.

Flags are accumulated with |=. I.e. flags = flags or new_flags. Explanations and event codes are populated based on the auto_qa_event generated by QaRules().

Parameters:
  • auto_qa_event – A boolean DataFrame with a column for each event the data was tested for.

  • flags – A boolean DataFrame with a column for each flag.

Returns:

updates instance variables self.event and self.flags

apply_final_flags()[source]
apply_flags_as_str(flags, col)[source]

Convert all accumulated flags to str.

Flags are accumlated through a boolean pd.DataFrame, self.flags using |= (df[col] = df[col] or RuleTrue ). So multiple rules can add to a given flag. SetNA or Set0 are applied directly to the data, but each rule should associate it with a particular flag to explain why the value was changed. :return: updates instance variable self.event.

apply_manual_flags(manual_notes)[source]

A list of manual entered notes is used to change the flags for a specified time period. Each item in the list is a dictionary containing exact date and time of an event, what flag to assign, and whether or not to delete the data during that period.

# EXAMPLE!!
- start: '11/8/21 1000'
  end: '11/8/21 1000'
  replace_wNAN: False
  flag: Q
  explanation: Tank level spikes, then immediately comes back down.

Note

To avoid multiple calls to instance, self.data is assigned to a local variable. But pandas.DataFrame is a mutable type, so both self.data and df refer to the same location in memory, i.e. are identical

Parameters:

manual_notes – list. List should contain dictionaries of exact time periods and how to flag them.

create_flag_log(probe, output_dir='./processed_data')[source]
get_flagged_days()[source]
import_provisional_data(prov_df, tank_col='INST', ppt_col='TOT', ppt_flag_col='TOT_Flag', tank_flag_col='INST_Flag')[source]

Populate pd.DataFrames with data from a provisional pivot table.

Parameters:
  • prov_df – pd.DataFrame. A pivot table of provisional data.

  • tank_col – str. Column name containing tank height.

  • ppt_col – str. Column name containing precipitation.

  • ppt_flag_col – str. column name containing precipitation flag.

Returns:

All values are saved to instance. Returns to None.

plot_flagged_day(day, site, tdelta='1D', **kwargs)[source]

Plot flags over the both instantaneous tank values and total accumulated precipitation to show how the raw data is acting and how flagging is being applied.

This is an interactive method that allows multiple inputs to increase the descriptive ability of the graph, while continuing to graph components in the same way to create consistency in review of flagging. Precipitation is plotted on the left axis, while tank levels are plotted on the right axis. There are several optional plotting inputs, but flags are always displayed:

  • All flags are plotted where the flag letter is a red point over top of the precipitation data.

  • Events, if provided, can be plotted on either axis and use predetermined symbology defined by the dictionary event_plt_kwargs. An events DataFrame as formated in post_gce_qc.QaRules.events is expected.

  • Paired tank, if provided, is plotted as a yellow dotted line on the right axis and is noramlized to the value of the site’s tank level at the beginning of the time period.

  • Running values, if provided, are plotted on the left axis as a dotted line for std deviation and a dashed line for running averages.

Parameters:
  • day – datetime object. This is the start time for the figure. Typically midnight of a given day

  • site – Str. The name of the site plotted

  • tdelta – Str. Defines how much time is plotted after day. Must be a valid format for pandas.to_timedelta(). Defaults to ‘1D’

  • auto_qa_event – DataFrame of boolean values as formated in post_gce_qc.QaRules.events

  • running_vals – DataFrame of running mean and std deviation

  • paired_tank – a DataFrame of instantaneous tank level for a cross comparison of gauges

Returns:

prorate_precip_during_tank_flux(tank_col='tank_height', precip_col='adj_precip', max_prorate=15)[source]

Adjust precipitation amounts to match total daily change in tank level.

Total daily tank level is prorated throughout each day based on the proportion of precipitation reported at each timestep. It is a simple linear interpolation. New, prorated daily totals match the midnight to midnight change in tank level.

If tank level changes by less than 2 x precision (positive or negative), the daily total is adjusted to zero.

Days where there is no likely rain outside of a fluctuation are not prorated and left with a value of 0.

Parameters:
  • tank_col – str. Name of column containing tank level.

  • precip_col – str. Name of column containing precipitation.

  • max_prorate – float. Max allowable ratio to use in prorating.

static read_manual_flags(site, qa_yaml='../qa_param.yaml')[source]
remove_GCE_E_flags()[source]

Where provisional processing has placed an E flag immediately following an R flag, the E flag does NOT represent an estimated value, but does represent a questionable value. This event identifies a jump in precip following a reduction in tank values when the current state is NOT_RAINING.

This event should be caught by QaRules.drain_recharge_flagging_wrap(). However, if it has not been caught, the GCE flag is misleading and should be changed. In practice, the only examples of this flagging pattern in the data are completely bogus precip, but there aren’t enough examples to have high confidence that this is always the case. Therefore, this method assigns flagging based on the underlying GCE logic that applies the flag.

Note, that any other flag assigned will take precedence over the Q flag assigned here, and that manual flags will clear any other flags for that period.

Returns:

updates instance variables

remove_GCE_F_flags()[source]

Where provisional processing has placed an F flag immediately following a J flag, the precip value from the record flagged J is duplicated in the record flagged F. The J flag signifies large precip jumps, so this artifact added > 200 mm of precip to CENT in WY19 if not removed.

Returns:

updates instance variables

static rolling_accumulate_increment(arr, window, increment)[source]

Rolling window that accumulates by increment.

All values within the window are summed. Output is filled when the sum is greater than the increment. Once a value is used to accumulate output it is not reused in subsequent windows. Any accumulated value greater than a whole increment is rounded off and added to the next timestep.

This method was designed to take the remainders of values off into full increments and scrape them together into additional precip over a larger moving window.

This is a JustInTime (jit) compiled function that explicitly uses numpy (not Python).

Parameters:
  • arr – numpy array. Intended for reainders from rounding precip down to full increments.

  • window – int. Size of moving window to be used.

  • increment – float. The increment to accumulate by.

Returns:

Numpy array of accumulated values in whole increments.

round_precip_to_min_increment(increment=None, scrape_remainder_window=6)[source]

Round precip to minimum increment.

Precipitation amounts cannot be smaller than what we can measure. With tipping buckets this is a pretty basic check, but with tank gauges there is the potential to round off large amounts of precip. To mitigate these large pools of precip, a moving window is applied to look for consecutive time steps that cumulatively total additional increments. For example, if 0.15 is rounded down to 0.1 for two consecutive time steps, then 0.1 is added to the total of the second timestep. Once added to the total, the 0.05 is excluded from all other window totals.

Parameters:
  • increment – float. The minimum increment by which precip can accumulate. Only “full” bins of this size persist in the final data.

  • scrape_remainder_window – int. The size moving window to use to look for cumulative precip.

class qaqc.QaRules(df, qa_params)[source]

Bases: object

A set of QA rules to run on a single sensor.

Rules to identify places where there are problems in the data or low confidence in the accuracy of the values and all the metrics and calculations to evaluate those rules. Raw data is input and 2 outputs are produced:

  1. A DataFrame of flags accumulated by the rules applied. This shares a DateTime index with the data

    and is in the format of a single boolean column for each flag, identifying rows where flag conditions exist (flag is True).

  2. A boolean DataFrame of events or conditions. E.g. column ‘overflow’ is true wherever the rain gauge overflowed.

static calc_dly_precip(df, day_keys, precip_col='TOT', exclude=None)[source]

Calculate the total daily precipitation.

This method totals the precipitation for each day. This method uses the format pd.DataFrame().groupby().transform(). Transform creates an output DataFrame with the same index as the input DataFrame, df, repeating the daily value at each sub-daily time step (5 min).

Any valid input to pd.DataFrame().groupby() will be accepted, including those at intervals other than daily.

Parameters:
  • df – DataFrame containing precipitation.

  • day_keys – Any valid input to pd.DataFrame().groupby() will be accepted. A pd.Grouper(freq=’1D’) object is expected.

  • precip_col – str. Column name containing precipitation.

  • exclude – Boolean Series or None. Default is None, including all data. If Series, all True values are excluded from daily total

Returns:

DataFrame containing daily precipitation totals with the same index as input df.

static calc_dly_tank_change(df, day_keys, precision, tank_col='INST')[source]

Calculate the change in tank level for each day.

This method takes the first and last tank level of each day, and returns the total change in tank level for the day, midnight to midnight. This method uses the format pd.DataFrame().groupby().transform(). Transform creates an output DataFrame with the same index as the input DataFrame, df, repeating the daily value at each time step.

Any valid input to pd.DataFrame().groupby() will be accepted, including those at intervals other than daily. A list of valid dates (without time) will create the same output as a pd.Grouper(freq=’1D’), but is slower.

Parameters:
  • df – DataFrame containing daily tank levels.

  • day_keys – Any valid input to pd.DataFrame().groupby() will be accepted. A pd.Grouper(freq=’1D’) object is expected.

  • precision – float. Precision of tank level measurement.

  • tank_col – str. Column name containing tank level.

Returns:

DataFrame containing daily tank level change with same index as input df.

static calc_rolling_mean(df_clean, precision=0.254, wind=4, nstd=2)[source]

Calculate the rolling avg and avg + n*std_deviation for the given pd.Series.

Rolling values are rounded to the nearest precision increment. E.g. 1.23 would round to 1.254.

Rolling window is centered; i.e. an equal number of values are included from ahead and behind of the current value.

Parameters:
  • df_clean – pd.Series containing values to calculate rolling avg on.

  • precision – float. Precision of base data. Output will be rounded to this increment.

  • wind – int. size of running window. If int, number of timesteps. If str, must be a valid format for pandas.to_timedelta().

  • nstd – float. Number of standard deviations to add to running average.

Returns:

two pandas Series: rolling avg, and avg + n*std_deviation.

calc_run_avg_rainfall(ppt_col='TOT', wind=4, nstd=2)[source]

Calculate the average and standard deviation for a rolling window of precipitation amounts.

Drain events are removed from data and running values are filled using linear interpolation. All running values are also rounded to the minimum precision.

Parameters:
  • rainfall_col – str. Column name for precip accumulated since last time step

  • wind – size of running window. If int, number of timesteps. If str, must be a valid format for pandas.to_timedelta().

  • nstd – number of standard deviations to add to running average.

Returns:

2 Pandas Series: 1) running avg; 2) running avg +N std deviation of running average.

drain_recharge_flagging_wrap(event_window=3, drain_threshold=-25, runavg_wind=4, runavg_nstd=2, max_recharge=2.67, tank_col='INST', ppt_col='TOT')[source]

Flag all drains and subsequent recharges.

This function wraps together the multi-part approach required to flag drains:

  1. identify a drain is occurring

  2. calculate the running average of precipitation

  3. flag precip during the drain using the running average

  4. calculate the running average + n * std deviation

  5. flag recharge following a drain using the avg + std.

Flagging only occurs during drain events, so it must be identified first, and both drain and rehcarge flagging require an auxiliary variable (avg; avg+n*std) calculated using a running window.

Parameters:
Returns:

None. Changes instance values.

static find_drops(df, precision, col='INST', wind=3, get_roll=False)[source]

Return boolean Series True where value is below the running average.

Primarily used to identify precip tank drain events and any subsequent recharge of mineral oil or antifreeze.

Note

Whole DataFrame is input instead of a slice with just one column to make it more clear what the function is doing.

Rolling values are not suitable for average precip: rolling average up to current time step instead of centering on timestep; no interpolation of nan values will create a gapped record; values are not rounded to nearest precision of measurement.

Parameters:
  • df – Pandas DataFrame

  • precision – float. minimum precision of measurement

  • col – str. Name of column to assess in DataFrame

  • wind – Size of rolling window to use. Integer interpreted as number of timesteps. Any Pandas DateTime frequency that evenly divides into multiyear data is also accepted. For example, month is not accepted because not all months have the same number of days.

  • get_roll – bool: If True, returns the rolling average that drops are assessed against.

Returns:

Panda Series of boolean values with index of df. Optional additional output get_roll=True.

static find_duplicate_precip(df, precision, ppt_col='TOT', tank_col='INST', min_ppt_nprecision=1, flat_tank_nprecision=1, flat_ppt_nprecision=1)[source]

Return boolean value True where the tank is flat, and the precip value is repeating and above a minimum threshold.

This is used to find both single time steps where large cumulative totals are being doubled and long periods where identical precip values repeat. In both cases, tank values do not change.

Note

Whole DataFrame is input instead of a slice with just one column to make it more clear what the function is doing.

Parameters:
  • df – Pandas DataFrame

  • precision – float. minimum precision of measurement

  • ppt_col – str with column name

  • tank_col – str with column name

  • min_ppt_nprecision – float. Multiple of precision

  • flat_tank_nprecision – float. Multiple of precision

  • flat_ppt_nprecision – float. Multiple of precision

Returns:

Pandas Series of boolean values with index of df.

static find_neg_delta(df, col='INST', threshold=-25)[source]

Return boolean Series True where value dropped more than the threshold

Primarily used for identifying the time stamp where the precip storage tank is drained.

Parameters:
  • df – Pandas DataFrame

  • col – str of column name to search

  • threshold – float. Threshold to use to define a drain.

Returns:

Pandas Series of boolean values with index of df.

classmethod find_over_accum(df, precision, nprecision=2, zero_precision=3, window='1D', tank_col='INST', precip_col='TOT')[source]

Return boolean Series True where precipitation values exceed the change in tank level.

This method was designed to be used with a daily window. It calculates the change in tank values over the specified window and compares them to the precipitation accumulated over the window. When the precipitation is greater than the change in tank by at least nprecision levels, it assigns a value of True indicating over accumulation of precip for this window. Run with a daily window calculates midnight to midnight values, NOT a rolling window.

Note

All drains are excluded. The change in tank is always negative following a drain, so it would always return an over accumulation. Therefore they have been excluded.Using this function will always ignore the day (or window) where a drain occurs.

:param df:Pandas DataFrame containing precipitation data. :param precision: float. minimum precision of measurement :param nprecision: float. Multiplied by precision to determine threshold for over accumulation. :param zero_preciion: inst. Multiplied by precision to determine tank threshold for 0 accumulation. :param window: If int, number of timesteps. If str, must be a valid format for pandas.to_timedelta(). :param tank_col: str. Name of column with tank level in DataFrame :param precip_col: str. Name of column with precipitation amount in DataFrame :return: Pandas Series of boolean values identifying over accumulation of precipitation.

static find_tank_flux(df, precision, col='INST', window=289, nprecision=5, extend_ahead=2)[source]

Return boolean value True where the tank notably fluctuates beyond the trend, i.e. beyond the median tank level.

This method applies a median filter to the data, calculating the median value within a moving window. When the tank value is more than nprecision levels beyond this running median, it identifies the tank level as fluxing. Any flux is then extended ahead a number of additional timesteps specifies by extend_ahead.

This method was designed to capture daily fluctuations in tank value. It may be used for other purposes by adjusting its parameters, but has only been trained on these diurnal tank fluctuations.

Parameters:
  • df – Pandas DataFrame containing precipitation data.

  • precision – float. minimum precision of measurement

  • col – str. Name of column containing tank values

  • window – inst. Size of rolling window applied

  • nprecision – float. Multiplied by precision to determine threshold for deviation from trend.

  • extend_ahead – int. Number of additional timesteps to extend flux events by

Returns:

Pandas Series of boolean values identifying tank fluctuations.

flag_double_precip(ppt_col='TOT', tank_col='INST', min_ppt_nprecision=2, flat_tank_nprecision=1, flat_ppt_nprecision=1)[source]

Large amounts of precip were found duplicated in consecutive records. For example 173.1 and 173.0 in consecutive 5 min intervals.

This method identifies duplicates by looking for large precip that occurs where the tank level is flat and nearly duplicates the previous value. This has similar purpose to ApplyFlags.remove_GCE_F_flags(), but uses a numerical method.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • ppt_col – str with column name

  • tank_col – str with column name

  • min_ppt_nprecision – float. Multiple of precision. Filters for the smallest amount of precip considered.

  • flat_tank_nprecision – float. Multiple of precision. Select for close but not identical tank values.

  • flat_ppt_nprecision – float. Multiple of precision. Select for close but not identical precip values.

flag_drains(runavg_rainfall, ppt_col='TOT')[source]

Flag data during drain events.

When the tank level is dropping, all precip values are changed to nan unless the value is <= running average of precipitation, which is flagged Q.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • runavg_rainfall – a Pandas Series containing the running average of precipitation. calc_run_avg_rainfall()

  • ppt_col – str of column containing precipitation data.

flag_empty_tank(tank_col='INST', pause_nsteps=2)[source]

A tank value <0 is not possible and means the sensor float is in a dead zone where it can not be read. This can be a result of a logger reboot or sensor removal rather than an actual measurement. If the tank value is <0 the next measurement will be falsely counted as precip. Due to the ‘F’ flag functionality in simple_pre.m it is necessary to filter for at least 2 timesteps after a tank measurement becomes <0.

flag_duplicate_precip() and ApplyFlags.remove_GCE_F_flags() catch the second timestep of values resulting from this case, but they leave the first timestep. This method removes both values.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • tank_col – str. Name of column with tank level

  • pause_nsteps – int. number of time steps after zero tank to delete.

flag_over_intensity(max_per_hour=25, ppt_col='TOT')[source]
flag_overaccum_precip(overaccum_threshold=5, tank_col='INST', ppt_col='TOT')[source]

The change in tank level should match the amount of precip.

The algorithm that evaluates the tank level for precipitation looks for increases in 3 consecutive measurements to begin a rain event, so this must be carefully parameterized to prevent overflagging. It is also unclear what flags should emanate from this metric.

Warning

With a test case of CENT, an over-accumulation-threshold of 5 x precision captures all the events captured by flag_duplicate_precip() plus one additional event. In that case, ApplyFlags.remove_GCE_F_flags() captures all the same events as this method. So this is a more accurate numerical approach to capturing the conditions occurring when a “J” precedes an “F” flag. But the criteria in this method have the potential to capture other events that are not necessarily duplicates. I don’t want to nebulously flag duplicates as Q when they are an artifact, nor do I want to remove things captured by this criteria, so as of 5/17/23 this function is not used.

Parameters:
  • overcount_threshold – float. Number multiplied by probe precision defining the threshold for ppt overcount

  • tank_col – col

  • ppt_col

Returns:

flag_precip_during_tank_flux(tank_col='INST', ppt_col='TOT', fluxprecision=5, accprecision=5, zero_precision=2, fluxwindow=289, accwindow='1D', extend_ahead=3)[source]

Flag all precipitation when tank values are fluctuating.

Cyclical fluctuations are normal in the rain collection tanks, but can be mistaken for precipitation. This method identifies excessive accumulation during these fluctuations. First, it selects days where accumulation exceeds the midnight to midnight change in tank level, then it selects moments within those days where the tank is fluctuating and rain was recorded.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • tank_col – str. Name of the column with tank level.

  • ppt_col – str. Name of the column containing precipitation data.

  • fluxprecision – float. Threshold for identifying fluctuations in intervals of precision. See find_tank_flux().

  • accprecision – float. Threshold for identifying over accumulation in intervals of precision. See find_over_accum().

  • zero_precision – int. Multiplied by precision to determine tank threshold for 0 accumulation.

  • fluxwindow – int. Number of time steps in moving window. See find_tank_flux().

  • accwindow – str. Timestep at which accumulation is compared. See find_over_accum().

  • extend_ahead – int. Number of time steps to extend flux by. Especially important in negative fluctuations.

flag_propagate_EM_from_tank(tankflag_col='INST_Flag', ppt_col='TOT')[source]

Makes sure that Estimated and Missing flags that are applied to tank are also applied to precip values.

flag_* functions assign values to instance without return. Adds str to flags in self.df_orig where a flag’s conditions are met. To avoid repeated calls to instance, a local variable, df is created to reference the memory where self.df_orig is stored, but the 2 are identical (mutable type).

Parameters:
  • tankflag_col – str. Name of column containing flags for

  • pptflag_col

flag_recharge(runstd_rainfall, max_recharge, ppt_col='TOT')[source]

Flag any recharge added to tank following a drain.

When some tanks are drained, they must be recharged with mineral oil and/or antifreeze. Mineral oil is used to prevent evaporation, primarily in summer months, while antifreeze is used to liquify unheated or frozen gauges. The addition of these liquids should not be counted as rain. The following criteria are applied:

  1. Drain events: a probe specific window following a drop in tank level (set_drain_event()).

  2. NA: impossible/highly-unlikely value is rainfall, meets both of:
    1. value > precip running avg +N std deviation of running avg

    2. value > probe max recharge

  3. Q: questionable whether value is rainfall or recharge. Only meets one of NA criteria, but does not meet both.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • runstd_rainfall – a Pandas Series containing precipitation running avg +N std deviation of running average calc_run_avg_rainfall()

  • max_recharge – float. maximum precip during a drain event. 75% of ppt during drain events recommended.

  • ppt_col – str of column containing precipitation data.

flag_repeating_val_precip(ppt_col='TOT', tank_col='INST', min_ppt_nprecision=0, flat_tank_nprecision=0, flat_ppt_nprecision=0, min_number_repeating=5)[source]

Large periods were found where small amounts of precip, 0.05 mm to 0.25 mm, are accumulated in the exact same amount, every 5 minutes, for as long as 80 hours straight, accumulating to over 200 mm. This rule is in place to catch these periods where the exact same value is repeated consecutively.

This method identifies duplicates by looking for any precip that occurs where the tank level is flat and exactly duplicates the previous value for multiple consecutive time steps.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • ppt_col – str with column name

  • tank_col – str with column name

  • min_ppt_nprecision – float. Multiple of precision. Filters the smallest amount of precip considered.

  • flat_tank_nprecision – float. Multiple of precision. Should be near 0 for flat or artificial tank values.

  • flat_ppt_nprecision – float. Multiple of precision Should be near 0 for repeating identical values.

  • min_number_repeating – int. Number of consecutive values required to be counted as repeating

flag_tank_overflow(tank_max=744.69, tank_col='INST')[source]

Flag values where tank is above maximum fill. Gauge will not be able to record additional precip until the tank level drops.

flag_* functions assign values to instance without return. Changes value of self.qa_flags to True where a flag’s conditions are met.

Parameters:
  • max_tank_depth – float. Maximum fill point of tank.

  • tank_col – str with column name

static round_to_precision(arr, precision, round_fnc=<function round>, digits=4)[source]

Round all values to the nearest precision of the instrument. For example, all tipping bucket measurements rounded to a number of whole bucket tips (no partial tips).

Parameters:
  • df_col – A single column of data. Array math will be preformed to each row of any input format.

  • precision – a numerical value that is the minimum step of the data.

  • round_fnc – a function such as round() or np.floor() that will round the input numbers.

  • digits

Returns:

A column or array of data that has been rounded to whole steps equal to precision.

set_drain_event(tank_col='INST', event_window=3, neg_delta_threshold=-25)[source]

Find the drain events, defined by a running tank average greater than tank level, and any moments where the tank has a negative change in depth.

set_* functions assign values to instance without return.

Parameters:
  • tank_col – str containing name of the column with tank level.

  • event_window – int. What size window to use to calculate the event running average.

  • neg_delta_threshold – int. What size threshold to use to define negative changes in tank depth