Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
97 changes: 56 additions & 41 deletions cuvis/FileWriteSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,33 @@ def _get_internal(self):
ge.add_fullscale_pan = int(self.add_fullscale_pan)
ge.permissive = int(self.permissive)
return ge

@classmethod
def _from_internal(cls, ge):
return cls(export_dir=ge.export_dir,
channel_selection=ge.channel_selection,
spectra_multiplier=ge.spectra_multiplier,
pan_sharpening_interpolation_type=internal.__PanSharpeningInterpolationType__[ge.pan_interpolation_type],
pan_sharpening_algorithm=internal.__PanSharpeningAlgorithm__[ge.pan_algorithm],
pan_sharpening_interpolation_type=internal.__PanSharpeningInterpolationType__[
ge.pan_interpolation_type],
pan_sharpening_algorithm=internal.__PanSharpeningAlgorithm__[
ge.pan_algorithm],
add_pan=bool(ge.add_pan),
add_fullscale_pan=bool(ge.add_fullscale_pan),
permissive=bool(ge.permissive))


@dataclass
class EnviExportSettings(GeneralExportSettings):

def _get_internal(self):
ge = super()._get_internal()
es = None
return ge, es

@classmethod
def _from_internal(cls, ge, es):
ge = super()._from_internal(ge)
return cls(**ge.__dict__)



@dataclass
Expand All @@ -72,17 +74,20 @@ class TiffExportSettings(GeneralExportSettings):
def _get_internal(self):
ge = super()._get_internal()
ts = cuvis_il.cuvis_export_tiff_settings_t()
ts.compression_mode = internal.__CuvisTiffCompressionMode__[self.compression_mode]
ts.compression_mode = internal.__CuvisTiffCompressionMode__[
self.compression_mode]
ts.format = internal.__CuvisTiffFormat__[self.format]
return ge, ts

@classmethod
def _from_internal(cls, ge, ts):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
compression_mode=internal.__TiffCompressionMode__[ts.compression_mode],
compression_mode=internal.__TiffCompressionMode__[
ts.compression_mode],
format=internal.__TiffFormat__[ts.format])


@dataclass(repr=False)
class ViewExportSettings(GeneralExportSettings):
userplugin: InitVar[str] = None
Expand All @@ -98,8 +103,9 @@ def __post_init__(self, userplugin: str):
with open(userplugin) as f:
self._userplugin = "".join(f.readlines())
else:
raise SDKException('Error when validating plugin data. Please provide a valid plugin or a path to a plugin file')

raise SDKException(
'Error when validating plugin data. Please provide a valid plugin or a path to a plugin file')

@property
def userplugin(self) -> str:
return self._userplugin
Expand All @@ -108,29 +114,28 @@ def userplugin(self) -> str:
def userplugin(self, v: str) -> None:
self.__post_init__(v)


def __repr__(self):
def short_str(s: str, l: int) -> str:
return (s[:l] + '...') if len(s) > l else s

"""Returns a string containing but shortens the userplugin field."""
s = ', '.join(list(f'{field.name}={getattr(self, field.name)}'
for field in fields(self)) + [f'userplugin={short_str(self._userplugin, 15)}'])
for field in fields(self)) + [f'userplugin={short_str(self._userplugin, 15)}'])
return f'{type(self).__name__}({s})'


def _get_internal(self):
ge = super()._get_internal()
vs = cuvis_il.cuvis_export_view_settings_t()
vs.userplugin = self.userplugin
return ge, vs

@classmethod
def _from_internal(cls, ge, vs):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
return cls(**ge.__dict__,
userplugin=vs.userplugin)


@dataclass
class SaveArgs(GeneralExportSettings):
allow_overwrite: bool = False
Expand All @@ -153,30 +158,33 @@ def _get_internal(self):
sa.allow_drop = int(self.allow_drop)
sa.allow_session_file = int(self.allow_session_file)
sa.allow_info_file = int(self.allow_info_file)
sa.operation_mode = internal.__CuvisOperationMode__[self.operation_mode]
sa.operation_mode = internal.__CuvisOperationMode__[
self.operation_mode]
sa.fps = int(self.fps)
sa.soft_limit = int(self.soft_limit)
sa.hard_limit = int(self.hard_limit)
sa.max_buftime = int(self.max_buftime)
sa.full_export = int(self.full_export)
return ge, sa

@classmethod
def _from_internal(cls, ge, sa):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
allow_overwrite = bool(sa.allow_overwrite),
allow_fragmentation = bool(sa.allow_fragmentation),
allow_drop = bool(sa.allow_drop),
allow_session_file = bool(sa.allow_session_file),
allow_info_file = bool(sa.allow_info_file),
operation_mode = internal.__OperationMode__[sa.operation_mode],
fps = sa.fps,
soft_limit = sa.soft_limit,
hard_limit = sa.hard_limit,
max_buftime = sa.max_buftime,
full_export = sa.full_export
)
allow_overwrite=bool(sa.allow_overwrite),
allow_fragmentation=bool(sa.allow_fragmentation),
allow_drop=bool(sa.allow_drop),
allow_session_file=bool(sa.allow_session_file),
allow_info_file=bool(sa.allow_info_file),
operation_mode=internal.__OperationMode__[
sa.operation_mode],
fps=sa.fps,
soft_limit=sa.soft_limit,
hard_limit=sa.hard_limit,
max_buftime=sa.max_buftime,
full_export=sa.full_export
)


@dataclass
class ProcessingArgs(object):
Expand All @@ -186,27 +194,34 @@ class ProcessingArgs(object):
def _get_internal(self):
pa = cuvis_il.cuvis_proc_args_t()
pa.allow_recalib = int(self.allow_recalib)
pa.processing_mode = int(internal.__CuvisProcessingMode__[self.processing_mode])
pa.processing_mode = int(internal.__CuvisProcessingMode__[
self.processing_mode])
return pa

@classmethod
def _from_internal(cls, pa):
return cls(allow_recalib=bool(pa.allow_recalib),
processing_mode=internal.__ProcessingMode__[pa.processing_mode])


@dataclass
class WorkerSettings(object):
worker_count: int = 0
poll_intervall: int = 10
hard_limit: int = 10
soft_limit: int = 10
can_drop: bool = True
input_queue_size: int = 0
mandatory_queue_size: int = 4
supplementary_queue_size: int = 4
output_queue_size: int = 10
can_skip_measurements: bool = False
can_skip_supplementary_steps: bool = True
can_drop_results: bool = True

def _get_internal(self):
wa = cuvis_il.cuvis_worker_settings_t()
wa.worker_count = int(self.worker_count)
wa.poll_interval = int(self.poll_intervall)
wa.worker_queue_hard_limit = int(self.hard_limit)
wa.worker_queue_soft_limit = int(self.soft_limit)
wa.can_drop = int(self.can_drop)
wa.input_queue_size = int(self.input_queue_size)
wa.mandatory_queue_size = int(self.mandatory_queue_size)
wa.supplementary_queue_size = int(self.supplementary_queue_size)
wa.output_queue_size = int(self.output_queue_size)
wa.can_skip_measurements = int(self.can_skip_measurements)
wa.can_skip_supplementary_steps = int(
self.can_skip_supplementary_steps)
wa.can_drop_results = int(self.can_drop_results)
return wa
Loading