Skip to content

v3.1.0 #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a96c831
Merge pull request #92 from jkuusk/dev
jkuusk Nov 18, 2024
180fa5b
Merge pull request #2 from jkuusk/main
jkuusk Apr 4, 2025
06d1d07
schedule schortcut bugfix for yocto-pictor-wifi boards
jkuusk May 5, 2025
4b1ea42
Updated config and sequence file comment formatting for importing int…
jkuusk May 5, 2025
4479b72
Improve error handling and logging if Yocto is sleeping on brown-out …
jkuusk May 5, 2025
08d85d5
Merge branch 'main' into dev
jkuusk May 5, 2025
f5ab895
Impove surveillance camera image quality
jkuusk May 5, 2025
065dfd8
Add 3 s sleep to leave time for camera to auto-adjust
jkuusk May 5, 2025
d4e0f97
Yocto detection bugfix for yocto-pictor-wifi
jkuusk May 6, 2025
7b20ed6
Allow Yocto auto-confing with existing config_static.ini
jkuusk May 16, 2025
75b4184
always generate rsa key if it does not exist when setting up hypernet…
jkuusk May 16, 2025
dffd060
power cycle radiometer for second attempt if exit code is 6
jkuusk Jun 12, 2025
b1a2ac2
if SWIR TEC stabilisation fails then catch exception and exit
jkuusk Jun 19, 2025
606f09a
add led option to pt command line tool
jkuusk Jun 19, 2025
829833f
Add hypernets/abstract/get_led_tilt.py that was left out from previou…
jkuusk Jun 19, 2025
fb7498a
python indentation bugfix
jkuusk Jun 19, 2025
53ced48
Wait for SWIR and TEC init completion before enabling TEC
jkuusk Jun 20, 2025
015652e
calculate absolute positions when printing geometry to log
jkuusk Jun 20, 2025
275e6e4
warn if SWIR measurement with S/N not in HYPSTAR-XR range
jkuusk Jun 27, 2025
5dae216
clarify help and comments
jkuusk Jun 27, 2025
9b0a121
set Yocto clock from PC at the beginning of sequence if not set already
jkuusk Jul 1, 2025
db373c8
improve yocto access error handling
jkuusk Jul 8, 2025
23ad709
improve error handling of relay command line tool
jkuusk Jul 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hypernets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.0.0"
__version__ = "3.1.0"

import sys
MIN_PYTHON = (3, 9)
Expand Down
5 changes: 3 additions & 2 deletions hypernets/abstract/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, reference: int, pan=0.0, tilt=0.0, flags=[]):

def __str__(self):
ref_pan, ref_tilt = Geometry.int_to_reference(self.reference)
self.get_absolute_pan_tilt(quiet=True)
str_output = f"{self.pan:.2f} ({ref_pan}) ; {self.tilt:.2f} ({ref_tilt})" # noqa
str_output += f" --> [{self.pan_abs:.2f} ; {self.tilt_abs:.2f}] (abs)"
str_output += f" -- {self.flags}"
Expand Down Expand Up @@ -100,7 +101,7 @@ def create_block_position_name(self, iter_line, iter_scheduler=1):

return block_position

def get_absolute_pan_tilt(self, now=None):
def get_absolute_pan_tilt(self, now=None, quiet=False):
try: # FIXME
from configparser import ConfigParser
config_file = "config_dynamic.ini"
Expand Down Expand Up @@ -129,7 +130,7 @@ def get_absolute_pan_tilt(self, now=None):
# Get sun position
if 'sun' in [pan_ref, tilt_ref]: # pickle me :
from hypernets.geometry.spa_hypernets import spa_from_datetime
azimuth_sun, zenith_sun = spa_from_datetime(now=now)
azimuth_sun, zenith_sun = spa_from_datetime(now=now, quiet=quiet)
zenith_sun = 180 - zenith_sun

# determine hemisphere
Expand Down
60 changes: 60 additions & 0 deletions hypernets/abstract/get_led_tilt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from hypernets.abstract.protocol import Protocol
from hypernets.abstract.request import Request, InstrumentAction
from hypernets.hypstar.libhypstar.python.data_structs.spectrum_raw \
import RadiometerEntranceType
from hypernets.abstract.geometry import Geometry
from configparser import ConfigParser
import sys

if __name__ == '__main__':
config = ConfigParser()
config.read('config_dynamic.ini')

## look for VM measurement in all sequence files
expected_keys = ['sequence_file_sched2', 'sequence_file_alt',
'sequence_file_sched1', 'sequence_file',
'sequence_file_sched3']
values = {}

## get file names from config_dynamic.ini
if config.has_section('general'):
for key in expected_keys:
value = config.get('general', key, fallback=None)
if value is not None:
values[key] = value

if not values:
print(f"No sequence file names found in config_dynamic.ini")
exit(-1)

