-
Notifications
You must be signed in to change notification settings - Fork 3
/
PRFBaseDebugTemplate.py
62 lines (44 loc) · 1.76 KB
/
PRFBaseDebugTemplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import numpy as np
import datetime
import os
import pickle
debug_logs_directory = r'C:\PROJECTS\SFA\debug'
class PRFBaseDebugTemplate:
def __init__(self):
self.name = 'Template to use to get into the pixel blocks'
self.description = 'This is a raster function that you can use to get into the pixel blocks.'
def getParameterInfo(self):
return [
{
'name': 'raster',
'dataType': 'raster',
'value': None,
'required': True,
'displayName': 'Raster',
'description': 'A Single Input Raster.',
}
]
def getConfiguration(self, **scalars):
return {
'inheritProperties': 1 | 2 | 4 | 8,
}
def updateRasterInfo(self, **kwargs):
return kwargs
def updateKeyMetadata(self, names, bandIndex, **keyMetadata):
return keyMetadata
def updatePixels(self, tlc, shape, props, **pixelBlocks):
fname = 'singleDataset_{:%Y_%b_%d_%H_%M_%S}.txt'.format(datetime.datetime.now())
filename = os.path.join(debug_logs_directory, fname)
pickle_filename = os.path.join(debug_logs_directory, fname)
## Using Print Statements
#file = open(filename, "w")
#file.write("in init.\n")
pix_blocks = pixelBlocks['raster_pixels']
pix_array = np.asarray(pix_blocks)
pickle.dump(pix_blocks, open(pickle_filename[:-4] + 'pix_blocks.p', "wb"))
pix_array_dim = pix_array.shape
mask = np.ones(pix_array_dim)
pixelBlocks['output_pixels'] = mask.astype(props['pixelType'], copy=False)
#file.write("DONE.")
#file.close()
return pixelBlocks