Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

python - Replace part of numpy 1D array with shorter array -


i have 1d numpy array containing audio data. i'm doing processing , want replace parts of data white noise. noise should, however, shorter replaced part. generating noise not problem, i'm wondering easiest way replace original data noise is. first thought of doing data[10:110] = noise[0:10] not work due obvious dimension mismatch.

what's easiest way replace part of numpy array part of different dimension?

edit: data uncompressed pcm data can hour long, taking few hundred mb of memory. avoid creating additional copies in memory.

what advantage numpy array have on python list application? think 1 of weaknesses of numpy arrays not easy resize:

http://mail.python.org/pipermail/python-list/2008-june/1181494.html

do need reclaim memory segments of array you're shortening? if not, maybe can use masked array:

http://docs.scipy.org/doc/numpy/reference/maskedarray.generic.html

when want replace section of signal shorter section of noise, replace first chunk of signal, mask out remainder of removed signal.

edit: here's clunky numpy code doesn't use masked arrays, , doesn't allocate more memory. doesn't free memory deleted segments. idea replace data want deleted shifting remainder of array, leaving zeros (or garbage) @ end of array.

import numpy = numpy.arange(10) # [0 1 2 3 4 5 6 7 8 9] ## replace a[2:7] length-2 noise: insert = -1 * numpy.ones((2)) new = slice(2, 4) old = slice(2, 7) #just indicate we'll replacing: a[old] = 0 # [0 1 0 0 0 0 0 7 8 9] a[new] = insert # [0 1 -1 -1 0 0 0 7 8 9] #shift remaining data over: a[new.stop:(new.stop - old.stop)] = a[old.stop:] # [0 1 -1 -1 7 8 9 7 8 9] #zero out dangly bit @ end: a[(new.stop - old.stop):] = 0 # [0 1 -1 -1 7 8 9 0 0 0] 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -