{"action":"created","issue":{"url":"https://api.github.com/repos/nilmtk/nilmtk/issues/342","labels_url":"https://api.github.com/repos/nilmtk/nilmtk/issues/342/labels{/name}","comments_url":"https://api.github.com/repos/nilmtk/nilmtk/issues/342/comments","events_url":"https://api.github.com/repos/nilmtk/nilmtk/issues/342/events","html_url":"https://github.com/nilmtk/nilmtk/issues/342","id":55747373,"number":342,"title":"Timestamp subtraction problems","user":{"login":"MingjunZhong","id":10740778,"avatar_url":"https://avatars.githubusercontent.com/u/10740778?v=3","gravatar_id":"","url":"https://api.github.com/users/MingjunZhong","html_url":"https://github.com/MingjunZhong","followers_url":"https://api.github.com/users/MingjunZhong/followers","following_url":"https://api.github.com/users/MingjunZhong/following{/other_user}","gists_url":"https://api.github.com/users/MingjunZhong/gists{/gist_id}","starred_url":"https://api.github.com/users/MingjunZhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MingjunZhong/subscriptions","organizations_url":"https://api.github.com/users/MingjunZhong/orgs","repos_url":"https://api.github.com/users/MingjunZhong/repos","events_url":"https://api.github.com/users/MingjunZhong/events{/privacy}","received_events_url":"https://api.github.com/users/MingjunZhong/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-28T11:55:41Z","updated_at":"2015-01-28T16:21:16Z","closed_at":"2015-01-28T13:18:24Z","body":"I have the following problems (see the code at the end of this post):\r\n\r\n```python\r\nrunfile('/home/mzhong/2015-ideal/nilmtk-afhmmsac/demo_nilmtk.py', wdir='/home/mzhong/2015-ideal/nilmtk-afhmmsac')\r\nUMD has deleted: nilmtk.stats.totalenergy, nilmtk.timeframegroup, nilmtk.datastore.datastore, nilmtk, nilmtk.preprocessing, nilmtk.stats.dropoutrate, nilmtk.stats, nilmtk.docinherit, nilmtk.disaggregate.fhmm_exact, nilmtk.node, nilmtk.disaggregate.combinatorial_optimisation, nilmtk.stats.dropoutrateresults, nilmtk.elecmeter, nilmtk.version, nilmtk.consts, nilm_metadata.version, nilm_metadata.object_concatenation, nilmtk.disaggregate.hart_85, nilmtk.datastore.hdfdatastore, nilm_metadata, nilm_metadata.convert_yaml_to_hdf5, nilmtk.measurement, nilmtk.stats.totalenergyresults, nilmtk.plots, nilmtk.building, nilmtk.stats.goodsections, nilmtk.feature_detectors, nilmtk.feature_detectors.cluster, nilmtk.datastore.csvdatastore, nilmtk.datastore, nilmtk.preprocessing.clip, nilmtk.timeframe, nilmtk.stats.goodsectionsresults, nilmtk.utils, nilmtk.feature_detectors.steady_states, nilmtk.hashable, nilmtk.stats.histogram, nilmtk.dataset, nilm_metadata.file_management, nilmtk.datastore.key, nilmtk.preprocessing.apply, nilmtk.electric, nilmtk.exceptions, nilmtk.metergroup, nilmtk.disaggregate, nilmtk.results, nilmtk.appliance\r\nTraining model for submeter 'ElecMeter(instance=5, building=1, dataset='REDD', appliances=[Appliance(type='fridge', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=6, building=1, dataset='REDD', appliances=[Appliance(type='dish washer', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=7, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=8, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=2)])'\r\nTraining model for submeter 'ElecMeter(instance=9, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=11, building=1, dataset='REDD', appliances=[Appliance(type='microwave', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=12, building=1, dataset='REDD', appliances=[Appliance(type='unknown', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=13, building=1, dataset='REDD', appliances=[Appliance(type='electric space heater', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=14, building=1, dataset='REDD', appliances=[Appliance(type='electric stove', instance=1)])'\r\nTraining model for submeter 'ElecMeter(instance=15, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=3)])'\r\nTraining model for submeter 'ElecMeter(instance=16, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=4)])'\r\nTraining model for submeter 'ElecMeter(instance=17, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=2)])'\r\nTraining model for submeter 'ElecMeter(instance=18, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=3)])'\r\nTraining model for submeter 'ElecMeter(instance=19, building=1, dataset='REDD', appliances=[Appliance(type='unknown', instance=2)])'\r\nTraining model for submeter 'MeterGroup(meters=\r\n  ElecMeter(instance=3, building=1, dataset='REDD', appliances=[Appliance(type='electric oven', instance=1)])\r\n  ElecMeter(instance=4, building=1, dataset='REDD', appliances=[Appliance(type='electric oven', instance=1)])\r\n)'\r\n/home/mzhong/nilmtk/nilmtk/nilmtk/timeframe.py:246: UserWarning: Using a pytz._FixedOffset timezone may cause issues (e.g. might cause Pandas to raise 'TypeError: too many timezones in this block, create separate data columns').  It is better to set the timezone to a geographical location e.g. 'Europe/London'.\r\n  warn(\"Using a pytz._FixedOffset timezone may cause issues\"\r\n/home/mzhong/nilmtk/nilmtk/nilmtk/electric.py:96: UserWarning: If you are using `preprocessing` to resample then please do not!  Instead, please use the `sample_period` parameter and set `resample=True`.\r\n  warn(\"If you are using `preprocessing` to resample then please\"\r\nTraceback (most recent call last):\r\n\r\n  File \"<ipython-input-2-19d33dc62593>\", line 1, in <module>\r\n    runfile('/home/mzhong/2015-ideal/nilmtk-afhmmsac/demo_nilmtk.py', wdir='/home/mzhong/2015-ideal/nilmtk-afhmmsac')\r\n\r\n  File \"/home/mzhong/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py\", line 580, in runfile\r\n    execfile(filename, namespace)\r\n\r\n  File \"/home/mzhong/2015-ideal/nilmtk-afhmmsac/demo_nilmtk.py\", line 57, in <module>\r\n    co.train(elec)\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/disaggregate/combinatorial_optimisation.py\", line 59, in train\r\n    for chunk in meter.power_series(preprocessing=[Clip()]):\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/electric.py\", line 587, in load_series\r\n    for chunk in generator:\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/metergroup.py\", line 663, in load\r\n    for section in split_timeframes(sections, duration_threshold):\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/timeframe.py\", line 293, in split_timeframes\r\n    for split in timeframe.split(duration_threshold):\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/timeframe.py\", line 274, in split\r\n    if duration_threshold >= self.timedelta.total_seconds():\r\n\r\n  File \"/home/mzhong/nilmtk/nilmtk/nilmtk/timeframe.py\", line 128, in timedelta\r\n    return self.end - self.start\r\n\r\n  File \"pandas/tslib.pyx\", line 913, in pandas.tslib._Timestamp.__sub__ (pandas/tslib.c:17178)\r\n\r\nTypeError: Timestamp subtraction must have the same timezones or no timezones\r\n```\r\n\r\n=============================================================================\r\nThe problems were posed after running the following code:\r\n\r\n```python\r\nfrom nilmtk import DataSet, TimeFrame\r\nfrom nilmtk.disaggregate import CombinatorialOptimisation\r\nfrom nilmtk.disaggregate import FHMM\r\n\r\ntarget_file = '/home/mzhong/2015-ideal/energy-data/REDD/redd.h5'\r\nredd = DataSet(target_file)\r\n\r\nredd.store.window = TimeFrame(start=None, end='2011-05-01 00:00:00-04:00')\r\n\r\nelec = redd.buildings[1].elec\r\n\r\nco = CombinatorialOptimisation()\r\nco.train(elec)\r\n```"},"comment":{"url":"https://api.github.com/repos/nilmtk/nilmtk/issues/comments/71863824","html_url":"https://github.com/nilmtk/nilmtk/issues/342#issuecomment-71863824","issue_url":"https://api.github.com/repos/nilmtk/nilmtk/issues/342","id":71863824,"user":{"login":"nipunreddevil","id":60985,"avatar_url":"https://avatars.githubusercontent.com/u/60985?v=3","gravatar_id":"","url":"https://api.github.com/users/nipunreddevil","html_url":"https://github.com/nipunreddevil","followers_url":"https://api.github.com/users/nipunreddevil/followers","following_url":"https://api.github.com/users/nipunreddevil/following{/other_user}","gists_url":"https://api.github.com/users/nipunreddevil/gists{/gist_id}","starred_url":"https://api.github.com/users/nipunreddevil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nipunreddevil/subscriptions","organizations_url":"https://api.github.com/users/nipunreddevil/orgs","repos_url":"https://api.github.com/users/nipunreddevil/repos","events_url":"https://api.github.com/users/nipunreddevil/events{/privacy}","received_events_url":"https://api.github.com/users/nipunreddevil/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T16:21:16Z","updated_at":"2015-01-28T16:21:16Z","body":"@JackKelly Glad you implemented the newer way of using the timezone. Else, DST changes would have really messed up things!\r\n\r\nI think this issue cropped up because we have not yet updated some of the IPython notebooks.\r\n\r\nThanks for reporting @MingjunZhong ."}}