diff --git a/pims_nd2/ND2SDK.py b/pims_nd2/ND2SDK.py index 0b198d6..cad2313 100644 --- a/pims_nd2/ND2SDK.py +++ b/pims_nd2/ND2SDK.py @@ -7,8 +7,6 @@ if platform == "linux" or platform == "linux2": nd2 = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), 'ND2SDK', 'linux', 'libnd2ReadSDK.so')) - def jdn_to_datetime(jdn): - return None # ND2SDK gives no timestamp on linux elif platform == "darwin": raise OSError("Unsupported OS. The ND2SDK for OSX is included, " "please try to implement!") @@ -23,8 +21,13 @@ def jdn_to_datetime(jdn): os.environ["PATH"] += os.pathsep + os.path.join(dlldir) nd2 = cdll.LoadLibrary('v6_w32_nd2ReadSDK.dll') - def jdn_to_datetime(jdn): - return datetime.fromtimestamp((jdn - 2440587.5) * 86400.) + +def jdn_to_datetime_local(jdn): + return datetime.fromtimestamp((jdn - 2440587.5) * 86400.) + + +def jdn_to_datetime_utc(jdn): + return datetime.utcfromtimestamp((jdn - 2440587.5) * 86400.) LIMFILEHANDLE = c_int diff --git a/pims_nd2/ND2SDK/linux/libnd2ReadSDK.so b/pims_nd2/ND2SDK/linux/libnd2ReadSDK.so index 7197941..fdd8826 100644 Binary files a/pims_nd2/ND2SDK/linux/libnd2ReadSDK.so and b/pims_nd2/ND2SDK/linux/libnd2ReadSDK.so differ diff --git a/pims_nd2/nd2reader.py b/pims_nd2/nd2reader.py index 0a30e3a..63be103 100644 --- a/pims_nd2/nd2reader.py +++ b/pims_nd2/nd2reader.py @@ -224,7 +224,8 @@ def metadata(self): 'plane_count': bufmd.uiPlaneCount, 'angle': bufmd.dAngle, 'calibration_um': bufmd.dCalibration, - 'time_start': h.jdn_to_datetime(bufmd.dTimeStart), + 'time_start': h.jdn_to_datetime_local(bufmd.dTimeStart), + 'time_start_utc': h.jdn_to_datetime_utc(bufmd.dTimeStart), 'objective': bufmd.wszObjectiveName, 'magnification': bufmd.dObjectiveMag, 'NA': bufmd.dObjectiveNA, diff --git a/pims_nd2/test.py b/pims_nd2/test.py index fde7e62..94dacff 100644 --- a/pims_nd2/test.py +++ b/pims_nd2/test.py @@ -143,12 +143,9 @@ def test_metadata(self): assert_allclose(self.v.colors[0], [0.47, 0.91, 0.06], atol=0.01) def test_time(self): - if platform == 'linux' or platform == 'linux2': - raise nose.SkipTest('time_start not supported on linux. Skipping.') - time = self.v.metadata['time_start'] + time = self.v.metadata['time_start_utc'] assert_equal((time.year, time.month, time.day, time.hour, time.minute, - time.second, time.microsecond), - (2014, 6, 18, 15, 55, 23, 392018)) + time.second), (2014, 6, 18, 13, 55, 23)) def test_metadata_framewise(self): self.v.bundle_axes = 'yx'