NAME

calibrate.pl - Data processing script for the radon database of the ``Institut für Umweltgeowissenschaften''


SYNOPSIS

  calibrate.pl [options]


DESCRIPTION

This script processes the raw data collected by the radon detector of the ``Institut für Umweltgeowissenschaften''. This data is held in a mysql database named ``radon_mon'' on the ``azug.minpet.unibas.ch'' server.

Depending on the options given on the command line, the script collects the background and/or the calibration events, calculates the respective background level or calibration factors and stores them into the database.

Based on the collected background and calibration event data, for all radon records a calibrated radon activity value is calculated and entered into the database.

By default only data records which have the hardcoded location code value of 3, which is the Jungfraujoch, are considered.


OPTIONS

-h, --help
   print a short help text.
-c, --cal
   process the latest calibration event sequence.
-C, --all-cal
   calculate all calibration factors, not only the latest one.
-b, --background
   process the latest background event sequence.
-B, --all-background
   calculate all background events, not only the latest one.
-o, --overwrite
   overwrite the calibration factors/backround values already
   in the database by freshly calculated values.
--accept-bg-pts <min bg points>
   accept <min bg points> instead of the default minimum of 48
   for valid background (>=18, <=48).
-r, --restrict <restriction spec>
   restrict the calculation and database insertion of calibrated radon activity
   values to those raw data samples, which fulfil all of the specified
   <restriction spec>s.
   May be given more than once to even set more restrictive limits.
   Format of <restriction spec> is: <db-field>:(<|>|=|<=|>=)<float value>.
   Don't forget to quote characters interpreted by the shell (i.e. '<' and '>').
--dry-run
   don't enter calibration factors or background values that have been
   calculated and don't enter calibrated radon activity values into database,
   only print them to stdout.
-n, --no-conc-calc
   skip the calculation of the calibrated radon activity values
   based on background and calibration measurements.
--renew-conc-calc <date>
   recalculate all concentration values back to the given <date>.
-p, --port <db port>
  uses <db port> to connect to the database instead of hardcoded default.
-l, --location <location code>
   process only data records which have location code <location code> instead
   of default code 3 (Jungfraujoch).
-v, --version
   print script version.
-d, --debug
   print debugging information to stdout. Can be given more than once (up to 4)
   to increase verbosity.
-q, --quiet
   suppress some messages printed to stdout.


Background Events processing

Data records marked by a flag field value of 1 represent a background event. Contiguous blocks of at least 48 background event data records are searched for backwards in time. The first 17 records are discarded and the mean of counts of the following 31 records is calculated and stored into the ``background'' table of the database.


Calibration Events processing

Data records marked by a flag field value of 2 represent a calibration event. Contiguous blocks of at least 12 calibration event data records are searched for backwards in time. The first 7 records of a calibration event are discarded, as steady state is usually reached after 4 hours only. The following 4 records are taken to calculate the mean of count, air flow, air temperature and atmospheric pressure.

Contiguous blocks of 5 data records directly preceeding and succeeding the calibration event record block are searched and the respective count value mean is calculated. The mean of that lead and tail background is subtracted from the calibration event mean count value and a calibration factor in [count/Bq] is calculated, according to the formula:

calib_factor [cnt/30min/(Bq/m3)] = (mean_calib_count - background) / calib_src * air_flow

where

calib_src:
 activity of the radon calibration source in [Bq/min]
airflow:
 flow of air into the radon monitor (exflow) in [m3/min]

Finally the calibration factor, the mean calibration event count value and the means of the air flow, air temperature and atmospheric pressure are stored to the ``calibration'' table of the database.


Calculating calibrated radon activity values.

The data records of the ``radon_mon'' database are scanned backwards in time until a record is found which has a non-NULL value in the ``rn_conc'' field. For each record the calibrated radon activity is calculated and entered to the database in one of two ways:

If the date of the processed record is later than the latest calibration sequence or it's date is later than the latest background value, the calibration factor of that latest calibration sequence and the value of the latest background sequence is taken to calculate the calibrated radon activity value and the result is entered to the ``provis_rn_conc'' field of the database.

If the date of the processed record is before the latest calibration sequence and the date of the processed record is before the latest background value, the mean of the calibration factor before and after that of the record and the interpolated value of the two surrounding background values are taken to calculate the calibrated radon activity value and the result is entered to the ``rn_conc'' field of the database.

The radon activity is calculated according to the formula:

rn_activity [Bq/m3] = (rn_count - background) / calib_factor

Only records which have the flag field set to zero are processed.


COPYRIGHT

Copyright (C) 2008, Universität Basel, Institut für Umweltgeowissenschaften, Lukas Zimmermann

This package may be distributed under the terms of either the GNU General Public License or the Perl Artistic License

All rights reserved.

$Id: calibrate.pl,v 1.30 2010/09/20 16:55:02 lukas Exp $