Skip to content

Instantly share code, notes, and snippets.

View mlubej's full-sized avatar

Matic Lubej mlubej

  • EO Research Team @ Sinergise
  • Ljubljana, Slovenia
View GitHub Profile
def select_best_pair(self):
"""
Select two individuals from the population randomly, where the probability of choosing an individual
is weighted by it's fitness level.
:return: two selected individuals
"""
pop_fitness_list = np.array([ind.fitness for ind in self.population])
pop_fitness_list = -pop_fitness_list + np.min(pop_fitness_list) + np.max(pop_fitness_list) + 1
pop_fitness_list = pop_fitness_list / np.sum(pop_fitness_list)
p1, p2 = np.random.choice(self.population,
for idx, c in enumerate(chromosome):
if np.random.rand() < mutation_probability:
has_mutated = True
rand_idx = np.random.choice(range(len(chromosome)))
chromosome[idx], chromosome[rand_idx] = chromosome[rand_idx], chromosome[idx]
def get_unique_orientations(poly):
"""
Out of all possible rotations and flips, take into account the polygon symmetry and
obtain the unique polygon orientations.
:param poly: input polygon
:return: array of unique settings of (rotation, flip)
"""
cx, cy = poly.centroid.x, poly.centroid.y
pts = np.array(poly.checkers)[:, :-1]
checkers = np.array(poly.checkers)[:, -1]
function setup() {
return {
input: ["sunZenithAngles", "sunAzimuthAngles"],
mosaicking: Mosaicking.ORBIT,
output: { id:"default", bands: 0}
}
}
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
download_task = SentinelHubInputTask(
bands_feature=(FeatureType.DATA, 'RGB'),
bands = ['B04', 'B03', 'B02'],
resolution=10,
maxcc=1.0,
time_difference=timedelta(hours=2),
data_source=DataSource.SENTINEL2_L2A,
max_threads=10,
additional_data=[
(FeatureType.MASK, 'dataMask'),
eopatch.timestamp
eopatch.mask['LULC']
eopatch.data['CLM'][0]
eopatch.data['BANDS'][5][..., [3, 2, 1]]
EOPatch(
data: {
BANDS: numpy.ndarray(shape=(80, 1010, 999, 6), dtype=float32)
}
mask: {
CLM: numpy.ndarray(shape=(80, 1010, 999, 1), dtype=uint8)
IS_DATA: numpy.ndarray(shape=(80, 1010, 999, 1), dtype=uint8)
IS_VALID: numpy.ndarray(shape=(80, 1010, 999, 1), dtype=bool)
}
mask_timeless: {
# load EOPatch
EOPatch.load('path_to_eopatches/eopatch-0x6/')
Model Overall Accuracy [%] F_1 Score [%]
Uniform at 16-day rate 94.4 94.1
Uniform at 8-day rate 94.5 94.3
Optimally selected 94.6 94.4
@mlubej
mlubej / cloud_effects.csv
Created February 6, 2019 14:27
Tables in gist
Model Overall Accuracy [%] F_1 Score [%]
No filtering/no masking 92.8 92.6
No filtering/with masking 94.2 93.9
With filtering/no masking 94.0 93.8
With filtering/with masking 94.4 94.1