project reorganization: 1. executable files in bin directory now. 2. add recursive_unpack_targz.py for recursive unpacking specified in this script archives tar.gz with MVN data. 3. add asotr_unzip_plot.sh bash file for unpacking MVN data, collect asotr data into csv files and plot asotr MVN data. 4. add brd_wheel_1Hz_parser.py for demonstrate how to work with brd telemetry data

This commit is contained in:
Danila Gamkov
2025-06-06 10:54:25 +03:00
parent 2f37a7329b
commit b04009ad27
34 changed files with 2151 additions and 138 deletions

560
asotr_csv/Cargo.lock generated Normal file
View File

@@ -0,0 +1,560 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys",
]
[[package]]
name = "asotr_csv"
version = "0.1.0"
dependencies = [
"byteorder",
"chrono",
"clap",
"lazy_static",
"regex",
"strum",
"walkdir",
]
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets",
]
[[package]]
name = "clap"
version = "4.5.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "iana-time-zone"
version = "0.1.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
dependencies = [
"spin",
]
[[package]]
name = "libc"
version = "0.2.169"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
[[package]]
name = "log"
version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "proc-macro2"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "rustversion"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "syn"
version = "2.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

15
asotr_csv/Cargo.toml Normal file
View File

@@ -0,0 +1,15 @@
[package]
name = "asotr_csv"
version = "0.1.0"
edition = "2021"
authors = ["Danila Gamkov <danila_gamkov@cosmos.ru"]
description = "The parser for converting data from the ASOTR MVN control channels into the CSV format (see files in asotr.tar.gz)"
[dependencies]
byteorder = "1.4.3"
chrono = "0.4"
strum = { version = "0.26", features = ["derive"] }
clap = { version = "4.*", features = ["derive"] }
lazy_static = { version = "1.5.0", features = ["spin_no_std"] }
regex = "1.7.0"
walkdir = "2.3.2"

122
asotr_csv/README.markdown Normal file
View File

