@@ -332,6 +332,8 @@ def hec_dss_gridRetrieve(self, pathname: str,
332332 def hec_dss_gridStore (
333333 self ,
334334 gd ,
335+ compressedData = None ,
336+ compressionSize = 0 ,
335337 ):
336338 self .dll .hec_dss_pdStore .restype = c_int
337339 self .dll .hec_dss_pdStore .argtypes = [
@@ -348,6 +350,7 @@ def hec_dss_gridStore(
348350 ctypes .c_int , # timeZoneRawOffset
349351 ctypes .c_int , # isInterval
350352 ctypes .c_int , # isTimeStamped
353+ ctypes .c_int , # compressionSize
351354 ctypes .c_char_p , # dataUnits
352355 ctypes .c_char_p , # dataSource
353356 ctypes .c_char_p , # srsName
@@ -378,6 +381,7 @@ def hec_dss_gridStore(
378381 c_timeZoneRawOffset = c_int (gd .timeZoneRawOffset )
379382 c_isInterval = c_int (gd .isInterval )
380383 c_isTimeStamped = c_int (gd .isTimeStamped )
384+ c_compressionSize = c_int (compressionSize ) # default compression
381385
382386 c_dataUnits = c_char_p (gd .dataUnits .encode ("utf-8" ))
383387 c_dataSource = c_char_p (gd .dataSource .encode ("utf-8" ))
@@ -397,15 +401,19 @@ def hec_dss_gridStore(
397401 c_numberEqualOrExceedingRangeLimit = (c_int * len (gd .numberEqualOrExceedingRangeLimit ))(
398402 * gd .numberEqualOrExceedingRangeLimit )
399403
400- arr = gd .data .astype ('float32' , copy = False )
401- c_data = arr .ctypes .data_as (ctypes .POINTER (ctypes .c_float ))
404+ if compressedData is not None and compressionSize :
405+ # Treat compressed data as raw bytes, not float32
406+ c_data = ctypes .cast (compressedData , ctypes .POINTER (ctypes .c_float ))
407+ else :
408+ arr = gd .data .astype ('float32' , copy = False )
409+ c_data = arr .ctypes .data_as (ctypes .POINTER (ctypes .c_float ))
402410
403411 return self .dll .hec_dss_gridStore (self .handle , c_pathname , c_gridType , c_dataType ,
404412 c_lowerLeftCellX , c_lowerLeftCellY ,
405413 c_numberOfCellsX , c_numberOfCellsY ,
406414 c_numberOfRanges , c_srsDefinitionType ,
407415 c_timeZoneRawOffset , c_isInterval ,
408- c_isTimeStamped ,
416+ c_isTimeStamped , c_compressionSize ,
409417 c_dataUnits , c_dataSource ,
410418 c_srsName , c_srsDefinition , c_timeZoneID ,
411419 c_cellSize , c_xCoordOfGridCellZero ,
0 commit comments