Exemplo n.º 1
0
 def test_scn_write():
     intervals = np.hstack((np.arange(1,501),np.arange(1,501)))
     amplitudes = np.ones(1000)*-1
     amplitudes[::2] = 0
     amplitudes = amplitudes.astype('int')
     flags = np.zeros(1000)
     flags = flags.astype('int')
     dcio.scn_write(intervals, amplitudes, flags, filename='./test.SCN')
     new_patch = Patch('./test.SCN')
     new_patch.read_scn(tres=0, tcrit=500)
     new_patch.write_scn()
     new_patch = Patch('./modified_test.SCN')
     new_patch.read_scn(tres=0, tcrit=np.inf)
     period = new_patch[1].period
     print(sum(intervals[3:-1]-period))
Exemplo n.º 2
0
 def write_scn(self, modified = 'modified_', filepath = None, 
               patch_name = None):
     '''
     Write into scn file.
     '''
     if filepath is None:
         filepath = self._filepath
     if patch_name is None:
         patch_name = modified + self._patch_name+'.SCN'
         
     intervals = []
     amplitudes = []
     flags = []
     
     end = 0
     
     for cluster_num in self._cluster_list:
         cluster = self._cluster_dict[cluster_num]
         #add a shut time interval which represents the intercluster shut time
         shut = cluster.start - end
         end = cluster.end
         intervals.append(shut)
         amplitudes.append(0)
         # Flag this shut time as bad
         flags.append(8)
         
         # Add data
         intervals.append(cluster.period)
         amplitudes.append(cluster.amp)
         flags.append(cluster.flag)
         
     intervals = np.hstack(intervals)
     amplitudes = np.hstack(amplitudes)*-1
     amplitudes = amplitudes.astype('int')
     flags = np.hstack(flags)
     flags = flags.astype('int')
     
     filename = os.path.join(filepath, patch_name)
     dcio.scn_write(intervals, amplitudes, flags, filename=filename)
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  4 14:03:19 2016

@author: zhiyiwu
"""

import numpy as np
from dcpyps import dataset, dcio

intervals = np.arange(10)/10
amplitudes = np.ones(10)
amplitudes[::2] = 0
amplitudes = amplitudes.astype('int')
flags = np.zeros(10)
flags = flags.astype('int')

dcio.scn_write(intervals, amplitudes, flags, filename='./test.SCN')

screcord = dataset.SCRecord(['./test.SCN',])
print(screcord.pint)