Does anyone know the best way to determine how many times a signal (I have 60 signals of interest) with xy coordinate locations is repeated over 10 measurements (how many times does it appear over 10 measurements). I have a list of >20,000 signals that were identified (all with different xy locations) but I only want to see how many times ~60 of them are repeated (each signal can NOT have the same xy coordinate so they don't overlap). The xy location can vary by a small amount for the same signal too so their needs to be some tolerance in the xy location. I searched the discussion board without finding anything relevant but please direct me to an appropriate discussion if you know of one. Thanks!
hi etucker0,
if you give a little sample of data (can be fake) i think i can help you. i am working with similar data myself. however, the solution depends on the way the table is built.
Hi Ron,
Here is some example data, each of the two rows are two "signals". One thing to keep in mind is that the ID actually changes for each repeat measurement result (the instrument renumbers all the signals for every measurement so I can't use the ID to pick out the same signal in each repeat measurement). SD1 and SD2 are different measurement channels that provide data for each signal. The position x and y for the same signal can vary a little as mentioned in my original post.
ID | x | y | Amplitude SD1 | Amplitude SD2 | ||||||
---|---|---|---|---|---|---|---|---|---|---|
21770 | -22281.78 | -6669.19 | 3000 | 0 | ||||||
21792 | -17728.65 | 7949.11 | 0 | 5000 |
not quite clear. can you give an example of a repeat and a non repeat? is it across rows or columns?
ron
Hi Ron,
Sorry, I should have been more clear. This mock data is for two signal from ONLY the 1st measurement. So, there are 9 other repeat measurements where for those two signals, there will be slightly shifted x and y values (and definitely different ID numbers). Also, the Amplitude SD1 and SD2 will vary a little too. Hope that helps.
A repeat may look something like this:
ID | x | y | Amplitude SD1 | Amplitude SD2 | ||||||
---|---|---|---|---|---|---|---|---|---|---|
21775 | -22285.12 | -6664.55 | 2950 | 0 | ||||||
21799 | -17723.33 | 7946.01 | 0 | 5050 |
-Eric
etucker0,
let me see if i got it. if i understand correctly there is a measurement and a location and you want to know how many repetitions are there for a measurement (with some tolerance) at a location (with some distance). take for example the Hurricanes sample data with locations and wind speed measures. if you want to know for each row how many times there are similar wind measurements (in knots) within a certain distance (radius in KM) you can use the following script.
at the end, you will have a number of "Matching" measurements for each row in the table.
alternatively, you could compare data across two tables, if you have a pre-selected list you want to compare with.
let me know if this is what you are looking for.
Clear Globals();
Names Default To Here( 1 );
// open data file (dots) - this includes the observation we want to update
sdots = Open( "C:\Program Files (x86)\SAS\JMPSW\11\Samples\Data\Hurricanes.jmp" );
dots = Data Table( sdots ) << Subset( Sample Size( 2000 ) ); // make a smaller table for speed
Close( sdots, no save );
// add some noise to the wind measurement
dots << New Column( "Wind", formula( :Name( "Wind (Knots)" ) + Random Normal() ) );
// introduce a count column
dots << New Column( "repeated" );
// extract the longitude and the latitude values from the table - as radians
x = (Column( dots, "Longitude" ) << getValues) * Pi() / 180;
y = (Column( dots, "Latitude" ) << getValues) * Pi() / 180;
// declare the calculation function in KM
haversine = Function( {long1, lat1, long2, lat2, R = 6371},
{Default Local},
a = Sin( (lat1 - lat2) / 2 ) ^ 2 + Cos( lat1 ) * Cos( lat2 ) * Sin( (long1 - long2) / 2 ) ^ 2;
c = 2 * ATan( a ^ 0.5, (1 - a) ^ 0.5 );
d = R * c;
);
// define tolerance in distance and wind speed
distance = 100; // in Km
difference = 10; // in Knots
Wait( 0.01 );
// run the function along the rows of the table
For( i = 1, i <= N Row( dots ) - 1, i++,
z = 0;
For( it = 1, it <= N Row( dots ) - 1, it++,
If(
haversine( x[i], y[i], x[it], y[it] ) < distance// condition for distance
& Abs( :Wind[i] - :Wind[it] ) < difference
, // condition for difference in wind measurement
z++; // count the matches
)
);
z--; // remove one that is match with itself.
:repeated[i] = z; // update the table
);
// map the results
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Longitude ), Y( :Latitude ), Size( :repeated ) ),
Elements( Points( X, Y, Legend( 1 ), Jitter( 1 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox, {Background Map( Images( "Simple Earth" ) ), Grid Line Order( 2 ), Reference Line Order( 3 )} )
)
)
Does the X,Y pair, rounded to, say, 2 decimal places, determine the "name" of the signal? If so, using the rounded values as a key to an associative array might be an approach for counting the occurrences of similar pairs.
counts = associative array();
counts<<SetDefaultValue(0);
counts[ char(round(pi(),2))||","||char(round(e(),2))] += 1;
show(counts);
counts = ["3.14,2.72" => 1, => 0];