@@ -3419,11 +3419,8 @@ def _write_nisar_pol_h5_from_bytes(self, downloaded_data, chunk_info, metadata,
34193419 if crop_info :
34203420 out_shape_b = (min (crop_az_end , orig_shape_b [0 ]) - crop_az_start ,
34213421 min (crop_rg_end_b , orig_shape_b [1 ]) - crop_rg_start_b )
3422- # DEBUG
3423- print (f"DEBUG B: orig={ orig_shape_b } , crop_az=[{ crop_az_start } :{ crop_az_end } ], crop_rg_b=[{ crop_rg_start_b } :{ crop_rg_end_b } ], out={ out_shape_b } " )
34243422 else :
34253423 out_shape_b = orig_shape_b
3426- print (f"DEBUG B: NO CROP! crop_info={ crop_info } , orig={ orig_shape_b } " )
34273424
34283425 dst_slc_b = h5_mem .create_dataset (
34293426 f'science/LSAR/RSLC/swaths/frequencyB/{ pol } ' ,
@@ -3492,9 +3489,22 @@ def _write_nisar_pol_h5_from_bytes(self, downloaded_data, chunk_info, metadata,
34923489 elif 'validSamplesSubSwath' in ds_path and len (data .shape ) == 2 :
34933490 az_end = min (crop_az_end , data .shape [0 ]) if crop_az_end else data .shape [0 ]
34943491 data = data [crop_az_start :az_end , :]
3495- # Create dataset with attributes
3492+
3493+ # GeolocationGrid: select sea level height layer (index 1 = 0m)
3494+ # Keep 3D shape (1, az, rg) for compatibility - saves ~162MB (20 layers -> 1 layer)
3495+ if 'geolocationGrid' in ds_path and len (data .shape ) == 3 :
3496+ data = data [1 :2 , :, :]
3497+ # GeolocationGrid 1D height coordinate: keep only sea level value
3498+ elif 'geolocationGrid' in ds_path and len (data .shape ) == 1 and 'height' in ds_path .lower ():
3499+ data = data [1 :2 ]
3500+
3501+ # Create dataset with compression for metadata (matches source HDF5)
34963502 try :
3497- ds = h5_mem .create_dataset (ds_path , data = data )
3503+ # Use gzip compression for arrays, skip for scalars
3504+ if hasattr (data , 'shape' ) and len (data .shape ) > 0 and data .size > 100 :
3505+ ds = h5_mem .create_dataset (ds_path , data = data , compression = 'gzip' , compression_opts = 4 )
3506+ else :
3507+ ds = h5_mem .create_dataset (ds_path , data = data )
34983508 # Copy dataset attributes (description, units, etc.)
34993509 if 'attrs' in ds_info :
35003510 for attr_key , attr_val in ds_info ['attrs' ].items ():
0 commit comments