Hola,
Tengo la tabla de temperatura de tiempo 1 y la tabla de inicio y finalización de la operación 2. Me gustaría agregar una nueva columna en el registro de temperatura y etiquetar la "operación" de la celda cuando esté en el tiempo de operación peroid. ¿Alguien sabe cómo hacer eso?
Kevin
La tabla 2 es confusa, la hora de finalización es anterior a la hora de inicio. La única vez que coincide con la tabla de temperatura es la hora de inicio. A continuación hay un script, sin embargo, esperaba que la hora de finalización fuera posterior a la hora de inicio.
Puede encontrar estas operaciones de inicio uniendo las dos tablas que coinciden entre Hora y Hora de inicio, vea el segundo bloque de JSL.
Como solo coincidía la hora de inicio, agregué código para copiar las diferentes operaciones y creé una columna de duración para comparar visualmente la estabilidad de la temperatura.
Names Default to Here(1);
dt1 = Data Table("Table 1 Temperature log");
dt2 = Data Table("Table 2 operation Time");
dt1 << New Column ("Operation", character);
for(i=1, i<=nrows(dt2), i++,
tbeg = dt2:Start Time[i];
tend = dt2:End Time[i];
_idx = dt1 << get rows where( tend <= dt1:Time <= tbeg);
if(nrow(_idx)>0,
dt1:Operation[_idx] = "Operation " || char(i);
); //end if
); //end for
//since there is only one row that matches, copy down
//if End Time column was the end of the operation, this would not be needed
//--copy down and get duration
dt1 << New Column("Duration", Numeric, Continuous, Format("min:s") );
_idx = dt1 << get rows where (:Operation != "");
for(i=1, i<=nrow(_idx), i++,
init = dt1:Time[_idx[i]];
If(i < nrow(_idx),
tbeg = _idx[i];
tend = _idx[i + 1] - 1;
dt1:Operation[tbeg :: tend ] = dt1:Operation[_idx[i] ];
, //else
tbeg = _idx[i];
tend = nrow(dt1);
dt1:Operation[tbeg :: tend ] = dt1:Operation[_idx[i] ];
);
dt1[tbeg :: tend,"Duration"] = Transpose(dt1:Time[tbeg :: tend] - init);
);
//--graph
gb = dt1 << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Variables( X( :Duration ), Y( :RoomTemp ), Overlay( :Operation ) ),
Elements( Points( X, Y, Legend( 9 ) ), Line( X, Y, Legend( 11 ) ) )
);
Unirse
Data Table( "Table 1 Temperature log" ) << Join(
With( Data Table( "Table 2 operation Time" ) ),
By Matching Columns( :Time = :Start Time ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 0 ),
Preserve main table order( 1 )
)