Replace negative values in multiple channels with "0'.

Hello

I'm calculating and then by creating a cumulative channel, multiple channels. Negative values in these channels aren't necessary, and I need a nice way to replace each negative value in these channels with a value of '0'.

My current code is:

Do
Do
If Data.Root.ChannelGroups (2). Channels (i). Values (II)< 0="" then="" data.root.channelgroups(2).channels(i).values(ii)="0    ">
II = ii + 1
Loop until the second > Data.Root.ChannelGroups (2). Channels (i). Properties ("length"). Value
II = 1
i = i + 1
Loop until I > Data.Root.ChannelGroups (2). Channels.Count

It works, but I don't like. He adds a few seconds when running my script, which was almost instantly. Is there a better way to do it?

Thank you.

Hello Kevin,

The fastest way to go through a channel and check the values less than or equal to 0 is through the canal's calculator. The code below takes all the channel first channel group (with the exception of the first string that is be the weather channel in my example data set) and replaces the values<0 with="" 0="" through="" the="" iif="">

Set Group = Data.Root.ChannelGroups (1)
iMax = Group.Channels.Count
FOR i = 2 to iMax
Adjust the strings = Group.Channels (i)
Formula = "= IIF (y '.<0, 0,="">
Call to calculate (formula, Array("y"), Array (Channel))
NEXT ' I

In this example we overwrite the existing values of data channel with 0, but you can also copy the channels to make sure that your raw data is available.

The calculator of channel is extremely fast for this type of operation because it does not create a loop to go if each line separately and check the values he...

I hope this is useful,

Otmar

Tags: NI Software