## loop through sequence files and look for VM measurements
for key, value in values.items():
try:
protocol = Protocol(value)
except FileNotFoundError as e:
print(f"Failed to open '{key}' file '{value}' when looking for LED source tilt position", file=sys.stderr)
continue
except Exception as e:
print(f"{e}", file=sys.stderr)
print(f"Failed to read '{key}' file '{sequence_file} when looking for LED source tilt position", file=sys.stderr)
print("Wrong syntax in sequence file?", file=sys.stderr)
continue

# found sequence containing VM measurement
if protocol.check_if_vm_requested() == True:
for i, (geometry, requests) in enumerate(protocol, start=1):
for request in requests:
## look for VM measurement with irradiance entrance
if request.action == InstrumentAction.VALIDATION and \
request.entrance == RadiometerEntranceType.IRRADIANCE:

geometry.get_absolute_pan_tilt()
#print(f"{geometry}")
#print(f"{request.entrance.name}")

## print absolute tilt position
print(f"{geometry.tilt_abs}")
exit(0)

print("Did not find any LED source irradiance measurements from sequence files defined in config_dynamic.ini")
exit(-1)
8 changes: 6 additions & 2 deletions hypernets/geometry/spa_hypernets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from logging import info, debug, error


def spa_from_datetime(now=None):
def spa_from_datetime(now=None, quiet=False):

if now is None:
now = datetime.now(timezone.utc)
Expand All @@ -32,7 +32,11 @@ def spa_from_datetime(now=None):
azimuth = get_azimuth(latitude, longitude, now, elevation)
zenith = 90 - get_altitude(latitude, longitude, now, elevation)

info(f"Sun Position (azimuth : {azimuth:.2f}, "
if quiet is False:
info(f"Sun Position (azimuth : {azimuth:.2f}, "
f"zenith : {zenith:.2f})")
else:
debug(f"Sun Position (azimuth : {azimuth:.2f}, "
f"zenith : {zenith:.2f})")

return azimuth, zenith
Expand Down
2 changes: 1 addition & 1 deletion hypernets/hypstar/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, instrument_port="/dev/radiometer0",
if self.hw_info.optical_multiplexer_available:
break
else:
if i < retry_count:
if i < retry_count - 1:
debug("MUX+SWIR+TEC hardware not available, retrying in 5 seconds")
sleep(5)
else:
Expand Down
38 changes: 33 additions & 5 deletions hypernets/open_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,36 @@ def run_sequence_file(sequence_file, instrument_port, instrument_br, # noqa C901
# power, one has to remember, that during initial thermal regulation
# TEC consumes 5x more current + does it for longer.
if swir_is_requested:
info(f"Cooling SWIR module to {instrument_swir_tec}°C...")
instrument_instance.set_SWIR_module_temperature(instrument_swir_tec)
info("Done!")
try:
# check if radiometer S/N is in the HYPSTAR-XR range and warn if it is not
if instrument_sn < 200000 or instrument_sn > 299999:
warning(f"Attempting SWIR measurement with radiometer S/N {instrument_sn} that is not in HYPSTAR-XR range!");

# make sure SWIR+TEC have finished init
for i in range(retry_count := 5):
if instrument_instance.hw_info.swir_module_available and \
instrument_instance.hw_info.swir_pixel_count != 0 and \
instrument_instance.hw_info.swir_tec_module_available:
break
else:
if i < retry_count - 1:
debug("SWIR+TEC hardware initialisation is not completed, retrying in 5 seconds")
sleep(5)
instrument_instance.get_hw_info()
else:
error("SWIR+TEC hardware not available")
exit(27)

info(f"Cooling SWIR module to {instrument_swir_tec}°C...")
instrument_instance.set_SWIR_module_temperature(instrument_swir_tec)
info("Done!")
except Exception as e:
# bail out instead of collecting bad data
error(f"{e}")
error("Failed to stabilise SWIR temperature. Aborting sequence.")
if not instrument_standalone:
park_to_nadir()
exit(33) # exit code 33

# print env log header
info(get_csv_header())
Expand All @@ -261,7 +288,7 @@ def run_sequence_file(sequence_file, instrument_port, instrument_br, # noqa C901
# print(f"\t- {key} : {value}")

# Check if it is raining
if check_rain:
if not instrument_standalone and check_rain:
try:
if is_raining(rain_sensor):
warning("Aborting sequence due to rain")
Expand Down Expand Up @@ -370,7 +397,8 @@ def run_sequence_file(sequence_file, instrument_port, instrument_br, # noqa C901
except Exception as e:
if request.action == InstrumentAction.VALIDATION:
error("LED source measurement failed, aborting sequence")
park_to_nadir()
if not instrument_standalone:
park_to_nadir()
exit(78) # exit code 78

error(f"Error : {e}")
Expand Down
Loading