@@ -137,7 +137,11 @@ def _create_scene(file_format, filenames, calib_coefs):
137
137
138
138
139
139
def _check_is_seviri_data (scene ):
140
- if not scene .attrs ['sensor' ] == {'seviri' }:
140
+ if hasattr (scene , 'sensor_names' ) and 'seviri' in scene .sensor_names :
141
+ pass
142
+ elif scene .attrs ['sensor' ] == {'seviri' }:
143
+ pass
144
+ else :
141
145
raise ValueError ('Not SEVIRI data' )
142
146
143
147
@@ -322,6 +326,8 @@ def update_coords(scene):
322
326
323
327
324
328
def add_ancillary_datasets (scene , lons , lats , sunz , satz , azidiff ,
329
+ suna , sata ,
330
+ save_azimuth_angles = False ,
325
331
chunks = (512 , 3712 )):
326
332
"""Add ancillary datasets to the scene.
327
333
@@ -375,6 +381,18 @@ def add_ancillary_datasets(scene, lons, lats, sunz, satz, azidiff,
375
381
da .from_array (azidiff [:, :], chunks = chunks ),
376
382
dims = ['y' , 'x' ], coords = angle_coords )
377
383
384
+ # Sunazimuth
385
+ if save_azimuth_angles :
386
+ scene ['sunazimuth' ] = xr .DataArray (
387
+ da .from_array (suna [:, :], chunks = chunks ),
388
+ dims = ['y' , 'x' ], coords = angle_coords )
389
+
390
+ # Satazimuth
391
+ if save_azimuth_angles :
392
+ scene ['satazimuth' ] = xr .DataArray (
393
+ da .from_array (sata [:, :], chunks = chunks ),
394
+ dims = ['y' , 'x' ], coords = angle_coords )
395
+
378
396
# Update the attributes
379
397
update_angle_attributes (scene , band = scene ['IR_108' ])
380
398
@@ -470,7 +488,7 @@ def get_encoding_seviri(scene):
470
488
encoding ['time' ] = {'units' : 'days since 2004-01-01 00:00' ,
471
489
'calendar' : 'standard' ,
472
490
'_FillValue' : None ,
473
- 'chunksizes' : [ 1 ] }
491
+ 'chunksizes' : ( 1 ,) }
474
492
475
493
return encoding
476
494
@@ -564,7 +582,8 @@ def _postproc_hrit(self, parsed):
564
582
def process_one_scan (tslot_files , out_path , rotate = True , engine = 'h5netcdf' ,
565
583
use_nominal_time_in_filename = False ,
566
584
apply_sun_earth_distance_correction = True ,
567
- clip_calib = False ):
585
+ clip_calib = False ,
586
+ save_azimuth_angles = False ):
568
587
"""Make level 1c files in PPS-format."""
569
588
for fname in tslot_files :
570
589
if not os .path .isfile (fname ):
@@ -577,7 +596,9 @@ def process_one_scan(tslot_files, out_path, rotate=True, engine='h5netcdf',
577
596
rotate = rotate ,
578
597
clip_calib = clip_calib
579
598
)
580
-
599
+ if hasattr (scn_ , 'start_time' ):
600
+ scn_ .attrs ['start_time' ] = scn_ .start_time
601
+ scn_ .attrs ['end_time' ] = scn_ .end_time
581
602
# Find lat/lon data
582
603
lons , lats = get_lonlats (scn_ ['IR_108' ])
583
604
@@ -590,8 +611,12 @@ def process_one_scan(tslot_files, out_path, rotate=True, engine='h5netcdf',
590
611
update_coords (scn_ )
591
612
592
613
# Add ancillary datasets to the scene
593
- add_ancillary_datasets (scn_ , lons = lons , lats = lats , sunz = sunz , satz = satz ,
594
- azidiff = azidiff )
614
+ add_ancillary_datasets (scn_ ,
615
+ lons = lons , lats = lats ,
616
+ sunz = sunz , satz = satz ,
617
+ azidiff = azidiff ,
618
+ suna = suna , sata = sata ,
619
+ save_azimuth_angles = save_azimuth_angles )
595
620
add_proj_satpos (scn_ )
596
621
597
622
# Set attributes. This changes SEVIRI band names to PPS band names.
@@ -601,6 +626,7 @@ def process_one_scan(tslot_files, out_path, rotate=True, engine='h5netcdf',
601
626
ir108_for_filename = scn_ ['IR_108' ]
602
627
if use_nominal_time_in_filename :
603
628
ir108_for_filename = set_nominal_scan_time (ir108_for_filename )
629
+
604
630
filename = compose_filename (
605
631
scene = scn_ ,
606
632
out_path = out_path ,
0 commit comments