From fd3e191cfc97c540871efb1299bac8240de31cc9 Mon Sep 17 00:00:00 2001 From: Federico Lolli <federico.lolli@skywarder.eu> Date: Fri, 22 Mar 2024 00:30:42 +0100 Subject: [PATCH] Added Python tools --- .gitignore | 6 ++++++ tools/.python-version | 1 + tools/README.md | 3 +++ tools/pyproject.toml | 34 +++++++++++++++++++++++++++++++ tools/requirements-dev.lock | 33 ++++++++++++++++++++++++++++++ tools/requirements.lock | 33 ++++++++++++++++++++++++++++++ tools/src/tools/__init__.py | 40 +++++++++++++++++++++++++++++++++++++ 7 files changed, 150 insertions(+) create mode 100644 tools/.python-version create mode 100644 tools/README.md create mode 100644 tools/pyproject.toml create mode 100644 tools/requirements-dev.lock create mode 100644 tools/requirements.lock create mode 100644 tools/src/tools/__init__.py diff --git a/.gitignore b/.gitignore index 3447ee4..f3ad40e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ +# rust target/ arpist build + +# python .cache/ +.ipynb_checkpoints/ +__pycache__/ +tools/dist diff --git a/tools/.python-version b/tools/.python-version new file mode 100644 index 0000000..8531a3b --- /dev/null +++ b/tools/.python-version @@ -0,0 +1 @@ +3.12.2 diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..7fb9a67 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,3 @@ +# tools + +Describe your project here. \ No newline at end of file diff --git a/tools/pyproject.toml b/tools/pyproject.toml new file mode 100644 index 0000000..17583c1 --- /dev/null +++ b/tools/pyproject.toml @@ -0,0 +1,34 @@ +[project] +name = "tools" +version = "0.1.0" +description = "Add your description here" +authors = [{ name = "Federico Lolli", email = "federico.lolli@skywarder.eu" }] +dependencies = [ + "fire==0.6.0", + "numpy==1.26.4", + "pandas==2.2.1", + "python-dateutil==2.9.0.post0", + "pytz==2024.1", + "six==1.16.0", + "termcolor==2.4.0", + "tzdata==2024.1", +] +readme = "README.md" +requires-python = ">= 3.8" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project.scripts] +tools = "tools:main" + +[tool.rye] +managed = true +dev-dependencies = [] + +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.wheel] +packages = ["src/tools"] diff --git a/tools/requirements-dev.lock b/tools/requirements-dev.lock new file mode 100644 index 0000000..cacd42d --- /dev/null +++ b/tools/requirements-dev.lock @@ -0,0 +1,33 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false + +-e file:. +fire==0.6.0 + # via tools +numpy==1.26.4 + # via pandas + # via tools +pandas==2.2.1 + # via tools +python-dateutil==2.9.0.post0 + # via pandas + # via tools +pytz==2024.1 + # via pandas + # via tools +six==1.16.0 + # via fire + # via python-dateutil + # via tools +termcolor==2.4.0 + # via fire + # via tools +tzdata==2024.1 + # via pandas + # via tools diff --git a/tools/requirements.lock b/tools/requirements.lock new file mode 100644 index 0000000..cacd42d --- /dev/null +++ b/tools/requirements.lock @@ -0,0 +1,33 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false + +-e file:. +fire==0.6.0 + # via tools +numpy==1.26.4 + # via pandas + # via tools +pandas==2.2.1 + # via tools +python-dateutil==2.9.0.post0 + # via pandas + # via tools +pytz==2024.1 + # via pandas + # via tools +six==1.16.0 + # via fire + # via python-dateutil + # via tools +termcolor==2.4.0 + # via fire + # via tools +tzdata==2024.1 + # via pandas + # via tools diff --git a/tools/src/tools/__init__.py b/tools/src/tools/__init__.py new file mode 100644 index 0000000..d4fdfb8 --- /dev/null +++ b/tools/src/tools/__init__.py @@ -0,0 +1,40 @@ +import fire +import pandas as pd +from pathlib import Path + + +def convert(file: Path): + # read csv + pdf = pd.read_csv(file) + + # columns to delete + to_del = ["left_servo_angle", "right_servo_angle", "wes_n", "wes_e", "wes_state"] + + # new columns + new_c = [ + "pressure_ada", + "pressure_dpl", + "ada_vert_speed", + "mea_mass", + "abk_angle", + "pin_quick_connector", + "ada_state", + "dpl_state", + "abk_state", + "mea_state", + "pin_launch", + "pin_expulsion", + ] + + # drop columns + df = pdf.drop(columns=to_del) + # add new columns (all 0) + for c in new_c: + df[c] = 0 + + # save to new file + df.to_csv("gemini_rocket.csv", index=False) + + +def main(): + fire.Fire(convert) -- GitLab