def __init__(self,sc,dt,mode,version='B',dir='/cluster/data/raw/'): version = version.upper() mode = mode.lower() if version not in ['A','B','K']: module_logger.error("Version must be one of 'A','B' or 'K'") raise Exception("Version must be one of 'A','B' or 'K'") if mode not in RawDataHeader.mode_dict.keys(): module_logger.error("Please select either 'NS' or 'BS'") raise Exception("Please select either 'NS' or 'BS'") if sc not in [1,2,3,4]: module_logger.error("Select a valid spacecraft (1,2,3,4)") raise Exception("Select a valid spacecraft (1,2,3,4)") Year,year,month,day = map(int,dt.strftime("%Y,%y,%m,%d").split(',')) if Year<2000: module_logger.error("Need to select a year after (or on) 2000") raise Exception("Need to select a year after (or on) 2000") directory = dir+'{0:4d}/{1:02d}/'.format(Year,month) file = 'C{0:1d}_{1:02d}{2:02d}{3:02d}_{4:s}.{5:s}'.format( sc,year,month,day,version,RawDataHeader.mode_dict[mode]) filepath = directory+file self.fgm_data = orddict([ ('Telemetry Mode',[]), ('Reset Count',[]), ('Packet Start HF',[]), ('Previous Sun Pulse',[]), ('Most Recent Sun Pulse',[]), ('First 1ry HF',[]), ('First 2ry HF',[]), ('Sumcheck code failure',[]), ('Incorrect vectors sampled',[]), ('Possible currupt science data',[]), ('DPU test sequence number',[]), ('MSA data filtered',[]), ('Calibration sequence number',[]), ('Memory Dump in Progress',[]), ('Code Patch in Progress',[])]) self.dds_data = orddict([ ('SCET',[]), ('Header ID',[]), ('sc ID',[]), ('Packet Length',[]), ('Groundstation ID',[])]) self.data = [] self.packet_info = pd.DataFrame() ''' Exceptions should probably be handled differently for the final code, since these are not really fatal errors, unless previous checking is done. ''' try: with open(filepath,'rb') as f: self.data = f.read() except IOError: module_logger.error("Could not open file:"+filepath) #raise Exception if not self.data: module_logger.error("Could not read file:"+filepath) #raise Exception("Could not read file:"+filepath) else: self.__read_headers()
def __tojson__(self): return orddict([ ("rawname", self._name), ("code", self._code)])
def __tojson__(self): return orddict([ ("name", self.getName()), ("parts", self._parts)])
def __tojson__(self): return orddict([ ("name", self.getName()), ("code", self.getCode().getTriposPart()), ("subjects", self._subjects)])