stemflow.utils.quadtree
A function module to get quadtree results for 2D indexing system. Returns ensemble_df and plotting axes.
generate_temporal_bins(start, end, step, bin_interval, temporal_bin_start_jitter='adaptive', rng=None)
Generate random temporal bins that splits the data
Parameters:
-
start
(Union[float, int]
) –start of the temporal sequence
-
end
(Union[float, int]
) –end of the temporal sequence
-
step
(Union[float, int]
) –step of the sliding window
-
bin_interval
(Union[float, int]
) –size of the sliding window
-
temporal_bin_start_jitter
(Union[float, int, str]
, default:'adaptive'
) –jitter of the start of the sliding window. If 'adaptive', a random jitter of range (-bin_interval, 0) will be generated for the start.
Returns:
-
list
–A list of tuple. Start and end of each temporal bin.
Source code in stemflow/utils/quadtree.py
get_one_ensemble_quadtree(ensemble_count, data, Spatio1='longitude', Spatio2='latitude', Temporal1='DOY', size=1, grid_len=None, grid_len_lon_upper_threshold=25, grid_len_lon_lower_threshold=5, grid_len_lat_upper_threshold=25, grid_len_lat_lower_threshold=5, points_lower_threshold=50, temporal_start=1, temporal_end=366, temporal_step=20, temporal_bin_interval=50, temporal_bin_start_jitter='adaptive', spatio_bin_jitter_magnitude='adaptive', save_gridding_plot=True, ax=None, plot_empty=False, rng=None, completely_random_rotation=False)
Generate QuadTree gridding based on the input dataframe
Parameters:
-
ensemble_count
–The index of ensemble
-
data
(DataFrame
) –Input pandas-like dataframe
-
Spatio1
(str
, default:'longitude'
) –Spatial column name 1 in data
-
Spatio2
(str
, default:'latitude'
) –Spatial column name 2 in data
-
Temporal1
(str
, default:'DOY'
) –Temporal column name 1 in data
-
size
(str
, default:1
) –How many ensemble to generate (how many round the data are gone through)
-
grid_len
(Union[None, float, int]
, default:None
) –If used by STEM, instead of AdaSTEM, the grid length will be fixed by this parameters. It overrides the following four gridding parameters.
-
grid_len_lon_upper_threshold
(Union[float, int]
, default:25
) –force divide if grid longitude larger than the threshold
-
grid_len_lon_lower_threshold
(Union[float, int]
, default:5
) –stop divide if grid longitude will be below than the threshold
-
grid_len_lat_upper_threshold
(Union[float, int]
, default:25
) –force divide if grid latitude larger than the threshold
-
grid_len_lat_lower_threshold
(Union[float, int]
, default:5
) –stop divide if grid latitude will be below than the threshold
-
points_lower_threshold
(int
, default:50
) –Do not train the model if the available data records for this stixel is less than this threshold, and directly set the value to np.nan.
-
temporal_start
(Union[float, int]
, default:1
) –start of the temporal sequence
-
temporal_end
(Union[float, int]
, default:366
) –end of the temporal sequence
-
temporal_step
(Union[float, int]
, default:20
) –step of the sliding window
-
temporal_bin_interval
(Union[float, int]
, default:50
) –size of the sliding window
-
temporal_bin_start_jitter
(Union[float, int, str]
, default:'adaptive'
) –jitter of the start of the sliding window. If 'adaptive', a adaptive jitter of range (-bin_interval, 0) will be generated for the start.
-
spatio_bin_jitter_magnitude
(Union[float, int]
, default:'adaptive'
) –jitter of the spatial gridding.
-
save_gridding_plot
(bool
, default:True
) –Whether ot save gridding plots
-
ax
–Matplotlib Axes to add to.
-
plot_empty
(bool
, default:False
) –Whether to plot the empty grid
-
rng
(Generator
, default:None
) –random number generator.
Returns:
-
–
A tuple of
1. ensemble dataframe;
2. grid plot. np.nan if save_gridding_plot=False
Source code in stemflow/utils/quadtree.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|