Scipy Lecture Notes, One document to learn numerics, science, and data with Python.
10 Essential Operations for Spatial Data in Python
有关于KD-Tree的介绍。
Just remember, assignment never copies. See here.
Package | Save | Load |
---|---|---|
numpy | np.save() , np.savez() | np.load() |
np.savetxt() | np.loadtxt() |
raise Exception('# lablablab...') # like matlab error('...') from warnings import warn warn('# blablabla...') # like marlab warn('...)
Function | description |
---|---|
numpy.ma | Masked arrays are arrays that may have missing or invalid entries. A masked array is the combination of a standard numpy.ndarray and a mask. |
https://www.liaoxuefeng.com/wiki/897692888725344/923056295693632
在windows下和在linux下的表现和性能不一样。
process 比 thread 要贵;thread 无法突破多核的限制,process 可以充分利用多核多CPU;
Iterate combinations of different lists while still get the combination indexes: (from here)
def enumerated_product(*args): yield from zip(itertools.product(*(range(len(x)) for x in args)), itertools.product(*args)) time0 = time.time() for idx, pair in enumerated_product(grid_dt, grid_lons, grid_lats):
Tight layout keeps shrink in iterative plotting:
fig.canvas.draw() plt.tight_layout()
Note that it's a best practice to use the if __name__ == "__main__"
guard for scripts anyway, so that code isn't unexpectedly executed if you find you need to import your script into another script at some point in the future. (see https://stackoverflow.com/a/24374798/11172061)