From 2ec7f7ae0a2bdeb752b4c5d0b1bc47ecb5429b04 Mon Sep 17 00:00:00 2001 From: chenghymichael Date: Tue, 5 Mar 2024 23:48:18 -0500 Subject: [PATCH 1/3] Update sensors.py added def get_datacube_size(self): """Get the size of datacube in bit.""" --- architect/systems/optical/sensors.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/architect/systems/optical/sensors.py b/architect/systems/optical/sensors.py index c3aac5f..f6683ee 100644 --- a/architect/systems/optical/sensors.py +++ b/architect/systems/optical/sensors.py @@ -188,6 +188,15 @@ def get_waveband(self) -> Quantity[unit.m]: return self.waveband else: raise ValueError("Waveband is not set.") + + def get_datacube_size(self): + """Get the size of datacube in bit.""" + + npxx = self.n_px[0] # 640 px, pixels on the sensor in the across-track direction -> spatial information + npxy = self.n_px[1] # 512 px, pixels on the sensor in the along-track direction -> spectral information + nbit = self.n_bit # bit depth + D = npxx * npxx * npxy * nbit + return D class TauSWIR(Sensor): From d396ef57e69f18cdce98a6494beccde0ec984ccf Mon Sep 17 00:00:00 2001 From: chenghymichael Date: Sat, 16 Mar 2024 15:20:39 -0400 Subject: [PATCH 2/3] fixed unit in get_datacube_size() in sensor.py --- .pre-commit-config.yaml | 12 ++++----- architect/libs/utillib.py | 1 + architect/luts/__init__.py | 1 + architect/systems/__init__.py | 1 + architect/systems/component.py | 1 + architect/systems/optical/__init__.py | 1 + .../systems/optical/optical_component.py | 1 + architect/systems/optical/sensors.py | 25 +++++++++++++------ architect/systems/optical/spectrometers.py | 1 + architect/systems/space/satellites.py | 1 + pyproject.toml | 2 +- .../test_TransmissiveDiffractor.py | 1 + .../test_diffractors/test_VPHGrating.py | 1 + .../test_diffractors/test_VPHGrism.py | 1 + .../test_foreoptics/test_Foreoptic.py | 1 + .../test_optical/test_lenses/test_Lens.py | 1 + .../test_optical/test_sensors/test_Sensor.py | 12 +++++++++ .../test_spectrometers/test_FINCHEye.py | 1 + tests/test_systems/test_space/test_CubeSat.py | 1 + tests/test_systems/test_space/test_FINCH.py | 1 + .../test_systems/test_space/test_Satellite.py | 1 + tests/test_systems/test_system.py | 1 + 22 files changed, 55 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c90246b..fa65972 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,26 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.3.0 hooks: - id: black - repo: https://github.com/PyCQA/autoflake - rev: v1.7.7 + rev: v2.3.1 hooks: - id: autoflake - repo: https://github.com/asottile/pyupgrade - rev: v2.32.0 + rev: v3.15.1 hooks: - id: pyupgrade - repo: https://github.com/myint/docformatter - rev: v1.5.0 + rev: v1.7.5 hooks: - id: docformatter args: [--blank, --in-place, --recursive, --wrap-descriptions=88, --wrap-summaries=80] # does not yet support toml config @@ -33,7 +33,7 @@ repos: - repo: https://github.com/nbQA-dev/nbQA - rev: 1.3.1 + rev: 1.8.4 hooks: - id: nbqa-isort - id: nbqa-black diff --git a/architect/libs/utillib.py b/architect/libs/utillib.py index 348e5c2..e29606a 100644 --- a/architect/libs/utillib.py +++ b/architect/libs/utillib.py @@ -1,4 +1,5 @@ """An assortment of utilities and classes for scientific computing.""" + # external import numpy as np from astropy.units.quantity import Quantity diff --git a/architect/luts/__init__.py b/architect/luts/__init__.py index 34f9c47..7e538de 100644 --- a/architect/luts/__init__.py +++ b/architect/luts/__init__.py @@ -1,2 +1,3 @@ """Look Up Table implementation.""" + from .functions import * diff --git a/architect/systems/__init__.py b/architect/systems/__init__.py index 34e1479..22ad80a 100644 --- a/architect/systems/__init__.py +++ b/architect/systems/__init__.py @@ -1,3 +1,4 @@ """Import base classes.""" + from .system import System # isort:skip from .component import Component diff --git a/architect/systems/component.py b/architect/systems/component.py index 1e80a7c..679fb50 100644 --- a/architect/systems/component.py +++ b/architect/systems/component.py @@ -1,4 +1,5 @@ """Component class.""" + # external import astropy.units as unit diff --git a/architect/systems/optical/__init__.py b/architect/systems/optical/__init__.py index dcf27d8..a303160 100644 --- a/architect/systems/optical/__init__.py +++ b/architect/systems/optical/__init__.py @@ -1,2 +1,3 @@ """Import component type.""" + from .optical_component import OpticalComponent diff --git a/architect/systems/optical/optical_component.py b/architect/systems/optical/optical_component.py index 39f4f71..1728769 100644 --- a/architect/systems/optical/optical_component.py +++ b/architect/systems/optical/optical_component.py @@ -1,4 +1,5 @@ """Optical component class.""" + # stdlib import logging diff --git a/architect/systems/optical/sensors.py b/architect/systems/optical/sensors.py index f6683ee..759a98f 100644 --- a/architect/systems/optical/sensors.py +++ b/architect/systems/optical/sensors.py @@ -188,15 +188,26 @@ def get_waveband(self) -> Quantity[unit.m]: return self.waveband else: raise ValueError("Waveband is not set.") - - def get_datacube_size(self): - """Get the size of datacube in bit.""" - npxx = self.n_px[0] # 640 px, pixels on the sensor in the across-track direction -> spatial information - npxy = self.n_px[1] # 512 px, pixels on the sensor in the along-track direction -> spectral information - nbit = self.n_bit # bit depth + def get_datacube_size(self) -> unit.bit: + """Get the size of datacube in bit. + + Ref: https://www.notion.so/utat-ss/Hyperspectral-Datacube-Size-5390b2593dff48b2b96d954eb8267844 + + """ + + assert self.n_px is not None, "n_px must be specified." + assert self.n_bit is not None, "n_bit must be specified." + + npxx = self.n_px[ + 0 + ] # 640 px, pixels on the sensor in the across-track direction -> spatial information + npxy = self.n_px[ + 1 + ] # 512 px, pixels on the sensor in the along-track direction -> spectral information + nbit = self.n_bit # bit depth D = npxx * npxx * npxy * nbit - return D + return D / unit.pix**3 class TauSWIR(Sensor): diff --git a/architect/systems/optical/spectrometers.py b/architect/systems/optical/spectrometers.py index f3fb0d1..d7f57db 100644 --- a/architect/systems/optical/spectrometers.py +++ b/architect/systems/optical/spectrometers.py @@ -1,4 +1,5 @@ """Spectrometer classes.""" + # stdlib import logging import math diff --git a/architect/systems/space/satellites.py b/architect/systems/space/satellites.py index 37d4a09..d384ff3 100644 --- a/architect/systems/space/satellites.py +++ b/architect/systems/space/satellites.py @@ -1,4 +1,5 @@ """Satellite system classes.""" + # external import astropy.constants as const import astropy.units as unit diff --git a/pyproject.toml b/pyproject.toml index f36b955..eb1e07d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "architect" -version = "0.1.0" +version = "1.4.0" description = "" authors = ["UTAT"] diff --git a/tests/test_systems/test_optical/test_diffractors/test_TransmissiveDiffractor.py b/tests/test_systems/test_optical/test_diffractors/test_TransmissiveDiffractor.py index 7eef6a1..4837719 100644 --- a/tests/test_systems/test_optical/test_diffractors/test_TransmissiveDiffractor.py +++ b/tests/test_systems/test_optical/test_diffractors/test_TransmissiveDiffractor.py @@ -1,4 +1,5 @@ """Tests for transmissive diffractor component.""" + # stdlib import logging diff --git a/tests/test_systems/test_optical/test_diffractors/test_VPHGrating.py b/tests/test_systems/test_optical/test_diffractors/test_VPHGrating.py index 29cceb8..04254c4 100644 --- a/tests/test_systems/test_optical/test_diffractors/test_VPHGrating.py +++ b/tests/test_systems/test_optical/test_diffractors/test_VPHGrating.py @@ -1,4 +1,5 @@ """Tests for VPH Grating component.""" + # stdlib import logging diff --git a/tests/test_systems/test_optical/test_diffractors/test_VPHGrism.py b/tests/test_systems/test_optical/test_diffractors/test_VPHGrism.py index 6353884..69e472f 100644 --- a/tests/test_systems/test_optical/test_diffractors/test_VPHGrism.py +++ b/tests/test_systems/test_optical/test_diffractors/test_VPHGrism.py @@ -1,4 +1,5 @@ """Tests for VPH Grism component.""" + # stdlib import logging diff --git a/tests/test_systems/test_optical/test_foreoptics/test_Foreoptic.py b/tests/test_systems/test_optical/test_foreoptics/test_Foreoptic.py index ca4ace4..54ba3ee 100644 --- a/tests/test_systems/test_optical/test_foreoptics/test_Foreoptic.py +++ b/tests/test_systems/test_optical/test_foreoptics/test_Foreoptic.py @@ -1,4 +1,5 @@ """Tests for Foreoptic component.""" + # stdlib import logging diff --git a/tests/test_systems/test_optical/test_lenses/test_Lens.py b/tests/test_systems/test_optical/test_lenses/test_Lens.py index 7e38ed0..f286581 100644 --- a/tests/test_systems/test_optical/test_lenses/test_Lens.py +++ b/tests/test_systems/test_optical/test_lenses/test_Lens.py @@ -1,4 +1,5 @@ """Tests for AchromLens component.""" + # stdlib import logging diff --git a/tests/test_systems/test_optical/test_sensors/test_Sensor.py b/tests/test_systems/test_optical/test_sensors/test_Sensor.py index 99e4382..9dad876 100644 --- a/tests/test_systems/test_optical/test_sensors/test_Sensor.py +++ b/tests/test_systems/test_optical/test_sensors/test_Sensor.py @@ -1,4 +1,5 @@ """Tests for Sensor component.""" + # stdlib import logging @@ -156,3 +157,14 @@ def test_get_efficiency(): LOG.info(result) assert result.unit == unit.pct * unit.electron + + +def test_get_datacube_size(): + """Test get_datacube_size method.""" + + sensor = Sensor(n_px=(640, 512) * unit.pix, n_bit=14 * unit.bit) + + result = sensor.get_datacube_size() + LOG.info(result) + + assert result.unit == unit.bit diff --git a/tests/test_systems/test_optical/test_spectrometers/test_FINCHEye.py b/tests/test_systems/test_optical/test_spectrometers/test_FINCHEye.py index d54db37..450a535 100644 --- a/tests/test_systems/test_optical/test_spectrometers/test_FINCHEye.py +++ b/tests/test_systems/test_optical/test_spectrometers/test_FINCHEye.py @@ -1,4 +1,5 @@ """FINCHEye class tests.""" + # stdlib import logging diff --git a/tests/test_systems/test_space/test_CubeSat.py b/tests/test_systems/test_space/test_CubeSat.py index ad1a594..1bd2b0a 100644 --- a/tests/test_systems/test_space/test_CubeSat.py +++ b/tests/test_systems/test_space/test_CubeSat.py @@ -1,4 +1,5 @@ """Satellite class tests.""" + # stdlib import logging diff --git a/tests/test_systems/test_space/test_FINCH.py b/tests/test_systems/test_space/test_FINCH.py index f4cefa0..ab22eca 100644 --- a/tests/test_systems/test_space/test_FINCH.py +++ b/tests/test_systems/test_space/test_FINCH.py @@ -1,4 +1,5 @@ """Satellite class tests.""" + # stdlib import logging diff --git a/tests/test_systems/test_space/test_Satellite.py b/tests/test_systems/test_space/test_Satellite.py index 1f9545e..67c39bc 100644 --- a/tests/test_systems/test_space/test_Satellite.py +++ b/tests/test_systems/test_space/test_Satellite.py @@ -1,4 +1,5 @@ """Satellite class tests.""" + # stdlib import logging diff --git a/tests/test_systems/test_system.py b/tests/test_systems/test_system.py index 6c1fc6b..3bd1238 100644 --- a/tests/test_systems/test_system.py +++ b/tests/test_systems/test_system.py @@ -1,4 +1,5 @@ """System class tests.""" + # stdlib import logging From 60f28039e65798dbd19ac38b33b065d23c213e04 Mon Sep 17 00:00:00 2001 From: chenghymichael <146039398+chenghymichael@users.noreply.github.com> Date: Tue, 2 Apr 2024 02:29:16 -0400 Subject: [PATCH 3/3] Update .pre-commit-config.yaml isort 5.13.2 changed back to 5.12.0 --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa65972..c6f8504 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 5.12.0 hooks: - id: isort @@ -45,4 +45,4 @@ repos: name: pylint entry: poetry run pylint language: system - types: [python] \ No newline at end of file + types: [python]