Detectors, loop and sharpening sessions moved to the repo root (D-084)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-28 17:19:51 +01:00
1 parent be8897e38e
commit 4d99585474
691 files changed
+122 -109

No files matched your search

@@ -0,0 +1,13 @@
import csv, glob, datetime as dt, statistics as st
D='out/pompage/NORDEND/displacement/NORDEND_advanced_%s.csv'
def f(v):
return float(v) if v not in ('',None) else None
def load(days=('20260904','20260905','20260906','20260907','20260908','20260909')):
rows=[]
for d in days:
for r in csv.DictReader(open(D%d)):
r['t']=dt.datetime.fromisoformat(r['time_utc'])
for k in ('x','y','error_value','error_threshold','relative_x','relative_y','corr_x','corr_y','reproj_err','inlier','sigma0'):
r[k]=f(r[k])
rows.append(r)
return rows
Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

@@ -0,0 +1,28 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections
rows=load()
by=collections.defaultdict(dict)
for r in rows: by[r['sensor_name']][r['t'].replace(second=0,microsecond=0)]=r
S=[s for s in by if s not in('PR04','CTR01')]
ts=sorted(by['PR01'])
# mediane d'erreur inter-capteurs vs sa mediane propre par heure
med={s:st.median([r['error_value'] for r in by[s].values()]) for s in by}
print('pas où la mediane (error/mediane propre) > 1.6')
for t in ts:
if not (dt.datetime(2026,9,5,tzinfo=dt.timezone.utc)<=t<dt.datetime(2026,9,9,tzinfo=dt.timezone.utc)): continue
q=[by[s][t]['error_value']/med[s] for s in S if t in by[s]]
m=st.median(q)
if m>1.6: print(t.strftime('%d %H:%M'),round(m,2),'max',round(max(q),1))
print('PR04 error par heure (médiane), taux de rejet')
for d in range(5,9):
line=[]
for h in range(24):
v=[by['PR04'][t]['error_value'] for t in ts if t.day==d and t.hour==h and t in by['PR04']]
line.append('%.2f'%st.median(v) if v else ' - ')
print(d,' '.join(line))
print('PR07 pics')
for t in ts:
r=by['PR07'][t] if t in by['PR07'] else None
if r and r['error_value']>0.15 and dt.datetime(2026,9,5,tzinfo=dt.timezone.utc)<=t<dt.datetime(2026,9,9,tzinfo=dt.timezone.utc):
print(t, 'PR07',round(r['error_value'],2),'y',r['y'],'corr_y',r['corr_y'],'mediane autres e',round(st.median([by[s][t]['error_value'] for s in S if s!='PR07']),3))
@@ -0,0 +1,32 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections, matplotlib; matplotlib.use('Agg')
import matplotlib.pyplot as plt
OUT=os.path.dirname(__file__)
rows=load()
by=collections.defaultdict(dict)
for r in rows: by[r['sensor_name']][r['t'].replace(second=0,microsecond=0)]=r
S=[s for s in by if s not in('PR04','PR07')]
def cm(col,t):
v=[by[s][t][col] for s in S if t in by[s] and by[s][t][col] is not None]
return st.median(v) if v else None
ts=sorted(by['PR01'])
fig,axs=plt.subplots(5,4,figsize=(28,18))
for j,d in enumerate((5,6,7,8)):
tt=[t for t in ts if t.day==d]
h=[t.hour+t.minute/60 for t in tt]
ax=axs[0][j]; ax.plot(h,[cm('y',t) for t in tt],'.-',lw=.5,ms=3); ax.set_title('%d/09 y brut médian'%d)
ax=axs[1][j]; ax.plot(h,[cm('x',t) for t in tt],'.-',lw=.5,ms=3); ax.set_title('x brut médian')
ax=axs[2][j]
for s in ('PR02','PR12','PR16','PR17','PR18','CTR02'):
ax.plot([t.hour+t.minute/60 for t in tt if t in by[s]],[by[s][t]['corr_y'] for t in tt if t in by[s]],lw=.7,label=s)
ax.legend(fontsize=7); ax.set_title('corr_y')
ax=axs[3][j]
for s in ('PR02','PR12','PR16','PR17','PR18','CTR02'):
ax.plot([t.hour+t.minute/60 for t in tt if t in by[s]],[by[s][t]['corr_x'] for t in tt if t in by[s]],lw=.7,label=s)
ax.set_title('corr_x')
ax=axs[4][j]
for s in ('PR04','PR07','CTR01','PR02','CTR04'):
ax.plot([t.hour+t.minute/60 for t in tt if t in by[s]],[by[s][t]['error_value'] for t in tt if t in by[s]],lw=.7,label=s)
ax.legend(fontsize=7); ax.set_title('error_value'); ax.axhline(.4,color='r',lw=.4)
fig.tight_layout(); fig.savefig(OUT+'/jours.png',dpi=50)
@@ -0,0 +1,20 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections, matplotlib; matplotlib.use('Agg')
import matplotlib.pyplot as plt
OUT=os.path.dirname(__file__)
rows=load()
by=collections.defaultdict(list)
for r in rows: by[r['sensor_name']].append(r)
t0=dt.datetime(2026,9,5,tzinfo=dt.timezone.utc); t1=dt.datetime(2026,9,9,tzinfo=dt.timezone.utc)
def win(l): return [r for r in l if t0<=r['t']<t1]
def med(l): return st.median(l)
for col in ('corr_x','corr_y','x','y','error_value'):
fig,axs=plt.subplots(6,4,figsize=(26,22),sharex=True)
for ax,(s,l) in zip(axs.flat,sorted(by.items())):
w=win(l); w=[r for r in w if r[col] is not None]
m=med([r[col] for r in w])
ax.plot([r['t'] for r in w],[r[col]-(0 if col=='error_value' else m) for r in w],lw=.6)
ax.set_title('%s %s (med %.3f)'%(s,l[0]['pattern_type'],m),fontsize=9)
ax.axhline(0.4 if col=='error_value' else 0,color='r',lw=.4)
fig.suptitle(col); fig.tight_layout(); fig.savefig(OUT+'/ensemble_%s.png'%col,dpi=55); plt.close(fig)
@@ -0,0 +1,21 @@
import sys,os,glob
from PIL import Image
OUT=os.path.dirname(__file__)
IM='out/pompage/NORDEND/images/'
def crop(stamp,box,name,scale=1):
f=glob.glob(IM+stamp+'*.jpg')[0]
im=Image.open(f).crop(box)
return im.resize((im.width*scale,im.height*scale))
def montage(stamps,box,name,scale=1):
ims=[crop(s,box,name,scale) for s in stamps]
W=sum(i.width for i in ims); H=max(i.height for i in ims)
m=Image.new('RGB',(W,H)); x=0
for i in ims: m.paste(i,(x,0)); x+=i.width
m.save(os.path.join(OUT,name))
if __name__=='__main__':
# PR04: avant, début, nuit, fin
montage(['20260906T0800Z','20260906T1200Z','20260907T0300Z','20260908T1200Z'],(1900,1280,2150,1480),'pr04.png',2)
# PR17 avant / après le saut
montage(['20260905T1100Z','20260905T1300Z'],(1900,880,2100,1060),'pr17.png',3)
# vue d'ensemble
Image.open(glob.glob(IM+'20260905T1200Z*')[0]).resize((1030,688)).save(os.path.join(OUT,'vue.png'))
Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

