Skip to content

Commit 8d42c36

Browse files
authored
Merge pull request #79 from MeteoSwiss/dev
Dev
2 parents c63a806 + cc0f661 commit 8d42c36

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/pyrad_tests_base_dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches: [ dev ]
77
pull_request:
88
branches: [ dev ]
9+
workflow_dispatch:
910

1011
jobs:
1112
unit_tests:

src/pyrad_proc/pyrad/io/read_data_sensor.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
import json
4242
import datetime
4343
import csv
44+
import pandas as pd
4445
from warnings import warn
4546
from copy import deepcopy
4647
import re
4748
from io import StringIO, BytesIO
48-
import pandas as pd
4949
import requests
5050
import numpy as np
5151
from zipfile import ZipFile
@@ -972,8 +972,8 @@ def read_trt_data(fname):
972972
973973
Returns
974974
-------
975-
A dict containing the read values in a list for every key. Lists are empty
976-
if trt file could not be read.
975+
A dict containing the read values in a numpy array for every key. If the file could
976+
not be read only None will be returned.
977977
978978
"""
979979
try:
@@ -986,6 +986,20 @@ def read_trt_data(fname):
986986
dict_trt = {key: [] for key in all_trt_keys}
987987
for key in all_trt_keys:
988988
dict_trt[key].append(feat["properties"][key])
989+
990+
# Use pandas to map string to float/int
991+
df = pd.DataFrame(dict_trt)
992+
for col in df.columns:
993+
try:
994+
df[col] = pd.to_numeric(df[col])
995+
except ValueError:
996+
continue
997+
998+
# convert back to dict
999+
dict_trt = df.to_dict(orient="list")
1000+
for key in dict_trt:
1001+
dict_trt[key] = np.array(dict_trt[key])
1002+
9891003
return dict_trt
9901004

9911005
except EnvironmentError as ee:

0 commit comments

Comments
 (0)