[R] Counting the number of cycles in a temperature test

Arien Lam A.Lam at geo.uu.nl
Fri Jul 10 14:10:41 CEST 2009


Hi Antje,

Say, if a cycle consists of an episode of high temperature and an episode of low temperature, you 
could count the end of these episodes, i.e. check how often your timeseries crosses an intermediate 
temperature.

try:

temperature <- sin(1:1000/10) # replace with your own
previoustemperature <- c(temperature[-(1)], temperature[length(temperature)])

threshold <- 0.1 # replace with your own
crossing <- ((temperature > threshold) != (previoustemperature > threshold))
crossingspercycle <- 2
cycles <- sum(crossing) / crossingspercycle


Moshe Olshansky schreef:
> Hi Antje,
> 
> Are your measurements taken every minute (i.e. 30 minutes correspond to 30 consecutive values)?
> How fast is your transition?
> If you had 30 minures of upper temperature, then 1000 minutes of room temperature and then 30 minutes of lower temperature - would you count this as a cycle?
> Can a cycle be 30 minutes of lower temperature followed by 30 minutes of upper temperature?
> 
> --- On Mon, 6/7/09, Steller, Antje (GQL-LM) <antje.steller at volkswagen.de> wrote:
> 
>> From: Steller, Antje (GQL-LM) <antje.steller at volkswagen.de>
>> Subject: [R] Counting the number of cycles in a temperature test
>> To: r-help at r-project.org
>> Received: Monday, 6 July, 2009, 9:14 PM
>> Hello dear R-users,
>> today I have a question that I completely do not know how
>> to solve (R-newbie!).
>>
>> In a temperature chamber I have measured temperature over
>> time. The result is shown in the attached eps-file (if
>> attachments are shown): There are two temperature levels,
>> 150°C and -40°C. A complete cycle includes about 30
>> minutes upper temperature, quick change to the lower level,
>> 30 minutes hold at lower level. Then the temperature rises
>> again to the upper level and a new cycle begins. About 500
>> cycles have been completed. 
>>
>> How can I count the number of cycles that have been
>> completed?
>>
>> The data does not only include perfect temperature cycles.
>> Once in a while the machine would stand still and for a day
>> or so the temperature would remain at room temperature. So I
>> cannot simply divide the measured time by the duration of a
>> cycle...
>>
>> Thanks a lot for your support, if necessary I could also
>> provide the dataset.
>>
>> Antje
>>
>>
>>  <<Temperaturzyklen.eps>> 
>>
>> -----Inline Attachment Follows-----
>>
>> ______________________________________________
>> R-help at r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.
>>
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
drs. H.A. (Arien) Lam (Ph.D. student)
Department of Physical Geography
Faculty of Geosciences
Utrecht University, The Netherlands




More information about the R-help mailing list