1- """Module 'heclib'
1+ """Module 'dssutil' for handling DSS grids
22
33Enumerations, constants and functions
44
55"""
66
7- from ctypes import (
8- CDLL ,
9- POINTER ,
10- LibraryLoader ,
11- Structure ,
12- c_char_p ,
13- c_float ,
14- c_int ,
15- c_void_p ,
16- pointer ,
17- )
187from enum import Enum , auto
198
20- import numpy
21-
22- # libtiffdss.so is compiled and put in /usr/lib during image creation
23- tiffdss = LibraryLoader (CDLL ).LoadLibrary ("libtiffdss.so" )
24- """ctypes.CDLL: tiff to dss shared object"""
25-
269FLOAT_MAX = 3.40282347e38
2710UNDEFINED = - FLOAT_MAX
2811
@@ -159,88 +142,4 @@ class TimeZone(Enum):
159142 HST = auto ()
160143
161144
162- time_zone = {i .name : i .value for i in TimeZone }
163-
164-
165- class zStructSpatialGrid (Structure ):
166- _fields_ = [
167- ("structType" , c_int ),
168- ("pathname" , c_char_p ),
169- ("_structVersion" , c_int ),
170- ("_type" , c_int ),
171- ("_version" , c_int ),
172- ("_dataUnits" , c_char_p ),
173- ("_dataType" , c_int ),
174- ("_dataSource" , c_char_p ),
175- ("_lowerLeftCellX" , c_int ),
176- ("_lowerLeftCellY" , c_int ),
177- ("_numberOfCellsX" , c_int ),
178- ("_numberOfCellsY" , c_int ),
179- ("_cellSize" , c_float ),
180- ("_compressionMethod" , c_int ),
181- ("_sizeofCompressedElements" , c_int ),
182- ("_compressionParameters" , c_void_p ),
183- ("_srsName" , c_char_p ),
184- ("_srsDefinitionType" , c_int ),
185- ("_srsDefinition" , c_char_p ),
186- ("_xCoordOfGridCellZero" , c_float ),
187- ("_yCoordOfGridCellZero" , c_float ),
188- ("_nullValue" , c_float ),
189- ("_timeZoneID" , c_char_p ),
190- ("_timeZoneRawOffset" , c_int ),
191- ("_isInterval" , c_int ),
192- ("_isTimeStamped" , c_int ),
193- ("_numberOfRanges" , c_int ),
194- ("_storageDataType" , c_int ),
195- ("_maxDataValue" , c_void_p ),
196- ("_minDataValue" , c_void_p ),
197- ("_meanDataValue" , c_void_p ),
198- ("_rangeLimitTable" , c_void_p ),
199- ("_numberEqualOrExceedingRangeLimit" , c_int ),
200- ("_data" , c_void_p ),
201- ]
202-
203- def __init__ (self , * args , ** kw ):
204- self ._nullValue = UNDEFINED
205- super ().__init__ (* args , ** kw )
206-
207-
208- def zwrite_record (
209- dssfilename : str ,
210- gridStructStore : zStructSpatialGrid ,
211- data_flat : numpy ,
212- ):
213- """Write the data array to DSS record using the 'writeRecord' C function
214-
215- Parameters
216- ----------
217- dssfilename : str
218- DSS file name and path
219- gridStructStore : zStructSpatialGrid
220- ctypes structure
221- data_flat : numpy
222- 1D numpy array
223- gridStats : GridStats
224- ctypes structure
225-
226- Returns
227- -------
228- int
229- Response from the C function
230- """
231- ND_POINTER_1 = numpy .ctypeslib .ndpointer (dtype = numpy .float32 , ndim = 1 , flags = "C" )
232-
233- tiffdss .writeRecord_External .argtypes = (
234- c_char_p ,
235- POINTER (zStructSpatialGrid ),
236- ND_POINTER_1 ,
237- )
238- tiffdss .writeRecord_External .restype = c_int
239-
240- res = tiffdss .writeRecord_External (
241- c_char_p (dssfilename .encode ()),
242- pointer (gridStructStore ),
243- data_flat ,
244- )
245-
246- return res
145+ time_zone = {i .name : i .value for i in TimeZone }
0 commit comments