@@ -0,0 +1,15 @@
import glob,os,sys
from PIL import Image
import numpy as np
IM='out/pompage/NORDEND/images/'
P={'PR04':(2019,1378),'PR17':(1992,973),'PR03':(1954,1344),'PR05':(2086,1386),'PR02':(1890,1339),'PR18':(2231,860),'PR16':(2430,1340)}
def pk(a,x,y,r=6):
w=a[y-r:y+r+1,x-r:x+r+1].astype(float)
bg=np.median(a[y-25:y+26,x-25:x+26])
return w.max()-bg, bg
out=[]
print('stamp',*P)
for f in sorted(glob.glob(IM+'2026090[5-8]T*.jpg')):
a=np.array(Image.open(f).convert('L'))
st=os.path.basename(f)[:13]
print(st,*['%d/%d'%pk(a,x,y) for x,y in P.values()])
@@ -0,0 +1,97 @@
stamp PR04 PR17 PR03 PR05 PR02 PR18 PR16
20260905T0000 196/59 187/68 187/68 184/71 190/65 187/68 179/76
20260905T0100 185/70 175/80 174/81 171/84 179/76 174/81 163/92
20260905T0215 200/55 194/61 192/63 190/65 195/60 193/62 185/70
20260905T0300 206/49 199/56 199/56 198/57 202/53 199/56 194/61
20260905T0400 169/86 158/97 158/97 156/99 164/91 158/97 148/107
20260905T0500 73/1 253/2 254/1 253/2 254/1 253/2 253/2
20260905T0600 19/1 147/2 114/1 229/1 85/1 241/2 254/1
20260905T0700 23/2 166/3 167/2 251/3 115/2 251/4 247/3
20260905T0800 28/4 228/5 206/3 250/5 159/2 249/6 250/5
20260905T0900 47/10 243/12 246/9 242/13 225/8 242/13 244/11
20260905T1000 65/14 242/13 242/13 238/17 245/10 241/14 243/12
20260905T1100 124/8 243/12 247/8 245/10 248/7 241/14 246/9
20260905T1200 45/25 235/20 227/23 227/28 234/21 237/18 240/15
20260905T1300 22/23 236/19 232/23 230/25 232/23 241/14 244/11
20260905T1400 179/18 230/25 237/18 236/19 236/19 234/21 239/16
20260905T1500 46/18 206/49 235/20 237/18 226/29 219/36 224/31
20260905T1600 133/67 167/88 184/71 193/62 169/86 194/61 204/51
20260905T1700 107/5 244/11 250/5 250/5 250/5 209/46 251/4
20260905T1800 238/17 226/29 237/18 236/19 237/18 229/26 235/20
20260905T1900 169/86 144/111 158/97 154/101 158/97 155/100 148/107
20260905T2000 194/61 178/77 186/69 183/72 187/68 184/71 177/78
20260905T2100 196/59 179/76 188/67 185/70 189/66 185/70 179/76
20260905T2200 232/23 225/30 228/27 228/27 229/26 228/27 225/30
20260905T2300 173/82 150/105 162/93 159/96 164/91 159/96 150/105
20260906T0000 174/81 151/104 162/93 159/96 165/90 159/96 151/104
20260906T0100 174/81 151/104 164/91 160/95 166/89 159/96 151/104
20260906T0200 177/78 154/101 166/89 163/92 169/86 162/93 152/103
20260906T0300 174/81 152/103 162/93 158/97 164/91 157/98 147/108
20260906T0400 172/83 149/106 162/93 157/98 162/93 156/99 146/109
20260906T0500 252/3 251/4 252/3 252/3 252/3 251/4 252/3
20260906T0600 38/2 247/2 253/2 253/2 252/1 253/2 253/2
20260906T0700 17/1 99/4 109/1 197/1 84/1 239/3 253/2
20260906T0800 50/6 245/10 250/5 248/7 251/4 246/9 247/8
20260906T0900 34/4 249/5 234/3 251/4 202/3 251/4 252/3
20260906T1000 11/15 238/17 241/14 237/18 244/11 240/15 241/14
20260906T1100 6/18 241/14 238/17 234/21 241/14 243/12 243/12
20260906T1200 5/23 237/18 233/22 230/25 235/20 241/14 243/12
20260906T1300 21/25 225/30 230/25 228/27 230/25 231/24 236/19
20260906T1400 19/29 222/33 226/29 225/30 224/31 230/25 236/19
20260906T1500 50/20 203/52 233/22 235/20 226/29 220/35 228/27
20260906T1600 108/65 169/86 187/68 194/61 172/83 195/60 205/50
20260906T1700 45/29 204/51 225/30 224/31 224/31 210/45 227/28
20260906T1800 199/55 168/87 189/66 184/71 192/63 178/77 182/73
20260906T1900 167/88 132/123 148/107 143/112 150/105 144/111 136/119
20260906T2000 167/88 133/122 148/107 145/110 152/103 147/108 137/118
20260906T2100 164/91 134/121 147/108 145/110 149/106 145/110 136/119
20260906T2200 169/86 136/119 150/105 146/109 152/103 146/109 137/118
20260906T2300 165/90 134/121 147/108 145/110 149/106 144/111 137/118
20260907T0000 170/85 138/117 153/102 149/106 155/100 149/106 139/116
20260907T0100 167/88 138/117 150/105 147/108 151/104 147/108 138/117
20260907T0200 163/92 133/122 144/111 143/112 148/107 140/115 134/121
20260907T0300 169/86 141/114 154/101 150/105 153/102 150/105 141/114
20260907T0400 167/88 138/117 150/105 146/109 151/104 144/111 137/118
20260907T0500 25/2 252/3 253/2 253/2 253/2 252/3 252/3
20260907T0600 0/1 115/2 118/1 206/1 101/1 243/2 254/1
20260907T0700 0/1 135/4 120/1 230/1 110/1 252/3 253/2
20260907T0800 3/6 245/10 250/5 247/8 251/4 245/10 247/8
20260907T0900 10/10 242/13 245/10 242/13 248/7 242/13 244/11
20260907T1000 8/14 239/16 242/13 238/17 244/11 240/15 242/13
20260907T1100 7/18 240/15 238/17 234/21 241/14 242/13 243/12
20260907T1200 24/26 233/22 230/25 226/29 232/23 238/17 240/15
20260907T1300 43/24 239/16 231/24 229/26 232/23 244/11 245/10
20260907T1400 15/26 228/27 229/26 228/27 227/28 236/19 241/14
20260907T1500 40/23 197/58 230/25 232/23 223/32 217/38 227/28
20260907T1600 92/61 171/84 192/63 198/57 178/77 195/60 209/46
20260907T1700 15/14 229/26 241/14 241/14 240/15 224/31 242/13
20260907T1800 112/12 235/20 240/15 239/16 240/15 238/17 239/16
20260907T1900 127/15 236/19 238/17 238/17 238/17 238/17 237/18
20260907T2000 234/14 237/18 239/16 239/16 239/16 239/16 238/17
20260907T2100 78/13 238/17 240/15 240/15 240/15 240/15 239/16
20260907T2200 169/86 136/119 149/106 151/104 150/105 148/107 137/118
20260907T2300 167/88 137/118 146/109 145/110 148/107 146/109 135/120
20260908T0000 172/83 141/114 153/102 152/103 155/100 152/103 142/113
20260908T0100 169/86 139/116 148/107 146/109 151/104 148/107 140/115
20260908T0200 165/90 143/112 151/104 148/107 151/104 149/106 151/104
20260908T0300 174/81 148/107 156/99 155/100 158/97 158/97 148/107
20260908T0400 177/78 149/106 157/98 158/97 161/94 158/97 148/107
20260908T0500 206/49 184/71 197/58 194/61 200/55 195/60 194/61
20260908T0600 28/23 227/28 232/23 228/27 233/22 232/23 236/19
20260908T0700 7/7 247/8 248/7 247/8 249/6 248/7 250/5
20260908T0800 44/40 209/46 218/37 210/45 220/35 219/36 221/34
20260908T0900 6/2 252/3 253/2 252/3 253/2 252/3 253/2
20260908T1000 7/4 250/5 251/4 250/5 245/3 250/5 251/4
20260908T1100 163/13 238/17 242/13 240/15 243/12 239/16 243/12
20260908T1200 56/29 229/26 228/27 223/32 230/25 233/22 235/20
20260908T1300 226/24 238/17 231/24 229/26 232/23 244/11 245/10
20260908T1400 64/14 240/15 239/14 241/14 240/15 246/9 248/7
20260908T1500 203/52 183/72 204/51 200/55 202/53 192/63 206/49
20260908T1600 25/11 240/15 244/11 242/13 244/11 241/14 244/11
20260908T1700 101/28 217/38 227/28 223/32 229/26 220/35 226/29
20260908T1800 231/24 221/34 232/23 229/26 232/23 228/27 235/20
20260908T1900 135/120 137/118 149/106 133/122 150/105 149/106 140/115
20260908T2000 153/102 144/111 155/100 143/112 157/98 155/100 145/110
20260908T2100 153/102 148/107 159/96 145/110 160/95 157/98 147/108
20260908T2200 157/98 152/103 161/94 147/108 163/92 160/95 151/104
20260908T2300 150/105 143/112 153/102 141/114 155/100 151/104 142/113
@@ -0,0 +1,29 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections
rows=load()
by=collections.defaultdict(dict)
for r in rows: by[r['sensor_name']][r['t'].replace(second=0,microsecond=0)]=r
S=[s for s in by if s not in('PR04','PR07')]
ts=sorted(by['PR01'])
def cm(col,t):
v=[by[s][t][col] for s in S if t in by[s] and by[s][t][col] is not None]
return st.median(v) if v else None
print('Sauts de mode commun (y brut) > 0.5 px entre pas successifs; puis dx')
prev=None
for t in ts:
y=cm('y',t); x=cm('x',t)
if prev and y is not None:
dy=y-prev[1]; dx=x-prev[2]
if abs(dy)>0.4 or abs(dx)>0.4: print(t, 'pas',(t-prev[0]).seconds//60,'min dy=%.2f dx=%.2f'%(dy,dx))
prev=(t,y,x)
# corr: mediane corr_x/corr_y des capteurs, sauts
print('corr médiane inter-capteurs: plus grands pas')
res=[]
prev=None
for t in ts:
cx=cm('corr_x',t); cy=cm('corr_y',t)
if prev and cx is not None and prev[1] is not None:
res.append((t,cx-prev[1],cy-prev[2]))
prev=(t,cx,cy)
for t,a,b in sorted(res,key=lambda z:-max(abs(z[1]),abs(z[2])))[:12]: print(t,round(a,3),round(b,3))
Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

@@ -0,0 +1,18 @@
import glob,os
from PIL import Image, ImageDraw
IM='out/pompage/NORDEND/images/'
stamps=['20260905T0300Z','20260905T1000Z','20260905T1400Z','20260906T1000Z','20260906T1400Z','20260907T0300Z','20260907T1200Z','20260908T0300Z','20260908T1000Z','20260908T1400Z']
W=100; sc=3
m=Image.new('RGB',(len(stamps)*W*sc,2*W*sc))
for i,s in enumerate(stamps):
f=glob.glob(IM+s+'*.jpg')[0]
im=Image.open(f).convert('L')
for j,(x,y) in enumerate(((2019,1378),(1992,973))):
c=im.crop((x-W//2,y-W//2,x+W//2,y+W//2)).resize((W*sc,W*sc),Image.NEAREST)
# étirer le contraste
lo,hi=c.getextrema(); c=c.point(lambda v:int(255*(v-lo)/max(hi-lo,1)))
d=ImageDraw.Draw(c.convert('RGB')) if False else None
m.paste(c.convert('RGB'),(i*W*sc,j*W*sc))
d=ImageDraw.Draw(m)
for i,s in enumerate(stamps): d.text((i*W*sc+4,4),s[4:],fill=(255,255,0))
m.save(os.path.join(os.path.dirname(__file__),'pr04_pr17_serie.png'))
Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

@@ -0,0 +1,15 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
rows=load()
def m(s,d,h0,h1,k):
v=[r[k] for r in rows if r['sensor_name']==s and r['t'].day==d and h0<=r['t'].hour+r['t'].minute/60<h1 and r[k] is not None]
return st.mean(v)
print('Baisse de corr entre 05:00-06:30 et 08:00-10:00 (UTC), par jour')
for k in ('corr_x','corr_y'):
print(k)
for s in ('CTR02','CTR03','CTR04','PR01','PR05','PR09','PR12','PR14','PR16','PR17','PR18'):
print(' ',s,*['%d:%+.3f'%(d,m(s,d,8,10,k)-m(s,d,5,6.5,k)) for d in (5,6,7,8)])
print('amplitude y brut médian (max-min) par jour, px')
for d in (5,6,7,8):
v=[st.median([r['y']-st.median([q['y'] for q in rows if q['sensor_name']==s]) for s in ('PR01','PR02','PR09')]) for r in rows if r['sensor_name']=='PR01' and r['t'].day==d]
print(d)
@@ -0,0 +1,14 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections
rows=load(days=('20260901','20260902','20260903','20260904','20260905','20260906','20260907','20260908','20260909'))
by=collections.defaultdict(list)
for r in rows: by[r['sensor_name']].append(r)
def med(l): l=[x for x in l if x is not None]; return st.median(l) if l else float('nan')
print('capteur | err med jour(5..8) ; err max ; corr_x med/day ; corr_y med/day')
for s,l in sorted(by.items()):
out=[]
for d in range(4,10):
ll=[r for r in l if r['t'].day==d]
out.append('%02d: e=%.3f/%.3f cx=%.3f cy=%.3f'%(d,med([r['error_value'] for r in ll]),max(r['error_value'] for r in ll),med([r['corr_x'] for r in ll]),med([r['corr_y'] for r in ll])))
print(s,l[0]['pattern_type']); print(' '+'\n '.join(out))
@@ -0,0 +1,15 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections
rows=load()
by=collections.defaultdict(dict)
for r in rows:
by[r['sensor_name']][r['t'].replace(second=0,microsecond=0)]=r
# PR17 corr_y jump
s=by['PR17']; ts=sorted(s)
d=[(b, s[b]['corr_y']-s[a]['corr_y'], s[b]['relative_y']-s[a]['relative_y']) for a,b in zip(ts,ts[1:]) if s[a]['corr_y'] is not None and s[b]['corr_y'] is not None]
print('PR17 plus gros sauts corr_y');
for b,dc,dr in sorted(d,key=lambda z:-abs(z[1]))[:5]: print(b,round(dc,3),round(dr,3))
for t in ts:
if dt.datetime(2026,9,5,6,tzinfo=dt.timezone.utc)<=t<=dt.datetime(2026,9,5,12,tzinfo=dt.timezone.utc):
r=s[t]; print(t.strftime('%H:%M'),r['corr_y'],r['relative_y'],r['y'],r['error_value'])
@@ -0,0 +1,19 @@
import sys,os; sys.path.insert(0,os.path.dirname(__file__))
from charge import *
import collections
rows=load()
ts=sorted({r['t'].replace(second=0,microsecond=0) for r in rows})
print('timestamps',len(ts))
for a,b in zip(ts,ts[1:]):
if b-a>dt.timedelta(minutes=16): print('trou',a,b)
# sensors per timestamp
c=collections.Counter(r['t'].replace(second=0,microsecond=0) for r in rows)
for t,n in sorted(c.items()):
if n!=22: print('n capteurs',t,n)
# error_value vs threshold: counts rejected per timestamp
rej=collections.defaultdict(list)
for r in rows:
if r['error_value'] is not None and r['error_value']>r['error_threshold']:
rej[r['t'].replace(second=0,microsecond=0)].append(r['sensor_name'])
if r['error_value'] is None: rej[r['t'].replace(second=0,microsecond=0)].append(r['sensor_name']+'(nan)')
for t,l in sorted(rej.items()): print('rej',t,len(l),l)
Binary file not shown.

After

Width:  |  Height:  |  Size: 681 KiB