From 9703d9c1371eadada1a2736408a30bf3b8fa0bf9 Mon Sep 17 00:00:00 2001 From: Sulaiman Ghori Date: Fri, 13 Sep 2024 18:20:26 -0700 Subject: [PATCH] :sparkles: (Optimizer) Implement tycho2 autodownloader + autorun optimizer --- CMakeLists.txt | 31 - Cargo.lock | 1240 +++++++++++++++++++++++++++++++++++++-- Cargo.toml | 8 +- README.md | 73 +-- bin/Activate.ps1 | 247 -------- bin/activate | 70 --- bin/activate.csh | 27 - bin/activate.fish | 69 --- bin/pip | 8 - bin/pip3 | 8 - bin/pip3.12 | 8 - bin/python | 1 - bin/python3 | 1 - bin/python3.12 | 1 - pyproject.toml | 2 +- src/bin/optimize.rs | 106 ---- src/constants.rs | 4 + src/lib.rs | 4 +- src/main.rs | 15 +- src/optimize.rs | 101 ++++ src/parse_and_render.rs | 74 ++- src/parsing_utils.rs | 46 +- src/render.cpp | 359 ------------ src/types/args.rs | 14 +- 24 files changed, 1447 insertions(+), 1070 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 bin/Activate.ps1 delete mode 100644 bin/activate delete mode 100644 bin/activate.csh delete mode 100644 bin/activate.fish delete mode 100755 bin/pip delete mode 100755 bin/pip3 delete mode 100755 bin/pip3.12 delete mode 120000 bin/python delete mode 120000 bin/python3 delete mode 120000 bin/python3.12 delete mode 100644 src/bin/optimize.rs create mode 100644 src/constants.rs create mode 100644 src/optimize.rs delete mode 100644 src/render.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 2005a3b..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.16.3) -project(starfinder) - - -add_compile_options(-std=c++17) - - -find_package(Boost REQUIRED COMPONENTS - program_options -) - -find_package(OpenCV REQUIRED) - - -include_directories( - ${Boost_INCLUDE_DIRS} - ${OpenCV_INCLUDE_DIRS} -) - - -add_executable(${PROJECT_NAME}_render - src/render.cpp -) -target_link_libraries(${PROJECT_NAME}_render - ${Boost_LIBRARIES} - ${OpenCV_LIBRARIES} -) -set_target_properties(${PROJECT_NAME}_render - PROPERTIES - OUTPUT_NAME render -) diff --git a/Cargo.lock b/Cargo.lock index 574bca9..5dfa166 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -56,7 +65,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -66,14 +75,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "approx" @@ -107,6 +116,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -136,6 +151,27 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide 0.8.0", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bit_field" version = "0.10.2" @@ -148,6 +184,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "bitstream-io" version = "2.5.3" @@ -184,6 +226,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cc" version = "1.1.18" @@ -263,6 +311,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crc32fast" version = "1.4.2" @@ -324,18 +388,58 @@ dependencies = [ "memchr", ] +[[package]] +name = "directories" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "exr" version = "1.72.0" @@ -352,6 +456,12 @@ dependencies = [ "zune-inflate", ] +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "fdeflate" version = "0.3.4" @@ -380,6 +490,86 @@ dependencies = [ "spin", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -401,6 +591,31 @@ dependencies = [ "weezl", ] +[[package]] +name = "gimli" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -423,6 +638,135 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" version = "0.25.2" @@ -489,6 +833,12 @@ dependencies = [ "syn", ] +[[package]] +name = "ipnet" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -525,6 +875,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" +[[package]] +name = "js-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "lebe" version = "0.5.2" @@ -548,6 +913,22 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lock_api" version = "0.4.12" @@ -607,6 +988,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -632,6 +1019,18 @@ dependencies = [ "adler2", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "nalgebra" version = "0.33.0" @@ -659,6 +1058,23 @@ dependencies = [ "syn", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -681,6 +1097,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -741,44 +1167,147 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "object" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +dependencies = [ + "memchr", +] [[package]] -name = "paste" -version = "1.0.15" +name = "once_cell" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "pkg-config" -version = "0.3.30" +name = "openssl" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] [[package]] -name = "png" -version = "0.17.13" +name = "openssl-macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "bitflags", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide 0.7.4", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "portable-atomic" -version = "1.7.0" +name = "openssl-probe" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] -name = "ppv-lite86" +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "png" +version = "0.17.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.7.4", +] + +[[package]] +name = "portable-atomic" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" + +[[package]] +name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" @@ -1006,6 +1535,61 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "reqwest" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + [[package]] name = "rgb" version = "0.8.50" @@ -1015,6 +1599,80 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.18" @@ -1030,12 +1688,44 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.210" @@ -1056,6 +1746,18 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.7" @@ -1065,6 +1767,27 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1099,12 +1822,31 @@ dependencies = [ "quote", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spec_math" version = "0.1.5" @@ -1122,16 +1864,21 @@ dependencies = [ [[package]] name = "starfinder" -version = "1.2.1" +version = "1.3.0" dependencies = [ + "anyhow", "clap", "csv", + "directories", "image", "nalgebra", "pyo3", + "reqwest", "serde", "spec_math", "thiserror", + "tracing", + "tracing-subscriber", ] [[package]] @@ -1140,6 +1887,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.77" @@ -1151,6 +1904,36 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -1170,6 +1953,19 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -1190,6 +1986,16 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tiff" version = "0.9.1" @@ -1201,6 +2007,70 @@ dependencies = [ "weezl", ] +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.8.19" @@ -1235,17 +2105,122 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] [[package]] name = "unindent" @@ -1253,6 +2228,23 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.2" @@ -1270,12 +2262,33 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1308,6 +2321,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.93" @@ -1337,6 +2362,16 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "web-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "weezl" version = "0.1.8" @@ -1353,13 +2388,98 @@ dependencies = [ "safe_arch", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1368,28 +2488,46 @@ 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_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1402,24 +2540,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1456,6 +2618,12 @@ dependencies = [ "syn", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zune-core" version = "0.4.12" diff --git a/Cargo.toml b/Cargo.toml index 1e52bc3..517afa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "starfinder" -version = "1.2.1" +version = "1.3.0" edition = "2021" license-file = "LICENSE" description = "starfinder is a Rust & Python package that provides functionality to read, process, and render star data from the Tycho-2 catalog. It's built with Rust for performance and exposes a Python API for ease of use." @@ -12,17 +12,21 @@ exclude = [ "images/*", "spaceros/*", ] -default-run = "starfinder" [dependencies] +anyhow = "1.0.88" clap = { version = "4.5.16", features = ["derive"] } csv = "1.3.0" +directories = "5.0.1" image = "0.25.2" nalgebra = "0.33.0" pyo3 = "0.22.2" +reqwest = { version = "0.12.7", features = ["blocking"] } serde = { version = "1.0.209", features = ["derive"] } spec_math = "0.1.5" thiserror = "1.0.63" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/README.md b/README.md index e5bd92f..6985070 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Pictured above: Example Starfinder output -[Here is a real result of successful analysis](https://nova.astrometry.net/user_images/10943719#annotated) of an image generated by the renderer, submitted to nova.astrometry.net. The location that the engine calculated was accurate to ~1/10th of a second. This is likely attributable to rendering techniques that can be improved moving forward (there are already ideas in the pipeline). +[Here is a real result of successful analysis](https://nova.astrometry.net/user_images/10943719#annotated) of an image generated by the renderer, submitted to nova.astrometry.net. The location that the engine calculated was accurate to ~1/10th of a second. This is likely attributable to rendering techniques that can be improved moving forward (there are already ideas in the pipeline). ## Setup @@ -37,69 +37,36 @@ ### Using Cargo (Rust) -The first step in using the renderer is to optimize your data. The optimizer can optimize against -_any_ star catalog as long as it fulfills the following requirements: - -1) Contains star data in CSV (any separator is usable) -2) Star data includes right ascension and declination for each record. Currently, they must be in degrees. -3) Star data includes vt_mag or bt_mag, preferably both - -Specify the column number of each of these four data points when calling the optimizer (bt and vt -mag are optional, but at least one is required). You'll also need to include the max FOV dimension -of your sensor to optimize properly. If your FOV changes, you'll need to re-run the optimizer. -To optimize for the Tycho 2 catalog, run the following command: -```bash -cargo run --bin optimize -- --idx-ra 24 --idx-dec 25 --idx-bt-mag 17 --idx-vt-mag 19 --fov-max 60 -``` -For other catalogs that satisfy the optimizer's requirements, simply replace the index values above -with the column indexes for those items in your catalog's data file. - -If view changes, you will need to re-optimize with new fov_max. - -### Optimizer command-line arguments - -| Flag | Description | Default | Notes | -|--------------|------------------------------|---------------------------|------------------------------| -| --source, -s | Source file path | `data/tycho2/catalog.dat` | | -| --output, -o | Output filepath | `data/optimized.dat` | Recommend default | -| --separator | CSV file character separator | "|" | Tycho 2 data uses "|" | -| --idx-vt-mag | Index of vt_mag | | | -| --idx-bt-mag | Index of bt_mag | | | -| --idx-ra | Index of right ascension | | | -| --idx-dec | Index of declination | | | -| --fov-max | Max value of fov w/h | | | - - -### Running the renderer +### Running the renderer To run the renderer with default settings: ```bash -cargo run +cargo run --release ``` To run with custom arguments: ```bash -cargo run -- --roll 0.0 --fov-w 75.0 --fov-h 50.0 +cargo run --release -- --roll 0.0 --fov-w 75.0 --fov-h 50.0 ``` ### Command-line Arguments -| Flag | Description | Default | Notes | -|-----------------|----------------------------------|---------------------------|-------------------| -| --source, -s | Source file path | `data/tycho2/catalog.dat` | | -| --center-ra | FOV center point right ascension | 180.0 | In degrees | -| --center-dec | FOV center point declination | 0.0 | In degrees | -| --fov-w | Width of FOV | 60.0 | In degrees | -| --fov-h | Height of FOV | 45.0 | In degrees | -| --roll | Camera sensor roll | 0.0 | In degrees | -| --max-magnitude | Maximum visual magnitude | 12.0 | Lower is brighter | -| --lambda-nm | Targeted wavelength | 540.0 | In nanometers | -| --pixel-size-m | Simulated sensor pixel size | 3e-6 | In meters | -| --width | Output image width | 800 | In pixels | -| --height | Output image height | 800 | In pixels | -| --output, -o | Output filename | `renders/star_map.png` | | +| Flag | Description | Default | Notes | +| --------------- | -------------------------------- | ---------------------- | ----------------- | +| --center-ra | FOV center point right ascension | 180.0 | In degrees | +| --center-dec | FOV center point declination | 0.0 | In degrees | +| --fov-w | Width of FOV | 60.0 | In degrees | +| --fov-h | Height of FOV | 45.0 | In degrees | +| --roll | Camera sensor roll | 0.0 | In degrees | +| --fov_max | Maximum FOV | 60.0 | In degrees | +| --max-magnitude | Maximum visual magnitude | 12.0 | Lower is brighter | +| --lambda-nm | Targeted wavelength | 540.0 | In nanometers | +| --pixel-size-m | Simulated sensor pixel size | 3e-6 | In meters | +| --width | Output image width | 800 | In pixels | +| --height | Output image height | 800 | In pixels | +| --output, -o | Output filename | `renders/star_map.png` | | ## Python Installation and Usage @@ -109,14 +76,14 @@ Ensure you have Python 3.8 or later, then: ```bash pip install starfinder -```` +``` Or if you want to install the package in development mode: ```bash pipx install maturin maturin develop -```` +``` ### Basic Usage diff --git a/bin/Activate.ps1 b/bin/Activate.ps1 deleted file mode 100644 index b49d77b..0000000 --- a/bin/Activate.ps1 +++ /dev/null @@ -1,247 +0,0 @@ -<# -.Synopsis -Activate a Python virtual environment for the current PowerShell session. - -.Description -Pushes the python executable for a virtual environment to the front of the -$Env:PATH environment variable and sets the prompt to signify that you are -in a Python virtual environment. Makes use of the command line switches as -well as the `pyvenv.cfg` file values present in the virtual environment. - -.Parameter VenvDir -Path to the directory that contains the virtual environment to activate. The -default value for this is the parent of the directory that the Activate.ps1 -script is located within. - -.Parameter Prompt -The prompt prefix to display when this virtual environment is activated. By -default, this prompt is the name of the virtual environment folder (VenvDir) -surrounded by parentheses and followed by a single space (ie. '(.venv) '). - -.Example -Activate.ps1 -Activates the Python virtual environment that contains the Activate.ps1 script. - -.Example -Activate.ps1 -Verbose -Activates the Python virtual environment that contains the Activate.ps1 script, -and shows extra information about the activation as it executes. - -.Example -Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv -Activates the Python virtual environment located in the specified location. - -.Example -Activate.ps1 -Prompt "MyPython" -Activates the Python virtual environment that contains the Activate.ps1 script, -and prefixes the current prompt with the specified string (surrounded in -parentheses) while the virtual environment is active. - -.Notes -On Windows, it may be required to enable this Activate.ps1 script by setting the -execution policy for the user. You can do this by issuing the following PowerShell -command: - -PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - -For more information on Execution Policies: -https://go.microsoft.com/fwlink/?LinkID=135170 - -#> -Param( - [Parameter(Mandatory = $false)] - [String] - $VenvDir, - [Parameter(Mandatory = $false)] - [String] - $Prompt -) - -<# Function declarations --------------------------------------------------- #> - -<# -.Synopsis -Remove all shell session elements added by the Activate script, including the -addition of the virtual environment's Python executable from the beginning of -the PATH variable. - -.Parameter NonDestructive -If present, do not remove this function from the global namespace for the -session. - -#> -function global:deactivate ([switch]$NonDestructive) { - # Revert to original values - - # The prior prompt: - if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { - Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt - Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT - } - - # The prior PYTHONHOME: - if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { - Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME - Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME - } - - # The prior PATH: - if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { - Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH - Remove-Item -Path Env:_OLD_VIRTUAL_PATH - } - - # Just remove the VIRTUAL_ENV altogether: - if (Test-Path -Path Env:VIRTUAL_ENV) { - Remove-Item -Path env:VIRTUAL_ENV - } - - # Just remove VIRTUAL_ENV_PROMPT altogether. - if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { - Remove-Item -Path env:VIRTUAL_ENV_PROMPT - } - - # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: - if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { - Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force - } - - # Leave deactivate function in the global namespace if requested: - if (-not $NonDestructive) { - Remove-Item -Path function:deactivate - } -} - -<# -.Description -Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the -given folder, and returns them in a map. - -For each line in the pyvenv.cfg file, if that line can be parsed into exactly -two strings separated by `=` (with any amount of whitespace surrounding the =) -then it is considered a `key = value` line. The left hand string is the key, -the right hand is the value. - -If the value starts with a `'` or a `"` then the first and last character is -stripped from the value before being captured. - -.Parameter ConfigDir -Path to the directory that contains the `pyvenv.cfg` file. -#> -function Get-PyVenvConfig( - [String] - $ConfigDir -) { - Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" - - # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). - $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue - - # An empty map will be returned if no config file is found. - $pyvenvConfig = @{ } - - if ($pyvenvConfigPath) { - - Write-Verbose "File exists, parse `key = value` lines" - $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath - - $pyvenvConfigContent | ForEach-Object { - $keyval = $PSItem -split "\s*=\s*", 2 - if ($keyval[0] -and $keyval[1]) { - $val = $keyval[1] - - # Remove extraneous quotations around a string value. - if ("'""".Contains($val.Substring(0, 1))) { - $val = $val.Substring(1, $val.Length - 2) - } - - $pyvenvConfig[$keyval[0]] = $val - Write-Verbose "Adding Key: '$($keyval[0])'='$val'" - } - } - } - return $pyvenvConfig -} - - -<# Begin Activate script --------------------------------------------------- #> - -# Determine the containing directory of this script -$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition -$VenvExecDir = Get-Item -Path $VenvExecPath - -Write-Verbose "Activation script is located in path: '$VenvExecPath'" -Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" -Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" - -# Set values required in priority: CmdLine, ConfigFile, Default -# First, get the location of the virtual environment, it might not be -# VenvExecDir if specified on the command line. -if ($VenvDir) { - Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" -} -else { - Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." - $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") - Write-Verbose "VenvDir=$VenvDir" -} - -# Next, read the `pyvenv.cfg` file to determine any required value such -# as `prompt`. -$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir - -# Next, set the prompt from the command line, or the config file, or -# just use the name of the virtual environment folder. -if ($Prompt) { - Write-Verbose "Prompt specified as argument, using '$Prompt'" -} -else { - Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" - if ($pyvenvCfg -and $pyvenvCfg['prompt']) { - Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" - $Prompt = $pyvenvCfg['prompt']; - } - else { - Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" - Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" - $Prompt = Split-Path -Path $venvDir -Leaf - } -} - -Write-Verbose "Prompt = '$Prompt'" -Write-Verbose "VenvDir='$VenvDir'" - -# Deactivate any currently active virtual environment, but leave the -# deactivate function in place. -deactivate -nondestructive - -# Now set the environment variable VIRTUAL_ENV, used by many tools to determine -# that there is an activated venv. -$env:VIRTUAL_ENV = $VenvDir - -if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { - - Write-Verbose "Setting prompt to '$Prompt'" - - # Set the prompt to include the env name - # Make sure _OLD_VIRTUAL_PROMPT is global - function global:_OLD_VIRTUAL_PROMPT { "" } - Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT - New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt - - function global:prompt { - Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " - _OLD_VIRTUAL_PROMPT - } - $env:VIRTUAL_ENV_PROMPT = $Prompt -} - -# Clear PYTHONHOME -if (Test-Path -Path Env:PYTHONHOME) { - Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME - Remove-Item -Path Env:PYTHONHOME -} - -# Add the venv to the PATH -Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH -$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/bin/activate b/bin/activate deleted file mode 100644 index 8d47be8..0000000 --- a/bin/activate +++ /dev/null @@ -1,70 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# You cannot run it directly - -deactivate () { - # reset old environment variables - if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then - PATH="${_OLD_VIRTUAL_PATH:-}" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then - PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # Call hash to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - hash -r 2> /dev/null - - if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then - PS1="${_OLD_VIRTUAL_PS1:-}" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - unset VIRTUAL_ENV_PROMPT - if [ ! "${1:-}" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelevant variables -deactivate nondestructive - -# on Windows, a path can contain colons and backslashes and has to be converted: -if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then - # transform D:\path\to\venv to /d/path/to/venv on MSYS - # and to /cygdrive/d/path/to/venv on Cygwin - export VIRTUAL_ENV=$(cygpath "/home/layton-miller/dev/nasa-workgroup/starfinder") -else - # use the path as-is - export VIRTUAL_ENV="/home/layton-miller/dev/nasa-workgroup/starfinder" -fi - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) -# could use `if (set -u; : $PYTHONHOME) ;` in bash -if [ -n "${PYTHONHOME:-}" ] ; then - _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" - unset PYTHONHOME -fi - -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then - _OLD_VIRTUAL_PS1="${PS1:-}" - PS1="(starfinder) ${PS1:-}" - export PS1 - VIRTUAL_ENV_PROMPT="(starfinder) " - export VIRTUAL_ENV_PROMPT -fi - -# Call hash to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -hash -r 2> /dev/null diff --git a/bin/activate.csh b/bin/activate.csh deleted file mode 100644 index f51f83c..0000000 --- a/bin/activate.csh +++ /dev/null @@ -1,27 +0,0 @@ -# This file must be used with "source bin/activate.csh" *from csh*. -# You cannot run it directly. - -# Created by Davide Di Blasi . -# Ported to Python 3.3 venv by Andrew Svetlov - -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' - -# Unset irrelevant variables. -deactivate nondestructive - -setenv VIRTUAL_ENV "/home/layton-miller/dev/nasa-workgroup/starfinder" - -set _OLD_VIRTUAL_PATH="$PATH" -setenv PATH "$VIRTUAL_ENV/bin:$PATH" - - -set _OLD_VIRTUAL_PROMPT="$prompt" - -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then - set prompt = "(starfinder) $prompt" - setenv VIRTUAL_ENV_PROMPT "(starfinder) " -endif - -alias pydoc python -m pydoc - -rehash diff --git a/bin/activate.fish b/bin/activate.fish deleted file mode 100644 index 5146d18..0000000 --- a/bin/activate.fish +++ /dev/null @@ -1,69 +0,0 @@ -# This file must be used with "source /bin/activate.fish" *from fish* -# (https://fishshell.com/). You cannot run it directly. - -function deactivate -d "Exit virtual environment and return to normal shell environment" - # reset old environment variables - if test -n "$_OLD_VIRTUAL_PATH" - set -gx PATH $_OLD_VIRTUAL_PATH - set -e _OLD_VIRTUAL_PATH - end - if test -n "$_OLD_VIRTUAL_PYTHONHOME" - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME - set -e _OLD_VIRTUAL_PYTHONHOME - end - - if test -n "$_OLD_FISH_PROMPT_OVERRIDE" - set -e _OLD_FISH_PROMPT_OVERRIDE - # prevents error when using nested fish instances (Issue #93858) - if functions -q _old_fish_prompt - functions -e fish_prompt - functions -c _old_fish_prompt fish_prompt - functions -e _old_fish_prompt - end - end - - set -e VIRTUAL_ENV - set -e VIRTUAL_ENV_PROMPT - if test "$argv[1]" != "nondestructive" - # Self-destruct! - functions -e deactivate - end -end - -# Unset irrelevant variables. -deactivate nondestructive - -set -gx VIRTUAL_ENV "/home/layton-miller/dev/nasa-workgroup/starfinder" - -set -gx _OLD_VIRTUAL_PATH $PATH -set -gx PATH "$VIRTUAL_ENV/bin" $PATH - -# Unset PYTHONHOME if set. -if set -q PYTHONHOME - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME - set -e PYTHONHOME -end - -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" - # fish uses a function instead of an env var to generate the prompt. - - # Save the current fish_prompt function as the function _old_fish_prompt. - functions -c fish_prompt _old_fish_prompt - - # With the original prompt function renamed, we can override with our own. - function fish_prompt - # Save the return status of the last command. - set -l old_status $status - - # Output the venv prompt; color taken from the blue of the Python logo. - printf "%s%s%s" (set_color 4B8BBE) "(starfinder) " (set_color normal) - - # Restore the return status of the previous command. - echo "exit $old_status" | . - # Output the original/"old" prompt. - _old_fish_prompt - end - - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" - set -gx VIRTUAL_ENV_PROMPT "(starfinder) " -end diff --git a/bin/pip b/bin/pip deleted file mode 100755 index 001511e..0000000 --- a/bin/pip +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/layton-miller/dev/nasa-workgroup/starfinder/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pip3 b/bin/pip3 deleted file mode 100755 index 001511e..0000000 --- a/bin/pip3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/layton-miller/dev/nasa-workgroup/starfinder/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/pip3.12 b/bin/pip3.12 deleted file mode 100755 index 001511e..0000000 --- a/bin/pip3.12 +++ /dev/null @@ -1,8 +0,0 @@ -#!/home/layton-miller/dev/nasa-workgroup/starfinder/bin/python3 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/bin/python b/bin/python deleted file mode 120000 index b8a0adb..0000000 --- a/bin/python +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/bin/python3 b/bin/python3 deleted file mode 120000 index ae65fda..0000000 --- a/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/python3 \ No newline at end of file diff --git a/bin/python3.12 b/bin/python3.12 deleted file mode 120000 index b8a0adb..0000000 --- a/bin/python3.12 +++ /dev/null @@ -1 +0,0 @@ -python3 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b9928f0..c641986 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "starfinder" -version = "1.2.1" +version = "1.3.0" description = "Generate images of the sky w/ accurate stars for star sensor simulation" requires-python = ">=3.8" classifiers = [ diff --git a/src/bin/optimize.rs b/src/bin/optimize.rs deleted file mode 100644 index 0edff89..0000000 --- a/src/bin/optimize.rs +++ /dev/null @@ -1,106 +0,0 @@ -use clap::Parser; -use csv::ReaderBuilder; -use starfinder::parsing_utils::parse_star_record; -use std::fs::File; -use std::io::{BufReader, BufWriter, Write}; -use std::time::Instant; -use std::f64::consts::PI; - -const CSV_SEPARATOR: char = '|'; - -/// CLI Arguments -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -pub struct Args { - /// Default to attempting to ingest and optimize the tycho2 data set per library standard - #[arg(short, long, default_value = "data/tycho2/catalog.dat")] - source: String, - - /// Output to standard pre-parsed file location - deviating from this means changing source when - /// calling the renderer - #[arg(short, long, default_value = "data/optimized.dat")] - output: String, - - #[arg(long, default_value = "|")] - separator: String, - - #[arg(long)] - idx_vt_mag: Option, - - #[arg(long)] - idx_bt_mag: Option, - - #[arg(long)] - idx_ra: usize, - - #[arg(long)] - idx_dec: usize, - - #[arg(long)] - fov_max: f64, -} - -fn main() -> Result<(), Box> { - let run_start = Instant::now(); - let args = Args::parse(); - - if args.idx_bt_mag.is_none() && args.idx_vt_mag.is_none() { - panic!("Must specify at least one of idx-bt-mag or idx-vt-mag (ideally both)."); - } - if args.separator.len() > 1 { - panic!("Separator must be a single character."); - } - - println!("Reading catalog data and optimizing to starfinder format. This may take a while..."); - let src_file = File::open(args.source)?; - let src_reader = BufReader::new(src_file); - let mut csv_reader = ReaderBuilder::new() - .delimiter(args.separator.to_string().into_bytes()[0]) - .has_headers(false) - .from_reader(src_reader); - - let out_file = File::create(args.output)?; - let mut out_buffer = BufWriter::new(out_file); - let fov_scale = args.fov_max.to_radians()/(4.0*PI); - - for (i, result) in csv_reader.records().enumerate() { - let record = result?; - - let mut skipped_rows = 0; - - match parse_star_record( - &record, - Some(args.idx_ra), - Some(args.idx_dec), - args.idx_bt_mag, - args.idx_vt_mag, - ) { - Ok(star) => { - let grid_coords = star.coords.to_grid(fov_scale); - let ra = star.coords.ra; - let dec = star.coords.dec; - let grid_ra = grid_coords.ra; - let grid_dec = grid_coords.dec; - let mag = star.mag; - let s = CSV_SEPARATOR; - - out_buffer.write_all( - format!("{ra}{s}{dec}{s}{grid_ra}{s}{grid_dec}{s}{mag}\n").as_bytes() - )?; - } - Err(e) => { - skipped_rows += 1; - if skipped_rows <= 10 { - println!("Skipping row {} due to error: {:?}", i, e); - println!("Problematic row: {:?}", record); - } else if skipped_rows == 11 { - println!("Further skipped rows will not be printed..."); - } - } - } - } - out_buffer.flush()?; - - println!("Total run time elapsed: {:?}", run_start.elapsed()); - Ok(()) -} diff --git a/src/constants.rs b/src/constants.rs new file mode 100644 index 0000000..c213451 --- /dev/null +++ b/src/constants.rs @@ -0,0 +1,4 @@ +pub mod file_paths { + pub const TYCHO2_CATALOG: &str = "starfinder/data/tycho2/catalog.dat"; + pub const TYCHO2_OPTIMIZED: &str = "starfinder/data/tycho2/catalog_optimized_FOV.dat"; +} diff --git a/src/lib.rs b/src/lib.rs index 0f5494a..091f419 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,13 @@ +pub mod constants; pub mod fov; +pub mod optimize; pub mod parse_and_render; pub mod parsing_utils; pub mod rendering; pub mod types; -use crate::types::StarCatalogArgs; use crate::parse_and_render::parse_and_render; +use crate::types::StarCatalogArgs; use pyo3::prelude::*; diff --git a/src/main.rs b/src/main.rs index cde11fc..c826f26 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use anyhow::Result; use clap::Parser; use starfinder::parse_and_render::parse_and_render; @@ -9,7 +10,8 @@ use starfinder::types::StarCatalogArgs; pub struct Args { /// Path to the optimized catalog file. The optimize binary should be run before running this to /// generate the optimized data file. - #[arg(short, long, default_value = "data/optimized.dat")]source: String, + // #[arg(short, long, default_value = "data/optimized.dat")] + // source: String, /// Right Ascension of camera view center point (degrees) #[arg(long, default_value_t = 180.0)] @@ -31,6 +33,10 @@ pub struct Args { #[arg(long, default_value_t = 0.0)] roll: f64, + /// Fov max, does not need to be changed unless you want ultra wide view + #[arg(long, default_value_t = 60.0)] + fov_max: f64, + /// Maximum visual magnitude (lower is brighter) #[arg(long, default_value_t = 12.0)] max_magnitude: f64, @@ -57,15 +63,18 @@ pub struct Args { output: String, } -fn main() -> Result<(), Box> { +fn main() -> Result<()> { + tracing_subscriber::fmt().init(); + let cmd_args = Args::parse(); let args = StarCatalogArgs { - source: cmd_args.source, + // source: cmd_args.source, center_ra: cmd_args.center_ra, center_dec: cmd_args.center_dec, fov_w: cmd_args.fov_w, fov_h: cmd_args.fov_h, roll: cmd_args.roll, + fov_max: cmd_args.fov_max, max_magnitude: cmd_args.max_magnitude, lambda_nm: cmd_args.lambda_nm, pixel_size_m: cmd_args.pixel_size_m, diff --git a/src/optimize.rs b/src/optimize.rs new file mode 100644 index 0000000..18e27fc --- /dev/null +++ b/src/optimize.rs @@ -0,0 +1,101 @@ +use anyhow::Result; +use csv::ReaderBuilder; +use std::f64::consts::PI; +use std::fs::File; +use std::io::{BufReader, BufWriter, Write}; +use std::path::PathBuf; +use std::time::Instant; +use tracing::{error, info, warn}; + +use crate::parsing_utils::parse_star_record; + +const CSV_SEPARATOR: char = '|'; + +/// Optimizes the given source data and writes the result to the output. +/// +/// # Arguments +/// +/// * `source` - A String that holds the path to the source file. +/// * `output` - A String that holds the path to the output file. +/// * `separator` - A String that specifies the delimiter used in the source file. +/// * `idx_vt_mag` - The index of the VT magnitude column in the source file. +/// * `idx_bt_mag` - The index of the BT magnitude column in the source file. +/// * `idx_ra` - The index of the Right Ascension column in the source file. +/// * `idx_dec` - The index of the Declination column in the source file. +/// * `fov_max` - The maximum field of view as a f64. +/// +/// # Returns +/// +/// Returns a `Result<()>` which is `Ok(())` if the operation was successful, +/// or an `Err` containing the error information if something went wrong. +pub fn optimize( + source: &PathBuf, + output: &PathBuf, + separator: &str, + idx_vt_mag: Option, + idx_bt_mag: Option, + idx_ra: u64, + idx_dec: u64, + fov_max: f64, +) -> Result<()> { + // First check if the tycho2 catalog already exists in the cache + if output.exists() { + info!("Tycho2 optimized catalog already exists at: {:?}", &output); + return Ok(()); + } + let run_start = Instant::now(); + + if idx_bt_mag.is_none() && idx_vt_mag.is_none() { + panic!("Must specify at least one of idx-bt-mag or idx-vt-mag (ideally both)."); + } + if separator.len() > 1 { + panic!("Separator must be a single character."); + } + + info!("Reading catalog data and optimizing to starfinder format. This may take a while..."); + let src_file = File::open(source)?; + let src_reader = BufReader::new(src_file); + let mut csv_reader = ReaderBuilder::new() + .delimiter(separator.to_string().into_bytes()[0]) + .has_headers(false) + .from_reader(src_reader); + + let out_file = File::create(output)?; + let mut out_buffer = BufWriter::new(out_file); + let fov_scale = fov_max.to_radians() / (4.0 * PI); + + for (i, result) in csv_reader.records().enumerate() { + let record = result?; + + let mut skipped_rows = 0; + + match parse_star_record(&record, Some(idx_ra), Some(idx_dec), idx_bt_mag, idx_vt_mag) { + Ok(star) => { + let grid_coords = star.coords.to_grid(fov_scale); + let ra = star.coords.ra; + let dec = star.coords.dec; + let grid_ra = grid_coords.ra; + let grid_dec = grid_coords.dec; + let mag = star.mag; + let s = CSV_SEPARATOR; + + out_buffer.write_all( + format!("{ra}{s}{dec}{s}{grid_ra}{s}{grid_dec}{s}{mag}\n").as_bytes(), + )?; + } + Err(e) => { + skipped_rows += 1; + if skipped_rows <= 10 { + error!("Skipping row {} due to error: {:?}", i, e); + error!("Problematic row: {:?}", record); + } else if skipped_rows == 11 { + warn!("Further skipped rows will not be printed..."); + } + } + } + } + out_buffer.flush()?; + + info!("Total run time elapsed: {:?}", run_start.elapsed()); + Ok(()) +} diff --git a/src/parse_and_render.rs b/src/parse_and_render.rs index f14e632..0a07f21 100644 --- a/src/parse_and_render.rs +++ b/src/parse_and_render.rs @@ -1,11 +1,65 @@ +use anyhow::Result; +use directories::BaseDirs; +use reqwest; +use std::fs; +use std::path::PathBuf; +use std::time::Duration; use std::time::Instant; +use tracing::info; +use crate::constants::file_paths::{TYCHO2_CATALOG, TYCHO2_OPTIMIZED}; use crate::fov; +use crate::optimize::optimize; use crate::parsing_utils::read_stars; use crate::rendering::render_stars; use crate::types::{EquatorialCoords, StarCatalogArgs}; -pub fn parse_and_render(args: &StarCatalogArgs) -> Result<(), Box> { +pub fn download_tycho2(tycho2_path: &PathBuf) -> Result<()> { + let tycho2_url = "https://archive.eso.org/ASTROM/TYC-2/data/catalog.dat"; + // Create all parent directories + if let Some(parent) = tycho2_path.parent() { + fs::create_dir_all(parent)?; + } + + // First check if the tycho2 catalog already exists in the cache + if tycho2_path.exists() { + info!("Tycho2 catalog already exists at: {:?}", &tycho2_path); + return Ok(()); + } + + info!("Downloading Tycho2 catalog from: {}", tycho2_url); + let client = reqwest::blocking::Client::builder() + .timeout(Duration::from_secs(120)) // 2 minutes + .build()?; + + let response = client.get(tycho2_url).send()?; + // let response = reqwest::blocking::get(tycho2_url)?; + let mut file = std::fs::File::create(&tycho2_path)?; + std::io::copy(&mut response.bytes().unwrap().as_ref(), &mut file)?; + info!("Tycho2 catalog downloaded to: {:?}", &tycho2_path); + + Ok(()) +} + +pub fn parse_and_render(args: &StarCatalogArgs) -> Result<()> { + let tycho2_path = BaseDirs::new().unwrap().cache_dir().join(TYCHO2_CATALOG); + + let tycho2_path_optimized = BaseDirs::new().unwrap().cache_dir().join(TYCHO2_OPTIMIZED); + + // TODO: a hash function to check if the file that is in the cache is the same as the one that we expect + + download_tycho2(&tycho2_path)?; + optimize( + &tycho2_path, + &tycho2_path_optimized, + "|", + Some(19), + Some(17), + 24, + 25, + args.fov_max, + )?; + let run_start = Instant::now(); let center_ra = args.center_ra.to_radians(); let center_dec = args.center_dec.to_radians(); @@ -20,12 +74,12 @@ pub fn parse_and_render(args: &StarCatalogArgs) -> Result<(), Box Result<(), Box>( Err(e) => { skipped_rows += 1; if skipped_rows <= 10 { - println!("Skipping row {} due to error: {:?}", i, e); - println!("Problematic row: {:?}", record); + error!("Skipping row {} due to error: {:?}", i, e); + warn!("Problematic row: {:?}", record); } else if skipped_rows == 11 { - println!("Further skipped rows will not be printed..."); + warn!("Further skipped rows will not be printed..."); } } } } - println!("Total stars read and filtered: {}", stars.len()); - println!("Total rows skipped: {}", skipped_rows); + info!("Total stars read and filtered: {}", stars.len()); + info!("Total rows skipped: {}", skipped_rows); Ok(stars) } /// Parses the *optimize* star data file and pulls out the star as well as its pre-computed ra/dec /// in the localization grid format as a separate EquatorialCoordinate -pub fn parse_optimized_star_record(record: &csv::StringRecord) -> Result<(Star, EquatorialCoords), CatalogError> { +pub fn parse_optimized_star_record( + record: &csv::StringRecord, +) -> Result<(Star, EquatorialCoords), CatalogError> { Ok(( Star { coords: EquatorialCoords { @@ -85,7 +88,7 @@ pub fn parse_optimized_star_record(record: &csv::StringRecord) -> Result<(Star, EquatorialCoords { ra: parse_field(record, 2, "GridRA")?, dec: parse_field(record, 3, "GridDec")?, - } + }, )) } @@ -94,10 +97,10 @@ pub fn parse_optimized_star_record(record: &csv::StringRecord) -> Result<(Star, /// specified differently if a different star catalog is to be used pub fn parse_star_record( record: &csv::StringRecord, - idx_ra: Option, - idx_dec: Option, - idx_bt_mag: Option, - idx_vt_mag: Option, + idx_ra: Option, + idx_dec: Option, + idx_bt_mag: Option, + idx_vt_mag: Option, ) -> Result { let ra = parse_field(record, idx_ra.unwrap_or(24), "RA")?; let dec = parse_field(record, idx_dec.unwrap_or(25), "Dec")?; @@ -117,28 +120,19 @@ pub fn parse_star_record( /// specified differently if a different star catalog is to be used pub fn parse_magnitude( record: &csv::StringRecord, - idx_bt_mag: Option, - idx_vt_mag: Option, + idx_bt_mag: Option, + idx_vt_mag: Option, ) -> Result { let bt_mag = parse_field(record, idx_bt_mag.unwrap_or(17), "BT magnitude").ok(); let vt_mag = parse_field(record, idx_vt_mag.unwrap_or(19), "VT magnitude").ok(); - // println!("Debug: BT_Mag = {:?}, VT_Mag = {:?}", bt_mag, vt_mag); - match (bt_mag, vt_mag) { (Some(bt), Some(vt)) => { let v_mag = vt - 0.090 * (bt - vt); - // println!("Debug: Calculated V_Mag = {:.3}", v_mag); Ok(v_mag) } - (None, Some(vt)) => { - // println!("Debug: Using VT_Mag as V_Mag = {:.3}", vt); - Ok(vt) - } - (Some(bt), None) => { - // println!("Debug: Using BT_Mag as V_Mag = {:.3}", bt); - Ok(bt) - } + (None, Some(vt)) => Ok(vt), + (Some(bt), None) => Ok(bt), (None, None) => Err(CatalogError::MissingMagnitude), } } @@ -146,11 +140,11 @@ pub fn parse_magnitude( /// Parses a field from the record, returning a helpful error if parsing fails. pub fn parse_field( record: &csv::StringRecord, - index: usize, + index: u64, field_name: &str, ) -> Result { record - .get(index) + .get(index.try_into().unwrap()) .ok_or_else(|| CatalogError::MissingField(field_name.to_string()))? .trim() .parse() diff --git a/src/render.cpp b/src/render.cpp deleted file mode 100644 index 78589c4..0000000 --- a/src/render.cpp +++ /dev/null @@ -1,359 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace po = boost::program_options; - - -constexpr char OPT_HELP[] = "help"; -constexpr char OPT_FILE[] = "FILE"; -constexpr char OPT_DISPLAY_COUNT[] = "display-count"; -constexpr char OPT_MIN_RA[] = "min-ra"; -constexpr char OPT_MAX_RA[] = "max-ra"; -constexpr char OPT_MIN_DEC[] = "min-dec"; -constexpr char OPT_MAX_DEC[] = "max-dec"; -constexpr char OPT_MAX_MAGNITUDE[] = "max-magnitude"; -constexpr char OPT_WIDTH[] = "width"; -constexpr char OPT_HEIGHT[] = "height"; -constexpr char OPT_OUTPUT[] = "output"; - - -/** - * \brief Represents a star with its right ascension, declination, and magnitude. - */ -struct Star { - const double ra_deg; - const double de_deg; - const double mag; - - Star( - const double ra_deg, - const double de_deg, - const double mag - ) noexcept: - ra_deg(ra_deg), - de_deg(de_deg), - mag(mag) - {} -}; - - -std::optional parse_field( - const std::vector& record, - const size_t index, - const std::string& field_name -) { - double value; - - try { - value = std::stod(record.at(index)); - } - catch (const std::out_of_range&) { - throw std::runtime_error( - ( - boost::format("Missing field: %1%") % field_name - ).str() - ); - } - catch (const std::invalid_argument& e) { - throw std::runtime_error( - ( - boost::format("Failed to parse %1%. %2%") % field_name % e.what() - ).str() - ); - } - - return value; -} - - -double parse_magnitude(const std::vector& record) { - std::optional bt_mag, vt_mag; - try { - bt_mag = parse_field(record, 17, "BT magnitude"); - vt_mag = parse_field(record, 19, "VT magnitude"); - } - catch (const std::runtime_error&) {}; - - if (bt_mag) { - const auto bt = bt_mag.value(); - if (vt_mag) { - const auto vt = vt_mag.value(); - const auto v_mag = vt - 0.090 * (bt - vt); - // std::cout << boost::format("Debug: Calculated V_Mag = %1$.3f") % v_mag << std::endl; - return v_mag; - } else { - // std::cout << boost::format("Debug: Using BT_Mag as V_Mag = %1$.3f") % bt << std::endl; - return bt; - } - } else { - if (vt_mag) { - const auto vt = vt_mag.value(); - // std::cout << boost::format("Debug: Using VT_Mag as V_Mag = %1$.3f") % vt << std::endl; - return vt; - } else { - throw std::runtime_error("Missing magnitude"); - } - } -} - - -Star parse_star_record(const std::vector& record) { - const auto ra = parse_field(record, 24, "RA"); - const auto dec = parse_field(record, 25, "Dec"); - const auto mag = parse_magnitude(record); - - return Star( - ra.value(), - dec.value(), - mag - ); -} - - -std::vector read_stars( - const std::string& path, - const double min_ra, - const double max_ra, - const double min_dec, - const double max_dec, - const double max_magnitude -) { - std::vector stars; - std::size_t skipped_rows = 0; - { - std::ifstream file(path); - std::size_t i = 0; - for (std::string line; std::getline(file, line);) { - std::vector record; - record.reserve(35); - boost::split( - record, - line, - boost::is_any_of("|") - ); - try { - const auto star = parse_star_record(record); - if ( - star.ra_deg >= min_ra - && - star.ra_deg <= max_ra - && - star.de_deg >= min_dec - && - star.de_deg <= max_dec - && - star.mag <= max_magnitude - ) { - if ((i % 10000) == 0) - std::cout << boost::format("Star %1%: RA=%2%, Dec=%3%, Mag=%4%") % i % star.ra_deg % star.de_deg % star.mag << std::endl; - - stars.push_back(star); - } - } - catch (const std::runtime_error& e) { - skipped_rows++; - if (skipped_rows <= 10) { - std::cerr << boost::format("Skipping row %1% due to error: %2%") % i % e.what() << std::endl; - std::cerr << boost::format("Problematic row: %1%") % line << std::endl; - } else if (skipped_rows == 11) { - std::cerr << "Further skipped rows will not be printed..." << std::endl; - } - } - } - } - - std::cout << "Total stars read and filtered: " << stars.size() << std::endl; - std::cout << "Total rows skipped: " << skipped_rows << std::endl; - - return stars; -}; - - -template -class Stopwatch { - public: - Stopwatch(); - - float elapsed() const; - - private: - const typename Clock::time_point start; -}; - - -template -Stopwatch::Stopwatch(): - start(Clock::now()) -{} - - -template -float Stopwatch::elapsed() const { - const auto stop = Clock::now(); - return static_cast(std::chrono::duration_cast(stop - start).count()) / 1000; -} - - -void render_stars( - const std::vector& stars, - const uint32_t width, - const uint32_t height, - const double min_ra, - const double max_ra, - const double min_dec, - const double max_dec, - cv::OutputArray dst -) { - dst.create(height, width, CV_8UC1); - cv::Mat img = dst.getMat(); - - // Find the minimum and maximum magnitudes in the dataset - const auto [min_mag_star, max_mag_star] = std::minmax_element( - stars.cbegin(), - stars.cend(), - [] (const Star& a, const Star& b) { - return (a.mag < b.mag); - } - ); - const auto min_mag = min_mag_star->mag; - const auto max_mag = max_mag_star->mag; - - std::cout << boost::format("Magnitude range: %1$.3f to %2$.3f") % min_mag % max_mag << std::endl; - - const auto ra_range = max_ra - min_ra; - const auto dec_range = max_dec - min_dec; - const auto mag_range = max_mag - min_mag; - for (const Star& star : stars) { - const uint32_t x = (star.ra_deg - min_ra) / ra_range * width; - const uint32_t y = (star.de_deg - min_dec) / dec_range * height; - - if (x < width && y < height) { - // Inverse the magnitude scale (brighter stars have lower magnitudes) - const auto normalized_mag = (max_mag - star.mag) / mag_range; - - // Apply a non-linear scaling to emphasize brighter stars - const uint8_t brightness = std::pow(normalized_mag, 2.5) * 255; - - cv::circle( - img, - cv::Point(x, y), - 0, - cv::Scalar(brightness) - ); - } - } -} - - -int main(int argc, char** argv) { - po::variables_map vm; - { - po::options_description general_options("General options"); - general_options.add_options() - (OPT_HELP, "print this message") - (OPT_WIDTH, po::value()->default_value(800), "Output image width in pixels") - (OPT_HEIGHT, po::value()->default_value(600), "Output image height in pixels") - (OPT_OUTPUT, po::value()->default_value("star_map.png"), "Output image file name") - ; - - po::options_description filter_options("Filter options"); - filter_options.add_options() - (OPT_DISPLAY_COUNT, po::value()->default_value(10), "Number of stars to display (0 for all)") - (OPT_MIN_RA, po::value()->default_value(0), "Minimum Right Ascension (degrees)") - (OPT_MAX_RA, po::value()->default_value(360), "Maximum Right Ascension (degrees)") - (OPT_MIN_DEC, po::value()->default_value(-90), "Minimum Declination (degrees)") - (OPT_MAX_DEC, po::value()->default_value(90), "Maximum Declination (degrees)") - (OPT_MAX_MAGNITUDE, po::value()->default_value(6), "Maximum visual magnitude (lower is brighter)") - ; - - po::options_description arguments("Arguments"); - arguments.add_options() - (OPT_FILE, po::value()->default_value("data/tycho2/catalog.dat"), "Path to the Tycho-2 catalog file") - ; - - po::positional_options_description arguments_positions; - arguments_positions.add(OPT_FILE, 1); - - po::options_description all_options("All options"); - all_options.add(general_options).add(filter_options).add(arguments); - - po::store( - po::command_line_parser(argc, argv).options(all_options).positional(arguments_positions).run(), - vm - ); - po::notify(vm); - - if (vm.count(OPT_HELP) != 0) { - std::cout << "render [options]"; - std::cout << ' ' << OPT_FILE; - std::cout << std::endl << std::endl; - std::cout << arguments << std::endl; - std::cout << general_options << std::endl; - std::cout << filter_options << std::endl; - return -1; - } - } - - - std::cout << boost::format("Reading stars from: %1%") % vm[OPT_FILE].as() << std::endl; - std::cout << boost::format("RA range: %1% to %2%") % vm[OPT_MIN_RA].as() % vm[OPT_MAX_RA].as() << std::endl; - std::cout << boost::format("Dec range: %1% to %2%") % vm[OPT_MIN_DEC].as() % vm[OPT_MAX_DEC].as() << std::endl; - std::cout << boost::format("Max magnitude: %1%") % vm[OPT_MAX_MAGNITUDE].as() << std::endl; - - const Stopwatch read_start; - const auto stars = read_stars( - vm[OPT_FILE].as(), - vm[OPT_MIN_RA].as(), - vm[OPT_MAX_RA].as(), - vm[OPT_MIN_DEC].as(), - vm[OPT_MAX_DEC].as(), - vm[OPT_MAX_MAGNITUDE].as() - ); - const auto read_duration = read_start.elapsed(); - - std::cout << "Time taken to read and filter stars: " << read_duration << std::endl; - std::cout << "Total stars after filtering: " << stars.size() << std::endl; - std::cout << std::endl; - - { - const uint32_t display_count = vm[OPT_DISPLAY_COUNT].as(); - std::cout << boost::format("First %1% stars:") % display_count << std::endl; - uint32_t i = 0; - for (const auto& star : stars) { - if (i >= display_count && display_count != 0) - break; - std::cout << boost::format("Star %1%: RA=%2$.2f, Dec=%3$.2f, Mag=%4$.2f") % i % star.ra_deg % star.de_deg % star.mag << std::endl; - i++; - } - } - - cv::Mat img; - const Stopwatch render_start; - render_stars( - stars, - vm[OPT_WIDTH].as(), - vm[OPT_HEIGHT].as(), - vm[OPT_MIN_RA].as(), - vm[OPT_MAX_RA].as(), - vm[OPT_MIN_DEC].as(), - vm[OPT_MAX_DEC].as(), - img - ); - cv::imwrite(vm[OPT_OUTPUT].as(), img); - const auto render_duration = render_start.elapsed(); - - std::cout << "Time taken to render and save image: " << render_duration << std::endl; - std::cout << "Image saved as: " << vm[OPT_OUTPUT].as() << std::endl; - std::cout << "Total time elapsed: " << read_start.elapsed() << std::endl; - - return 0; -} \ No newline at end of file diff --git a/src/types/args.rs b/src/types/args.rs index 43b1380..e60d27e 100644 --- a/src/types/args.rs +++ b/src/types/args.rs @@ -4,8 +4,8 @@ use pyo3::prelude::{pyclass, pymethods}; #[pyclass] #[derive(Parser, Debug, Clone)] pub struct StarCatalogArgs { - #[pyo3(get, set)] - pub source: String, + // #[pyo3(get, set)] + // pub source: String, #[pyo3(get, set)] pub center_ra: f64, #[pyo3(get, set)] @@ -17,6 +17,8 @@ pub struct StarCatalogArgs { #[pyo3(get, set)] pub roll: f64, #[pyo3(get, set)] + pub fov_max: f64, + #[pyo3(get, set)] pub max_magnitude: f64, #[pyo3(get, set)] pub lambda_nm: f64, @@ -34,12 +36,13 @@ pub struct StarCatalogArgs { impl StarCatalogArgs { #[new] fn new( - source: String, + // source: String, center_ra: f64, center_dec: f64, fov_w: f64, fov_h: f64, roll: f64, + fov_max: f64, max_magnitude: f64, lambda_nm: f64, pixel_size_m: f64, @@ -48,12 +51,13 @@ impl StarCatalogArgs { output: String, ) -> Self { Self { - source, + // source, center_ra, center_dec, fov_w, fov_h, roll, + fov_max, max_magnitude, lambda_nm, pixel_size_m, @@ -62,4 +66,4 @@ impl StarCatalogArgs { output, } } -} \ No newline at end of file +}