Hello Moulshree, Using the function numpy.random.uniform(), you can define the range of random numbers by the half-open interval [low, high):
np_rand = np.random.uniform(0,100,numCells) The details are as follows. https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.uniform.html And of course the conditional statements are available in Programmable filter's script as is the case in normal python script. Best 2018-02-21 18:06 GMT+09:00 Moulshree Tripathi <[email protected]>: > Hello > > Thank you very much for the response. It worked. Also, is it possible to > give a range between which we want random numbers and could we use > conditional statements? > > Best Regards > > Moulshree Tripathi > > On Wed, Feb 21, 2018 at 1:42 AM, kenichiro yoshimi <[email protected]> > wrote: >> >> Hi Moulshree, >> >> The Programmable filter's script would be more flexible to add an >> array rather than doing it in the calculator filter since it allows us >> to use various NumPy modules. >> >> Here is a simple example that generates a random numpy array and adds >> it to the mesh as a vtk array. >> ---- >> import numpy as np >> >> input = self.GetInput() >> numCells = input.GetNumberOfCells() >> np_rand = np.random.rand(numCells) >> output.CellData.append(np_rand, "random") >> ---- >> >> Some information can be found here: >> https://www.paraview.org/Wiki/Python_Programmable_Filter >> >> Thanks >> >> 2018-02-20 17:37 GMT+09:00 Moulshree Tripathi <[email protected]>: >> > Greetings! >> > >> > I am new to ParaView and have few queries regarding the assigning of a >> > new >> > variable in mesh: >> > >> > 1: I am using calculator filter to add a new array. Is it possible to >> > interpolate the values in this array and also is it possible to generate >> > random numbers? (say if I want values between 0 to 1 in my array of 2000 >> > cells) >> > >> > 2: Is there any other method by which I could assign properties to the >> > mesh? >> > (say I want to assign different values to my cell - say hydraulic >> > conductivities in inhomogeneous porous medium) How can I do this with >> > calculator filter or with any other tool? >> > >> > I am sorry if the questions are naive. >> > Looking forward to your response. >> > >> > Regards >> > >> > Moulshree Tripathi >> > >> > _______________________________________________ >> > Powered by www.kitware.com >> > >> > Visit other Kitware open-source projects at >> > http://www.kitware.com/opensource/opensource.html >> > >> > Please keep messages on-topic and check the ParaView Wiki at: >> > http://paraview.org/Wiki/ParaView >> > >> > Search the list archives at: http://markmail.org/search/?q=ParaView >> > >> > Follow this link to subscribe/unsubscribe: >> > https://public.kitware.com/mailman/listinfo/paraview >> > > > _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://public.kitware.com/mailman/listinfo/paraview
