def createEmptyPhotonListFile(obsFile,fileName=None): """ creates a photonList h5 file using header in headers.ArconsHeaders INPUTS: fileName - string, name of file to write to. If not supplied, default is used based on name of original obs. file and standard directories etc. (see usil.FileName). Added 4/29/2013, JvE """ if fileName is None: fileTimestamp = obsFile.fileName.split('_')[1].split('.')[0] fileDate = os.path.basename(os.path.dirname(obsFile.fullFileName)) run = os.path.basename(os.path.dirname(os.path.dirname(obsFile.fullFileName))) fn = FileName(run=run, date=fileDate, tstamp=fileTimestamp) fullPhotonListFileName = fn.photonList() else: fullPhotonListFileName = fileName if (os.path.exists(fullPhotonListFileName)): if utils.confirm('Photon list file %s exists. Overwrite?' % fullPhotonListFileName, defaultResponse=False) == False: warnings.warn('No photon list file created') return zlibFilter = tables.Filters(complevel=1, complib='zlib', fletcher32=False) try: plFile = tables.openFile(fullPhotonListFileName, mode='w') plGroup = plFile.createGroup('/', 'photons', 'Group containing photon list') plTable = plFile.createTable(plGroup, 'photons', ArconsHeaders.CrabList, 'Photon List Data', filters=zlibFilter, expectedrows=300000) #Temporary fudge to see if it helps! except: plFile.close() raise return plFile
def relabel(self, new_name): fn = FileName(new_name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_VOLUME_NAME, file_name=name, node=self) self.root.name = new_name self.root.write() self.name = new_name self.root_dir.name = new_name
def create(self, name, meta_info=None, dos_type=None, boot_code=None, is_ffs=False, is_intl=False, is_dircache=False): # determine dos_type if dos_type == None: dos_type = DosType.DOS0 if is_ffs: dos_type |= DosType.DOS_MASK_FFS if is_dircache: dos_type |= DosType.DOS_MASK_DIRCACHE elif is_intl: dos_type |= DosType.DOS_MASK_INTL # update flags self.is_ffs = DosType.is_ffs(dos_type) self.is_intl = DosType.is_intl(dos_type) self.is_dircache = DosType.is_dircache(dos_type) # convert and check volume name if not isinstance(name, FSString): raise ValueError("create's name must be a FSString") fn = FileName(name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_VOLUME_NAME, file_name=name, node=self) # create a boot block self.boot = BootBlock(self.blkdev) self.boot.create(dos_type=dos_type, boot_code=boot_code) self.boot.write() # create a root block self.root = RootBlock(self.blkdev, self.boot.calc_root_blk) if meta_info == None: meta_info = RootMetaInfo() meta_info.set_current_as_create_time() meta_info.set_current_as_mod_time() meta_info.set_current_as_disk_time() create_ts = meta_info.get_create_ts() disk_ts = meta_info.get_disk_ts() mod_ts = meta_info.get_mod_ts() self.meta_info = meta_info self.root.create(name.get_ami_str(), create_ts, disk_ts, mod_ts) self.name = name # create bitmap self.bitmap = ADFSBitmap(self.root) self.bitmap.create() self.bitmap.write() # writes root block, too # create empty root dir self.root_dir = ADFSVolDir(self, self.root) self.root_dir.read() # all ok self.valid = True
def _create_node(self, node, name, meta_info, update_ts=True): self.ensure_entries() # make sure a default meta_info is available if meta_info == None: meta_info = MetaInfo() meta_info.set_current_as_mod_time() meta_info.set_default_protect() # check file name fn = FileName(name, is_intl=self.volume.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=name, node=self) # does already exist an entry in this dir with this name? if self.has_name(fn): raise FSError(NAME_ALREADY_EXISTS, file_name=name, node=self) # calc hash index of name fn_hash = fn.hash() hash_chain = self.name_hash[fn_hash] if len(hash_chain) == 0: hash_chain_blk = 0 else: hash_chain_blk = hash_chain[0].block.blk_num # return the number of blocks required to create this node num_blks = node.blocks_get_create_num() # try to find free blocks free_blks = self.volume.bitmap.alloc_n(num_blks) if free_blks == None: raise FSError(NO_FREE_BLOCKS, node=self, file_name=name, extra="want %d" % num_blks) # now create the blocks for this node new_blk = node.blocks_create_new(free_blks, name, hash_chain_blk, self.block.blk_num, meta_info) # dircache: create record for this node if self.volume.is_dircache: ok = self._dircache_add_entry(name, meta_info, new_blk, node.get_size(), update_myself=False) if not ok: self.delete() raise FSError(NO_FREE_BLOCKS, node=self, file_name=name, extra="want dcache") # update my dir self.block.hash_table[fn_hash] = new_blk self.block.write() # add node self.name_hash[fn_hash].insert(0,node) self.entries.append(node) # update time stamps if update_ts: self.update_dir_mod_time() self.volume.update_disk_time()
def create(self, name, meta_info=None, dos_type=None, boot_code=None, is_ffs=False, is_intl=False, is_dircache=False, is_longname=False): # determine dos_type if dos_type == None: dos_type = DosType.DOS0 if is_longname: dos_type = DosType.DOS6 elif is_dircache: dos_type |= DosType.DOS_MASK_DIRCACHE elif is_intl: dos_type |= DosType.DOS_MASK_INTL if is_ffs: dos_type |= DosType.DOS_MASK_FFS # update flags self.is_ffs = DosType.is_ffs(dos_type) self.is_intl = DosType.is_intl(dos_type) self.is_dircache = DosType.is_dircache(dos_type) self.is_longname = DosType.is_longname(dos_type) # convert and check volume name if not isinstance(name, FSString): raise ValueError("create's name must be a FSString") fn = FileName(name, is_intl=self.is_intl, is_longname=False) # Volumes don't support long names if not fn.is_valid(): raise FSError(INVALID_VOLUME_NAME, file_name=name, node=self) # create a boot block self.boot = BootBlock(self.blkdev) self.boot.create(dos_type=dos_type, boot_code=boot_code) self.boot.write() # create a root block self.root = RootBlock(self.blkdev, self.boot.calc_root_blk) if meta_info == None: meta_info = RootMetaInfo() meta_info.set_current_as_create_time() meta_info.set_current_as_mod_time() meta_info.set_current_as_disk_time() create_ts = meta_info.get_create_ts() disk_ts = meta_info.get_disk_ts() mod_ts = meta_info.get_mod_ts() self.meta_info = meta_info self.root.create(name.get_ami_str(), create_ts, disk_ts, mod_ts, fstype=dos_type) self.name = name # create bitmap self.bitmap = ADFSBitmap(self.root) self.bitmap.create() self.bitmap.write() # writes root block, too # create empty root dir self.root_dir = ADFSVolDir(self, self.root) self.root_dir.read() # all ok self.valid = True
def relabel(self, name): """Relabel the volume""" # make sure its a FSString if not isinstance(name, FSString): raise ValueError("relabel's name must be a FSString") # validate file name fn = FileName(name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_VOLUME_NAME, file_name=name, node=self) # update root block ami_name = name.get_ami_str() self.root.name = ami_name self.root.write() # store internally self.name = name self.root_dir.name = name
def set_block(self, block): self.block = block self.name = FileName( FSString(self.block.name), is_intl=self.volume.is_intl, is_longname=self.volume.is_longname ) self.valid = True self.create_meta_info()
def get_path_name(self, path_name, allow_file=True, allow_dir=True): """get node for given path""" # make sure path name is a FSString if not isinstance(path_name, FSString): raise ValueError("get_path_name's path must be a FSString") # create and check file name fn = FileName(path_name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=path_name, node=self) # find node if fn.is_root_path_alias(): # its the root node return self.root_dir else: # find a sub node path = fn.split_path() return self.root_dir.get_path(path, allow_file, allow_dir)
def _create_node(self, node, name, meta_info): self.ensure_entries() # make sure a default meta_info is available if meta_info == None: meta_info = MetaInfo() meta_info.set_current_time() meta_info.set_default_protect() # check file name fn = FileName(name) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=name, node=self) # does already exist an entry in this dir with this name? if self.has_name(fn): raise FSError(NAME_ALREADY_EXISTS, file_name=name, node=self) # calc hash index of name fn_hash = fn.hash() hash_chain = self.name_hash[fn_hash] if len(hash_chain) == 0: hash_chain_blk = 0 else: hash_chain_blk = hash_chain[0].block.blk_num # return the number of blocks required to create this node num_blks = node.blocks_get_create_num() # try to find free blocks free_blks = self.volume.bitmap.find_n_free(num_blks) if free_blks == None: raise FSError(NO_FREE_BLOCKS, node=self, file_name=name, extra="want %d" % num_blks) # update bitmap for b in free_blks: self.volume.bitmap.clr_bit(b) self.volume.bitmap.write_only_bits() # now create the blocks for this node new_blk = node.blocks_create_new(free_blks, name, hash_chain_blk, self.block.blk_num, meta_info) # update my dir self.block.hash_table[fn_hash] = new_blk self.block.write() # add node self.name_hash[fn_hash].insert(0,node) self.entries.append(node)
def get_path_name(self, path_name, allow_file=True, allow_dir=True): if path_name == "" or path_name == "/": return self.root_dir pc = path_name.split("/") fn = [] for path in pc: fn.append(FileName(path)) return self.root_dir.get_path(fn, allow_file, allow_dir)
def create_dir(self, ami_path): """Create a new directory""" # make sure its a FSString if not isinstance(ami_path, FSString): raise ValueError("create_dir's ami_path must be a FSString") # check file path fn = FileName(ami_path, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=ami_path) # split into dir and base name dir_name, base_name = fn.get_dir_and_base_name() if base_name == None: raise FSError(INVALID_FILE_NAME, file_name=ami_path) # find parent of dir if dir_name == None: node = self.root_dir else: # no parent dir found node = self.get_dir_path_name(dir_name) if node == None: raise FSError(INVALID_PARENT_DIRECTORY, file_name=ami_path, extra="not found: "+dir_name) node.create_dir(base_name)
def get_create_path_name(self, path_name, suggest_name=None): """get a parent node and path name for creation return: parent_node_or_none, file_name_or_none """ # make sure input is correct if not isinstance(path_name, FSString): raise ValueError( "get_create_path_name's path_name must be a FSString") if suggest_name != None and not isinstance(suggest_name, FSString): raise ValueError( "get_create_path_name's suggest_name must be a FSString") # is root path? fn = FileName(path_name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=path_name, node=self) # find node if fn.is_root_path_alias(): return self.root_dir, suggest_name else: # try to get path_name as a directory node = self.get_dir_path_name(path_name) if node != None: return node, suggest_name else: # split into dir and file name dn, fn = fn.get_dir_and_base_name() if dn != None: # has a directory -> try to fetch it node = self.get_dir_path_name(dn) else: # no dir -> assume root dir node = self.root_dir if fn != None: # take given name return node, fn else: # use suggested name return node, suggest_name
def create_dir(self, ami_path): """Create a new directory""" # make sure its a FSString if not isinstance(ami_path, FSString): raise ValueError("create_dir's ami_path must be a FSString") # check file path fn = FileName(ami_path, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=ami_path) # split into dir and base name dir_name, base_name = fn.get_dir_and_base_name() if base_name == None: raise FSError(INVALID_FILE_NAME, file_name=ami_path) # find parent of dir if dir_name == None: node = self.root_dir else: # no parent dir found node = self.get_dir_path_name(dir_name) if node == None: raise FSError(INVALID_PARENT_DIRECTORY, file_name=ami_path, extra="not found: " + dir_name) node.create_dir(base_name)
def get_create_path_name(self, path_name, suggest_name=None): """get a parent node and path name for creation return: parent_node_or_none, file_name_or_none """ # make sure input is correct if not isinstance(path_name, FSString): raise ValueError("get_create_path_name's path_name must be a FSString") if suggest_name != None and not isinstance(suggest_name, FSString): raise ValueError("get_create_path_name's suggest_name must be a FSString") # is root path? fn = FileName(path_name, is_intl=self.is_intl) if not fn.is_valid(): raise FSError(INVALID_FILE_NAME, file_name=path_name, node=self) # find node if fn.is_root_path_alias(): return self.root_dir, suggest_name else: # try to get path_name as a directory node = self.get_dir_path_name(path_name) if node != None: return node, suggest_name else: # split into dir and file name dn, fn = fn.get_dir_and_base_name() if dn != None: # has a directory -> try to fetch it node = self.get_dir_path_name(dn) else: # no dir -> assume root dir node = self.root_dir if fn != None: # take given name return node, fn else: # use suggested name return node, suggest_name
class ADFSNode: def __init__(self, volume, parent): self.volume = volume self.blkdev = volume.blkdev self.parent = parent self.block_bytes = self.blkdev.block_bytes self.block = None self.name = None self.valid = False self.meta_info = None def __str__(self): return "%s:'%s'(@%d)" % (self.__class__.__name__, self.get_node_path_name(), self.block.blk_num) def set_block(self, block): self.block = block self.name = FileName(FSString(self.block.name), is_intl=self.volume.is_intl) self.valid = True self.create_meta_info() def create_meta_info(self): self.meta_info = MetaInfo(self.block.protect, self.block.mod_ts, FSString(self.block.comment)) def get_file_name(self): return self.name def delete(self, wipe=False, all=False, update_ts=True): if all: self.delete_children(wipe, all, update_ts) self.parent._delete(self, wipe, update_ts) def delete_children(self, wipe, all, update_ts): pass def get_meta_info(self): return self.meta_info def change_meta_info(self, meta_info): dirty = False # dircache? rebuild_dircache = False if self.volume.is_dircache and self.parent != None: record = self.parent.get_dircache_record( self.name.get_ami_str_name()) if record == None: raise FSError(INTERNAL_ERROR, node=self) else: record = None # alter protect flags protect = meta_info.get_protect() if protect != None and hasattr(self.block, 'protect'): self.block.protect = protect self.meta_info.set_protect(protect) dirty = True if record != None: record.protect = protect # alter mod time mod_ts = meta_info.get_mod_ts() if mod_ts != None: self.block.mod_ts = mod_ts self.meta_info.set_mod_ts(mod_ts) dirty = True if record != None: record.mod_ts = mod_ts # alter comment comment = meta_info.get_comment() if comment != None and hasattr(self.block, "comment"): self.block.comment = comment.get_ami_str() self.meta_info.set_comment(comment) dirty = True if record != None: rebuild_dircache = len(record.comment) < comment record.comment = comment.get_ami_str() # really need update? if dirty: self.block.write() # dirache update if record != None: self.parent.update_dircache_record(record, rebuild_dircache) def change_comment(self, comment): self.change_meta_info(MetaInfo(comment=comment)) def change_protect(self, protect): self.change_meta_info(MetaInfo(protect=protect)) def change_protect_by_string(self, pr_str): p = ProtectFlags() p.parse(pr_str) self.change_protect(p.mask) def change_mod_ts(self, mod_ts): self.change_meta_info(MetaInfo(mod_ts=mod_ts)) def change_mod_ts_by_string(self, tm_str): t = TimeStamp() t.parse(tm_str) self.change_meta_info(MetaInfo(mod_ts=t)) def get_list_str(self, indent=0, all=False, detail=False): istr = u' ' * indent if detail: extra = self.get_detail_str() else: extra = self.meta_info.get_str_line() return u'%-40s %8s %s' % (istr + self.name.get_unicode_name(), self.get_size_str(), extra) def list(self, indent=0, all=False, detail=False, encoding="UTF-8"): print( self.get_list_str(indent=indent, all=all, detail=detail).encode(encoding)) def get_size_str(self): # re-implemented in derived classes! return "" def get_blocks(self, with_data=False): # re-implemented in derived classes! return 0 def get_file_data(self): return None def dump_blocks(self, with_data=False): blks = self.get_blocks(with_data) for b in blks: b.dump() def get_node_path(self, with_vol=False): if self.parent != None: if not with_vol and self.parent.parent == None: r = [] else: r = self.parent.get_node_path() else: if not with_vol: return [] r = [] r.append(self.name.get_unicode_name()) return r def get_node_path_name(self, with_vol=False): r = self.get_node_path() return FSString(u"/".join(r)) def get_detail_str(self): return "" def get_block_usage(self, all=False, first=True): return (0, 0) def get_file_bytes(self, all=False, first=True): return (0, 0) def is_file(self): return False def is_dir(self): return False def get_info(self, all=False): # block usage: data + fs blocks (data, fs) = self.get_block_usage(all=all) total = data + fs bb = self.blkdev.block_bytes btotal = total * bb bdata = data * bb bfs = fs * bb prc_data = 10000 * data / total prc_fs = 10000 - prc_data res = [] res.append("sum: %10d %s %12d" % (total, ByteSize.to_byte_size_str(btotal), btotal)) res.append( "data: %10d %s %12d %5.2f%%" % (data, ByteSize.to_byte_size_str(bdata), bdata, prc_data / 100.0)) res.append("fs: %10d %s %12d %5.2f%%" % (fs, ByteSize.to_byte_size_str(bfs), bfs, prc_fs / 100.0)) return res
def set_block(self, block): self.block = block self.name = FileName(FSString(self.block.name), is_intl=self.volume.is_intl) self.valid = True self.create_meta_info()
class ADFSNode: def __init__(self, volume, parent): self.volume = volume self.blkdev = volume.blkdev self.parent = parent self.block_bytes = self.blkdev.block_bytes self.block = None self.name = None self.valid = False self.meta_info = None def __str__(self): return "%s:'%s'(@%d)" % (self.__class__.__name__, self.get_node_path_name(), self.block.blk_num) def set_block(self, block): self.block = block self.name = FileName(FSString(self.block.name), is_intl=self.volume.is_intl) self.valid = True self.create_meta_info() def create_meta_info(self): self.meta_info = MetaInfo(self.block.protect, self.block.mod_ts, FSString(self.block.comment)) def get_file_name(self): return self.name def delete(self, wipe=False, all=False, update_ts=True): if all: self.delete_children(wipe, all, update_ts) self.parent._delete(self, wipe, update_ts) def delete_children(self, wipe, all, update_ts): pass def get_meta_info(self): return self.meta_info def change_meta_info(self, meta_info): dirty = False # dircache? rebuild_dircache = False if self.volume.is_dircache and self.parent != None: record = self.parent.get_dircache_record(self.name.get_ami_str_name()) if record == None: raise FSError(INTERNAL_ERROR, node=self) else: record = None # alter protect flags protect = meta_info.get_protect() if protect != None and hasattr(self.block, 'protect'): self.block.protect = protect self.meta_info.set_protect(protect) dirty = True if record != None: record.protect = protect # alter mod time mod_ts = meta_info.get_mod_ts() if mod_ts != None: self.block.mod_ts = mod_ts self.meta_info.set_mod_ts(mod_ts) dirty = True if record != None: record.mod_ts = mod_ts # alter comment comment = meta_info.get_comment() if comment != None and hasattr(self.block, "comment"): self.block.comment = comment.get_ami_str() self.meta_info.set_comment(comment) dirty = True if record != None: rebuild_dircache = len(record.comment) < comment record.comment = comment.get_ami_str() # really need update? if dirty: self.block.write() # dirache update if record != None: self.parent.update_dircache_record(record, rebuild_dircache) def change_comment(self, comment): self.change_meta_info(MetaInfo(comment=comment)) def change_protect(self, protect): self.change_meta_info(MetaInfo(protect=protect)) def change_protect_by_string(self, pr_str): p = ProtectFlags() p.parse(pr_str) self.change_protect(p.mask) def change_mod_ts(self, mod_ts): self.change_meta_info(MetaInfo(mod_ts=mod_ts)) def change_mod_ts_by_string(self, tm_str): t = TimeStamp() t.parse(tm_str) self.change_meta_info(MetaInfo(mod_ts=t)) def get_list_str(self, indent=0, all=False, detail=False): istr = u' ' * indent if detail: extra = self.get_detail_str() else: extra = self.meta_info.get_str_line() return u'%-40s %8s %s' % (istr + self.name.get_unicode_name(), self.get_size_str(), extra) def list(self, indent=0, all=False, detail=False, encoding="UTF-8"): print(self.get_list_str(indent=indent, all=all, detail=detail).encode(encoding)) def get_size_str(self): # re-implemented in derived classes! return "" def get_blocks(self, with_data=False): # re-implemented in derived classes! return 0 def get_file_data(self): return None def dump_blocks(self, with_data=False): blks = self.get_blocks(with_data) for b in blks: b.dump() def get_node_path(self, with_vol=False): if self.parent != None: if not with_vol and self.parent.parent == None: r = [] else: r = self.parent.get_node_path() else: if not with_vol: return [] r = [] r.append(self.name.get_unicode_name()) return r def get_node_path_name(self, with_vol=False): r = self.get_node_path() return FSString(u"/".join(r)) def get_detail_str(self): return "" def get_block_usage(self, all=False, first=True): return (0,0) def get_file_bytes(self, all=False, first=True): return (0,0) def is_file(self): return False def is_dir(self): return False def get_info(self, all=False): # block usage: data + fs blocks (data,fs) = self.get_block_usage(all=all) total = data + fs bb = self.blkdev.block_bytes btotal = total * bb bdata = data * bb bfs = fs * bb prc_data = 10000 * data / total prc_fs = 10000 - prc_data res = [] res.append("sum: %10d %s %12d" % (total, ByteSize.to_byte_size_str(btotal), btotal)) res.append("data: %10d %s %12d %5.2f%%" % (data, ByteSize.to_byte_size_str(bdata), bdata, prc_data / 100.0)) res.append("fs: %10d %s %12d %5.2f%%" % (fs, ByteSize.to_byte_size_str(bfs), bfs, prc_fs / 100.0)) return res
def set_block(self, block): self.block = block self.name = FileName(self.block.name) self.valid = True self.create_meta_info()
def makeCubeTimestream(configFileName): configData = readDict() configData.read_from_file(configFileName) # Extract parameters from config file nPos = int(configData['nPos']) startTimes = np.array(configData['startTimes'], dtype=int) stopTimes = np.array(configData['stopTimes'], dtype=int) darkSpan = np.array(configData['darkSpan'], dtype=int) flatSpan = np.array(configData['flatSpan'], dtype=int) xPos = np.array(configData['xPos'], dtype=int) yPos = np.array(configData['yPos'], dtype=int) numRows = int(configData['numRows']) numCols = int(configData['numCols']) upSample = int(configData['upSample']) padFraction = float(configData['padFraction']) coldCut = int(configData['coldCut']) fitPos = bool(configData['fitPos']) target = str(configData['target']) run = str(configData['run']) date = str(configData['date']) outputDir = str(configData['outputDir']) useImg = bool(configData['useImg']) doHPM = bool(configData['doHPM']) subtractDark = bool(configData['subtractDark']) divideFlat = bool(configData['divideFlat']) refFile = str(configData['refFile']) #hard coded for now to the daytime wvl cal we did with the WL data wvlCalTS = '1491870376' calPath = os.getenv('MKID_PROC_PATH', '/') timeMaskPath = os.path.join(calPath, "darkHotPixMasks") hpPath = os.path.join(timeMaskPath, date) ################################################# # Create empty arrays to save to npz file later timeStamps = [] cubes = [] ################################################# #get wvl cal soln file name cfn = FileName(run=run, date=date, tstamp=wvlCalTS).calSoln() #loop through obs files and each second within each file to make 1-s cubes for ts in startTimes: #load obs file obsFN = FileName(run=run, date=date, tstamp=str(ts)).obs() print obsFN obs = darkObsFile(obsFN) totalIntTime = obs.totalIntegrationTime #load wvlSoln file obs.loadWvlCalFile(cfn) for i in range(totalIntTime): fullTS = ts + i timeStamps.append(fullTS) print i, fullTS #get spectral cube for this second cDict = obs.getSpectralCube(i, 1, weighted=False, fluxWeighted=False, energyBinWidth=0.07) cube = cDict['cube'] cubes.append(cube) wvlBinEdges = np.array(cDict['wvlBinEdges']) cubes = np.array(cubes) times = np.array(timeStamps) ################################################# # Setup npz file to save imageStack intermediate/cal files, parameter, and output stackPath = os.path.join(calPath, "imageStacks") npzPath = os.path.join(stackPath, date) #if configFileName.split('/')[0] is not 'Params': # print "Config file not in Params! Output stack will have wrong filename!" # print configFileName.split('/')[0] # npzBaseName = target #else: npzBaseName = configFileName.split('/')[1].split('.')[0] npzFileName = npzPath + '/%s.npz' % npzBaseName print npzFileName np.savez(npzFileName, times=times, cubes=cubes, wvlBinEdges=wvlBinEdges) return {'cubes': cubes, 'times': times, 'wvlBinEdges': wvlBinEdges}