@@ -0,0 +1,122 @@
# asotr_csv
The parser for converting data from the ASOTR MVN control channels into the CSV format
## Contents
- **Setup**
- **Using**
- parsing ASOTR MVN data files in specified directory
- parsing all ASOTR MVN data files in specified directory and subdirectories
- plot data in python
- **Output asotr_csv data files description**
- **Contacts**
**Note**: \<PATH_TO_ASOTR_CSV\> - path where is asotr_csv program is cloned from heagit
## Setup
1. Install Rust compiler (if you don't have).
Installation on Linux:
```
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
```
Installation on Windows:
Go to address https://www.rust-lang.org/tools/install and follow instructions
For more detailed information you can go to: https://doc.rust-lang.ru/book/ch01-01-installation.html
**Instruction for setup asotr_csv project**
2. Clone the repo to your computer:
```
git clone http://heagit.cosmos.ru/gamkov/asotr_csv.git
```
3. Enter the repo and compile it:
```
cd <PATH_TO_ASOTR_CSV>
cargo build --release
```
After running this commands you will get an execution file (asotr_csv) in the following directory:
\<PATH_TO_ASOTR_CSV\>/target/release/
## Using
### Parsing ASOTR MVN data files in specified directory
1. Donwload data from science data server to directory \<PATH_TO_ASOTR_DATA\>.
If you don't have MVN data, you might download it from server with science SRG data (IP: 193.232.11.95).
For questions about downloading science data contact Shtykovsky A. (a.shtykovsky@cosmos.ru) or Chelovekov I. (chelovekov@cosmos.ru)
2. Run linux bash script **asotr_unzip.sh** for directory with MVN data in order to unpack **asotr.tar.gz** archive with ASOTR MVN data, for example:
```
cd <PATH_TO_ASOTR_CSV>
./asotr_unzip.sh <PATH_TO_ASOTR_DATA>/20241231-001
```
**Note**: the script **asotr_unzip.sh** will not work on windows, you will need to unpack the archive **\<PATH_TO_ASOTR_DATA\>/20241231-001/data/asotr.tar.gz** manually or write the corresponding Windows bat-file
3. Run program asotr_csv:
```
cd <PATH_TO_ASOTR_CSV>/target/release/
./asotr_csv -d <PATH_TO_ASOTR_DATA>/20241231-001
```
csv data are ready to use in directory:
\<PATH_TO_ASOTR_CSV\>/target/release/
### Parsing all ASOTR MVN data files in specified directory and subdirectories
1. Donwload data from science data server to directory \<PATH_TO_ASOTR_DATA\>.
If you don't have MVN data, you might download it from server with science SRG data (IP: 193.232.11.95).
For questions about downloading science data contact Shtykovsky A. (a.shtykovsky@cosmos.ru) or Chelovekov I. (chelovekov@cosmos.ru)
2. Run linux bash script **asotr_all_unzip.sh** for directory with MVN data in order to unpack all **asotr.tar.gz** archives with ASOTR MVN data, for example:
```
cd <PATH_TO_ASOTR_CSV>
./asotr_all_unzip.sh <PATH_TO_ASOTR_DATA>/
```
**Note**: the script **asotr_all_unzip.sh** will not work on windows, you will need to unpack the each archive **\<PATH_TO_ASOTR_DATA\>/\<DIRECTORY_WITH_DATA\>/data/asotr.tar.gz** manually or write the corresponding Windows bat-file
If you want to parse astor data in specified directory, run program asotr_csv directly:
```
cd <PATH_TO_ASOTR_CSV>/target/release/
./asotr_csv -d <PATH_TO_ASOTR_DATA>
```
Or if you want to parse all raw data from ASOTR into csv files and plot csv data you might use shell script:
```
cd <PATH_TO_ASOTR_CSV>
./asotr_all_unzip_auto.sh <PATH_TO_ASOTR_DATA>/
```
csv data will be in directory:
\<PATH_TO_ASOTR_CSV\>/data/
### Plot csv data in Python
If you want to parse all raw data from astor into csv files and plot csv data you might use shell script:
```
cd <PATH_TO_ASOTR_CSV>
./asotr_all_unzip_auto.sh
```
or if you already have csv files with ASOTR data, you might use plot script only:
```
cd <PATH_TO_ASOTR_CSV>/data/
python3 plot_flight_all.py
```
## Output asotr_csv data files description
**description:**
asotr01_data_T.csv - ASOTR1 temperature data in channels 1-6 (in Celsius)
asotr01_data_P.csv - ASOTR1 power data in channels 1-6 (in %)
asotr01_data_TSET.csv - ASOTR1 temperature sets in channels 1-6 (in Celsius)
asotr02_data_T.csv - ASOTR2 temperature data in channels 1-6 (in Celsius)
asotr02_data_P.csv - ASOTR2 power data in channels 1-6 (in %)
asotr02_data_TSET.csv - ASOTR2 temperature sets in channels 1-6 (in Celsius)
**file data csv fromat:**
column 1: Unix timestamp in seconds
column 2: timestamp (data and time)
columns 3-8 - data from control channels (power, temperature or temperature set)
## Contatcs
For questions about the program, please contact Danila Gamkov, email: danila_gamkov@cosmos.ru

View File

@@ -0,0 +1,16 @@
#! /bin/bash
if [ $# != 1 ]
then
echo "erorr use $0. Right use this script: "
echo "$0 path"
else
cp ../asotr_csv/target/release/asotr_csv ../data/asotr
path_=$1
find ${path_} -maxdepth 1 -type d | xargs -I {} ./asotr_unzip.sh {}
cd ../data/asotr
./asotr_csv -d ${path_}
python3 ../../bin/plot_asotr_flight_all.py
fi

30
asotr_csv/data/prepare_csv.sh Executable file
View File

@@ -0,0 +1,30 @@
#! /bin/bash
if [ $# != 2 ]
then
echo "error use $0. Right use this script: "
echo "$0 path_to_file data_type (flight or KDI)"
echo "example 1: $0 ./data/flight/30_12_2024/ASOTR_1_SOTR_T flight"
else
data_file=$1
data_type=$2
if [ "$data_type" == "flight" ]
then
cat ${data_file}.csv | grep -Eo '[0-9]{2}\.[0-9]{2}\.[0-9]{4}' > file1
cat ${data_file}.csv | grep -Eo [0-9]{2}:.* > file2
elif [ "$data_type" == "KDI" ]
then
cat ${data_file}.csv | grep -Eo [0-9]{2}.[0-9]{2}.[0-9]{4} > file1
cat ${data_file}.csv | grep -Eo [0-9]{2}:.* > file2
else
echo "error argument of data_type: write \"flight\" or \"KDI\" in second argument"
exit 1
fi
paste --delimiter=' ' file1 file2 > file.csv
echo "timestamp;ch1;ch2;ch3;ch4;ch5;ch6" > ${data_file}_clear.csv
cat file.csv >> ${data_file}_clear.csv
rm file1 file2 file.csv
fi

132
asotr_csv/src/.vimrc Normal file
View File

@@ -0,0 +1,132 @@
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set colorcolumn=90
highlight ColorColumnt ctermbg=darkgray
augroup project
autocmd!
autocmd BufRead,BufNewFile *.h,*.c set filetype=c.doxygen
augroup END
let &path.="src/include, src/source,"
" Включаем использование системного буфера
set clipboard=unnamedplus
" Работа с текстом
" Python использует 4 пробела для отступов
autocmd FileType python setlocal tabstop=4 shiftwidth=4
" Кодировка текста
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,cp1251,koi8-r,cp866
" Поиск по тексту
set hlsearch " подсвечивать результаты поиска
" Перемещение по тексту
" Когда достигаем границ строки, то перемещаемся на предыдующую/следующую
set whichwrap+=h,l,<,>,[,]
set number
" Настройки автодополнения
set completeopt=menu,menuone,noselect
" Разделение экрана
set splitbelow " разбивать вниз
set splitright " разбивать вправо
" сочетание клавиш
" Использование h, j, k, l для перемещения с зажатым Ctrl в режиме
" редактирования
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
let g:mapleader = "\<Space>"
" Переключение между вкладками
nnoremap <leader>t :tabnext<CR>
nnoremap <leader>T :tabprevious<CR>
" Список вкладок
nnoremap <leader>tl :tabs<CR>
" nnoremap <leader>tn :tabnew<CR>
nnoremap <leader>tc :tabclose<CR>
nnoremap <leader>to :tabonly<CR>
nnoremap <leader>tm :tabmove<CR>
" Редактировать файл в новой вкладке
nnoremap <leader>te :tabedit |
" Выбор вкладки
nnoremap <leader>1 1gt
nnoremap <leader>2 2gt
nnoremap <leader>3 3gt
nnoremap <leader>4 4gt
nnoremap <leader>5 5gt
nnoremap <leader>6 6gt
nnoremap <leader>7 7gt
nnoremap <leader>8 8gt
nnoremap <leader>9 9gt
nnoremap <leader>0 :tablast<CR>
" Разбиение окон
nnoremap <leader>s :split<CR>
nnoremap <leader>v :vsplit<CR>
" Выбор окна
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Размер окна
nnoremap <C-u> <C-w>+
nnoremap <C-d> <C-w>-
nnoremap <C-p> <C-w><
nnoremap <C-n> <C-w>>
" Vimspector
" nnoremap <leader><F2> <F10>
" nnoremap <leader>q <F11>
nmap <Leader><Right> <Plug>VimspectorStepOver
nmap <Leader><Down> <Plug>VimspectorStepInto
nmap <Leader><Up> <Plug>VimspectorStepOut
nmap <Leader><Tab> <Plug>VimspectorDisassemble
" Сделать окна одного размера
nnoremap <leader>= <C-w>=
" Переключения между буферами
" nnoremap <leader>b :bnext<CR>
" nnoremap <leader>B :bprevious<CR>
" nnoremap <leader>l :ls<CR>
" nnoremap <leader>d :bd<CR>
" " Скрыть/раскрыть блок кода
" nnoremap <leader>z za
" настройка плагинов
" настройки для отступов
" let g:indent_guides_enable_on_vim_startup = 1
" Настройки для разноцветной подсветки скобок
let g:rainbow_active = 1
" Настройки для vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_powerline_fonts = 1
let g:airline_solarized_bg = 'luna'
let g:vimspector_enable_mappings = 'HUMAN'

355
asotr_csv/src/main.rs Normal file
View File

@@ -0,0 +1,355 @@
use clap::{Parser};
pub mod asotr_data {
use std::{fs::File, io::Read};
use byteorder::{LittleEndian, ReadBytesExt};
use chrono::{DateTime, Utc};
use std::time::{SystemTime, UNIX_EPOCH, Duration};
use strum::FromRepr;
use lazy_static::lazy_static;
use regex::Regex;
use walkdir::WalkDir;
lazy_static! {
pub static ref support_dtypes: String =
String::from(".data01.asotr01(02), data02.asotr01(02), data06.asotr01(02)");
pub static ref patterns_fnames_csv_data: Vec<(String, String)> = {
let mut patterns: Vec<(String, String)> = Vec::new();
patterns.push((String::from(".*data01.asotr01"),
String::from("../data/asotr/asotr01_data_T.csv")));
patterns.push((String::from(".*data02.asotr01"),
String::from("../data/asotr/asotr01_data_P.csv")));
patterns.push((String::from(".*data06.asotr01"),
String::from("../data/asotr/asotr01_data_TSET.csv")));
patterns.push((String::from(".*data01.asotr02"),
String::from("../data/asotr/asotr02_data_T.csv")));
patterns.push((String::from(".*data02.asotr02"),
String::from("../data/asotr/asotr02_data_P.csv")));
patterns.push((String::from(".*data06.asotr02"),
String::from("../data/asotr/asotr02_data_TSET.csv")));
patterns
};
pub static ref patterns_disp: Vec<String> = {
let mut patterns: Vec<String> = Vec::new();
patterns.push(String::from("ASOTR01 temperature"));
patterns.push(String::from("ASOTR01 power"));
patterns.push(String::from("ASOTR01 temperature setpoint"));
patterns.push(String::from("ASOTR02 temperature"));
patterns.push(String::from("ASOTR02 power"));
patterns.push(String::from("ASOTR02 temperature setpoint"));
patterns
};
}
#[derive(Debug, FromRepr, PartialEq)]
enum AsotrDataType {
Temp = 1,
Pow = 2,
TempSet = 6,
}
struct AsotrDataDesc {
time_s: u64,
time_mks: u32,
date: String,
time: String,
data_type: AsotrDataType,
// kit: u8,
}
impl AsotrDataDesc {
pub fn new(time_s: u64, time_mks: u32, date: String, time: String,
data_type: AsotrDataType) -> AsotrDataDesc {
AsotrDataDesc { time_s, time_mks, date, time, data_type }
}
}
pub fn read_data(filename_full: String) -> Result<String, String> {
let ch_u16: [u16; 6];
let ch_f32: [f32; 6];
let asotr_head = parse_filename(filename_full.clone())?;
let mut buf = Vec::new();
let mut out = String::new();
let mut data = match File::open(filename_full.clone())
{
Ok(file) => file,
Err(msg) => { return Err(format!("Error opening data file {}: {}", filename_full, msg)) }
};
match data.read_to_end(&mut buf) {
Ok(stat) => stat,
Err(msg) => { return Err(format!("Error reading data file {}: {}", filename_full, msg)) }
};
out.push_str(&format!("{};{} {}.{:02};",
&asotr_head.time_s,
&asotr_head.date,
&asotr_head.time,
asotr_head.time_mks));
if asotr_head.data_type == AsotrDataType::Temp ||
asotr_head.data_type == AsotrDataType::TempSet {
ch_f32 = parse_data_f32(buf)?;
for elem in ch_f32 {
out.push_str(&elem.to_string());
out.push(';');
}
}
else if asotr_head.data_type == AsotrDataType::Pow {
ch_u16 = parse_data_u16(buf)?;
for elem in ch_u16 {
out.push_str(&elem.to_string());
out.push(';');
}
}
out.remove(out.len() - 1);
return Ok(out);
}
pub fn parse_data_dir(dir: &str, disp: bool) -> Result<(), String> {
let mut data: Vec<String> = Vec::new();
println!("parse data from directory: {}", dir);
for (i, (pattern, fname)) in patterns_fnames_csv_data.iter().enumerate() {
let files = find_files_regex(dir, pattern)?;
for elem in files {
data.push(read_data(elem)?);
}
data.sort();
data.dedup();
if disp { disp_data(&data, &patterns_disp[i])?; }
println!("save csv data to file: {}", fname);
save_data_csv(data.clone(), fname)?;
data.clear();
}
return Ok(());
}
fn parse_data_f32(buf: Vec<u8>) -> Result<[f32; 6], String> {
let mut data = &buf[..];
let mut ch: [f32; 6] = [0.0; 6];
for i in 0..6 {
ch[i] = match data.read_f32::<LittleEndian>() {
Ok(val) => val,
Err(msg) => {
return Err(format!(
"Error parsing file: failed parsing float32 data: {}", msg)); }
}
}
return Ok(ch);
}
fn parse_data_u16(buf: Vec<u8>) -> Result<[u16; 6], String> {
let mut data = &buf[..];
let mut ch: [u16; 6] = [0; 6];
for i in 0..6 {
ch[i] = match data.read_u16::<LittleEndian>() {
Ok(val) => val,
Err(msg) => {
return Err(format!(
"Error parsing file: failed parsing uint16 data: {}", msg)); }
}
}
return Ok(ch);
}
fn parse_filename(filename_full: String) -> Result<AsotrDataDesc, String> {
let mut fname = String::new();
let msg_prev = format!("Error parsing filename {}:", filename_full);
match filename_full.rfind('/') {
Some(val) => { fname = (filename_full[val+1..filename_full.len()]).to_string(); }
_ => { fname = filename_full.clone(); }
}
if fname.len() != 32 {
return Err(format!("{} unsupported file", msg_prev));
}
let time_unix_ = fname[0..10].parse::<u64>();
let time_unix = match &time_unix_ {
Ok(data) => data,
Err(msg) => {
return Err(format!("{} expected digits in timestamp sec part ({})",
msg_prev, msg));
}
};
let data_type_ = fname[22..24].parse::<u8>();
let data_type_u8 = match &data_type_ {
Ok(data) => data,
Err(msg) => {
return Err(format!("{} expected digits in data type part ({})",
msg_prev, msg));
}
};
if *data_type_u8 == 1 || *data_type_u8 == 2 || *data_type_u8 == 6 { }
else {
return Err(format!("{} parser supports data types: {}",
msg_prev, support_dtypes.to_string()));
}
let data_type = match AsotrDataType::from_repr(*data_type_u8 as usize) {
Some(value) => value,
_ => return Err(format!("{} expected digits in data type part",
msg_prev))
};
// let _kit = filename[30..32].parse::<u8>();
// let kit = match &_kit {
// Ok(data) => data,
// Err(msg) => { return Err(format!("{}: expected digits in asotr kit part ({})",
// msg_prev, msg)); }
// };
let _time_str_mks = fname[11..14].parse::<u32>();
let time_mks = match &_time_str_mks {
Ok(data) => data,
Err(msg) => { return Err(format!("{}: expected digits in timestamp mks part ({})",
msg_prev, msg)); }
};
let time: SystemTime = UNIX_EPOCH + Duration::from_secs(*time_unix);
let date_time = DateTime::<Utc>::from(time);
let date_s = date_time.format("%d.%m.%Y").to_string();
let time_s = date_time.format("%H:%M:%S").to_string();
let head = AsotrDataDesc::new(*time_unix, *time_mks, date_s, time_s, data_type);
return Ok(head);
}
fn find_files_regex(dir: &str, template: &str) -> Result<Vec<String>, String> {
let mut path_vec: Vec<String> = Vec::new();
let regex = match Regex::new(template) {
Ok(val) => val,
Err(msg) => {
return Err(format!("Error create regex template ({}): {}",
template, msg));
}
};
let data = WalkDir::new(dir)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| regex.is_match(e.file_name().to_str().unwrap()))
.map(|e| e.into_path());
for elem in data {
path_vec.push(elem.display().to_string());
}
if path_vec.len() == 0 {
return Err(format!(
"Error searching files for pattern ({}): files not found in directory {}",
template, dir));
}
return Ok(path_vec);
}
fn disp_data(data: &Vec<String>, about: &str) -> Result<(), String> {
println!("{}", about);
println!("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
"timestamp_sec", "timestamp",
"ch1", "ch2", "ch3", "ch4", "ch5", "ch6");
for elem in data {
println!("{}", elem.replace(';', "\t"));
}
return Ok(())
}
fn save_data_csv(data: Vec<String>, fname: &str) -> Result<(), String> {
let mut data_w: Vec<String> = Vec::new();
data_w.push(format!("{};{};{};{};{};{};{};{}",
"timestamp_sec", "timestamp",
"ch1", "ch2", "ch3", "ch4", "ch5", "ch6"));
for elem in data {
data_w.push(elem);
}
match std::fs::write(fname, data_w.join("\n")) {
Ok(f) => f,
Err(msg) => {
return Err(format!("Error write data to csv file {}: {}", fname, msg))
}
}
return Ok(());
}
}
#[derive(Parser, Debug)]
#[command(version, author, about, long_about = None)]
struct Cli {
/// file with ASOTR MVN data (.data01.asotr01(02), data02.asotr01(02), data06.asotr01(02))
#[arg(long, short = 'f', value_name = "FILE_DATA")]
filename: Option<String>,
/// directory with ASOTR MVN data
#[arg(long, short = 'd', value_name = "DIRECTORY_DATA")]
directory: Option<String>,
/// show data in console
#[arg(short = 's')]
show: bool,
}
fn main() {
use crate::asotr_data::*;
let cli = Cli::parse();
let show = cli.show;
if let Some(fname) = &cli.filename {
let s = match read_data(fname.clone()) {
Ok(elem) => elem,
Err(msg) => { println!("{}", msg); return; }
};
println!("{}", s);
return;
}
if let Some(dir) = &cli.directory {
match parse_data_dir(&dir.clone(), show) {
Ok(elem) => elem,
Err(msg) => { println!("{}", msg); return; }
}
return;
}
println!("Unexpected command. Type --help for more iformation");
}

View File

@@ -0,0 +1 @@
{"rustc_fingerprint":2742313010855374649,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/danila/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.83.0 (90b35a623 2024-11-26)\nbinary: rustc\ncommit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\ncommit-date: 2024-11-26\nhost: x86_64-unknown-linux-gnu\nrelease: 1.83.0\nLLVM version: 19.1.1\n","stderr":""}},"successes":{}}

View File

@@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/