class TestArchiver(unittest.TestCase): def setUp(self): self.archiver = Archiver('http://fake') self.archiver.archiver = MockArchiver() def test_scan_archives_all(self): self.archiver.scan_archives() archives_for_channel = self.archiver.archives_for_channel data = self.archiver.get('XF:23IDA-VA:0{DP:1-IP:1}P-I', '2013-08-11', '2013-08-12') print data self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertTrue('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertTrue('EXAMPLE:ENUM_SCALAR' in archives_for_channel) self.assertEqual( archives_for_channel, { 'EXAMPLE:DOUBLE_SCALAR{TD:1}': [ ArchiveProperties( key=1001, start_time=datetime.datetime(2012, 7, 12, 21, 47, 23, 664000, tzinfo=utc), end_time=datetime.datetime(2012, 7, 13, 11, 18, 55, 671259, tzinfo=utc) ) ], 'EXAMPLE:INT_WAVEFORM': [ ArchiveProperties( key=1001, start_time=datetime.datetime(2012, 7, 12, 23, 14, 19, 129600, tzinfo=utc), end_time=datetime.datetime(2012, 7, 13, 8, 26, 18, 558211, tzinfo=utc) ) ], 'EXAMPLE:ENUM_SCALAR': [ ArchiveProperties( key=1008, start_time=datetime.datetime(2012, 7, 12, 22, 41, 10, 765676, tzinfo=utc), end_time=datetime.datetime(2012, 7, 13, 9, 20, 23, 623789, tzinfo=utc) ) ] } ) def test_scan_archives_one(self): self.archiver.scan_archives('EXAMPLE:DOUBLE_SCALAR{TD:1}') archives_for_channel = self.archiver.archives_for_channel.keys() self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertFalse('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertFalse('EXAMPLE:ENUM_SCALAR' in archives_for_channel) def test_scan_archives_list(self): self.archiver.scan_archives(['EXAMPLE:DOUBLE_SCALAR{TD:1}', 'EXAMPLE:ENUM_SCALAR']) archives_for_channel = self.archiver.archives_for_channel.keys() self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertFalse('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertTrue('EXAMPLE:ENUM_SCALAR' in archives_for_channel) def test_get_scalar(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) data = self.archiver.get(['EXAMPLE:DOUBLE_SCALAR{TD:1}'], start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(data, list)) channel_data = data[0] self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.data_type, codes.data_type.DOUBLE) self.assertEqual(channel_data.elements, 1) self.assertEqual(channel_data.values, [ 200.5, 199.9, 198.7, 196.1 ]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 12, 21, 47, 23, 664000, utc), datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc), datetime.datetime(2012, 7, 13, 11, 18, 55, 671259, utc) ]) self.assertEqual(channel_data.statuses, [0, 6, 6, 5]) self.assertEqual(channel_data.severities, [0, 1, 1, 2]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC()') def test_get_interpolation_string(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation='raw') self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.values, [ 200.5, 199.9, 198.7, 196.1 ]) def test_get_scalar_str(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(channel_data, ChannelData)) self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.data_type, codes.data_type.DOUBLE) def test_get_scalar_in_tz(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW, tz=utils.UTC(11.5)) self.assertEqual(str(data.times[0].tzinfo), 'UTC+11:30') self.assertEqual(repr(data.times[0].tzinfo), 'UTC(+11.5)') def test_get_without_scan(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) self.assertRaises(exceptions.ChannelNotFound, self.archiver.get, ['EXAMPLE:DOUBLE_SCALAR{TD:1}'], start, end, interpolation=codes.interpolation.RAW, scan_archives=False) def test_get_with_restrictive_interval(self): start = datetime.datetime(2012, 7, 13, tzinfo=utc) end = datetime.datetime(2012, 7, 13, 10, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [ 199.9, 198.7 ]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) def test_get_with_restrictive_interval_with_tzs(self): start = datetime.datetime(2012, 7, 13, 10, tzinfo=utils.UTC(10)) end = datetime.datetime(2012, 7, 13, 20, tzinfo=utils.UTC(10)) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [ 199.9, 198.7 ]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC(+10)') def test_get_with_str_times(self): start = '2012-07-13 00:00:00Z' end = '2012-07-13 10:00:00Z' channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [ 199.9, 198.7 ]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) def test_get_with_str_times_incl_tz(self): start = '2012-07-13 10:00:00+10:00' end = '2012-07-13 20:00:00+10:00' channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [ 199.9, 198.7 ]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC(+10)') def test_get_waveform(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) channel_data = self.archiver.get( 'EXAMPLE:INT_WAVEFORM', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.channel, 'EXAMPLE:INT_WAVEFORM') self.assertEqual(channel_data.data_type, codes.data_type.INT) self.assertEqual(channel_data.elements, 3) self.assertEqual(channel_data.values, [ [3, 5, 13], [2, 4, 11], [0, 7, 1] ]) def test_get_enum(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) channel_data = self.archiver.get( 'EXAMPLE:ENUM_SCALAR', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.channel, 'EXAMPLE:ENUM_SCALAR') self.assertEqual(channel_data.data_type, codes.data_type.ENUM) self.assertEqual(channel_data.values, [7, 1, 8]) def test_get_multiple(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) data = self.archiver.get( ['EXAMPLE:DOUBLE_SCALAR{TD:1}', 'EXAMPLE:INT_WAVEFORM', 'EXAMPLE:ENUM_SCALAR'], start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(data, list)) self.assertEqual(data[0].channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(data[1].channel, 'EXAMPLE:INT_WAVEFORM') self.assertEqual(data[2].channel, 'EXAMPLE:ENUM_SCALAR') self.assertEqual(data[0].values, [ 200.5, 199.9, 198.7, 196.1 ]) self.assertEqual(data[1].values, [[3, 5, 13], [2, 4, 11], [0, 7, 1]]) self.assertEqual(data[2].values, [7, 1, 8]) def test_get_with_wrong_number_of_keys(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) self.assertRaises(exceptions.ChannelKeyMismatch, self.archiver.get, [ 'EXAMPLE:DOUBLE_SCALAR{TD:1}' ], start, end, archive_keys=[1001, 1008], interpolation=codes.interpolation.RAW)
# playing around from channelarchiver import Archiver, codes, utils ss = 'http://sdss-telemetry.apo.nmsu.edu/telemetry/cgi/ArchiveDataServer.cgi' #ss='http://localhost:5080/telemetry/cgi/ArchiveDataServer.cgi' archiver = Archiver(ss) archiver.scan_archives() start = '2018-06-25 10:00:00' end = '2018-06-26 11:00:00' archiver.scan_archives() data1 = archiver.get('25m:boss:SP1B2LN2TempRead', start, end, interpolation='raw', scan_archives=False) data2 = archiver.get('25m:boss:SP1R0LN2TempRead', start, end, interpolation='raw', scan_archives=False) data3 = archiver.get('25m:boss:SP2B2LN2TempRead', start, end, interpolation='raw', scan_archives=False) data4 = archiver.get('25m:boss:SP2R0LN2TempRead', start, end,
[ '2018-12-05 00:00:00', '2018-12-05 11:43:13' ], \ [ '2018-12-06 00:00:00', '2018-12-06 12:42:36' ], \ [ '2018-12-07 00:00:00', '2018-12-07 10:00:54' ], \ [ '2018-12-08 00:00:00', '2018-12-08 11:38:05' ], \ [ '2018-12-09 00:00:00', '2018-12-09 13:11:02' ], \ [ '2018-12-10 00:00:00', '2018-12-10 11:54:55' ]) for period in range(len(periods)): start = periods[period][0] end = periods[period][1] # NEED TO TAKE THIS FROM THE COMMAND LINE pvs_to_retrieve = [ '25m:guider:cartridgeLoaded:plateID', '25m:guider:guideState' ] archiver.scan_archives() for pv in pvs_to_retrieve: print("# " + pv) # print "# DIAGNOSTIC: start: " + start # print "# DIAGNOSTIC: end: " + end retrieved_pv = archiver.get(pv, start, end, interpolation='raw', scan_archives=False) for i in range(len(retrieved_pv.values)): print("%s\t%d" % (retrieved_pv.times[i].strftime('%Y-%m-%d %H:%M:%S.%f'), retrieved_pv.values[i]))
class TestArchiver(unittest.TestCase): def setUp(self): self.archiver = Archiver('http://fake') self.archiver.archiver = MockArchiver() def test_scan_archives_all(self): self.archiver.scan_archives() archives_for_channel = self.archiver.archives_for_channel data = self.archiver.get('XF:23IDA-VA:0{DP:1-IP:1}P-I', '2013-08-11', '2013-08-12') print data self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertTrue('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertTrue('EXAMPLE:ENUM_SCALAR' in archives_for_channel) self.assertEqual( archives_for_channel, { 'EXAMPLE:DOUBLE_SCALAR{TD:1}': [ ArchiveProperties( key=1001, start_time=datetime.datetime( 2012, 7, 12, 21, 47, 23, 664000, tzinfo=utc), end_time=datetime.datetime( 2012, 7, 13, 11, 18, 55, 671259, tzinfo=utc)) ], 'EXAMPLE:INT_WAVEFORM': [ ArchiveProperties( key=1001, start_time=datetime.datetime( 2012, 7, 12, 23, 14, 19, 129600, tzinfo=utc), end_time=datetime.datetime( 2012, 7, 13, 8, 26, 18, 558211, tzinfo=utc)) ], 'EXAMPLE:ENUM_SCALAR': [ ArchiveProperties( key=1008, start_time=datetime.datetime( 2012, 7, 12, 22, 41, 10, 765676, tzinfo=utc), end_time=datetime.datetime( 2012, 7, 13, 9, 20, 23, 623789, tzinfo=utc)) ] }) def test_scan_archives_one(self): self.archiver.scan_archives('EXAMPLE:DOUBLE_SCALAR{TD:1}') archives_for_channel = self.archiver.archives_for_channel.keys() self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertFalse('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertFalse('EXAMPLE:ENUM_SCALAR' in archives_for_channel) def test_scan_archives_list(self): self.archiver.scan_archives( ['EXAMPLE:DOUBLE_SCALAR{TD:1}', 'EXAMPLE:ENUM_SCALAR']) archives_for_channel = self.archiver.archives_for_channel.keys() self.assertTrue('EXAMPLE:DOUBLE_SCALAR{TD:1}' in archives_for_channel) self.assertFalse('EXAMPLE:INT_WAVEFORM' in archives_for_channel) self.assertTrue('EXAMPLE:ENUM_SCALAR' in archives_for_channel) def test_get_scalar(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) data = self.archiver.get(['EXAMPLE:DOUBLE_SCALAR{TD:1}'], start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(data, list)) channel_data = data[0] self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.data_type, codes.data_type.DOUBLE) self.assertEqual(channel_data.elements, 1) self.assertEqual(channel_data.values, [200.5, 199.9, 198.7, 196.1]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 12, 21, 47, 23, 664000, utc), datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc), datetime.datetime(2012, 7, 13, 11, 18, 55, 671259, utc) ]) self.assertEqual(channel_data.statuses, [0, 6, 6, 5]) self.assertEqual(channel_data.severities, [0, 1, 1, 2]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC()') def test_get_interpolation_string(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation='raw') self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.values, [200.5, 199.9, 198.7, 196.1]) def test_get_scalar_str(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(channel_data, ChannelData)) self.assertEqual(channel_data.channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(channel_data.data_type, codes.data_type.DOUBLE) def test_get_scalar_in_tz(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW, tz=utils.UTC(11.5)) self.assertEqual(str(data.times[0].tzinfo), 'UTC+11:30') self.assertEqual(repr(data.times[0].tzinfo), 'UTC(+11.5)') def test_get_without_scan(self): start = datetime.datetime(2012, 1, 1, tzinfo=utc) end = datetime.datetime(2013, 1, 1, tzinfo=utc) self.assertRaises(exceptions.ChannelNotFound, self.archiver.get, ['EXAMPLE:DOUBLE_SCALAR{TD:1}'], start, end, interpolation=codes.interpolation.RAW, scan_archives=False) def test_get_with_restrictive_interval(self): start = datetime.datetime(2012, 7, 13, tzinfo=utc) end = datetime.datetime(2012, 7, 13, 10, tzinfo=utc) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [199.9, 198.7]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) def test_get_with_restrictive_interval_with_tzs(self): start = datetime.datetime(2012, 7, 13, 10, tzinfo=utils.UTC(10)) end = datetime.datetime(2012, 7, 13, 20, tzinfo=utils.UTC(10)) channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [199.9, 198.7]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC(+10)') def test_get_with_str_times(self): start = '2012-07-13 00:00:00Z' end = '2012-07-13 10:00:00Z' channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [199.9, 198.7]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) def test_get_with_str_times_incl_tz(self): start = '2012-07-13 10:00:00+10:00' end = '2012-07-13 20:00:00+10:00' channel_data = self.archiver.get('EXAMPLE:DOUBLE_SCALAR{TD:1}', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.values, [199.9, 198.7]) self.assertEqual(channel_data.times, [ datetime.datetime(2012, 7, 13, 2, 5, 1, 443589, utc), datetime.datetime(2012, 7, 13, 7, 19, 31, 806097, utc) ]) self.assertEqual(repr(channel_data.times[0].tzinfo), 'UTC(+10)') def test_get_waveform(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) channel_data = self.archiver.get('EXAMPLE:INT_WAVEFORM', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.channel, 'EXAMPLE:INT_WAVEFORM') self.assertEqual(channel_data.data_type, codes.data_type.INT) self.assertEqual(channel_data.elements, 3) self.assertEqual(channel_data.values, [[3, 5, 13], [2, 4, 11], [0, 7, 1]]) def test_get_enum(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) channel_data = self.archiver.get('EXAMPLE:ENUM_SCALAR', start, end, interpolation=codes.interpolation.RAW) self.assertEqual(channel_data.channel, 'EXAMPLE:ENUM_SCALAR') self.assertEqual(channel_data.data_type, codes.data_type.ENUM) self.assertEqual(channel_data.values, [7, 1, 8]) def test_get_multiple(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) data = self.archiver.get([ 'EXAMPLE:DOUBLE_SCALAR{TD:1}', 'EXAMPLE:INT_WAVEFORM', 'EXAMPLE:ENUM_SCALAR' ], start, end, interpolation=codes.interpolation.RAW) self.assertTrue(isinstance(data, list)) self.assertEqual(data[0].channel, 'EXAMPLE:DOUBLE_SCALAR{TD:1}') self.assertEqual(data[1].channel, 'EXAMPLE:INT_WAVEFORM') self.assertEqual(data[2].channel, 'EXAMPLE:ENUM_SCALAR') self.assertEqual(data[0].values, [200.5, 199.9, 198.7, 196.1]) self.assertEqual(data[1].values, [[3, 5, 13], [2, 4, 11], [0, 7, 1]]) self.assertEqual(data[2].values, [7, 1, 8]) def test_get_with_wrong_number_of_keys(self): start = datetime.datetime(2012, 1, 1) end = datetime.datetime(2013, 1, 1) self.assertRaises(exceptions.ChannelKeyMismatch, self.archiver.get, ['EXAMPLE:DOUBLE_SCALAR{TD:1}'], start, end, archive_keys=[1001, 1008], interpolation=codes.interpolation.RAW)
def get_archived_pv(pv, start_time, end_time, label=None, limit=None, make_wave=True, interpolation='raw'): '''Yugang May 15, 2017 Get a archived PV value Input: start time: str, e.g., '2017-04-11 09:00', end time: str, e.g., '2017-04-12 11:00' label: str, a meaningful label for the pv limit: integer, the limit data point make_wave: if True, make a 'square-wave like' data interpolation: 'raw', gives the raw archived data Return: a pandas.dataframe with column as datetime, float time, and value data An example: data = get_archived_pv('XF:11IDA-OP{Mono:DCM-Ax:Bragg}T-I', '2017-04-11 09:00', '2017-04-11 11:00') ''' from channelarchiver import Archiver archiver = Archiver( 'http://xf11id-ca.cs.nsls2.local/cgi-bin/ArchiveDataServer.cgi') import numpy as np import pandas as pd if label is None: label = pv #if pv[0][:2] == 'SR': # res = arget( pv,start=start_time, # end=end_time,count=limit, conf = 'middle') #else: print('Seraching PV: %s from: %s---to: %s' % (label, start_time, end_time)) res = archiver.get(pv, start_time, end_time, scan_archives=True, limit=limit, interpolation=interpolation) #print res key = pv v = np.array(res[key][0], dtype=float) k1 = res[key][1] N = len(k1) sec = np.array([k1[i][2] for i in range(N)]) nsec = np.array([k1[i][3] for i in range(N)]) tf = sec + nsec * 10**(-9) if make_wave: v = make_wave_data(v, dtype='y') tf = make_wave_data(tf, dtype='x') td = trans_tf_to_td(tf, dtype='array') NN = len(td) tv = np.array([td, tf.reshape(NN), v.reshape(NN)]).T index = np.arange(len(tv)) data = tv df = pd.DataFrame(data, index=index, columns=['td', 'tf', label[0]]) if make_wave: fnum = len(df.td) / 2 else: fnum = len(df.td) return df
'--verbose', action="store_true", help='print incremental dust data') args = parser.parse_args() mjd = args.mjd vBool = args.verbose start, end = getTimeStamps(mjd) print("MJD start/end times") print(start) print(end) archiver.scan_archives() data1 = archiver.get('25m:mcp:rotFiducialCrossing:index', start, end, interpolation='raw', scan_archives=False) # data2= archiver.get('25m:apo:encl25m', start, end, interpolation='raw',scan_archives=False) # print " Enlosure open/close times" # print data2 print("") nn = len(data1.values) print("date time index encl sum") for i in range(nn): tm = data1.times[i] degrees = archiver.get('25m:mcp:rotFiducialCrossing:deg', tm, tm, interpolation='raw',
'--verbose', action="store_true", help='print incremental dust data') args = parser.parse_args() mjd = args.mjd vBool = args.verbose start, end = getTimeStamps(mjd) print("MJD start/end times") print(start) print(end) archiver.scan_archives() data1 = archiver.get('25m:apo:dustb', start, end, interpolation='raw', scan_archives=False) data2 = archiver.get('25m:apo:encl25m', start, end, interpolation='raw', scan_archives=False) print(" Enlosure open/close times") print(data2) print("") sum = 0 nn = len(data1.values) print("date time dust encl sum") for i in range(nn):