Commit d104602d authored by Wit, Allard de's avatar Wit, Allard de
Browse files

Small changes to grompy commandline tools

parent 2a02e4e9
......@@ -45,4 +45,4 @@ def main():
if __name__ == "__main__":
cli()
\ No newline at end of file
cli()
......@@ -13,6 +13,9 @@ def init(input_path=None):
if input_path is None:
input_path = Path.cwd()
else:
input_path = Path(input_path)
input_path = input_path.absolute()
yaml_conf = yaml_conf.format(input_path=input_path)
yaml_output_fname = Path.cwd() / "grompy.yaml"
......
......@@ -7,7 +7,6 @@ from csv import DictReader
import time
import multiprocessing as mp
import traceback
import math
import sqlalchemy as sa
import sqlalchemy.exc
......@@ -16,7 +15,7 @@ import geopandas as gpd
import numpy as np
import yaml
from .util import count_lines, prepare_db, printProgressBar
from .util import prepare_db, printProgressBar
dummy_date = "19000101"
......@@ -68,6 +67,7 @@ def load_parcel_info(dsn, counts_file, shape_file, table_name):
engine = sa.create_engine(dsn)
df_out.to_sql(table_name, engine, if_exists="replace", index=False)
df_out = df = df_counts = None
def process_rows(rows):
......@@ -82,7 +82,8 @@ def process_rows(rows):
fieldIDs = []
for column_name, row in rows.items():
fieldIDs.append(int(row.pop("field_ID")))
count = row.pop("count")
if "count" in row:
count = row.pop("count")
recs = []
for sdate, value in row.items():
value = float(value)
......@@ -93,10 +94,7 @@ def process_rows(rows):
# We add one dummy record to make sure we can create the dataframe properly
recs.append({"day": dummy_date, "value": None, "band": column_name})
df_tmp = pd.DataFrame(recs)
try:
df_tmp["day"] = pd.to_datetime(df_tmp.day).dt.date
except:
pass
df_tmp["day"] = pd.to_datetime(df_tmp.day).dt.date
df = pd.concat([df, df_tmp])
df = df.pivot(index="day", columns="band", values="value")
df.reset_index(inplace=True)
......@@ -232,6 +230,7 @@ def load_data(yaml_file):
grompy_conf = yaml.safe_load(open(yaml_file))
# First load parcel info
print("Start loading parcel information. This will take some time...")
parcel_info = grompy_conf.pop("parcel_info")
load_parcel_info(**parcel_info)
......
Markdown is supported
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