Similar Questions

  • Replace negative values of table 2d

    Hi all

    I have a large dataset I want for post processing... My data are in the form of a 2D array of typically 1e5 + lines by 100 + models! I want to replace all the negative values in the table with zeros.

    My initial was however to use two indexed for loops with a structure of matter inside looking for > 0 condition. However, this way I'm practically rebuild the table from scratch and it takes forever (had to give up after about 5 minutes of Calc, while I was still less than 10% of fact). I've attached a snapshot of my sample vi for your review.

    Is there a more efficient and faster way to do this?

    Thanks a lot for your time,.

    Harry

    There are many ways to do this, but in your case I would just wire table 2D to a primitive range and Coerce (from the palette of comparison) with the range of 0 to + infinity.

  • How can I replace the value of the column with a particular value in SQL

    Hi all

    Is someone can you please tell me how can I format my output with the replacement of a column value with a specific value that really depends on the current value of the column

    I am executing the following SQL statement

    Select state, count (id) from < table_name > where composite_dn = < composite_dn_name > Group by State;
    My current performance is:

    State Instance number
    1 3
    3 28

    I want to replace the value in the State column as follows

    No.OfInstances State
    3 filled
    28 faulted

    I want '1' to be reppaced of 'Done' and '3' is replaced by 'Faulted. '

    Is is possible with SQL or PL/SQL, if it is then how I can achieve this required. Help, please!

    Thanks in advance!

    Published by: Roshni Shankar on October 27, 2012 12:38 AM

    Hi Claude,.

    I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
    See - http://www.techonthenet.com/oracle/functions/decode.php

    select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
    from  t2, (select state,count(id) count_id
     from 
     where composite_dn= 
    group by state) t1
    where t1.state = t2.state_id;
    

    HTH
    Vanessa B.

    Published by: Vanessa B on October 27, 2012 14:02
    -link added

    Published by: Vanessa B on October 27, 2012 14:19
    -added code sample

  • Removal of multiple channels with wildcards

    Can antbody help... ?

    I am trying to create a little routine to remove Channels starting with 'T_' and using the * wildcard.

    I tried copy similar examples on the forum but can't seeem to operate...

    Sun group, the canals, the DataChannel, I have
    Set Group = Data.Root.ChannelGroups (1)
    Set Channels (i) = Data.GetChannels("T_*")
    FOR i = 1 TO Channels.Count
    Data.Root.ChannelGroups (1). Channels.Remove
    NEXT ' I

    Hey Adek,.

    Check it out,

    Dim oGr, oChn, DataChannel, I have

    Set the oGr = Data.Root.ChannelGroups (1)
    Set oChn = Data.GetChannels(""&oGr.Name&"/T_*") "
    For i = 1 to oChn.Count
    Dial oGr.Channels.Remove (oChn.Item (i). Name)
    Next

    I assumed that you only want to delete channels in the group "first." Otherwise just include an additional loop to scan all your groups

    Kind regards

    Javier

  • [.ini files] Get the value of multiple labels with the same name

    Hello!

    In an ini.files, I need to get the value of each tag named in a certain way in a section, but unfortunately, I have 3 or 4 tags with the same name in several sections. I don't know how to retrieve these values, the program always consider that the first tag and not others, I tried to remove each tag after obtaining its values, that he did not.

    Does anyone have an idea to solve the problem?

    Thank you!

    As you can read in my last post, you must read and throw 'x' lines:

    OpenFile)

    Skip lines

    for (i = 0; i< x;="" i++)="" readline="">

    Start reading the useful lines

    ReadLine () / / read a line

    ... / / Interpret the line

    Don't forget to add a control during i/o operations of robust error and to check the end of the file.

  • Replace the values in the channels, if a string has a model value

    Version: Oracle 10g

    Hi all, I have a need for which I am trying to write a proc.
    I wanted to know if there is an another easier way to do this.
    Please let me know


    T_DATE and v_value will have an equal number of values
    If the value T_DATE or v_value is = # remove this T_DATE value and the corresponding value
    v_value (and vice versa)
    Example 1:
    -------------
       v_date  
          := 'August, 16, 2010~August, 16, 2010~September, 17, 2010~August, 16, 2010~###';
       v_value   := '###~EFGH~IJKL~MNOP~QRST';
       
       O/P required :
       v_date := 'August, 16, 2010~September, 17, 2010~August, 16, 2010';
       v_value   'EFGH~IJKL~MNOP';
       
    Example 2
    ----------
      
       v_date  
          := 'August, 17, 2010~###~September, 19, 2010~###~August, 21, 2010';
       v_value   := '###~EFGH~###~MNOP~###';
       
     O/P required :
     ---------------
       v_date := NULL;
       v_value   NULL;
    Thank you

    Hello

    new learner wrote:
    Version: Oracle 10g

    Hi all, I have a need for which I am trying to write a proc.
    I wanted to know if there is an another easier way to do this.

    Easier than what? Post what you're doing now.

    It seems simple enough
    Are T_DATE and v_value are IN OUT parameters?
    (1) create new variable this_date, this_vlaue, new_date and new_value, NULL string initially.
    (2) loop while T_DATE and v_value are not NULL.
    (3) use INSTR to find date_pos, the position of the first delimiter in T_DATE.
    (4) set this_date: = SUBSTR (T_DATE, date_pos, 1, -1) and then T_DATE: = SUBSTR (T_DATE, date_pos + 1). Watch out for the special case when you are at the last iitem, and there is no delimiter in v_pos.
    (5) do the same thing with v_value, this_value, and new_value.
    (6) If is neither this_date nor this_value ' #', concatenate them (with a delimiter, if necessary) to new_date and new_pos.
    (7) repeat the loop.
    (8) Finally, set T_DATE > = new_date and v_value: = new_value.

  • Write to digitall all ports (channels) with the decimal value

    Hello

    It is possible to write all digital channels with a value decimal for a device with 96 channels at the same time?

    I have a USB-6509 camera and I want to write each value of Pentecost bit 1 in the loop (for the first transfer I write 0,1,2,4,8,16, 32, 64 and 128) with the line "Dev3/port0 / line0:7", but if I want to write all ports at the same time, how to set the line and the "write.vi DAQmx?

    Thank you.

    You can configure the reading and writing in the ports of 8 bits with the 6509.  For example, you could write just 128 to "Dev3/port0.  If you want to write to all 12 ports, I recommend doing a task that is several channels on the 6509 module, each channel of the task being a port.  You can then use the channel Multiple, single sample of writing of your values.  Your values must be in a table of U8.

  • DAQmx create track (I-current-Basic) 8 channels with different values of Shunt resistance

    Hello

    I want to measure 8 current channels with different values of Shunt resistance.

    Problem: The channel create DAQmx (HAVE current Basic) specifies that a value of Shunt resistance.

    How can I set the value of Shunt resistance for each channel individually?

    Concerning

    Marcel

    Hi Marcel_C,

    Take a look to get attached.

    Best regards

    Mencef

  • acquisition of continuous sample with multiple channels

    Hello! Please tell me what I'm doing wrong here, I'm confused about how the acquisition of continuous sample with several channels (using NI USB-6215 boxes).

    Following code is python code, but I don't know who confuse you (and it's only a part of my code in order to not try, it won't work

    buffer_size = 2000 #samples to read
    sampling_rate_hz = 20000
    channels = "Dev1/ai0 ai1/Dev1" #this can be a string or a large number...

    CHK (nidaq. DAQmxCreateTask ("", ctypes.byref (taskHandle)))

    CHK (nidaq. DAQmxCreateAIVoltageChan (taskHandle, channels,"", DAQmx_Val_Cfg_Default, float64(-10.0), float64 (10.0), DAQmx_Val_Volts, None "))

    CHK (nidaq. DAQmxCfgSampClkTiming (taskHandle,"", float64 (sampling_rate_hz), DAQmx_Val_Rising, DAQmx_Val_ContSamps, uInt64 (buffer_size) "))

    CHK (nidaq. DAQmxRegisterEveryNSamplesEvent (taskHandle, DAQmx_Val_Acquired_Into_Buffer, uInt32 (1000), uInt32 (0), EveryNCallback_func, None))

    CHK (nidaq. DAQmxRegisterDoneEvent (taskHandle, uInt32 (0), DoneCallback_func, None))

    the callback function #and

    def py_EveryNCallback_func (self, taskHandle, event_type, nSamples):
    data = numpy.zeros ((self.channel_amount,buffer_size,), dtype = numpy.float64)
    read = int32()
    CHK (nidaq. DAQmxReadAnalogF64 (taskHandle, buffer_size, float64 (10.0), DAQmx_Val_GroupByScanNumber, data.ctypes.data, buffer_size * number_of_channels, ctypes.byref (read), None))

    With only one channel, everything's fine, and tension diagram looks like this:

    buffer_size = 2000, sampling_rate_hz = 20000

    But if I use two channels, voltage diagram looks like this

    buffer_size = 2000, sampling_rate_hz = 20000

    It looks like the sampling rate is higher or there are fewer values?, but with two channels with the results table is 2000 * 2 long and with a single result is 2000 * 1 long is not smaller

    most of the settings important (?) in my code:

    DAQmxCfgSampClkTiming "float64 rate": 20000 (sampling_rate_hz)
    'UInt64 sampsPerChanToAcquire' DAQmxCfgSampClkTiming: 2000 (buffer_size)
    DAQmxRegisterEveryNSamplesEvent "uInt32 nSamples": 1000 (?)
    'Int32 numSampsPerChan' DAQmxReadAnalogF64: 2000 (buffer_size)
    DAQmxReadAnalogF64 "float64 [] readArray": [[buffer_size] * number_of_channels]
    'UInt32 arraySizeInSamps' DAQmxReadAnalogF64: buffer_size * number_of_channels

    as you can see nSamples is a big question mark, but the problem still exists if I set variable buffer_size y (2000)

    Hi Dazzler,

    It is not a multi-channel example that ships with the driver, but after a quick look at the code that you use in your third post, everything seems to be configured correctly. The only thing I was thing I got a question about your plots. Looks like you draw each time the same number of points. If you draw just the table of data directly from the playback feature, you need to draw (buffer_size * number_of_channels) number of channels since the data returned is as an interlaced array. You can also choose to deinterleave samples. More information about this lie in the NOR-DAQmx C reference help, which is installed with the NOR-DAQmx driver.

    Kind regards

    Kent

    Technical sales engineer

  • create file csv with multiple channels

    I am writing a program that uses the Keithley 705 scaner and 580 ohms meter. What I have to do is to create an excel file that contains a timestamp to MM/DD/YYYY HH: mmS as a column, then a new column for each channel (1 to 10 in the case of the keithley 705). Each channel column will contain reading the resistance of this specific at the parking meter channel. The timastamp should do when the first analysis was performed; for example if one scans the channels 1 and 2, their resistance values will be associated with the same timestamp.

    My question is how can I format it as an excel file.

    Answer your original query
    Set the number of channels (1-10)
    Organize your table value to it form the first column with timestamp and treatment of channel values, then write in the chain of worksheet
    You can include the header for your nominale1

  • Problem with multiple downloads with the router. Allows you to change the TCP MSS value?

    Original title: TCP MSS

    Hi all.

    I currently have a problem with multiple downloads with my current router.  If I have two current downloads at the same time I have no access to all web sites.  It's almost as if the downloads take my meaning of bandwidth there is more nothing for ordinary surfing.

    As a test I put an older router on my system and have a significant improvement in performance.  I have 2 downloads in progress and also surf at the same time.

    To compare two routers, I noticed that the only real difference between the two is that the TCP MSS value is set to '0' on the router of the problem, and then assign him 1392 (MTU - 40) on the router to elderly who gives better performance.

    It is my understanding that this value governs the size of transmitted packets.

    My question is this:

    What is the MSS value which is causing the problem?

    Congratulations in advance.

    Be sure to interpret the values. The '0' means no not literally because the link would not work. It is likely, that it allows the local device set limits for the link. Don't forget that there is a Maximum value and as such can be any value up to such limit as defined by all devices in the path.

    You can try capping manually but it is unlikely that any local limit will come to effect unless you set very low.

  • Gears - error when you try to insert values into a table with multiple columns

    Hello

    I started playing with the gears and SQlLite today and I get an error when I try to insert values into a table with multiple columns.

    I have:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text, DeveloperAge int)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?, ?)', [devName, devAge]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I get the error:

    net.rim.device.api.database.DatabaseException; insert into developers values (?,?): SQL logic error or missing database.

    I use this reference: http://code.google.com/apis/gears/api_database.html

    Everything works if I have only one field as:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?)', [devName]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I use the plug-in Visual Studio 2.0 for 2008 that are running Windows XP SP and Simulator 2.13.0.56

    Thank you

    Davy

    Yes, a SQLite database will persist between battery pulls.  The database is registered either to internal MEM or removable media (not the device memory), depending on which is available on your device.

    In general, its not considered a best practice to remove your table as soon as it is empty and re - create it again when you want to add data.  This adds extra overhead fresh for the final, delete and insert first for a given table.  Instead, define and finalize your drawing before you create your table.  Once created, review the static schema.

    That being said, for development purposes, it may be easier to provide an easy way to drop your tables while you develop your schema.

    See you soon,.

    Adam

  • Check for multiple users with the value of the UID 0

    Hi gurus,

    The runclufvy.sh gives the warning below can I ignore this or need to fix for the installation of the 11202 RAC on RHEL 5?

    Check for multiple users with the value of the UID 0
    PRVF-4132: several users 'root, jnftsi0' with '0' the UID exists on "hwvpa6".
    PRVF-4132: several users 'root, jnftsi0' with '0' the UID exists on "hwvpa2".

    Thank you

    Hello

    The runclufvy.sh gives the warning below can I ignore this or need to fix for the installation of the 11202 RAC on RHEL 5?

    Check for multiple users with the value of the UID 0
    PRVF-4132: several users 'root, jnftsi0' with '0' the UID exists on "hwvpa6".
    PRVF-4132: several users 'root, jnftsi0' with '0' the UID exists on "hwvpa2".

    User jnftsi0 cannot be used by the Oracle Installer or start the Oracle process, because what is the root group.

    If the user jnftsi0 is used by Oracle install or start Oracle process should then be removed from the root group, otherwise you can ignore it.

    Kind regards
    Levi pereira

  • negative value with sign minus

    Hello

    I have requirment if table.column has a negative value, then it should display - first else no sign
    For example, 500 points should be '0000000500', but - 500 points should be '-000000500'.»

    Thank you
    Sandy
    SQL> select case when to_char(a.point,'0999999999') < 0 then
      2                   trim(to_char(a.point,'099999999'))
      3              else
      4                   trim(to_char(a.point,'0999999999'))
      5         end point
      6    from (select 500 point from dual union all
      7          select -500 point from dual union all
      8          select 100 point from dual union all
      9          select 200 point from dual union all
     10          select -100 point from dual) a;
    
    POINT
    -----------
    0000000500
    -000000500
    0000000100
    0000000200
    -000000100
    
    SQL> 
    
  • DAQmx showing not readings to multiple channels

    Hello

    I am trying to acquire values of temperature of 3 consecutive using a task DAQmx channel as shown in the attached photo.

    I have a loop of producer-consumer for fast reading and writing samples in a file.

    To specify the channels, I typed in the box connected to a terminal of "physical channel" (not shown in picture) as follows:-SC1Mod2 / ai2:4.  This is to acquire a reading of analog channels 2, 3 and 4. The program must then write a file reading on channel 3.

    The code works perfectly if I purchase samples of 1 channel only.

    When I try to acquire multiple channels, I don't see readings on one of the task of acquiring Wired Digital indicators.

    I would appreciate your input on what might be wrong with the code.

    Thank you.

    kumv10 wrote:

    The broken wire seen in the photo is the result of adding more channels to the task of acquiring.  I managed to get around this by specifying a different, but even with an intact wire data type, the program is not displayed readings since the 2 remaining channels.

    Instead of use for dynamic data Type, then the channels Split, just use an array of Index to get your three values.

Maybe you are looking for