Commit 49d528a6 authored by Paulo Medeiros's avatar Paulo Medeiros
Browse files

Add option "--selected_stations" to csv2obsoul

parents 0a70c72d 8e4c53da
Pipeline #9236 passed with stages
in 1 minute and 12 seconds
......@@ -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,27 @@ 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,
......
......@@ -7,7 +7,7 @@
[tool.poetry]
name = "netatmoqc"
version = "0.3.4.dev1"
version = "0.3.4.dev2"
description = "Use machine learning clustering methods to perform quality control over NetAtmo data"
authors = [
"Paulo V. C. Medeiros <paulo.medeiros@smhi.se>"
......
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