- support VistaVision version 416
This commit is contained in:
@@ -3,7 +3,7 @@ Library for opening [ISS](https://iss.com) files and their conversion to tiff.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
pip install git+https://github.com/wimpomp/issfile.git
|
pip install issfile
|
||||||
|
|
||||||
## Converting .iss-pt files to .tiff files
|
## Converting .iss-pt files to .tiff files
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@ Library for opening [ISS](https://iss.com) files and their conversion to tiff.
|
|||||||
|
|
||||||
iss2tiff file.iss-pt
|
iss2tiff file.iss-pt
|
||||||
|
|
||||||
this will create file.tiff and file.carpet.tiff containing images and carpets respectively.
|
this will create file.tif and file.carpet.tif containing images and carpets respectively.
|
||||||
Metadata is also saved in the tiffs in the description tag.
|
Metadata is also saved in the tiffs in the description tag. A pdf with some plots is created too.
|
||||||
|
|
||||||
## Use as a library
|
## Use as a library
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class TiffFile(IJTiffFile):
|
|||||||
|
|
||||||
|
|
||||||
class IssFile:
|
class IssFile:
|
||||||
def __init__(self, file, version=388):
|
def __init__(self, file, version=416):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.version = version
|
self.version = version
|
||||||
self.zip = ZipFile(self.file)
|
self.zip = ZipFile(self.file)
|
||||||
@@ -122,20 +122,25 @@ class IssFile:
|
|||||||
frame_bytes = self.shape[0] * self.shape[1] * self.delta
|
frame_bytes = self.shape[0] * self.shape[1] * self.delta
|
||||||
data, metadata = [], []
|
data, metadata = [], []
|
||||||
self.data.seek(frame * frame_bytes)
|
self.data.seek(frame * frame_bytes)
|
||||||
for i in range(int(1000 * self.time_interval / self.cycle_time)):
|
cycles = int(1000 * self.time_interval / self.cycle_time)
|
||||||
|
for i in range(cycles):
|
||||||
line = [unpack('<H', self.data.read(2))[0] for _ in range(self.points_per_orbit * self.orbits_per_cycle)]
|
line = [unpack('<H', self.data.read(2))[0] for _ in range(self.points_per_orbit * self.orbits_per_cycle)]
|
||||||
data.append(line)
|
data.append(line)
|
||||||
if self.version >= 388:
|
if self.version >= 388:
|
||||||
metadata.append(unpack('<ffff', self.data.read(16)))
|
metadata.append(unpack('<ffff', self.data.read(16)))
|
||||||
else:
|
else:
|
||||||
metadata.append([i * self.cycle_time, 0, 0, 0])
|
metadata.append([(i + 1) * self.cycle_time, 0, 0, 0])
|
||||||
|
data, metadata = np.vstack(data), np.vstack(metadata).T
|
||||||
data, metadata = np.vstack(data), np.vstack(metadata)
|
if self.version >= 416:
|
||||||
index = np.zeros(int(round(max(metadata[:, 0]) / self.cycle_time)) + 1, int)
|
index = np.argsort(metadata[0])
|
||||||
for i, j in enumerate(metadata[:, 0]):
|
index = index[metadata[0, index] > 0]
|
||||||
index[int(round(j / self.cycle_time))] = i
|
else:
|
||||||
metadata[:, 0] += self.get_carpet_t0(t, metadata.shape[0])
|
index = np.zeros(int(round(max(metadata[0]) / self.cycle_time)) + 1, int)
|
||||||
return data[index], metadata[index].T
|
for i, j in enumerate(metadata[0]):
|
||||||
|
index[int(round(j / self.cycle_time)) - 1] = i
|
||||||
|
index = index[metadata[0, index] > 0]
|
||||||
|
metadata[0] += self.get_carpet_t0(t, cycles)
|
||||||
|
return data[index], metadata[:, index]
|
||||||
|
|
||||||
def get_carpet_t0(self, t, cycles=None):
|
def get_carpet_t0(self, t, cycles=None):
|
||||||
if t + 1 > len(self._carpet_t0):
|
if t + 1 > len(self._carpet_t0):
|
||||||
@@ -214,8 +219,8 @@ class IssFile:
|
|||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser(description='Convert .iss-pt files into .tiff files.')
|
parser = ArgumentParser(description='Convert .iss-pt files into .tiff files.')
|
||||||
parser.add_argument('files', help='files to be converted', nargs='*')
|
parser.add_argument('files', help='files to be converted', nargs='*')
|
||||||
parser.add_argument('-v', '--version', type=int, default=388,
|
parser.add_argument('-v', '--version', type=int, default=416,
|
||||||
help='version of VistaVision with which the .iss-pt was written, default: 388')
|
help='version of VistaVision with which the .iss-pt was written, default: 416')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
for file in [Path(file) for files in args.files for file in glob(files)]:
|
for file in [Path(file) for files in args.files for file in glob(files)]:
|
||||||
|
|||||||
Reference in New Issue
Block a user