Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,60 @@
Dim As String filename = "readings.txt"
Dim As String linea, Part, salida, ErrEnds, rejected_date, Tabu = Chr(9)
Dim As Integer i, posic, startPos, endPos, Errcnt, ErrMax, rejects,
Dim As Integer readings, max_rejected, n_rejected
Dim As Double lsum, tsum, valor
Open filename For Input As #1
Do While Not Eof(1)
Line Input #1, linea
salida = ""
lsum = 0
rejects = 0
posic = 1
For i = 1 To 1 + 2 * 24
startPos = posic
endPos = Instr(posic, linea, Tabu)
If endPos = 0 Then endPos = Len(linea) + 1
Part = Mid(linea, startPos, endPos - startPos)
posic = endPos + 1
If i = 1 Then ' Date
salida = Part
Elseif i Mod 2 = 0 Then ' Recorded value
valor = Val(Part)
Else ' Status part
If Val(Part) > 0 Then
Errcnt = 0
readings += 1
lsum += valor
tsum += valor
Else
rejects += 1
Errcnt += 1
If Errcnt > ErrMax Then
ErrMax = Errcnt
ErrEnds = salida
End If
End If
End If
Next i
salida &= " Rejects: " & Str(rejects)
salida &= " Accepts: " & Str(24 - rejects)
salida &= " Line_tot: " & Str(lsum)
If rejects < 24 Then
salida &= " Line_avg: " & Str(lsum / (24 - rejects))
Else
salida &= " Line_avg: N/A"
End If
Print "Line: " & salida
Loop
Close #1
Print !"\nFile = " & filename
Print "Total = " & Str(tsum)
Print "Readings = " & Str(readings)
Print "Average = " & Str(tsum / readings)
Print !"\nMaximum of " & Str(ErrMax) & " consecutive false readings, ends at " & ErrEnds
Sleep

View file

@ -0,0 +1,3 @@
(let (handle (open "readings.txt" "read"))
(setq all-lines (collect (read-line handle)))
(close handle))

View file

@ -0,0 +1,22 @@
;; (20.0 "1990-01-01" 1 0)
(define (line->matrix line)
(letn (fields (parse line {\s+} 0)
day (pop fields)
lst)
(for (i 0 (- (length fields) 1) 2)
(push (array 4 (list (float (fields i)) day (int (fields (+ i 1))) 0))
lst -1))
lst))
(setq all-readings
(array (* 24 (length all-lines)) 4
'(0.0 "2000-00-00" 0 0))
_ nil)
(let (cnt 0)
(dolist (line all-lines)
(setq one-day (line->matrix line))
(dolist (reading one-day)
(setf (all-readings cnt) reading)
(++ cnt)))
'ok)

View file

@ -0,0 +1,7 @@
(local (prev)
(dotimes (i (length all-readings))
(unless (= 1 (all-readings i -2))
(setq prev
(if (zero? i) 0 (all-readings (- i 1) -1)))
(setf (all-readings i -1) (+ 1 prev))))
'ok)

View file

@ -0,0 +1,2 @@
(setq len (apply max (clean zero? (map last all-readings))))
(println "Longest run of bad readings: " len)

View file

@ -0,0 +1,4 @@
(setq days
(map (fn(i) (all-readings i 1))
(index (curry = len) (map last all-readings))))
(println "Bad runs with that length ended on these days: " days)

View file

@ -0,0 +1,3 @@
(setq grand-total (apply add (map first all-readings)))
(setq grand-count (length (filter zero? (map last all-readings))))
(println "Total number of bad readings: " (- (length all-readings) grand-count))

View file

@ -0,0 +1,2 @@
(println (format "Grand total: %.3f Count: %d Average: %.3f"
grand-total grand-count (div grand-total grand-count)))

View file

@ -0,0 +1,4 @@
(define (get-day day)
(filter (fn(e) (= day (e 1))) (array-list all-readings)))
(get-day "1993-03-05")

View file

@ -0,0 +1,8 @@
(define (sum-day day)
(letn (lst (filter (fn(a) (= 1 (a 2))) (get-day day))
tot (apply add (map first lst)))
(println (format "%s Good readings: %d Total: %.3f Avg.: %.3f"
day (length lst) tot
(div tot (if (zero? (length lst)) 0 (length lst)))))))
(sum-day "1993-03-05")