An error occurred while loading the file. Please try again.
-
Manuel Grizonnet authored
OTB followed since the beginning the ITK convention and use .txx extension for all template classes. Nevertheless, some development tools do not recognize .txx file extension. Other tool like GitHub can't do in-browser syntax highlighting for txx files I think. The root problem is the use of the txx which should be changed to hxx (or hpp). In 2011, after an in-depth discussion near April 20, 2011 on the Insight-Developers mailing list, ITK rename all txx files to hxx (and event prevent the push of .txx files with a pre-commit hook). It happens is major release v4. You can find some arguments in the discussion about the change and also in other projects related to ITK which applied the same modification, see for instance VXL: https://github.com/vxl/vxl/issues/209 This commit apply now the same modification for OTB. I understand that it will change some habit for developers and don't bring new features but I think that in general it is better to stay align with ITK guidelines. In my opinion, it always facilitate the use of OTB and ITK together if we share when we can the same code architecture, directory organization, naming conventions...
3a1fd1fc
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
from typing import List
import pandas as pd
from spatio_temporal_dataset.marginals.abstract_marginals import AbstractMarginals
from spatio_temporal_dataset.marginals.spatial_marginals import SpatialMarginal
from spatio_temporal_dataset.stations.station import Station, load_stations_from_dataframe
from spatio_temporal_dataset.stations.station_distance import EuclideanDistance2D, StationDistance
import pickle
import os.path as op
from itertools import combinations
class SpatioTemporalDataHandler(object):
def __init__(self, marginals_class: type, stations: List[Station], station_distance: StationDistance):
self.stations = stations
# Compute once the distances between stations
for station1, station2 in combinations(self.stations, 2):
distance = station_distance.compute_distance(station1, station2)
station1.distance[station2] = distance
station2.distance[station1] = distance
# Compute the marginals
self.marginals = marginals_class(self.stations) # type: AbstractMarginals
# Define the max stable
# self.max_stable =
print(self.marginals.gev_parameters)
@classmethod
def from_dataframe(cls, df):
return cls.from_spatial_dataframe(df)
@classmethod
def from_spatial_dataframe(cls, df):
stations = load_stations_from_dataframe(df)
marginal_class = SpatialMarginal
station_distance = EuclideanDistance2D()
return cls(marginals_class=marginal_class, stations=stations, station_distance=station_distance)
def get_spatio_temporal_data_handler(pickle_path: str, load_pickle: bool = True, dump_pickle: bool = False, *args) \
-> SpatioTemporalDataHandler:
# Either load or dump pickle of a SpatioTemporalDataHandler object
assert load_pickle or dump_pickle
if load_pickle:
assert op.exists(pickle_path) and not dump_pickle
spatio_temporal_experiment = pickle.load(pickle_path)
else:
assert not op.exists(pickle_path)
spatio_temporal_experiment = SpatioTemporalDataHandler(*args)
pickle.dump(spatio_temporal_experiment, file=pickle_path)
return spatio_temporal_experiment
if __name__ == '__main__':
df = pd.DataFrame(1, index=['station1', 'station2'], columns=['200' + str(i) for i in range(18)])
xp = SpatioTemporalDataHandler.from_dataframe(df)