Advertisement
lightmaster

WeeWX CSV Import Config

Apr 9th, 2024
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # EXAMPLE CONFIGURATION FILE FOR IMPORTING FROM CSV FILES
  2. #
  3. # Copyright (c) 2009-2024 Tom Keffer <tkeffer@gmail.com> and Gary Roderick.
  4. # See the file LICENSE.txt for your rights.
  5.  
  6. ##############################################################################
  7.  
  8. # Specify the source. Available options are:
  9. #   CSV - import obs from a single CSV format file
  10. #   WU - import obs from a Weather Underground PWS history
  11. #   Cumulus - import obs from a one or more Cumulus monthly log files
  12. #   WD - import obs from a one or more WD monthly log files
  13. #   WeatherCat - import obs from a one or more WeatherCat monthly .cat files
  14. # Format is:
  15. #   source = (CSV | WU | Cumulus | WD | WeatherCat)
  16. source = CSV
  17.  
  18. ##############################################################################
  19.  
  20. [CSV]
  21.    # Parameters used when importing from a CSV file
  22.  
  23.     # Path and name of our CSV source file. Format is:
  24.    #   file = full path and filename
  25.     file = /tmp/meteobridge.csv
  26.  
  27.     # Specify the character used to separate fields. The character must be
  28.    # enclosed in quotes. Format is:
  29.    #   delimiter = '<single character>'
  30.    # Default is ',' (comma).
  31.     delimiter = ','
  32.    
  33.     # Specify the character used as the decimal point. The character must be
  34.    # enclosed in quotes.
  35.    # Format is:
  36.    #   decimal = '<single character>'
  37.    #   or
  38.    # Default is '.' (period).
  39.     decimal = '.'
  40.  
  41.     # If there is no mapped interval field how will the interval field be
  42.    # determined for the imported records. Available options are:
  43.    #   derive - Derive the interval field from the timestamp of successive
  44.    #            records. This setting is best used when there are no missing
  45.    #            records from period being imported. Missing records will cause
  46.    #            the interval field to be incorrectly calculated for some
  47.    #            records.
  48.    #   conf   - Use the interval setting from weewx.conf. This setting is best
  49.    #            used if the records to be imported have been produced by WeeWX
  50.    #            or some other means with the same archive interval as set in
  51.    #            weewx.conf on this machine.
  52.    #   x      - Use a fixed interval of 'x' minutes for every record where 'x'
  53.    #            is a number. This setting is best used if the records to be
  54.    #            imported are equally spaced in time but there are some missing
  55.    #            records.
  56.    #
  57.    # Note: If there is a mapped interval field this setting will be ignored.
  58.    # Format is:
  59.    #   interval = (derive | conf | x)
  60.    # Default is derive.
  61.     interval = derive
  62.  
  63.     # Should the [StdQC] max/min limits in weewx.conf be applied to the
  64.    # imported data. This may be useful if the source has extreme values that
  65.    # are clearly incorrect for some observations. Available options are:
  66.    #   True  - weewx.conf [StdQC] max/min limits are applied.
  67.    #   False - weewx.conf [StdQC] max/min limits are not applied.
  68.    # Format is:
  69.    #   qc = (True | False)
  70.    # Default is True.
  71.     qc = True
  72.  
  73.     # Should any missing derived observations be calculated from the imported
  74.    # data if possible. Available options are:
  75.    #   True  - Any missing derived observations are calculated.
  76.    #   False - Any missing derived observations are not calculated.
  77.    # Format is:
  78.    #   calc_missing = (True | False)
  79.    # Default is True.
  80.     calc_missing = True
  81.  
  82.     # Specify how imported data fields that contain invalid data (eg a numeric
  83.    # field containing non-numeric data) are handled. Available options are:
  84.    #   True  - The invalid data is ignored, the WeeWX target field is set to
  85.    #           None and the import continues.
  86.    #   False - The import is halted.
  87.    # Format is:
  88.    #   ignore_invalid_data = (True | False)
  89.    # Default is True.
  90.     ignore_invalid_data = True
  91.  
  92.     # Imported records are written to archive in transactions of 'tranche'
  93.    # records at a time. Increase for faster throughput, decrease to reduce
  94.    # memory requirements. Format is:
  95.    #   tranche = x
  96.    # where x is an integer
  97.    # Default is 250.
  98.     tranche = 250
  99.  
  100.     # Specify whether a UV sensor was used to produce UV observation data.
  101.    # Available options are:
  102.    #   True  - UV sensor was used and UV data will be imported.
  103.    #   False - UV sensor was not used and any UV data will not be imported.
  104.    #           UV field will be set to None/NULL.
  105.    # For a CSV import UV_sensor should be set to False if a UV sensor was
  106.    # NOT present when the import data was created. Otherwise it may be set to
  107.    # True or omitted. Format is:
  108.    #   UV_sensor = (True | False)
  109.    # Default is True.
  110.     UV_sensor = True
  111.  
  112.     # Specify whether a solar radiation sensor was used to produce solar
  113.    # radiation observation data. Available options are:
  114.    #   True  - Solar radiation sensor was used and solar radiation data will
  115.    #           be imported.
  116.    #   False - Solar radiation sensor was not used and any solar radiation
  117.    #           data will not be imported. radiation field will be set to
  118.    #           None/NULL.
  119.    # For a CSV import solar_sensor should be set to False if a solar radiation
  120.    # sensor was NOT present when the import data was created. Otherwise it may
  121.    # be set to True or omitted. Format is:
  122.    #   solar_sensor = (True | False)
  123.    # Default is True.
  124.     solar_sensor = True
  125.  
  126.     # Date-time format of CSV field from which the WeeWX archive record
  127.    # dateTime field is to be extracted. The import utility first attempts to
  128.    # interpret date-time data in this format, if this fails it then attempts
  129.    # to interpret it as a timestamp and if this fails an error is raised. Uses
  130.    # Python strptime() format codes. Format is:
  131.    #   raw_datetime_format = Python strptime() format string
  132.     raw_datetime_format = %Y-%m-%d %H:%M:%S
  133.  
  134.     # Lower and upper bounds for imported wind direction. It is possible,
  135.    # particularly for a calculated direction, to have a value (eg -45) outside
  136.    # of the WeeWX limits (0 to 360 inclusive). Format is:
  137.    #
  138.    # wind_direction = lower,upper
  139.    #
  140.    # where :
  141.    #   lower is the lower limit of acceptable wind direction in degrees
  142.    #   (may be negative)
  143.    #   upper is the upper limit of acceptable wind direction in degrees
  144.    #
  145.    # Imported values from lower to upper will be normalised to the range 0 to
  146.    # 360. Values outside of the parameter range will be stored as None.
  147.    # Default is -360,360.
  148.     wind_direction = 0,360
  149.  
  150.     # Map CSV record fields to WeeWX archive fields. Format for each map entry
  151.    # is:
  152.    #
  153.    #   [[[weewx_archive_field_name]]]
  154.    #       source_field = csv_field_name
  155.    #       unit = weewx_unit_name
  156.    #       is_cumulative = True | False
  157.    #       is_text = True | False
  158.    #
  159.    # where:
  160.    #   weewx_archive_field_name - An observation name in the WeeWX database
  161.    #                              schema.
  162.    #   source_field             - Config option specifying the CSV field being
  163.    #                              mapped.
  164.    #   csv_field_name           - The name of a field from the CSV file.
  165.    #   unit                     - Config option specifying the unit used by
  166.    #                              the CSV field being mapped.
  167.    #   weewx_unit_name          - The WeeWX unit name for the the units used
  168.    #                              by csv_field_name.
  169.    #   is_cumulative            - Config option specifying whether the CSV
  170.    #                              field being mapped is cumulative,
  171.    #                              e.g: dayrain. Optional, default value is
  172.    #                              False.
  173.    #   is_text                  - Config option specifying whether the CSV
  174.    #                              field being mapped is text. Optional,
  175.    #                              default value is False.
  176.    # For example,
  177.    #   [[[outTemp]]]
  178.    #       source_field = Temp
  179.    #       unit = degree_C
  180.    # would map the CSV field 'Temp', in degrees C, to the WeeWX archive field
  181.    # 'outTemp'.
  182.    #
  183.    # A mapping for WeeWX field 'dateTime' is mandatory and the WeeWX unit name
  184.    # for the 'dateTime' mapping must be 'unix_epoch'. For example,
  185.    #   [[[dateTime]]]
  186.    #       source_field = csv_date_and_time
  187.    #       unit = unix_epoch
  188.    # would map the CSV field 'csv_date_and_time' to the WeeWX 'dateTime' field
  189.    # with the 'csv_date_and_time' field being interpreted first using the
  190.    # format specified at the 'raw_datetime_format' config option and if that
  191.    # fails as a unix epoch timestamp.
  192.    #
  193.    # If the CSV data contains a field with WeeWX 'usUnits' data the field may
  194.    # be mapped to WeeWX field 'usUnits' and this value will be used to
  195.    # determine the units used for each CSV field. If a 'usUnits' mapping is
  196.    # included the 'unit' option may be omitted as the 'usUnits' value is
  197.    # unitless. If the 'unit' option is set it will be ignored. If a 'usUnits'
  198.    # mapping is included the 'unit' option for all other fields may be
  199.    # omitted.
  200.    #
  201.    # WeeWX archive fields that do not exist in the CSV data may be omitted.
  202.    # Any omitted fields that are derived (eg 'dewpoint') may be calculated
  203.    # during import using the equivalent of the WeeWX StdWXCalculate service
  204.    # through setting the 'calc-missing' parameter above.
  205.     [[FieldMap]]
  206.         [[[dateTime]]]
  207.             source_field = dateTime
  208.             unit = unix_epoch
  209.         [[[outTemp]]]
  210.             source_field = outTemp
  211.             unit = degree_F
  212.         [[[inTemp]]]
  213.             source_field = inTemp
  214.             unit = degree_F
  215.         [[[outHumidity]]]
  216.             source_field = outHumidity
  217.             unit = percent
  218.         [[[inHumidity]]]
  219.             source_field = inHumidity
  220.             unit = percent
  221.         [[[dewpoint]]]
  222.             source_field = dewpoint
  223.             unit = degree_F
  224.         [[[heatindex]]]
  225.             source_field = heatindex
  226.             unit = degree_F
  227.         [[[windchill]]]
  228.             source_field = windchill
  229.             unit = degree_F
  230.         [[[barometer]]]
  231.             source_field = barometer
  232.             unit = hPa
  233.         [[[rain]]]
  234.             source_field = rain
  235.             unit = inch
  236.             is_cumulative = True
  237.         [[[rainRate]]]
  238.             source_field = rainRate
  239.             unit = inch_per_hour
  240.         [[[windSpeed]]]
  241.             source_field = windSpeed
  242.             unit = mile_per_hour
  243.         [[[windDir]]]
  244.             source_field = windDir
  245.             unit = degree_compass
  246.         [[[windGust]]]
  247.             source_field = windGust
  248.             unit = mile_per_hour
  249.         [[[radiation]]]
  250.             source_field = radiation
  251.             unit = watt_per_meter_squared
  252.         [[[UV]]]
  253.             source_field = UV
  254.             unit = uv_index
  255.         [[[inDewpoint]]]
  256.             source_field = inDewpoint
  257.             unit = degree_F
  258.         [[[pressure]]]
  259.             source_field = pressure
  260.             unit = hPa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement