CSV import having trouble with units

40 views
Skip to first unread message

Rick M0LEP

unread,
Apr 20, 2020, 7:07:39 AM4/20/20
to weewx...@googlegroups.com
I'm trying to use wee_import (in weewx 3.9.2) to fill in a gap in my
records using data extracted from an external source.

I've created a CSV with the following header line:

timestamp,outTemp,outHumidity,barometer,altimeter,windSpeed,windDir,gustSpeed,gustDir,rainRate,rain

The first data row looks like this:

1584821700,40.71,58,1010,129.00,3.2,135,7.6,45,0.00,0.00

I have the following fields defined in the csv-import.conf

[[FieldMap]]
dateTime = timestamp, unix_epoch
barometer = barometer, mbar
altimeter = altimeter, meter
outTemp = outTemp, degree_F
outHumidity = outHumidity, percent
windSpeed = windSpeed, mile_per_hour
windDir = windDir, degree_compass
windGust = gustSpeed, mile_per_hour
windGustDir = gustDir, degree_compass
rainRate = rainRate, inch_per_hour
rain = rain, inch

The import is complaining about a unit conversion issue:

wee_import --import-config=csv-import.conf --dry-run --log=csv-import.log --verbose
Starting wee_import...
A CSV import from source file 'bloomsky_hillside_combined.csv' has been requested.
The following options will be used:
config=/etc/weewx/weewx.conf, import-config=csv-import.conf
source=bloomsky_hillside_combined.csv, from=None, to=None
dry-run=True, calc_missing=True, ignore_invalid_data=True
tranche=250, interval=5, date/time_string_format=%Y-%m-%d %H:%M:%S
rain=cumulative, wind_direction=[-360.0, 360.0]
UV=False, radiation=False
Using database binding 'wx_binding', which is bound to database 'weewx.sdb'
Destination table 'archive' unit system is '0x01' (US).
Missing derived observations will be calculated.
All WeeWX UV fields will be set to None.
All WeeWX radiation fields will be set to None.
This is a dry run, imported data will not be saved to archive.
Obtaining raw import data for period 1...
The following imported field-to-WeeWX field map will be used:
source field 'barometer' in units 'mbar' --> WeeWX field 'barometer'
source field 'outHumidity' in units 'percent' --> WeeWX field 'outHumidity'
source field 'rainRate' in units 'inch_per_hour' --> WeeWX field 'rainRate'
source field 'rain' in units 'inch' --> WeeWX field 'rain'
source field 'timestamp' in units 'unix_epoch' --> WeeWX field 'dateTime'
source field 'windDir' in units 'degree_compass' --> WeeWX field 'windDir'
source field 'outTemp' in units 'degree_F' --> WeeWX field 'outTemp'
source field 'windSpeed' in units 'mile_per_hour' --> WeeWX field 'windSpeed'
source field 'gustSpeed' in units 'mile_per_hour' --> WeeWX field 'windGust'
source field 'altimeter' in units 'meter' --> WeeWX field 'altimeter'
source field 'gustDir' in units 'degree_compass' --> WeeWX field 'windGustDir'
Raw import data read successfully for period 1.
Mapping raw import data for period 1...
Traceback (most recent call last):
File "/usr/bin/wee_import", line 834, in <module>
main()
File "/usr/bin/wee_import", line 784, in main
source_obj.run()
File "/usr/share/weewx/weeimport/weeimport.py", line 350, in run
_mapped_data = self.mapRawData(_raw_data, self.archive_unit_sys)
File "/usr/share/weewx/weeimport/weeimport.py", line 723, in mapRawData
_conv_vt = convertStd(_temp_vt, unit_sys)
File "/usr/share/weewx/weewx/units.py", line 1161, in convertStd
return StdUnitConverters[target_std_unit_system].convert(val_t)
File "/usr/share/weewx/weewx/units.py", line 784, in convert
new_val_t = convert(val_t, new_unit_type)
File "/usr/share/weewx/weewx/units.py", line 1128, in convert
conversion_func = conversionDict[val_t[1]][target_unit_type]
KeyError: 'inHg'

I've burrowed down various rabbit holes, but not come up with anything.
Any ideas what I've got wrong?

--
73, Rick, M0LEP

gjr80

unread,
Apr 20, 2020, 7:13:59 AM4/20/20
to weewx-user
Yep, you are telling wee_import that WeeWX field altimeter (a pressure) has source (import) data in metres. If your altimeter data is in fact a pressure then it needs to be in a pressure unit supported by WeeWX (hPa, inHg etc). If it is fact an altitude (or something measured in metres) then don’t map it to WeeWX field altimeter.

Gary

Rick M0LEP

unread,
Apr 20, 2020, 7:26:01 AM4/20/20
to weewx...@googlegroups.com
On Mon 20 Apr gjr80 wrote:
> Yep, you are telling wee_import that WeeWX field altimeter (a
> pressure) has source (import) data in metres. If your altimeter data
> is in fact a pressure then it needs to be in a pressure unit supported
> by WeeWX (hPa, inHg etc ). If it is fact an altitude (or something
> measured in metres) then don=E2= =80=99t map it to WeeWX field
> altimeter.

Cheers. It is in fact an altitude, so I'll just leave it out.

--
73, Rick, M0LEP

Reply all
Reply to author
Forward
0 new messages