wolfhece 2.2.14__py3-none-any.whl → 2.2.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/Model1D.py +12 -12
- wolfhece/PyDraw.py +200 -3
- wolfhece/PyGui.py +9 -1
- wolfhece/PyVertexvectors.py +6 -4
- wolfhece/PyWMS.py +633 -2
- wolfhece/__init__.py +1 -1
- wolfhece/apps/version.py +1 -1
- wolfhece/apps/wolf.py +1 -1
- wolfhece/assets/__init__.py +0 -1
- wolfhece/assets/mesh.py +685 -0
- wolfhece/friction_law.py +3 -3
- wolfhece/hydrology/SubBasin.py +154 -154
- wolfhece/hydrometry/kiwis.py +55 -16
- wolfhece/hydrometry/kiwis_wolfgui.py +8 -7
- wolfhece/lazviewer/laz_viewer.py +4 -4
- wolfhece/mesh2d/wolf2dprev.py +23 -0
- wolfhece/pyshields.py +38 -2
- wolfhece/wolf_array.py +19 -16
- wolfhece/wolf_texture.py +74 -13
- wolfhece/wolfresults_2D.py +220 -74
- {wolfhece-2.2.14.dist-info → wolfhece-2.2.16.dist-info}/METADATA +2 -3
- {wolfhece-2.2.14.dist-info → wolfhece-2.2.16.dist-info}/RECORD +25 -24
- {wolfhece-2.2.14.dist-info → wolfhece-2.2.16.dist-info}/WHEEL +1 -1
- {wolfhece-2.2.14.dist-info → wolfhece-2.2.16.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.14.dist-info → wolfhece-2.2.16.dist-info}/top_level.txt +0 -0
wolfhece/PyWMS.py
CHANGED
@@ -17,8 +17,12 @@ import wx
|
|
17
17
|
import logging
|
18
18
|
from typing import Union, Literal
|
19
19
|
from enum import Enum
|
20
|
+
from datetime import datetime, timedelta
|
20
21
|
|
21
|
-
|
22
|
+
try:
|
23
|
+
from .PyTranslate import _
|
24
|
+
except:
|
25
|
+
from wolfhece.PyTranslate import _
|
22
26
|
|
23
27
|
def to_image(mybytes:BytesIO) -> Image:
|
24
28
|
return Image.open(mybytes)
|
@@ -272,11 +276,638 @@ def getLifeWatch(cat:Literal['None'],
|
|
272
276
|
logging.warning(_('Impossible to get data from web services'))
|
273
277
|
return None
|
274
278
|
|
279
|
+
def getNGI(cat:Literal['orthoimage_coverage',
|
280
|
+
'orthoimage_coverage_2016',
|
281
|
+
'orthoimage_coverage_2017',
|
282
|
+
'orthoimage_coverage_2018',
|
283
|
+
'orthoimage_coverage_2019',
|
284
|
+
'orthoimage_coverage_2020',
|
285
|
+
'orthoimage_coverage_2021',
|
286
|
+
'orthoimage_coverage_2022'],
|
287
|
+
xl:float,
|
288
|
+
yl:float,
|
289
|
+
xr:float,
|
290
|
+
yr:float,
|
291
|
+
w:int = None,
|
292
|
+
h:int = None,
|
293
|
+
tofile=True,
|
294
|
+
format:Literal['image/png', 'image/GeoTIFF']='image/png') -> BytesIO:
|
295
|
+
|
296
|
+
wms=WebMapService(f'https://wms.ngi.be/inspire/ortho/service?',
|
297
|
+
version='1.3.0', timeout=10)
|
298
|
+
|
299
|
+
ppkm = 300
|
300
|
+
if w is None and h is None:
|
301
|
+
real_w = (xr-xl)/1000
|
302
|
+
real_h = (yr-yl)/1000
|
303
|
+
w = int(real_w * ppkm)
|
304
|
+
h = int(real_h * ppkm)
|
305
|
+
elif w is None:
|
306
|
+
real_w = (xr-xl)/1000
|
307
|
+
real_h = (yr-yl)/1000
|
308
|
+
ppkm = h/real_h
|
309
|
+
w = int(real_w * ppkm)
|
310
|
+
# h = int(real_h * ppkm)
|
311
|
+
elif h is None:
|
312
|
+
real_w = (xr-xl)/1000
|
313
|
+
real_h = (yr-yl)/1000
|
314
|
+
ppkm = w/real_w
|
315
|
+
# w = int(real_w * ppkm)
|
316
|
+
h = int(real_h * ppkm)
|
317
|
+
|
318
|
+
MAXSIZE = 4000
|
319
|
+
if w > MAXSIZE:
|
320
|
+
pond = w / MAXSIZE
|
321
|
+
w = MAXSIZE
|
322
|
+
h = int(h / pond)
|
323
|
+
if h > MAXSIZE:
|
324
|
+
pond = h / MAXSIZE
|
325
|
+
h = MAXSIZE
|
326
|
+
w = int(w / pond)
|
327
|
+
|
328
|
+
if tofile:
|
329
|
+
img=wms.getmap(layers=['lc_hr_raster'],
|
330
|
+
# styles=['default'],
|
331
|
+
srs='EPSG:31370',
|
332
|
+
bbox=(xl,yl,xr,yr),
|
333
|
+
size=(w,h),
|
334
|
+
format='image/png',
|
335
|
+
transparent=False)
|
336
|
+
|
337
|
+
out = open('LifeWatch.png', 'wb')
|
338
|
+
out.write(img.read())
|
339
|
+
out.close()
|
340
|
+
return None
|
341
|
+
else:
|
342
|
+
mycontents=list(wms.contents) # List all available layers
|
343
|
+
curcont=[cat] # 'MS
|
344
|
+
curstyles=['1']
|
345
|
+
|
346
|
+
# convert from EPSG:31370 to EPSG:3812
|
347
|
+
transf=pyproj.Transformer.from_crs('EPSG:31370','EPSG:3812')
|
348
|
+
x1,y1=transf.transform(xl,yl)
|
349
|
+
x2,y2=transf.transform(xr,yr)
|
350
|
+
|
351
|
+
try:
|
352
|
+
img=wms.getmap(layers=curcont,
|
353
|
+
# styles=curstyles,
|
354
|
+
srs='EPSG:3812',
|
355
|
+
bbox=(x1,y1,x2,y2),
|
356
|
+
size=(w,h),
|
357
|
+
format=format,
|
358
|
+
transparent=False)
|
359
|
+
|
360
|
+
return BytesIO(img.read())
|
361
|
+
|
362
|
+
except:
|
363
|
+
logging.warning(_('Impossible to get data from web services'))
|
364
|
+
return None
|
365
|
+
|
366
|
+
def getCartoweb(cat:Literal['crossborder',
|
367
|
+
'crossborder_grey',
|
368
|
+
'overlay',
|
369
|
+
'topo',
|
370
|
+
'topo_grey'],
|
371
|
+
xl:float,
|
372
|
+
yl:float,
|
373
|
+
xr:float,
|
374
|
+
yr:float,
|
375
|
+
w:int = None,
|
376
|
+
h:int = None,
|
377
|
+
tofile=True,
|
378
|
+
format:Literal['image/png', 'image/GeoTIFF']='image/png') -> BytesIO:
|
379
|
+
|
380
|
+
wms=WebMapService(f'https://cartoweb.wms.ngi.be/service?',
|
381
|
+
version='1.3.0', timeout=10)
|
382
|
+
|
383
|
+
ppkm = 300
|
384
|
+
if w is None and h is None:
|
385
|
+
real_w = (xr-xl)/1000
|
386
|
+
real_h = (yr-yl)/1000
|
387
|
+
w = int(real_w * ppkm)
|
388
|
+
h = int(real_h * ppkm)
|
389
|
+
elif w is None:
|
390
|
+
real_w = (xr-xl)/1000
|
391
|
+
real_h = (yr-yl)/1000
|
392
|
+
ppkm = h/real_h
|
393
|
+
w = int(real_w * ppkm)
|
394
|
+
# h = int(real_h * ppkm)
|
395
|
+
elif h is None:
|
396
|
+
real_w = (xr-xl)/1000
|
397
|
+
real_h = (yr-yl)/1000
|
398
|
+
ppkm = w/real_w
|
399
|
+
# w = int(real_w * ppkm)
|
400
|
+
h = int(real_h * ppkm)
|
401
|
+
|
402
|
+
MAXSIZE = 2000
|
403
|
+
if w > MAXSIZE:
|
404
|
+
pond = w / MAXSIZE
|
405
|
+
w = MAXSIZE
|
406
|
+
h = int(h / pond)
|
407
|
+
if h > MAXSIZE:
|
408
|
+
pond = h / MAXSIZE
|
409
|
+
h = MAXSIZE
|
410
|
+
w = int(w / pond)
|
411
|
+
|
412
|
+
if tofile:
|
413
|
+
img=wms.getmap(layers=['lc_hr_raster'],
|
414
|
+
# styles=['default'],
|
415
|
+
srs='EPSG:31370',
|
416
|
+
bbox=(xl,yl,xr,yr),
|
417
|
+
size=(w,h),
|
418
|
+
format='image/png',
|
419
|
+
transparent=False)
|
420
|
+
|
421
|
+
out = open('LifeWatch.png', 'wb')
|
422
|
+
out.write(img.read())
|
423
|
+
out.close()
|
424
|
+
return None
|
425
|
+
else:
|
426
|
+
mycontents=list(wms.contents) # List all available layers
|
427
|
+
curcont=[cat] # 'MS
|
428
|
+
curstyles=['1']
|
429
|
+
|
430
|
+
try:
|
431
|
+
img=wms.getmap(layers=curcont,
|
432
|
+
# styles=curstyles,
|
433
|
+
srs='EPSG:31370',
|
434
|
+
bbox=(xl,yl,xr,yr),
|
435
|
+
size=(w,h),
|
436
|
+
format=format,
|
437
|
+
transparent=True)
|
438
|
+
|
439
|
+
return BytesIO(img.read())
|
440
|
+
|
441
|
+
except:
|
442
|
+
logging.warning(_('Impossible to get data from web services'))
|
443
|
+
return None
|
444
|
+
|
445
|
+
def getOrthoPostFlood2021(cat:Literal['orthoimage_flood'],
|
446
|
+
xl:float,
|
447
|
+
yl:float,
|
448
|
+
xr:float,
|
449
|
+
yr:float,
|
450
|
+
w:int = None,
|
451
|
+
h:int = None,
|
452
|
+
tofile=True,
|
453
|
+
format:Literal['image/png', 'image/GeoTIFF']='image/png') -> BytesIO:
|
454
|
+
|
455
|
+
wms=WebMapService(f'https://wms.ngi.be/inspire/flood_ortho/service?',
|
456
|
+
version='1.3.0', timeout=10)
|
457
|
+
|
458
|
+
ppkm = 300
|
459
|
+
if w is None and h is None:
|
460
|
+
real_w = (xr-xl)/1000
|
461
|
+
real_h = (yr-yl)/1000
|
462
|
+
w = int(real_w * ppkm)
|
463
|
+
h = int(real_h * ppkm)
|
464
|
+
elif w is None:
|
465
|
+
real_w = (xr-xl)/1000
|
466
|
+
real_h = (yr-yl)/1000
|
467
|
+
ppkm = h/real_h
|
468
|
+
w = int(real_w * ppkm)
|
469
|
+
# h = int(real_h * ppkm)
|
470
|
+
elif h is None:
|
471
|
+
real_w = (xr-xl)/1000
|
472
|
+
real_h = (yr-yl)/1000
|
473
|
+
ppkm = w/real_w
|
474
|
+
# w = int(real_w * ppkm)
|
475
|
+
h = int(real_h * ppkm)
|
476
|
+
|
477
|
+
MAXSIZE = 4000
|
478
|
+
if w > MAXSIZE:
|
479
|
+
pond = w / MAXSIZE
|
480
|
+
w = MAXSIZE
|
481
|
+
h = int(h / pond)
|
482
|
+
if h > MAXSIZE:
|
483
|
+
pond = h / MAXSIZE
|
484
|
+
h = MAXSIZE
|
485
|
+
w = int(w / pond)
|
486
|
+
|
487
|
+
if tofile:
|
488
|
+
img=wms.getmap(layers=['lc_hr_raster'],
|
489
|
+
# styles=['default'],
|
490
|
+
srs='EPSG:31370',
|
491
|
+
bbox=(xl,yl,xr,yr),
|
492
|
+
size=(w,h),
|
493
|
+
format='image/png',
|
494
|
+
transparent=False)
|
495
|
+
|
496
|
+
out = open('LifeWatch.png', 'wb')
|
497
|
+
out.write(img.read())
|
498
|
+
out.close()
|
499
|
+
return None
|
500
|
+
else:
|
501
|
+
mycontents=list(wms.contents) # List all available layers
|
502
|
+
curcont=[cat] # 'MS
|
503
|
+
curstyles=['1']
|
504
|
+
|
505
|
+
# convert from EPSG:31370 to EPSG:3812
|
506
|
+
transf=pyproj.Transformer.from_crs('EPSG:31370','EPSG:3812')
|
507
|
+
x1,y1=transf.transform(xl,yl)
|
508
|
+
x2,y2=transf.transform(xr,yr)
|
509
|
+
|
510
|
+
try:
|
511
|
+
img=wms.getmap(layers=curcont,
|
512
|
+
# styles=curstyles,
|
513
|
+
srs='EPSG:3812',
|
514
|
+
bbox=(x1,y1,x2,y2),
|
515
|
+
size=(w,h),
|
516
|
+
format=format,
|
517
|
+
transparent=False)
|
518
|
+
|
519
|
+
return BytesIO(img.read())
|
520
|
+
|
521
|
+
except:
|
522
|
+
logging.warning(_('Impossible to get data from web services'))
|
523
|
+
return None
|
524
|
+
|
525
|
+
def get_Alaro_times():
|
526
|
+
wms=WebMapService(f'https://opendata.meteo.be/service/alaro/wms?',
|
527
|
+
version='1.3.0', timeout=10)
|
528
|
+
times = wms['Total_precipitation'].timepositions[0].split('/')
|
529
|
+
|
530
|
+
return times
|
531
|
+
|
532
|
+
def get_Alaro_legend(layer:str):
|
533
|
+
""" Get the legend of the layer
|
534
|
+
|
535
|
+
:param layer: name of the layer
|
536
|
+
:return: legend of the layer
|
537
|
+
"""
|
538
|
+
import requests
|
539
|
+
from io import BytesIO
|
540
|
+
layers = ['10_m_u__wind_component',
|
541
|
+
'10_m_v__wind_component',
|
542
|
+
'2_m_Max_temp_since_ppp',
|
543
|
+
'2_m_Min_temp_since_ppp',
|
544
|
+
'2_m_dewpoint_temperature',
|
545
|
+
'2_m_temperature',
|
546
|
+
'2m_Relative_humidity',
|
547
|
+
'Convective_rain',
|
548
|
+
'Convective_snow',
|
549
|
+
'Geopotential',
|
550
|
+
'Inst_flx_Conv_Cld_Cover',
|
551
|
+
'Inst_flx_High_Cld_Cover',
|
552
|
+
'Inst_flx_Low_Cld_Cover',
|
553
|
+
'Inst_flx_Medium_Cld_Cover',
|
554
|
+
'Inst_flx_Tot_Cld_cover',
|
555
|
+
'Large_scale_rain',
|
556
|
+
'Large_scale_snow',
|
557
|
+
'Mean_sea_level_pressure',
|
558
|
+
'Relative_humidity',
|
559
|
+
'Relative_humidity_isobaric',
|
560
|
+
'SBL_Meridian_gust',
|
561
|
+
'SBL_Zonal_gust',
|
562
|
+
'Specific_humidity',
|
563
|
+
'Surf_Solar_radiation',
|
564
|
+
'Surf_Thermal_radiation',
|
565
|
+
'Surface_CAPE',
|
566
|
+
'Surface_Temperature',
|
567
|
+
'Surface_orography',
|
568
|
+
'Temperature',
|
569
|
+
'Total_precipitation',
|
570
|
+
'U-velocity',
|
571
|
+
'V-velocity',
|
572
|
+
'Vertical_velocity',
|
573
|
+
'Wet_Bulb_Poten_Temper',
|
574
|
+
'freezing_level_zeroDegC_isotherm']
|
575
|
+
|
576
|
+
layers_lowercase = [l.lower() for l in layers]
|
577
|
+
if layer.lower() not in layers_lowercase:
|
578
|
+
logging.warning(_('Layer not found in the list of available layers'))
|
579
|
+
return None
|
580
|
+
|
581
|
+
layer = layers[layers_lowercase.index(layer.lower())]
|
582
|
+
|
583
|
+
ows = "https://opendata.meteo.be/geoserver/alaro/ows?"
|
584
|
+
|
585
|
+
legend = requests.get(ows, params={'layer': layer,
|
586
|
+
'width': 50,
|
587
|
+
'height': 50,
|
588
|
+
'format': 'image/png',
|
589
|
+
'service': 'WMS',
|
590
|
+
'version': '1.3.0',
|
591
|
+
'request': 'GetLegendGraphic'})
|
592
|
+
|
593
|
+
return BytesIO(legend.content)
|
594
|
+
|
595
|
+
def getAlaro(cat:Literal['10_m_u__wind_component',
|
596
|
+
'10_m_v__wind_component',
|
597
|
+
'2_m_Max_temp_since_ppp',
|
598
|
+
'2_m_Min_temp_since_ppp',
|
599
|
+
'2_m_dewpoint_temperature',
|
600
|
+
'2_m_temperature',
|
601
|
+
'2m_Relative_humidity',
|
602
|
+
'Convective_rain',
|
603
|
+
'Convective_snow',
|
604
|
+
'Geopotential',
|
605
|
+
'Inst_flx_Conv_Cld_Cover',
|
606
|
+
'Inst_flx_High_Cld_Cover',
|
607
|
+
'Inst_flx_Low_Cld_Cover',
|
608
|
+
'Inst_flx_Medium_Cld_Cover',
|
609
|
+
'Inst_flx_Tot_Cld_cover',
|
610
|
+
'Large_scale_rain',
|
611
|
+
'Large_scale_snow',
|
612
|
+
'Mean_sea_level_pressure',
|
613
|
+
'Relative_humidity',
|
614
|
+
'Relative_humidity_isobaric',
|
615
|
+
'SBL_Meridian_gust',
|
616
|
+
'SBL_Zonal_gust',
|
617
|
+
'Specific_humidity',
|
618
|
+
'Surf_Solar_radiation',
|
619
|
+
'Surf_Thermal_radiation',
|
620
|
+
'Surface_CAPE',
|
621
|
+
'Surface_Temperature',
|
622
|
+
'Surface_orography',
|
623
|
+
'Temperature',
|
624
|
+
'Total_precipitation',
|
625
|
+
'U-velocity',
|
626
|
+
'V-velocity',
|
627
|
+
'Vertical_velocity',
|
628
|
+
'Wet_Bulb_Poten_Temper',
|
629
|
+
'freezing_level_zeroDegC_isotherm'],
|
630
|
+
xl:float,
|
631
|
+
yl:float,
|
632
|
+
xr:float,
|
633
|
+
yr:float,
|
634
|
+
w:int = None,
|
635
|
+
h:int = None,
|
636
|
+
tofile=True,
|
637
|
+
format:Literal['image/png', 'image/GeoTIFF']='image/png',
|
638
|
+
time = None) -> BytesIO:
|
639
|
+
|
640
|
+
wms=WebMapService(f'https://opendata.meteo.be/service/alaro/wms?',
|
641
|
+
version='1.3.0', timeout=10)
|
642
|
+
|
643
|
+
ppkm = 300
|
644
|
+
if w is None and h is None:
|
645
|
+
real_w = (xr-xl)/1000
|
646
|
+
real_h = (yr-yl)/1000
|
647
|
+
w = int(real_w * ppkm)
|
648
|
+
h = int(real_h * ppkm)
|
649
|
+
elif w is None:
|
650
|
+
real_w = (xr-xl)/1000
|
651
|
+
real_h = (yr-yl)/1000
|
652
|
+
ppkm = h/real_h
|
653
|
+
w = int(real_w * ppkm)
|
654
|
+
# h = int(real_h * ppkm)
|
655
|
+
elif h is None:
|
656
|
+
real_w = (xr-xl)/1000
|
657
|
+
real_h = (yr-yl)/1000
|
658
|
+
ppkm = w/real_w
|
659
|
+
# w = int(real_w * ppkm)
|
660
|
+
h = int(real_h * ppkm)
|
661
|
+
|
662
|
+
MAXSIZE = 2000
|
663
|
+
if w > MAXSIZE:
|
664
|
+
pond = w / MAXSIZE
|
665
|
+
w = MAXSIZE
|
666
|
+
h = int(h / pond)
|
667
|
+
if h > MAXSIZE:
|
668
|
+
pond = h / MAXSIZE
|
669
|
+
h = MAXSIZE
|
670
|
+
w = int(w / pond)
|
671
|
+
|
672
|
+
if tofile:
|
673
|
+
img=wms.getmap(layers=['lc_hr_raster'],
|
674
|
+
# styles=['default'],
|
675
|
+
srs='EPSG:31370',
|
676
|
+
bbox=(xl,yl,xr,yr),
|
677
|
+
size=(w,h),
|
678
|
+
format='image/png',
|
679
|
+
transparent=False)
|
680
|
+
|
681
|
+
out = open('LifeWatch.png', 'wb')
|
682
|
+
out.write(img.read())
|
683
|
+
out.close()
|
684
|
+
return None
|
685
|
+
else:
|
686
|
+
mycontents=list(wms.contents) # List all available layers
|
687
|
+
curcont=[cat] # 'MS
|
688
|
+
curstyles=['1']
|
689
|
+
|
690
|
+
# test = get_Alaro_legend(cat)
|
691
|
+
|
692
|
+
try:
|
693
|
+
if time is None:
|
694
|
+
time = wms[cat].timepositions[0].split('/')[0]
|
695
|
+
|
696
|
+
img=wms.getmap(layers=curcont,
|
697
|
+
# styles=curstyles,
|
698
|
+
srs='EPSG:31370',
|
699
|
+
bbox=(xl,yl,xr,yr),
|
700
|
+
size=(w,h),
|
701
|
+
format=format,
|
702
|
+
transparent=False,
|
703
|
+
time = time)
|
704
|
+
|
705
|
+
return BytesIO(img.read())
|
706
|
+
|
707
|
+
except:
|
708
|
+
logging.warning(_('Impossible to get data from web services'))
|
709
|
+
return None
|
710
|
+
|
711
|
+
class Alaro_Navigator(wx.Frame):
|
712
|
+
""" Frame to navigate through Alaro data
|
713
|
+
|
714
|
+
Propose a caolendar to select the time of the data
|
715
|
+
"""
|
716
|
+
|
717
|
+
def __init__(self, parent, id, title):
|
718
|
+
super(Alaro_Navigator, self).__init__(parent, title=title, size=(500, 150))
|
719
|
+
|
720
|
+
panel = wx.Panel(self)
|
721
|
+
vbox = wx.BoxSizer(wx.VERTICAL)
|
722
|
+
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
723
|
+
hbox_start_end = wx.BoxSizer(wx.HORIZONTAL)
|
724
|
+
hbox_interv_alpha = wx.BoxSizer(wx.HORIZONTAL)
|
725
|
+
|
726
|
+
t_start, t_end, interv = get_Alaro_times()
|
727
|
+
self._start_date = wx.TextCtrl(panel, value=t_start.replace('.000Z', 'Z'), size=(100, -1), style=wx.TE_READONLY | wx.TE_CENTER)
|
728
|
+
self._end_date = wx.TextCtrl(panel, value=t_end.replace('.000Z', 'Z'), size=(100, -1), style=wx.TE_READONLY | wx.TE_CENTER)
|
729
|
+
self._interval = wx.TextCtrl(panel, value=interv.replace('PT',''), size=(100, -1), style=wx.TE_READONLY | wx.TE_CENTER)
|
730
|
+
|
731
|
+
self._btn_previous = wx.Button(panel, label=_('Previous'), size=(100, -1))
|
732
|
+
self._btn_next = wx.Button(panel, label=_('Next'), size=(100, -1))
|
733
|
+
self._time = wx.TextCtrl(panel, value=t_start.replace('.000Z', 'Z'), size=(100, -1), style=wx.TE_CENTER | wx.TE_PROCESS_ENTER)
|
734
|
+
self._alpha = wx.TextCtrl(panel, value='1.0', size=(100, -1), style=wx.TE_CENTER | wx.TE_PROCESS_ENTER)
|
735
|
+
self._alpha.SetToolTip(_('Transparency of the image (0-1)'))
|
736
|
+
|
737
|
+
self._btn_legend = wx.Button(panel, label=_('Legend'), size=(100, -1))
|
738
|
+
self._btn_legend.Bind(wx.EVT_BUTTON, self.OnLegend)
|
739
|
+
|
740
|
+
self._time.Bind(wx.EVT_TEXT_ENTER, self.OnEnterTime)
|
741
|
+
|
742
|
+
hbox.Add(self._btn_previous, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
743
|
+
hbox.Add(self._time, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
744
|
+
hbox.Add(self._btn_next, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
745
|
+
|
746
|
+
hbox_start_end.Add(self._start_date, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
747
|
+
hbox_start_end.Add(self._end_date, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
748
|
+
|
749
|
+
hbox_interv_alpha.Add(self._interval, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
750
|
+
hbox_interv_alpha.Add(self._alpha, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
751
|
+
|
752
|
+
vbox.Add(hbox, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
753
|
+
vbox.Add(hbox_start_end, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
754
|
+
vbox.Add(hbox_interv_alpha, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
755
|
+
vbox.Add(self._btn_legend, 1, flag=wx.EXPAND | wx.ALL, border=1)
|
756
|
+
|
757
|
+
panel.SetSizer(vbox)
|
758
|
+
|
759
|
+
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
760
|
+
self._btn_previous.Bind(wx.EVT_BUTTON, self.OnPrevious)
|
761
|
+
self._btn_next.Bind(wx.EVT_BUTTON, self.OnNext)
|
762
|
+
|
763
|
+
def OnPrevious(self, event):
|
764
|
+
""" Hour minus interval
|
765
|
+
"""
|
766
|
+
|
767
|
+
try:
|
768
|
+
time = self.time
|
769
|
+
|
770
|
+
# force the time to be rounded to the nearest interval
|
771
|
+
interval = timedelta(hours=1)
|
772
|
+
# nullify the minutes and seconds
|
773
|
+
time = time.replace(minute=0, second=0, microsecond=0, hour=time.hour - 1)
|
774
|
+
|
775
|
+
# check is the time is in the interval
|
776
|
+
if time < self.start or time > self.end:
|
777
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
778
|
+
return
|
779
|
+
|
780
|
+
self.time = time
|
781
|
+
except ValueError:
|
782
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
783
|
+
return
|
784
|
+
except Exception as e:
|
785
|
+
wx.MessageBox(_('An error occurred: ') + str(e), _('Error'), wx.OK | wx.ICON_ERROR)
|
786
|
+
return
|
787
|
+
|
788
|
+
self.Parent._alaro_update_time()
|
789
|
+
|
790
|
+
event.Skip()
|
791
|
+
|
792
|
+
def OnNext(self, event):
|
793
|
+
""" Hour plus interval
|
794
|
+
"""
|
795
|
+
|
796
|
+
try:
|
797
|
+
time = self.time
|
798
|
+
|
799
|
+
# force the time to be rounded to the nearest interval
|
800
|
+
interval = timedelta(hours=1)
|
801
|
+
# nullify the minutes and seconds
|
802
|
+
time = time.replace(minute=0, second=0, microsecond=0, hour=time.hour + 1)
|
803
|
+
|
804
|
+
# check is the time is in the interval
|
805
|
+
if time < self.start or time > self.end:
|
806
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
807
|
+
return
|
808
|
+
|
809
|
+
self.time = time
|
810
|
+
except ValueError:
|
811
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
812
|
+
return
|
813
|
+
except Exception as e:
|
814
|
+
wx.MessageBox(_('An error occurred: ') + str(e), _('Error'), wx.OK | wx.ICON_ERROR)
|
815
|
+
return
|
816
|
+
|
817
|
+
self.Parent._alaro_update_time()
|
818
|
+
|
819
|
+
event.Skip()
|
820
|
+
|
821
|
+
def OnCloseWindow(self, event):
|
822
|
+
self.Hide()
|
823
|
+
|
824
|
+
event.Skip()
|
825
|
+
|
826
|
+
def OnLegend(self, event):
|
827
|
+
""" Called when the user press the legend button
|
828
|
+
"""
|
829
|
+
|
830
|
+
# get the legend of the layer
|
831
|
+
layer = self.Parent._alaro_legends()
|
832
|
+
|
833
|
+
event.Skip()
|
834
|
+
|
835
|
+
def OnEnterTime(self, event):
|
836
|
+
""" Called when the user press enter in the time text box
|
837
|
+
"""
|
838
|
+
|
839
|
+
# time must be rounded to the nearest interval
|
840
|
+
try:
|
841
|
+
time = self.time
|
842
|
+
|
843
|
+
# force the time to be rounded to the nearest interval
|
844
|
+
interval = timedelta(hours=1)
|
845
|
+
# nullify the minutes and seconds
|
846
|
+
time = time.replace(minute=0, second=0, microsecond=0)
|
847
|
+
|
848
|
+
# check is the time is in the interval
|
849
|
+
if time < self.start or time > self.end:
|
850
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
851
|
+
return
|
852
|
+
|
853
|
+
self.time = time
|
854
|
+
except ValueError:
|
855
|
+
wx.MessageBox(_('The date is not valid'), _('Error'), wx.OK | wx.ICON_ERROR)
|
856
|
+
return
|
857
|
+
except Exception as e:
|
858
|
+
wx.MessageBox(_('An error occurred: ') + str(e), _('Error'), wx.OK | wx.ICON_ERROR)
|
859
|
+
return
|
860
|
+
|
861
|
+
self.Parent._alaro_update_time()
|
862
|
+
|
863
|
+
event.Skip()
|
864
|
+
|
865
|
+
@property
|
866
|
+
def start(self):
|
867
|
+
""" Return the start date selected by the user
|
868
|
+
"""
|
869
|
+
return datetime.strptime(self._start_date.GetValue(), '%Y-%m-%dT%H:%M:%SZ')
|
870
|
+
|
871
|
+
@property
|
872
|
+
def end(self):
|
873
|
+
""" Return the end date selected by the user
|
874
|
+
"""
|
875
|
+
return datetime.strptime(self._end_date.GetValue(), '%Y-%m-%dT%H:%M:%SZ')
|
876
|
+
|
877
|
+
@property
|
878
|
+
def time(self):
|
879
|
+
""" Return the time selected by the user
|
880
|
+
"""
|
881
|
+
return datetime.strptime(self._time.GetValue(), '%Y-%m-%dT%H:%M:%SZ')
|
882
|
+
|
883
|
+
@time.setter
|
884
|
+
def time(self, value:datetime):
|
885
|
+
""" Set the time selected by the user
|
886
|
+
"""
|
887
|
+
self._time.SetValue(value.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
888
|
+
|
889
|
+
@property
|
890
|
+
def time_str(self):
|
891
|
+
""" Return the time selected by the user as string
|
892
|
+
"""
|
893
|
+
return self._time.GetValue()
|
894
|
+
|
895
|
+
@property
|
896
|
+
def alpha(self):
|
897
|
+
""" Return the alpha value selected by the user
|
898
|
+
"""
|
899
|
+
try:
|
900
|
+
return float(self._alpha.GetValue())
|
901
|
+
except:
|
902
|
+
self._alpha.SetValue('1.0')
|
903
|
+
return 1.0
|
904
|
+
|
905
|
+
|
275
906
|
if __name__=='__main__':
|
276
907
|
# me=pyproj.CRS.from_epsg(27573)
|
277
908
|
# t=pyproj.Transformer.from_crs(27573,4326)
|
278
909
|
# getIGNFrance('OI.OrthoimageCoverage.HR','EPSG:27563',878000,332300,879000,333300,1000,1000)
|
279
|
-
img =
|
910
|
+
img = getAlaro('Total_precipitation',250000,160000,252000,162000,1000,1000,False)
|
280
911
|
img = Image.open(img)
|
281
912
|
img.show()
|
282
913
|
pass
|
wolfhece/__init__.py
CHANGED
@@ -7,7 +7,7 @@ try:
|
|
7
7
|
ogr.UseExceptions()
|
8
8
|
osr.UseExceptions()
|
9
9
|
except ImportError as e:
|
10
|
-
print(e)
|
10
|
+
# print(e)
|
11
11
|
raise Exception(_('Error importing GDAL library\nPlease ensure GDAL is installed and the Python bindings are available\n\ngdal wheels can be found at https://github.com/cgohlke/geospatial-wheels'))
|
12
12
|
|
13
13
|
from .apps.version import WolfVersion
|
wolfhece/apps/version.py
CHANGED
wolfhece/apps/wolf.py
CHANGED
@@ -8,10 +8,10 @@ This script and its content are protected by copyright law. Unauthorized
|
|
8
8
|
copying or distribution of this file, via any medium, is strictly prohibited.
|
9
9
|
"""
|
10
10
|
|
11
|
+
import ctypes
|
11
12
|
import wx
|
12
13
|
from ..PyTranslate import _
|
13
14
|
|
14
|
-
import ctypes
|
15
15
|
myappid = 'wolf_hece_uliege' # arbitrary string
|
16
16
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
17
17
|
|
wolfhece/assets/__init__.py
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
from . import _add_path
|