Menu

Code snippets

CMRP Software
Attachments
image.png (43948 bytes)

Code recipes

Code recipes are easily readable trenches of code you can use to work your data. In this wiki you can find example of how to load and save data in different file formats, how to calculate moving window attributes from grids, how to view your data, etc. There's really no well defined boundary of what type of code can be put here.

If you have a recipe you want to put in this wiki please send us an email to: cerena.cmrp@gmail.com.

We'll try to separate the recipes by purposes and inside each purpose you may have more than one language available to check the code.

Example

The example below in Python shows an example of a 2d array being created with the indices function from numpy library.

The array is than plotted with imshow function from matplotlib library. Notice the origin argument makes sure the plots starts in X,Y = "0,0" in bottom left corner. The interpolation argument is put as nearest to call the nearest neighbor interpolation method (if other the image would appear smoothed beyond normality). Finally the colormap, cmap argument, is put as Greens. I've also called for a grid over the plot.

# Creating some 2D data...
ind = np.indices((100,100))
grid = np.cos(ind[0]/20)**2+np.sin(ind[1]/20)**2

# Plotting the data with imshow function...
plt.imshow(grid,origin='lower',interpolation='nearest',cmap='Greens')
plt.grid()
plt.show() # Function to draw the plot once all editing is finished.

The result is this:

Tags

Files:
- File reading and writing
- Binary file reading and writing
- File format

Statistics:
- Linear regression
- Basic statistics parameters
- Experimental variogram

Statistics;Plot:
- Histogram
- Scatterplot
- Boxplot
- Lineplot
- Stereonet

Spatial estimation:
- Nearest neighbor
- Inverse weighted distance
- Kriging
- Cubic interpolation


Related

Wiki: Colormap
Wiki: Inverse weighted distance
Wiki: Kriging
Wiki: Nearest neighbor

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.