Commit 70510f1c authored by Markus Koskela's avatar Markus Koskela Committed by Paulo Medeiros
Browse files

Add option "--selected_stations" to csv2obsoul

parent 0a70c72d
......@@ -183,6 +183,17 @@ def get_parsed_args(program_name):
nargs="+",
metavar="data_column=fillna_value_for_col",
)
parser_csv2obsoul.add_argument(
"--selected_stations",
metavar="STATIONS_FILE_PATH",
default=None,
type=Path,
help=(
"Path to the optional selected stations file. If specified, "
+ "then only these stations are kept."
),
)
parser_csv2obsoul.set_defaults(func=csv2obsoul)
###########################################
......
......@@ -445,11 +445,24 @@ def csv2obsoul(args):
# Allow mkdir to raise eventual exceptions if cannot write to outdir
outdir.mkdir(parents=True)
if args.selected_stations is not None:
if str(args.selected_stations).endswith(".csv"):
selected_stations = pd.read_csv(args.selected_stations)["id"]
logger.info("Read %s stations from file '%s'",
len(selected_stations), args.selected_stations)
else:
logger.warning(
"Only csv files supported. Skipping file '%s'",
args.selected_stations
)
selected_stations = None
netatmoqc_input2output(
config.general.dtgs,
netatmo_data_rootdir=config.general.data_rootdir,
dropna=args.dropna,
fillna=args.fillna,
selected_stations=selected_stations,
rm_duplicate_stations=args.rm_duplicate_stations,
rm_moving_stations=args.rm_moving_stations,
outdir=outdir,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment