bluesky / suitcase-tiff

http://nsls-ii.github.io/suitcase
Other
2 stars 5 forks source link

Cannot convert `hdr.start['time'] using the specified format #21

Open EliotGann opened 5 years ago

EliotGann commented 5 years ago

Observed at SST-2/RSOXS by @mrakitin and @awalter-bnl. The issue is created by @mrakitin.

In [75]: tiff_series.export(db[-1].documents(fill=True), file_prefix='{start[institution]}-{start[time]:%Y-%m-%d_%H-%M}-', directory=os.getcwd())
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-75-1cb6645c4b01> in <module>
----> 1 tiff_series.export(db[-1].documents(fill=True), file_prefix='{start[institution]}-{start[time]:%Y-%m-%d_%H-%M}-', directory=os.getcwd())

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\suitcase\tiff_series\__init__.py in export(gen, directory, file_prefix, bigtiff, byteorder, imagej, **kwargs)
     99                     **kwargs) as serializer:
    100         for item in gen:
--> 101             serializer(*item)
    102
    103     return serializer.artifacts

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\event_model\__init__.py in __call__(self, name, doc, validate)
     69             instance as doc, a copy of doc, or a different dict altogether.
     70         """
---> 71         output_doc = getattr(self, name)(doc)
     72         if validate:
     73             jsonschema.validate(output_doc,

c:\users\greateyes\appdata\local\conda\conda\envs\collection-2019-1.2-rsoxs\lib\site-packages\suitcase\tiff_series\__init__.py in event(self, doc)
    219                 self._templated_file_prefix = self._file_prefix.format(
    220                     start=self._start, descriptor=descriptor,
--> 221                     event=doc)
    222                 num = next(self._counter[streamname][field])
    223                 filename = (f'{self._templated_file_prefix}'

ValueError: Invalid format specifier

It turns out that hdr.start['time'] is a float, and it's not possible to convert a float to the datetime object, and then format it to a string.