Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Koushikphy committed Mar 16, 2022
1 parent 7f83026 commit 1b1a7f9
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions kfutils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .funcs import *
2 changes: 2 additions & 0 deletions kfutils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import glob
import numpy as np

__all__ = []


class CustomParser(argparse.ArgumentParser):

Expand Down
48 changes: 48 additions & 0 deletions kfutils/funcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
__all__ = ['smoothen', 'getShape', 'writeShapedFile', 'writeFile']



import numpy as np
from scipy.interpolate import RectBivariateSpline
import os,shutil,subprocess,sys
from csaps import csaps





def smoothen(data, shape, tc, pc, cols, sm=0.95):
data.shape = shape

grid = [data[:,0,tc], data[0,:, pc]]

res = np.copy(data)

for c in cols:
res[...,c] = csaps(grid, data[...,c], grid, smooth=sm)
return res




def getShape(data):
for i in range(data.shape[1]):
print(np.unique(data[:,i]).shape)



def writeShapedFile(file,data,fmt='%.8f'):
assert len(data.shape)==3, "A 3D data is required for this function"
with open(file, 'w') as f:
for i in data:
np.savetxt(f,i,delimiter='\t', fmt=fmt)
f.write('\n')



def writeFile(file,dat,tc=0,fmt='%.8f'):
with open(file,'w') as f:
for i in np.unique(dat[:,tc]):
np.savetxt(f,dat[dat[:,tc]==i],delimiter='\t', fmt=fmt)
f.write('\n')

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
txt = f.read()

setup(name='kfutils',
version='0.0.7',
version='0.0.8',
description='A common file operation utility',
long_description=txt,
author='Koushik Naskar',
Expand Down

0 comments on commit 1b1a7f9

Please sign in to comment.